Best Python code snippet using localstack_python
cmd_write.py
Source:cmd_write.py
...39 if not arg1 or not arg2 or not arg3:40 ch.send("Syntax: Write <page> <title/line> <text>.\n")41 return42 item = ch.get_eq("left_hand")43 if not item or (item.item_type != merc.ITEM_TOOL or not state_checks.is_set(item.value[0], merc.TOOL_PEN)):44 item = ch.get_eq("right_hand")45 if not item or (item.item_type != merc.ITEM_TOOL or not state_checks.is_set(item.value[0], merc.TOOL_PEN)):46 ch.send("You are not holding a pen.\n")47 return48 item = ch.get_item_carry(arg1)49 if not item:50 ch.send("You are not carrying that item.\n")51 return52 if item.item_type not in [merc.ITEM_PAGE, merc.ITEM_BOOK]:53 ch.send("You cannot write on that.\n")54 return55 if game_utils.str_cmp(arg2, "title"):56 item.victpoweruse = arg357 ch.send("Ok.\n")58 handler_game.act("$n writes something on $p.", ch, item, None, merc.TO_ROOM)59 return60 if not game_utils.str_cmp(arg2, "line"):61 ch.send("You can write a TITLE or a LINE.\n")62 return63 if item.item_type == merc.ITEM_BOOK:64 ch.send("You can only write a title on the book.\n")65 return66 if not item.chpoweruse:67 return68 buf = item.chpoweruse69 if not buf:70 item.chpoweruse = arg3.capitalize()71 ch.send("Ok.\n")72 handler_game.act("$n writes something on $p.", ch, item, None, merc.TO_ROOM)73 if not ch.is_mage() and not ch.is_immortal() and not item.spectype.is_set(merc.ADV_FINISHED):74 item.spectype.set_bit(merc.ADV_FAILED)75 elif game_utils.str_cmp(arg3, "start.damage.spell") and item.spectype.empty():76 item.spectype.set_bit(merc.ADV_STARTED)77 item.spectype.set_bit(merc.ADV_DAMAGE)78 elif game_utils.str_cmp(arg3, "start.affect.spell") and item.spectype.empty():79 item.spectype.set_bit(merc.ADV_STARTED)80 item.spectype.set_bit(merc.ADV_AFFECT)81 elif game_utils.str_cmp(arg3, "start.action.spell") and item.spectype.empty():82 item.spectype.set_bit(merc.ADV_STARTED)83 item.spectype.set_bit(merc.ADV_ACTION)84 elif game_utils.str_cmp(arg3, "start.spell") and item.spectype.empty():85 item.spectype.set_bit(merc.ADV_STARTED)86 elif not item.spectype.is_set(merc.ADV_FINISHED):87 item.spectype.set_bit(merc.ADV_FAILED)88 return89 if item.chpoweruse and buf:90 if len(buf) + len(arg3) >= settings.MAX_STRING_LENGTH - 4:91 ch.send("Line too long.\n")92 return93 item.chpoweruse = buf + "\n" + arg394 argument, arg1 = game_utils.read_word(argument)95 arg2 = argument96 if not ch.is_mage() and not ch.is_immortal() and not item.spectype.is_set(merc.ADV_FINISHED):97 item.spectype.set_bit(merc.ADV_FAILED)98 elif game_utils.str_cmp(arg1, "start.damage.spell") and item.spectype.empty():99 item.spectype.set_bit(merc.ADV_STARTED)100 item.spectype.set_bit(merc.ADV_DAMAGE)101 elif game_utils.str_cmp(arg1, "start.affect.spell") and item.spectype.empty():102 item.spectype.set_bit(merc.ADV_STARTED)103 item.spectype.set_bit(merc.ADV_AFFECT)104 elif game_utils.str_cmp(arg1, "start.action.spell") and item.spectype.empty():105 item.spectype.set_bit(merc.ADV_STARTED)106 item.spectype.set_bit(merc.ADV_ACTION)107 elif game_utils.str_cmp(arg1, "start.spell") and item.spectype.empty():108 item.spectype.set_bit(merc.ADV_STARTED)109 elif game_utils.str_cmp(arg1, "end.spell") and item.spectype.is_set(merc.ADV_STARTED) and not item.spectype.is_set(merc.ADV_FINISHED):110 item.spectype.set_bit(merc.ADV_FINISHED)111 item.toughness = ch.powers[merc.MPOWER_RUNE0]112 item.points += 1113 elif game_utils.str_cmp(arg1, "damage.spell") and item.spectype.is_set(merc.ADV_STARTED) and not item.spectype.is_set(merc.ADV_DAMAGE) and \114 not item.spectype.is_set(merc.ADV_AFFECT) and not item.spectype.is_set(merc.ADV_ACTION) and not item.spectype.is_set(merc.ADV_FINISHED):115 item.spectype.set_bit(merc.ADV_DAMAGE)116 elif game_utils.str_cmp(arg1, "affect.spell") and item.spectype.is_set(merc.ADV_STARTED) and not item.spectype.is_set(merc.ADV_DAMAGE) and \117 not item.spectype.is_set(merc.ADV_AFFECT) and not item.spectype.is_set(merc.ADV_ACTION) and not item.spectype.is_set(merc.ADV_FINISHED):118 item.spectype.set_bit(merc.ADV_AFFECT)119 elif game_utils.str_cmp(arg1, "action.spell") and item.spectype.is_set(merc.ADV_STARTED) and not item.spectype.is_set(merc.ADV_DAMAGE) and \120 not item.spectype.is_set(merc.ADV_AFFECT) and not item.spectype.is_set(merc.ADV_ACTION) and not item.spectype.is_set(merc.ADV_FINISHED):121 item.spectype.set_bit(merc.ADV_AFFECT)122 elif game_utils.str_cmp(arg1, "area.affect") and item.spectype.is_set(merc.ADV_STARTED) and not item.spectype.is_set(merc.ADV_AREA_AFFECT) and \123 not item.spectype.is_set(merc.ADV_FINISHED):124 item.spectype.set_bit(merc.ADV_AREA_AFFECT)125 item.points += 100126 elif game_utils.str_cmp(arg1, "victim.target") and item.spectype.is_set(merc.ADV_STARTED) and not item.spectype.is_set(merc.ADV_VICTIM_TARGET) and \127 not item.spectype.is_set(merc.ADV_FINISHED):128 item.spectype.set_bit(merc.ADV_VICTIM_TARGET)129 item.points += 5130 elif game_utils.str_cmp(arg1, "object.target") and item.spectype.is_set(merc.ADV_STARTED) and not item.spectype.is_set(merc.ADV_OBJECT_TARGET) and \131 not item.spectype.is_set(merc.ADV_FINISHED):132 item.spectype.set_bit(merc.ADV_OBJECT_TARGET)133 item.points += 5134 elif game_utils.str_cmp(arg1, "global.target") and item.spectype.is_set(merc.ADV_STARTED) and not item.spectype.is_set(merc.ADV_GLOBAL_TARGET) and \135 not item.spectype.is_set(merc.ADV_FINISHED):136 item.spectype.set_bit(merc.ADV_GLOBAL_TARGET)137 item.points += 50138 elif game_utils.str_cmp(arg1, "next.page") and item.spectype.is_set(merc.ADV_STARTED) and not item.spectype.is_set(merc.ADV_NEXT_PAGE) and \139 not item.spectype.is_set(merc.ADV_FINISHED):140 item.spectype.set_bit(merc.ADV_NEXT_PAGE)141 item.points += 5142 elif game_utils.str_cmp(arg1, "parameter:") and item.spectype.is_set(merc.ADV_STARTED) and not item.spectype.is_set(merc.ADV_PARAMETER) and \143 not item.spectype.is_set(merc.ADV_FINISHED):144 if not arg2:145 item.spectype.set_bit(merc.ADV_FAILED)146 else:147 item.spectype.set_bit(merc.ADV_PARAMETER)148 item.chpoweron = arg2149 elif game_utils.str_cmp(arg1, "spell.first") and item.spectype.is_set(merc.ADV_STARTED) and not item.spectype.is_set(merc.ADV_SPELL_FIRST) and \150 not item.spectype.is_set(merc.ADV_FINISHED):151 item.spectype.set_bit(merc.ADV_SPELL_FIRST)152 elif game_utils.str_cmp(arg1, "not.caster") and item.spectype.is_set(merc.ADV_STARTED) and not item.spectype.is_set(merc.ADV_NOT_CASTER) and \153 not item.spectype.is_set(merc.ADV_FINISHED):154 item.spectype.set_bit(merc.ADV_NOT_CASTER)155 elif game_utils.str_cmp(arg1, "no.players") and item.spectype.is_set(merc.ADV_STARTED) and not item.spectype.is_set(merc.ADV_NO_PLAYERS) and \156 not item.spectype.is_set(merc.ADV_FINISHED):157 item.spectype.set_bit(merc.ADV_NO_PLAYERS)158 elif game_utils.str_cmp(arg1, "second.victim") and item.spectype.is_set(merc.ADV_STARTED) and not item.spectype.is_set(merc.ADV_SECOND_VICTIM) and \159 not item.spectype.is_set(merc.ADV_FINISHED):160 item.spectype.set_bit(merc.ADV_SECOND_VICTIM)161 item.points += 5162 elif game_utils.str_cmp(arg1, "second.object") and item.spectype.is_set(merc.ADV_STARTED) and not item.spectype.is_set(merc.ADV_SECOND_OBJECT) and \163 not item.spectype.is_set(merc.ADV_FINISHED):164 item.spectype.set_bit(merc.ADV_SECOND_OBJECT)165 item.points += 5166 elif game_utils.str_cmp(arg1, "reversed") and item.spectype.is_set(merc.ADV_STARTED) and not item.spectype.is_set(merc.ADV_REVERSED) and \167 not item.spectype.is_set(merc.ADV_FINISHED):168 item.spectype.set_bit(merc.ADV_REVERSED)169 elif game_utils.str_cmp(arg1, "min.damage:") and item.spectype.is_set(merc.ADV_STARTED) and item.spectype.is_set(merc.ADV_DAMAGE) and \170 not item.spectype.is_set(merc.ADV_FINISHED):171 if not arg2 or not arg2.isdigit() or int(arg2) not in merc.irange(0, 500):172 item.spectype.set_bit(merc.ADV_FAILED)173 else:174 item.value[1] = int(arg2)175 item.points += int(arg2) * 0.5176 elif game_utils.str_cmp(arg1, "max.damage:") and item.spectype.is_set(merc.ADV_STARTED) and item.spectype.is_set(merc.ADV_DAMAGE) and \177 not item.spectype.is_set(merc.ADV_FINISHED):178 if not arg2 or not arg2.isdigit() or int(arg2) not in merc.irange(0, 1000):179 item.spectype.set_bit(merc.ADV_FAILED)180 else:181 item.value[2] = int(arg2)182 item.points += int(arg2) * 0.5183 elif game_utils.str_cmp(arg1, "move") and item.spectype.is_set(merc.ADV_STARTED) and item.spectype.is_set(merc.ADV_ACTION) and \184 item.value[1] == merc.ACTION_NONE and not item.spectype.is_set(merc.ADV_FINISHED):185 item.value[1] = merc.ACTION_MOVE186 item.points += 500187 elif game_utils.str_cmp(arg1, "mob:") and item.spectype.is_set(merc.ADV_STARTED) and item.spectype.is_set(merc.ADV_ACTION) and \188 item.value[1] == merc.ACTION_NONE and not item.specytpe.is_set(merc.ADV_FINISHED):189 item.value[1] = merc.ACTION_MOB190 mobile = ch.get_char_world2(arg2)191 if not arg2 or not mobile:192 item.spectype.set_bit(merc.ADV_FAILED)193 else:194 item.value[2] = mobile.vnum195 item.points += 500196 elif game_utils.str_cmp(arg1, "object:") and item.spectype.is_set(merc.ADV_STARTED) and item.spectype.is_set(merc.ADV_ACTION) and \197 item.value[1] == merc.ACTION_NONE and not item.spectype.is_set(merc.ADV_FINISHED):198 item.value[1] = merc.ACTION_OBJECT199 obj = ch.get_char_world2(arg2)200 if not arg2 or not obj or obj.flags.artifact or obj.questowner:201 item.spectype.set_bit(merc.ADV_FAILED)202 else:203 item.value[2] = obj.vnum204 item.points += 500205 elif game_utils.str_cmp(arg1, "apply:") and item.spectype.is_set(merc.ADV_STARTED) and item.spectype.is_set(merc.ADV_AFFECT) and \206 not item.spectype.is_set(merc.ADV_FINISHED):207 if not arg2:208 item.spectype.set_bit(merc.ADV_FAILED)209 elif game_utils.str_cmp(arg2, ["strength", "str"]) and not state_checks.is_set(item.value[1], merc.ADV_STR):210 state_checks.set_bit(item.value[1], merc.ADV_STR)211 elif game_utils.str_cmp(arg2, ["dexterity", "dex"]) and not state_checks.is_set(item.value[1], merc.ADV_DEX):212 state_checks.set_bit(item.value[1], merc.ADV_DEX)213 elif game_utils.str_cmp(arg2, ["intelligence", "int"]) and not state_checks.is_set(item.value[1], merc.ADV_INT):214 state_checks.set_bit(item.value[1], merc.ADV_INT)215 elif game_utils.str_cmp(arg2, ["wisdom", "wis"]) and not state_checks.is_set(item.value[1], merc.ADV_WIS):216 state_checks.set_bit(item.value[1], merc.ADV_WIS)217 elif game_utils.str_cmp(arg2, ["constitution", "con"]) and not state_checks.is_set(item.value[1], merc.ADV_CON):218 state_checks.set_bit(item.value[1], merc.ADV_CON)219 elif game_utils.str_cmp(arg2, "mana") and not state_checks.is_set(item.value[1], merc.ADV_MANA):220 state_checks.set_bit(item.value[1], merc.ADV_MANA)221 elif game_utils.str_cmp(arg2, ["hp", "hits", "hitpoints"]) and not state_checks.is_set(item.value[1], merc.ADV_HIT):222 state_checks.set_bit(item.value[1], merc.ADV_HIT)223 elif game_utils.str_cmp(arg2, ["move", "movement"]) and not state_checks.is_set(item.value[1], merc.ADV_MOVE):224 state_checks.set_bit(item.value[1], merc.ADV_MOVE)225 elif game_utils.str_cmp(arg2, ["ac", "armour", "armor"]) and not state_checks.is_set(item.value[1], merc.ADV_AC):226 state_checks.set_bit(item.value[1], merc.ADV_AC)227 elif game_utils.str_cmp(arg2, ["hr", "hit", "hitroll"]) and not state_checks.is_set(item.value[1], merc.ADV_HITROLL):228 state_checks.set_bit(item.value[1], merc.ADV_HITROLL)229 elif game_utils.str_cmp(arg2, ["dr", "dam", "damroll"]) and not state_checks.is_set(item.value[1], merc.ADV_DAMROLL):230 state_checks.set_bit(item.value[1], merc.ADV_DAMROLL)231 elif game_utils.str_cmp(arg2, ["save", "save.spell", "save_spell"]) and not state_checks.is_set(item.value[1], merc.ADV_SAVING_SPELL):232 state_checks.set_bit(item.value[1], merc.ADV_SAVING_SPELL)233 else:234 item.spectype.set_bit(merc.ADV_FAILED)235 return236 item.points += 25237 elif game_utils.str_cmp(arg1, "affect:") and item.spectype.is_set(merc.ADV_STARTED) and item.spectype.is_set(merc.ADV_AFFECT) and \238 not item.spectype.is_set(merc.ADV_FINISHED):239 if not arg2:240 item.spectype.set_bit(merc.ADV_FAILED)241 elif game_utils.str_cmp(arg2, ["blind", "blindness"]) and not state_checks.is_set(item.value[3], merc.AFF_BLIND):242 state_checks.set_bit(item.value[3], merc.AFF_BLIND)243 elif game_utils.str_cmp(arg2, ["invis", "invisible", "invisibility"]) and not state_checks.is_set(item.value[3], merc.AFF_BLIND):244 state_checks.set_bit(item.value[3], merc.AFF_INVISIBLE)245 elif game_utils.str_cmp(arg2, "detect.evil") and not state_checks.is_set(item.value[3], merc.AFF_DETECT_EVIL):246 state_checks.set_bit(item.value[3], merc.AFF_DETECT_EVIL)247 elif game_utils.str_cmp(arg2, ["detect.invis", "detect.invisible", "detect.invisibility"]) and not state_checks.is_set(item.value[3], merc.AFF_DETECT_INVIS):248 state_checks.set_bit(item.value[3], merc.AFF_DETECT_INVIS)249 elif game_utils.str_cmp(arg2, "detect.magic") and not state_checks.is_set(item.value[3], merc.AFF_DETECT_MAGIC):250 state_checks.set_bit(item.value[3], merc.AFF_DETECT_MAGIC)251 elif game_utils.str_cmp(arg2, "detect.hidden") and not state_checks.is_set(item.value[3], merc.AFF_DETECT_HIDDEN):252 state_checks.set_bit(item.value[3], merc.AFF_DETECT_HIDDEN)253 elif game_utils.str_cmp(arg2, ["shadowplane", "shadow.plane"]) and not state_checks.is_set(item.value[3], merc.AFF_SHADOWPLANE):254 state_checks.set_bit(item.value[3], merc.AFF_SHADOWPLANE)255 elif game_utils.str_cmp(arg2, ["sanct", "sanctuary"]) and not state_checks.is_set(item.value[3], merc.AFF_SANCTUARY):256 state_checks.set_bit(item.value[3], merc.AFF_SANCTUARY)257 elif game_utils.str_cmp(arg2, "faerie.fire") and not state_checks.is_set(item.value[3], merc.AFF_FAERIE_FIRE):258 state_checks.set_bit(item.value[3], merc.AFF_FAERIE_FIRE)259 elif game_utils.str_cmp(arg2, ["infravision", "infrared", "infra"]) and not state_checks.is_set(item.value[3], merc.AFF_SANCTUARY):260 state_checks.set_bit(item.value[3], merc.AFF_SANCTUARY)261 elif game_utils.str_cmp(arg2, "curse") and not state_checks.is_set(item.value[3], merc.AFF_CURSE):262 state_checks.set_bit(item.value[3], merc.AFF_CURSE)263 elif game_utils.str_cmp(arg2, ["flaming", "burning"]) and not state_checks.is_set(item.value[3], merc.AFF_FLAMING):264 state_checks.set_bit(item.value[3], merc.AFF_FLAMING)265 elif game_utils.str_cmp(arg2, "poison") and not state_checks.is_set(item.value[3], merc.AFF_POISON):266 state_checks.set_bit(item.value[3], merc.AFF_POISON)267 elif game_utils.str_cmp(arg2, ["protect", "protection"]) and not state_checks.is_set(item.value[3], merc.AFF_PROTECT):268 state_checks.set_bit(item.value[3], merc.AFF_PROTECT)269 elif game_utils.str_cmp(arg2, "ethereal") and not state_checks.is_set(item.value[3], merc.AFF_ETHEREAL):270 state_checks.set_bit(item.value[3], merc.AFF_ETHEREAL)271 elif game_utils.str_cmp(arg2, "sneak") and not state_checks.is_set(item.value[3], merc.AFF_SNEAK):272 state_checks.set_bit(item.value[3], merc.AFF_SNEAK)273 elif game_utils.str_cmp(arg2, "hide") and not state_checks.is_set(item.value[3], merc.AFF_HIDE):274 state_checks.set_bit(item.value[3], merc.AFF_HIDE)275 elif game_utils.str_cmp(arg2, "sleep") and not state_checks.is_set(item.value[3], merc.AFF_SLEEP):276 state_checks.set_bit(item.value[3], merc.AFF_SLEEP)277 elif game_utils.str_cmp(arg2, "charm") and not state_checks.is_set(item.value[3], merc.AFF_CHARM):278 state_checks.set_bit(item.value[3], merc.AFF_CHARM)279 elif game_utils.str_cmp(arg2, ["fly", "flying"]) and not state_checks.is_set(item.value[3], merc.AFF_FLYING):280 state_checks.set_bit(item.value[3], merc.AFF_FLYING)281 elif game_utils.str_cmp(arg2, ["passdoor", "pass.door"]) and not state_checks.is_set(item.value[3], merc.AFF_PASS_DOOR):282 state_checks.set_bit(item.value[3], merc.AFF_PASS_DOOR)283 elif game_utils.str_cmp(arg2, ["shadowsight", "shadow.sight"]) and not state_checks.is_set(item.value[3], merc.AFF_SHADOWSIGHT):284 state_checks.set_bit(item.value[3], merc.AFF_SHADOWSIGHT)285 elif game_utils.str_cmp(arg2, ["web", "webbed"]) and not state_checks.is_set(item.value[3], merc.AFF_WEBBED):286 state_checks.set_bit(item.value[3], merc.AFF_WEBBED)287 else:288 item.spectype.set_bit(merc.ADV_FAILED)289 return290 item.points += 25291 elif game_utils.str_cmp(arg1, "bonus:") and item.spectype.is_set(merc.ADV_STARTED) and item.spectype.is_set(merc.ADV_AFFECT) and \292 not item.spectype.is_set(merc.ADV_FINISHED):293 if not arg2 or not arg2.isdigit() or int(arg2) not in merc.irange(0, 100):294 item.spectype.set_bit(merc.ADV_FAILED)295 else:296 item.value[2] = int(arg2)297 item.points += int(arg2) * 15298 elif game_utils.str_cmp(arg1, "duration:") and item.spectype.is_set(merc.ADV_STARTED) and item.spectype.is_set(merc.ADV_AFFECT) and \299 item.level == 0 and not item.spectype.is_set(merc.ADV_FINISHED):300 if not arg2 or not arg2.isdigit() or int(arg2) not in merc.irange(1, 60):301 item.spectype.set_bit(merc.ADV_FAILED)302 else:303 item.level = int(arg2)304 item.points += int(arg2) * 10305 elif game_utils.str_cmp(arg1, ["message.one:", "message.1:"]) and item.spectype.is_set(merc.ADV_STARTED) and \306 not item.spectype.is_set(merc.ADV_MESSAGE_1) and not item.spectype.is_set(merc.ADV_FINISHED):307 if not arg2:308 item.spectype.set_bit(merc.ADV_FAILED)309 else:310 item.spectype.set_bit(merc.ADV_MESSAGE_1)311 item.chpoweroff = arg2312 elif game_utils.str_cmp(arg1, ["message.two:", "message.2:"]) and item.spectype.is_set(merc.ADV_STARTED) and \313 not item.spectype.is_set(merc.ADV_MESSAGE_2) and not item.spectype.is_set(merc.ADV_FINISHED):314 if not arg2:315 item.spectype.set_bit(merc.ADV_FAILED)316 else:317 item.spectype.set_bit(merc.ADV_MESSAGE_2)318 item.victpoweron = arg2319 elif game_utils.str_cmp(arg1, ["message.three:", "message.3:"]) and item.spectype.is_set(merc.ADV_STARTED) and \320 not item.spectype.is_set(merc.ADV_MESSAGE_3) and not item.spectype.is_set(merc.ADV_FINISHED):321 if not arg2:322 item.spectype.set_bit(merc.ADV_FAILED)323 else:324 item.spectype.set_bit(merc.ADV_MESSAGE_3)325 item.victpoweroff = arg2326 elif not item.spectype.is_set(merc.ADV_FINISHED):327 item.spectype.set_bit(merc.ADV_FAILED)328 else:329 return330 handler_game.act("$n writes something on $p.", ch, item, None, merc.TO_ROOM)331 ch.send("Ok.\n")332interp.register_command(333 interp.CmdType(334 name="write",335 cmd_fun=cmd_write,336 position=merc.POS_MEDITATING, level=0,337 log=merc.LOG_NORMAL, show=True,338 default_arg=""339 )340)
cmd_diagnose.py
Source:cmd_diagnose.py
...28import handler_game29import interp30import merc31def check_left_arm(ch, victim):32 if victim.arm_left.is_set(merc.LOST_ARM) and victim.arm_right.is_set(merc.LOST_ARM):33 handler_game.act("$N has lost both of $S arms.", ch, None, victim, merc.TO_CHAR)34 if victim.bleeding.is_set(merc.BLEEDING_ARM_L) and victim.bleeding.is_set(merc.BLEEDING_ARM_R):35 handler_game.act("...Blood is spurting from both stumps.", ch, None, victim, merc.TO_CHAR)36 elif victim.bleeding.is_set(merc.BLEEDING_ARM_L):37 handler_game.act("...Blood is spurting from the left stump.", ch, None, victim, merc.TO_CHAR)38 elif victim.bleeding.is_set(merc.BLEEDING_ARM_R):39 handler_game.act("...Blood is spurting from the right stump.", ch, None, victim, merc.TO_CHAR)40 return41 if victim.arm_left.is_set(merc.LOST_ARM):42 handler_game.act("$N has lost $S left arm.", ch, None, victim, merc.TO_CHAR)43 if victim.bleeding.is_set(merc.BLEEDING_ARM_L):44 handler_game.act("...Blood is spurting from the stump.", ch, None, victim, merc.TO_CHAR)45 return46 if victim.arm_left.is_set(merc.BROKEN_ARM) and victim.arm_right.is_set(merc.BROKEN_ARM):47 handler_game.act("$N arms are both broken.", ch, None, victim, merc.TO_CHAR)48 elif victim.arm_left.is_set(merc.BROKEN_ARM):49 handler_game.act("$N's left arm is broken.", ch, None, victim, merc.TO_CHAR)50 if victim.arm_left.is_set(merc.LOST_HAND) and victim.arm_right.is_set(merc.LOST_HAND) and not victim.arm_right.is_set(merc.LOST_ARM):51 handler_game.act("$N has lost both of $S hands.", ch, None, victim, merc.TO_CHAR)52 if victim.bleeding.is_set(merc.BLEEDING_HAND_L) and victim.bleeding.is_set(merc.BLEEDING_HAND_R):53 handler_game.act("...Blood is spurting from both stumps.", ch, None, victim, merc.TO_CHAR)54 elif victim.bleeding.is_set(merc.BLEEDING_HAND_L):55 handler_game.act("...Blood is spurting from the left stump.", ch, None, victim, merc.TO_CHAR)56 elif victim.bleeding.is_set(merc.BLEEDING_HAND_R):57 handler_game.act("...Blood is spurting from the right stump.", ch, None, victim, merc.TO_CHAR)58 return59 if victim.arm_left.is_set(merc.LOST_HAND):60 handler_game.act("$N has lost $S left hand.", ch, None, victim, merc.TO_CHAR)61 if victim.bleeding.is_set(merc.BLEEDING_HAND_L):62 handler_game.act("...Blood is spurting from the stump.", ch, None, victim, merc.TO_CHAR)63 return64 fingers = 065 part_list = [merc.LOST_FINGER_I, merc.LOST_FINGER_M, merc.LOST_FINGER_R, merc.LOST_FINGER_L]66 for part in part_list:67 if victim.arm_left.is_set(part):68 fingers += 169 finger = "finger{}".format("" if fingers == 1 else "s")70 if fingers > 0 and victim.arm_left.is_set(merc.LOST_THUMB):71 handler_game.act(f"$N has lost {fingers} {finger} and $S thumb from $S left hand.", ch, None, victim, merc.TO_CHAR)72 elif fingers > 0:73 handler_game.act(f"$N has lost {fingers} {finger} from $S left hand.", ch, None, victim, merc.TO_CHAR)74 elif victim.arm_left.is_set(merc.LOST_THUMB):75 handler_game.act("$N has lost the thumb from $S left hand.", ch, None, victim, merc.TO_CHAR)76 fingers = 077 part_list = [(merc.BROKEN_FINGER_I, merc.LOST_FINGER_I), (merc.BROKEN_FINGER_M, merc.LOST_FINGER_M),78 (merc.BROKEN_FINGER_R, merc.LOST_FINGER_R), (merc.BROKEN_FINGER_L, merc.LOST_FINGER_L)]79 for (aa, bb) in part_list:80 if victim.arm_left.is_set(aa) and not victim.arm_left.is_set(bb):81 fingers += 182 finger = "finger{}".format("" if fingers == 1 else "s")83 if fingers > 0 and victim.arm_left.is_set(merc.BROKEN_THUMB) and not victim.arm_left.is_set(merc.LOST_THUMB):84 handler_game.act(f"$N has broken {fingers} {finger} and $S thumb on $S left hand.", ch, None, victim, merc.TO_CHAR)85 elif fingers > 0:86 handler_game.act(f"$N has broken {fingers} {finger} on $S left hand.", ch, None, victim, merc.TO_CHAR)87 elif victim.arm_left.is_set(merc.BROKEN_THUMB) and not victim.arm_left.is_set(merc.LOST_THUMB):88 handler_game.act("$N has broken the thumb on $S left hand.", ch, None, victim, merc.TO_CHAR)89def check_right_arm(ch, victim):90 if victim.arm_left.is_set(merc.LOST_ARM) and victim.arm_right.is_set(merc.LOST_ARM):91 return92 if victim.arm_right.is_set(merc.LOST_ARM):93 handler_game.act("$N has lost $S right arm.", ch, None, victim, merc.TO_CHAR)94 if victim.bleeding.is_set(merc.BLEEDING_ARM_R):95 handler_game.act("...Blood is spurting from the stump.", ch, None, victim, merc.TO_CHAR)96 return97 if not victim.arm_left.is_set(merc.BROKEN_ARM) and victim.arm_right.is_set(merc.BROKEN_ARM):98 handler_game.act("$N's right arm is broken.", ch, None, victim, merc.TO_CHAR)99 elif victim.arm_left.is_set(merc.LOST_ARM) and victim.arm_right.is_set(merc.BROKEN_ARM):100 handler_game.act("$N's right arm is broken.", ch, None, victim, merc.TO_CHAR)101 if victim.arm_left.is_set(merc.LOST_HAND) and victim.arm_right.is_set(merc.LOST_HAND):102 return103 if victim.arm_right.is_set(merc.LOST_HAND):104 handler_game.act("$N has lost $S right hand.", ch, None, victim, merc.TO_CHAR)105 if victim.bleeding.is_set(merc.BLEEDING_HAND_R):106 handler_game.act("...Blood is spurting from the stump.", ch, None, victim, merc.TO_CHAR)107 return108 fingers = 0109 part_list = [merc.LOST_FINGER_I, merc.LOST_FINGER_M, merc.LOST_FINGER_R, merc.LOST_FINGER_I]110 for part in part_list:111 if victim.arm_right.is_set(part):112 fingers += 1113 finger = "finger{}".format("" if fingers == 1 else "s")114 if fingers > 0 and victim.arm_right.is_set(merc.LOST_THUMB):115 handler_game.act(f"$N has lost {fingers} {finger} and $S thumb from $S right hand.", ch, None, victim, merc.TO_CHAR)116 elif fingers > 0:117 handler_game.act(f"$N has lost {fingers} {finger} from $S right hand.", ch, None, victim, merc.TO_CHAR)118 elif victim.arm_right.is_set(merc.LOST_THUMB):119 handler_game.act("$N has lost the thumb from $S right hand.", ch, None, victim, merc.TO_CHAR)120 fingers = 0121 part_list = [(merc.BROKEN_FINGER_I, merc.LOST_FINGER_I), (merc.BROKEN_FINGER_M, merc.LOST_FINGER_M),122 (merc.BROKEN_FINGER_R, merc.LOST_FINGER_R), (merc.BROKEN_FINGER_L, merc.LOST_FINGER_L)]123 for (aa, bb) in part_list:124 if victim.arm_right.is_set(aa) and not victim.arm_right.is_set(bb):125 fingers += 1126 finger = "finger{}".format("" if fingers == 1 else "s")127 if fingers > 0 and victim.arm_right.is_set(merc.BROKEN_THUMB) and not victim.arm_right.is_set(merc.LOST_THUMB):128 handler_game.act(f"$N has broken {fingers} {finger} and $S thumb on $S right hand.", ch, None, victim, merc.TO_CHAR)129 elif fingers > 0:130 handler_game.act(f"$N has broken {fingers} {finger} on $S right hand.", ch, None, victim, merc.TO_CHAR)131 elif victim.arm_right.is_set(merc.BROKEN_THUMB) and not victim.arm_right.is_set(merc.LOST_THUMB):132 handler_game.act("$N has broken the thumb on $S right hand.", ch, None, victim, merc.TO_CHAR)133def check_left_leg(ch, victim):134 if victim.leg_left.is_set(merc.LOST_LEG) and victim.leg_right.is_set(merc.LOST_LEG):135 handler_game.act("$N has lost both of $S legs.", ch, None, victim, merc.TO_CHAR)136 if victim.bleeding.is_set(merc.BLEEDING_LEG_L) and victim.bleeding.is_set(merc.BLEEDING_LEG_R):137 handler_game.act("...Blood is spurting from both stumps.", ch, None, victim, merc.TO_CHAR)138 elif victim.bleeding.is_set(merc.BLEEDING_LEG_L):139 handler_game.act("...Blood is spurting from the left stump.", ch, None, victim, merc.TO_CHAR)140 elif victim.bleeding.is_set(merc.BLEEDING_LEG_R):141 handler_game.act("...Blood is spurting from the right stump.", ch, None, victim, merc.TO_CHAR)142 return143 if victim.leg_left.is_set(merc.LOST_LEG):144 handler_game.act("$N has lost $S left leg.", ch, None, victim, merc.TO_CHAR)145 if victim.bleeding.is_set(merc.BLEEDING_LEG_L):146 handler_game.act("...Blood is spurting from the stump.", ch, None, victim, merc.TO_CHAR)147 return148 if victim.leg_left.is_set(merc.BROKEN_LEG) and victim.leg_right.is_set(merc.BROKEN_LEG):149 handler_game.act("$N legs are both broken.", ch, None, victim, merc.TO_CHAR)150 elif victim.leg_left.is_set(merc.BROKEN_LEG):151 handler_game.act("$N's left leg is broken.", ch, None, victim, merc.TO_CHAR)152 if victim.leg_left.is_set(merc.LOST_FOOT) and victim.leg_right.is_set(merc.LOST_FOOT):153 handler_game.act("$N has lost both of $S feet.", ch, None, victim, merc.TO_CHAR)154 if victim.bleeding.is_set(merc.BLEEDING_FOOT_L) and victim.bleeding.is_set(merc.BLEEDING_FOOT_R):155 handler_game.act("...Blood is spurting from both stumps.", ch, None, victim, merc.TO_CHAR)156 elif victim.bleeding.is_set(merc.BLEEDING_FOOT_L):157 handler_game.act("...Blood is spurting from the left stump.", ch, None, victim, merc.TO_CHAR)158 elif victim.bleeding.is_set(merc.BLEEDING_FOOT_R):159 handler_game.act("...Blood is spurting from the right stump.", ch, None, victim, merc.TO_CHAR)160 return161 if victim.leg_left.is_set(merc.LOST_FOOT):162 handler_game.act("$N has lost $S left foot.", ch, None, victim, merc.TO_CHAR)163 if victim.bleeding.is_set(merc.BLEEDING_FOOT_L):164 handler_game.act("...Blood is spurting from the stump.", ch, None, victim, merc.TO_CHAR)165 return166 toes = 0167 part_list = [merc.LOST_TOE_A, merc.LOST_TOE_B, merc.LOST_TOE_C, merc.LOST_TOE_D]168 for part in part_list:169 if victim.leg_left.is_set(part):170 toes += 1171 toe = "toe{}".format("" if toes == 1 else "s")172 if toes > 0 and victim.leg_left.is_set(merc.LOST_TOE_BIG):173 handler_game.act(f"$N has lost {toes} {toe} and $S big toe from $S left foot.", ch, None, victim, merc.TO_CHAR)174 elif toes > 0:175 handler_game.act(f"$N has lost {toes} {toe} from $S left foot.", ch, None, victim, merc.TO_CHAR)176 elif victim.leg_left.is_set(merc.LOST_TOE_BIG):177 handler_game.act("$N has lost the big toe from $S left foot.", ch, None, victim, merc.TO_CHAR)178 toes = 0179 part_list = [(merc.BROKEN_TOE_A, merc.LOST_TOE_A), (merc.BROKEN_TOE_B, merc.LOST_TOE_B),180 (merc.BROKEN_TOE_C, merc.LOST_TOE_C), (merc.BROKEN_TOE_D, merc.LOST_TOE_D)]181 for (aa, bb) in part_list:182 if victim.leg_left.is_set(aa) and not victim.leg_left.is_set(bb):183 toes += 1184 toe = "toe{}".format("" if toes == 1 else "s")185 if toes > 0 and victim.leg_left.is_set(merc.BROKEN_TOE_BIG) and not victim.leg_left.is_set(merc.LOST_TOE_BIG):186 handler_game.act(f"$N has broken {toes} {toe} and $S big toe from $S left foot.", ch, None, victim, merc.TO_CHAR)187 elif toes > 0:188 handler_game.act(f"$N has broken {toes} {toe} on $S left foot.", ch, None, victim, merc.TO_CHAR)189 elif victim.leg_left.is_set(merc.BROKEN_TOE_BIG) and not victim.leg_left.is_set(merc.LOST_TOE_BIG):190 handler_game.act("$N has broken the big toe on $S left foot.", ch, None, victim, merc.TO_CHAR)191def check_right_leg(ch, victim):192 if victim.leg_left.is_set(merc.LOST_LEG) and victim.leg_right.is_set(merc.LOST_LEG):193 return194 if victim.leg_right.is_set(merc.LOST_LEG):195 handler_game.act("$N has lost $S right leg.", ch, None, victim, merc.TO_CHAR)196 if victim.bleeding.is_set(merc.BLEEDING_LEG_R):197 handler_game.act("...Blood is spurting from the stump.", ch, None, victim, merc.TO_CHAR)198 return199 if not victim.leg_left.is_set(merc.BROKEN_LEG) and victim.leg_right.is_set(merc.BROKEN_LEG):200 handler_game.act("$N's right leg is broken.", ch, None, victim, merc.TO_CHAR)201 if victim.leg_left.is_set(merc.LOST_FOOT) and victim.leg_right.is_set(merc.LOST_FOOT):202 return203 if victim.leg_right.is_set(merc.LOST_FOOT):204 handler_game.act("$N has lost $S right foot.", ch, None, victim, merc.TO_CHAR)205 if victim.bleeding.is_set(merc.BLEEDING_FOOT_R):206 handler_game.act("...Blood is spurting from the stump.", ch, None, victim, merc.TO_CHAR)207 return208 toes = 0209 part_list = [merc.LOST_TOE_A, merc.LOST_TOE_B, merc.LOST_TOE_C, merc.LOST_TOE_D]210 for part in part_list:211 if victim.leg_right.is_set(part):212 toes += 1213 toe = "toe{}".format("" if toes == 1 else "s")214 if toes > 0 and victim.leg_right.is_set(merc.LOST_TOE_BIG):215 handler_game.act(f"$N has lost {toes} {toe} and $S big toe from $S right foot.", ch, None, victim, merc.TO_CHAR)216 elif toes > 0:217 handler_game.act(f"$N has lost {toes} {toe} from $S right foot.", ch, None, victim, merc.TO_CHAR)218 elif victim.leg_right.is_set(merc.LOST_TOE_BIG):219 handler_game.act("$N has lost the big toe from $S right foot.", ch, None, victim, merc.TO_CHAR)220 toes = 0221 part_list = [(merc.BROKEN_TOE_A, merc.LOST_TOE_A), (merc.BROKEN_TOE_B, merc.LOST_TOE_B),222 (merc.BROKEN_TOE_C, merc.LOST_TOE_C), (merc.BROKEN_TOE_D, merc.LOST_TOE_D)]223 for (aa, bb) in part_list:224 if victim.leg_right.is_set(aa) and not victim.leg_right.is_set(bb):225 toes += 1226 toe = "toe{}".format("" if toes == 1 else "s")227 if toes > 0 and victim.leg_right.is_set(merc.BROKEN_TOE_BIG) and not victim.leg_right.is_set(merc.LOST_TOE_BIG):228 handler_game.act(f"$N has broken {toes} {toe} and $S big toe on $S right foot.", ch, None, victim, merc.TO_CHAR)229 elif toes > 0:230 handler_game.act(f"$N has broken {toes} {toe} on $S right foot.", ch, None, victim, merc.TO_CHAR)231 elif victim.leg_right.is_set(merc.BROKEN_TOE_BIG) and not victim.leg_right.is_set(merc.LOST_TOE_BIG):232 handler_game.act("$N has broken the big toe on $S right foot.", ch, None, victim, merc.TO_CHAR)233def cmd_diagnose(ch, argument):234 argument, arg = game_utils.read_word(argument)235 if not arg:236 ch.send("Who do you wish to diagnose?\n")237 return238 victim = ch.get_char_room(arg)239 if not victim:240 ch.not_here(arg)241 return242 handler_game.act("$n examines $N carefully, diagnosing $S injuries.", ch, None, victim, merc.TO_NOTVICT)243 handler_game.act("$n examines you carefully, diagnosing your injuries.", ch, None, victim, merc.TO_VICT)244 handler_game.act("Your diagnoses of $N reveals the following...", ch, None, victim, merc.TO_CHAR)245 ch.send("--------------------------------------------------------------------------------\n")246 if victim.head.empty() and victim.body.empty() and victim.arm_left.empty() and victim.arm_right.empty() and victim.leg_left.empty() and \247 victim.leg_right.empty() and victim.bleeding.empty():248 handler_game.act("$N has no apparent injuries.", ch, None, victim, merc.TO_CHAR)249 ch.send("--------------------------------------------------------------------------------\n")250 return251 # Check head252 if victim.head.is_set(merc.LOST_EYE_L) and victim.head.is_set(merc.LOST_EYE_R):253 handler_game.act("$N has lost both of $S eyes.", ch, None, victim, merc.TO_CHAR)254 elif victim.head.is_set(merc.LOST_EYE_L):255 handler_game.act("$N has lost $S left eye.", ch, None, victim, merc.TO_CHAR)256 elif victim.head.is_set(merc.LOST_EYE_R):257 handler_game.act("$N has lost $S right eye.", ch, None, victim, merc.TO_CHAR)258 if victim.head.is_set(merc.LOST_EAR_L) and victim.head.is_set(merc.LOST_EAR_R):259 handler_game.act("$N has lost both of $S ears.", ch, None, victim, merc.TO_CHAR)260 elif victim.head.is_set(merc.LOST_EAR_L):261 handler_game.act("$N has lost $S left ear.", ch, None, victim, merc.TO_CHAR)262 elif victim.head.is_set(merc.LOST_EAR_R):263 handler_game.act("$N has lost $S right ear.", ch, None, victim, merc.TO_CHAR)264 if victim.head.is_set(merc.LOST_NOSE):265 handler_game.act("$N has lost $S nose.", ch, None, victim, merc.TO_CHAR)266 elif victim.head.is_set(merc.BROKEN_NOSE):267 handler_game.act("$N has got a broken nose.", ch, None, victim, merc.TO_CHAR)268 if victim.head.is_set(merc.BROKEN_JAW):269 handler_game.act("$N has got a broken jaw.", ch, None, victim, merc.TO_CHAR)270 if victim.head.is_set(merc.LOST_HEAD):271 handler_game.act("$N has had $S head cut off.", ch, None, victim, merc.TO_CHAR)272 if victim.bleeding.is_set(merc.BLEEDING_HEAD):273 handler_game.act("...Blood is spurting from the stump of $S neck.", ch, None, victim, merc.TO_CHAR)274 else:275 if victim.body.is_set(merc.BROKEN_NECK):276 handler_game.act("$N has got a broken neck.", ch, None, victim, merc.TO_CHAR)277 if victim.body.is_set(merc.CUT_THROAT):278 handler_game.act("$N has had $S throat cut open.", ch, None, victim, merc.TO_CHAR)279 if victim.bleeding.is_set(merc.BLEEDING_THROAT):280 handler_game.act("...Blood is pouring from the wound.", ch, None, victim, merc.TO_CHAR)281 if victim.head.is_set(merc.BROKEN_SKULL):282 handler_game.act("$N has got a broken skull.", ch, None, victim, merc.TO_CHAR)283 teeth = 0284 part_list = [(merc.LOST_TOOTH_1, 1), (merc.LOST_TOOTH_2, 2), (merc.LOST_TOOTH_4, 4), (merc.LOST_TOOTH_8, 8), (merc.LOST_TOOTH_16, 16)]285 for (aa, bb) in part_list:286 if victim.head.is_set(aa):287 teeth += bb288 if teeth > 0:289 handler_game.act(f"$N has had {teeth} teeth knocked out.", ch, None, victim, merc.TO_CHAR)290 if victim.head.is_set(merc.LOST_TONGUE):291 handler_game.act("$N has had $S tongue ripped out.", ch, None, victim, merc.TO_CHAR)292 if victim.head.is_set(merc.LOST_HEAD):293 ch.send("--------------------------------------------------------------------------------\n")294 return295 # Check body296 ribs = 0297 part_list = [(merc.BROKEN_RIBS_1, 1), (merc.BROKEN_RIBS_2, 2), (merc.BROKEN_RIBS_4, 4), (merc.BROKEN_RIBS_8, 8), (merc.BROKEN_RIBS_16, 16)]298 for (aa, bb) in part_list:299 if victim.body.is_set(aa):300 ribs += bb301 if ribs > 0:302 handler_game.act(f"$N has got {ribs} broken ribs.", ch, None, victim, merc.TO_CHAR)303 if victim.body.is_set(merc.BROKEN_SPINE):304 handler_game.act("$N has got a broken spine.", ch, None, victim, merc.TO_CHAR)305 # Check arms and legs306 check_left_arm(ch, victim)307 check_right_arm(ch, victim)308 check_left_leg(ch, victim)309 check_right_leg(ch, victim)310 ch.send("--------------------------------------------------------------------------------\n")311interp.register_command(312 interp.CmdType(313 name="diagnose",314 cmd_fun=cmd_diagnose,315 position=merc.POS_FIGHTING, level=0,316 log=merc.LOG_NORMAL, show=True,317 default_arg=""...
cpu.py
Source:cpu.py
1#!/usr/bin/env python32from cpuinfo import get_cpu_info3from cpuid import *4import cpuid_native5def is_set(id, reg_idx, bit):6 regs = cpuid(id)7 if (1 << bit) & regs[reg_idx]:8 return "Yes"9 else:10 return "--"11def get_cpus():12 cpu_info = [{13 "vendor": cpu_vendor(),14 "name": cpu_name(),15 "microarch": cpu_microarchitecture(),16 "vector_instructions": {17 "sse": is_set(1, 3, 25),18 "sse2": is_set(1, 3, 26),19 "sse3": is_set(1, 2, 0),20 "ssse3": is_set(1, 2, 9),21 "sse4.1": is_set(1, 2, 19),22 "sse4.2": is_set(1, 2, 20),23 "sse4a": is_set(0x80000001, 2, 6),24 "avx": is_set(1, 2, 28),25 "avx2": is_set(7, 1, 5),26 "bmi1": is_set(7, 1, 3),27 "bmi2": is_set(7, 1, 8),28 },29 "cpu_info": get_cpu_info()30 }]...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!