def adjacent_moves_enemy(self, area): moves = [] if world.tile_exists(x=self.x, y=self.y - 1, area=self.area): moves.append(actions.MoveNorthEnemy()) if world.tile_exists(x=self.x, y=self.y + 1, area=self.area): moves.append(actions.MoveSouthEnemy()) if world.tile_exists(x=self.x + 1, y=self.y, area=self.area): moves.append(actions.MoveEastEnemy()) if world.tile_exists(x=self.x - 1, y=self.y, area=self.area): moves.append(actions.MoveWestEnemy()) return moves
def __init__(self, character, **kwargs): DoActions.__init__(self, character, **kwargs) if character.check_round_time(): return if character.is_dead(): return if not character.check_position_to_move(): return if world.tile_exists(x=self.character.location_x + 1, y=self.character.location_y, area=self.character.area): if character.room.shop_filled == True: if character.room.shop.in_shop == True: character.room.shop.exit_shop() old_room = self.character.room.room_number self.character.move_east() self.update_room(old_room_number=old_room, new_room_number=self.character.room.room_number) self.update_status(character.get_status()) return else: events.game_event( "You cannot find a way to move in that direction.") return
def obvious_exits(self): """Returns all of the available actions in this room.""" moves = [] if world.tile_exists(x=self.x, y=self.y - 1, area=self.area): moves.append("north") if world.tile_exists(x=self.x, y=self.y + 1, area=self.area): moves.append("south") if world.tile_exists(x=self.x + 1, y=self.y, area=self.area): moves.append("east") if world.tile_exists(x=self.x - 1, y=self.y, area=self.area): moves.append("west") obvious = [] if len(moves) == 0: obvious = 'None' return "Obvious exits: {}".format(obvious) for move in moves: obvious.append(move) obvious = ', '.join(obvious) return "Obvious exits: {}".format(obvious)
def move(self, dx, dy): self.room.remove_enemy(self) if self.room == self.target.room: events.game_event(self.text_move_out) self.location_x += dx self.location_y += dy self.room = world.tile_exists(x=self.location_x, y=self.location_y, area=self.area) self.room.add_enemy(self) if self.room == self.target.room: events.game_event(self.text_move_in)
def go_object(self, character): if character.room.room_name == self.object_data['location_1']['name']: new_location = self.object_data['location_2'] elif character.room.room_name == self.object_data['location_2']['name']: new_location = self.object_data['location_1'] character.room = world.tile_exists(x=new_location['x'], y=new_location['y'], area=new_location['area'].replace(" ","")) character.location_x = new_location['x'] character.location_y = new_location['y'] character.area = new_location['area'] character.room.fill_room(character=character) print("does code go here?") character.room.intro_text() character.print_status() character.room.run(character=character)
def __init__(self, character, **kwargs): DoActions.__init__(self, character, **kwargs) if character.check_round_time(): return if character.is_dead(): return if not character.check_position_to_move(): return if world.tile_exists(x=self.character.location_x - 1, y=self.character.location_y, area=self.character.area): if character.room.shop_filled == True: if character.room.shop.in_shop == True: character.room.shop.exit_shop() self.character.move_west() character.print_status() else: events.game_event( "You cannot find a way to move in that direction.")
def spawn_generator(self, character): area_rooms = world.area_rooms(self.area) while character.area == self.area.replace(" ", ""): time.sleep(5) area_enemies = world.area_enemies(self.area) if len(area_enemies) < 1: area_rooms = { keys: value for keys, value in area_rooms.items() if value is not None } spawn_room_coords = random.choice(list(area_rooms)) if random.randint(0, 100) > 50: spawn_room = world.tile_exists(x=spawn_room_coords[0], y=spawn_room_coords[1], area=self.area) spawn_room.enemies.append( enemies.Enemy(enemy_name=self._room_data['spawn'][0], target=character, room=spawn_room, location_x=spawn_room_coords[0], location_y=spawn_room_coords[1], area=self.area)) spawn_room.enemies[-1].start()
def move(self, dx, dy): self.location_x += dx self.location_y += dy self.room = world.tile_exists(x=self.location_x, y=self.location_y, area=self.area) self.room.fill_room(character=self) return
def __init__(self, player_name: str, **kwargs): self._player_data = self.get_player_by_name(name=player_name) self._name = self._player_data['first_name'] self._first_name = self._player_data['first_name'] self._last_name = self._player_data['last_name'] self._gender = self._player_data['gender'] self._object_pronoun = None self._possessive_pronoun = None self._race = self._player_data['race'] self._profession = self._player_data['profession'] self._category = self._player_data['category'] self._position = self._player_data['position'] self._stance = self._player_data['stance'] self._level = self._player_data['level'] self._experience = self._player_data['experience'] self._stats = self._player_data['stats'] self._stats_bonus = self._player_data['stats_bonus'] self._stats_base = self._player_data['stats_base'] self._training_points = self._player_data['training'] self._physical_training_points = self._player_data['training']['physical_points'] self._mental_training_points = self._player_data['training']['mental_points'] self._skills = self._player_data['skills'] self._skills_base = self._player_data['skills_base'] self._skills_bonus = self._player_data['skills_bonus'] self._health = self._player_data['health'] self._health_max = self._player_data['health_max'] self._attack_strength_base = 0 self._defense_strength_evade_base = 0 self._defense_strength_block_base = 0 self._defense_strength_parry_base = 0 self.mana = self._player_data['mana'] self.money = self._player_data['money'] self._armor = {} for category in self._player_data['armor']: for item in self._player_data['armor'][category]: self._armor[category] = items.create_item('armor', item_name=item) self._inventory = [] for category in self._player_data['inventory']: for item in self._player_data['inventory'][category]: self._inventory.append(items.create_item(item_category=category, item_name=item)) self._right_hand_inv = None if len(self._player_data['right_hand']['item_name']) != 0: self._right_hand_inv.append(items.create_item(item_category=self._player_data['right_hand']['item_category'], item_name=self._player_data['right_hand']['item_name'])) self._left_hand_inv = None if len(self._player_data['left_hand']['item_name']) != 0: self._left_hand_inv.append(items.create_item(item_category=self._player_data['left_hand']['item_category'], item_name=self._player_data['left_hand']['item_name'])) self.dominance = "right_hand" self.non_dominance = "left_hand" self.location_x, self.location_y = world.starting_position self.room = world.tile_exists(x=self.location_x, y=self.location_y, area='Field') self.area = 'Field' self.target = None self.rt_start = 0 self.rt_end = 0 self.quests = {} for quest in self._player_data['quests']: self.quests[quest] = quests.Quest(quest_name=quest, character=self) self.quests[quest].start()
def new_character(): message = "" form = NewCharacterForm() stats = config.get_stats_data_file() stats_initial = {} stats_total = 0 if form.validate_on_submit(): result = request.form first_name = result['first_name'] last_name = result['last_name'] gender = result['gender'] profession = result['profession'] for stat in stats: stats_initial[stat.lower()] = int(result[stat]) stats_total += stats_initial[stat.lower()] new_character = player.create_character('new_player') new_character.name = first_name new_character.first_name = first_name new_character.last_name = last_name new_character.gender = gender new_character.profession = profession for stat in new_character.stats: new_character.stats[stat] = stats_initial[stat] new_character.set_character_attributes() new_character.set_gender(new_character.gender) new_character.level_up_skill_points() # character_print = ''' # *** You have created a new character! *** # First Name: {} # Last Name: {} # Gender: {} # Profession: {} # '''.format(first_name, # last_name, # gender, # profession) # stat_print = "" # for stat in stats: # stat_print = stat_print + "\n" + stat + ": " + str(stats_initial[stat.lower()]) # character_print = character_print + "\n" + stat_print # events.game_event(character_print) # game_intro = ''' # The beast becomes restless... hungry and tired... # ...it trembles with anger, and the earth shakes... # Far away, you lay in a field surrounded by trees. # You close your eyes and an unsettling feeling comes over you. You dread having to go back into town and resume a # day you already know is going to be a waste. But you know that people rely on you and your resolve. They trust you, # at least that's what they say. "{} really knows how to get things done," they would say. # You open your eyes... # '''.format(new_character.object_pronoun) # events.game_event(game_intro) new_character.room = world.tile_exists(x=new_character.location_x, y=new_character.location_y, area=new_character.area) current_user.character_1 = new_character db.session.commit() new_character.room.fill_room(character=new_character) new_character.room.intro_text() new_character.get_status() return '<h1>Character Created! Please close the window and return to the main page.</h1>' return render_template('/new_character.html', form=form, Stats=stats)