def step(plr): if random.random() < 0.75: opponent = crog_bruiser() print('\nYou bumped into a %s!' % font.lvl_diff(plr, opponent, opponent.name)) input() combat.fight(opponent, plr)
def step(plr): if random.random() < 0.75: opponent = goblin() print('\nA %s is attacking!' % font.lvl_diff(plr, opponent, opponent.name)) input('> ') combat.fight(opponent, plr)
def main(): """Drive the program.""" guide.INTRODUCTION() guide.CONTROLS() DIRECTIONS = movement.MOVE_DIRECTION() the_map = movement.BOARD() char_name, char_hp = descriptions.character() list_of_monsters = descriptions.MONSTERS() room_description = descriptions.ROOM_DESCRIPTIONS(char_name) y_current = 4 x_current = 0 movement.mini_map(the_map) mission_complete = False while not mission_complete: players_move = input( f"{text_color.GREEN_TEXT}What do you do?: {text_color.FINISH_COLOR}" ) if players_move in DIRECTIONS: valid_move = movement.validate_move(players_move, y_current, x_current) if valid_move is True: the_map, y_current, x_current = movement.player_moving( char_name, players_move, the_map, y_current, x_current) if random.randrange(5) == 2: battle = combat.fight(list_of_monsters[0], char_hp) if battle == "won": list_of_monsters.pop(0) if battle == "ranaway": print(f"{char_name} survived to fight another day.") else: mission_complete = True else: char_hp = combat.healing(char_hp) room_description = descriptions.ROOM_DESCRIPTIONS( char_name) print(room_description) elif valid_move is False: print( f"There's no opening and the wall seems impenetrable, perhaps you should take a {text_color.YELLOW_TEXT}different path{text_color.FINISH_COLOR}?" ) elif players_move == "check map": movement.mini_map(the_map) elif players_move == "look around": print(room_description) elif players_move == "help": guide.HELP() else: print(f"{char_name} lost their train of thought.")
def do_fight(self, args): """fight <mob> - fights a mob""" global mob_dead what_to_fight = args.lower() mob = cave_rooms[location][MOBS] if mob_dead: print('The', mob, 'is already dead!') elif what_to_fight == mob: mob_dead = combat.fight(mob) elif mob is None: print('There\'s nothing to fight!') else: print('Fight what?')
def assign(plr): if learning_the_ropes in plr.completed_quests: pass else: plr.quests.append(learning_the_ropes) plr.sim_type('\nElric: Pleased to see a new member. I will give you this wooden sword to get started.') wait() print("You've just received %s!\n" % swords.wooden_sword.name) swords.wooden_sword.graphic() print("\n --- %s --- " % swords.wooden_sword.name) print("Damage: 1") wait() plr.sim_type('Your first task is to attack this dummy. Give it a try.') wait() combat.fight(mobs.dummy(), plr) plr.sim_type('Elric: Well done %s. Your form is good, so I am assuming you have held a sword before.\n' % plr.name) learning_the_ropes.hand_in(plr)
def deal_with_challenge(challenge, character, corridor): from models.characters import Character, create_goblin messages = [ f"{character.name} takes a few more steps in the dark {corridor.name}" ] if isinstance(challenge, Character): enemy = challenge messages.append( f"{character.name} finds {enemy.name}, a {enemy.race} and get's ready for a fight." ) character, enemy, fight_message = fight(character, enemy) messages.append(fight_message) if not enemy.is_alive: messages.append(f"{enemy.name} dies") old_weapon = character.weapon equiped = character.loot(enemy.weapon) if equiped: messages.append( f"{character.name} equips {character.weapon} from the corpse" ) enemy.weapon = old_weapon elif isinstance(challenge, Item): item = challenge messages.append( f"{character.name} picks up the '{item}' triumphantly.") messages.append( f"The {character.name} gets corrupted by {item} and becomes the {corridor.name} master." ) corridor.update_boss(character) messages.extend(dm_creates_creatures(corridor)) elif isinstance(challenge, Scroll): messages.append(f"{character.name} finds a dusty scroll and reads it.") scroll = challenge messages.append(scroll.apply(character)) corridor.remove_from_corridor(scroll) messages.append(f"...the scroll crumbles into dust") elif isinstance(challenge, Food): messages.append( f"{character.name} finds a {challenge} and gobbles it down.") character.eat(challenge) elif isinstance(challenge, Weapon): weapon = challenge messages.append(f"{character.name} finds a {weapon}.") old_weapon = character.weapon equiped = character.loot(challenge) if equiped: messages.append(f"{character.name} equips {weapon}") corridor.add_to_corridor(old_weapon) corridor.remove_from_corridor(weapon) else: messages.append( f"After some inspection, {character.name} decides not to take {weapon}" ) #### #### #### #### #### if not character.is_alive: messages.append(f"{character.name} dies") if character.level > 2: messages.append( f"{character.name} gets ressurected by the {corridor.name} and becomes a part of it." ) corridor.add_to_corridor(character) else: messages.append( f"{character.name} is not worthy for the {corridor.name}. Three goblins get spawned in their place." ) corridor.add_to_corridor(create_goblin(character.weapon)) corridor.add_to_corridor(create_goblin()) corridor.add_to_corridor(create_goblin()) elif challenge == corridor.boss: messages.append( f"The {character.name} becomes the new {corridor.name} master.") corridor.update_boss(character) messages.extend(dm_creates_creatures(corridor)) return messages
def darkness(): #import text and make a user in the start state import darkness user.state = darkness.start nl() print(reformat(user.state.start[0])) nl() while user.complete == False: #User response rsp = play() #User escape option if rsp == 'exit': user.complete = True break #For testing only if rsp == 'list': print(user.state.options.keys()) rsp = play() if rsp == 'skip': user.state = darkness.state42 rsp = play() #Result of response result = testRsp(user.state.options, rsp) #Test if response is generated error message else run function if type(result) is str: print(result) else: print(reformat(result[0])) try: #How to call a combat scenario if result[1][0] == 'combat': x = fight(result[2], result[3]) #Successful combat means you move on if x == 'success': state = result[1][1] user.state = getattr(darkness, state) #If combat doesn't return success then it is a fail else: print(reformat(user.state.fail[0])) nl() user.complete = True break else: state = result[1] user.state = getattr(darkness, state) #The way to print end lines if result[1] == 'end' or result[1][1] == 'end': nl() print(reformat(darkness.end.closing[0])) nl() user.complete = True break #except: # pass #in case of tests except Exception: raise nl()