def create_test_map(): linguistics_logic.sync_static_restrictions() map_logic.create_test_map_info() p1 = places_logic.create_place( x=1, y=1, size=1, utg_name=names.generator().get_test_name(name='1x1'), race=relations.RACE.HUMAN) p2 = places_logic.create_place( x=3, y=3, size=3, utg_name=names.generator().get_test_name(name='10x10'), race=relations.RACE.HUMAN) p3 = places_logic.create_place( x=1, y=3, size=3, utg_name=names.generator().get_test_name(name='1x10'), race=relations.RACE.HUMAN) for place in places_storage.places.all(): for i in range(3): places_logic.add_person_to_place(place) RoadPrototype.create(point_1=p1, point_2=p2).update() RoadPrototype.create(point_1=p2, point_2=p3).update() update_waymarks() nearest_cells.update_nearest_cells() mob_1 = MobRecordPrototype.create_random('mob_1') mob_2 = MobRecordPrototype.create_random('mob_2') mob_3 = MobRecordPrototype.create_random('mob_3') ArtifactRecordPrototype.create_random('loot_1', mob=mob_1) ArtifactRecordPrototype.create_random('loot_2', mob=mob_2) ArtifactRecordPrototype.create_random('loot_3', mob=mob_3) ArtifactRecordPrototype.create_random('helmet_1', type_=ARTIFACT_TYPE.HELMET, mob=mob_1) ArtifactRecordPrototype.create_random('plate_1', type_=ARTIFACT_TYPE.PLATE, mob=mob_2) ArtifactRecordPrototype.create_random('boots_1', type_=ARTIFACT_TYPE.BOOTS, mob=mob_3) for equipment_slot in heroes_relations.EQUIPMENT_SLOT.records: if equipment_slot.default: ArtifactRecordPrototype.create_random(equipment_slot.default, type_=equipment_slot.artifact_type) companions_logic.create_random_companion_record('companion_1', dedication=companions_relations.DEDICATION.HEROIC, state=companions_relations.STATE.ENABLED) companions_logic.create_random_companion_record('companion_2', dedication=companions_relations.DEDICATION.BOLD, state=companions_relations.STATE.ENABLED) companions_logic.create_random_companion_record('companion_3', dedication=companions_relations.DEDICATION.BOLD, state=companions_relations.STATE.DISABLED) return p1, p2, p3
def test_person_arrived(self): with check_record_created(self, RECORD_TYPE.PERSON_ARRIVED_TO_PLACE): places_logic.add_person_to_place(self.place1)
def create_map(self): # pylint: disable=R0914, R0915 places_models.Place.objects.all().delete() roads_models.Road.objects.all().delete() map_info_storage.set_item( MapInfoPrototype.create( turn_number=0, width=map_settings.WIDTH, height=map_settings.HEIGHT, terrain=[[ TERRAIN.PLANE_GREENWOOD for j in xrange(map_settings.WIDTH) ] for i in xrange(map_settings.HEIGHT)], world=WorldInfoPrototype.create(w=map_settings.WIDTH, h=map_settings.HEIGHT))) p1x1 = self.create_place(1, 1, size=1) p14x1 = self.create_place(14, 1, size=1) p27x1 = self.create_place(27, 1, size=6) p5x3 = self.create_place(5, 3, size=5) p1x9 = self.create_place(1, 9, size=6) p5x12 = self.create_place(5, 12, size=1) p3x17 = self.create_place(3, 17, size=10) p10x18 = self.create_place(10, 18, size=3) p11x11 = self.create_place(11, 11, size=4) p11x6 = self.create_place(11, 6, size=4) p19x5 = self.create_place(19, 5, size=3) p20x8 = self.create_place(20, 8, size=9) p24x8 = self.create_place(24, 8, size=10) p17x12 = self.create_place(17, 12, size=2) p19x17 = self.create_place(19, 17, size=8) p24x13 = self.create_place(24, 13, size=1) p27x13 = self.create_place(27, 13, size=1) p28x19 = self.create_place(28, 19, size=3) self.create_road(p1x1, p5x3) self.create_road(p5x3, p1x9) self.create_road(p5x3, p11x6) self.create_road(p1x9, p5x12) self.create_road(p5x12, p3x17) self.create_road(p5x12, p11x11) self.create_road(p3x17, p10x18) self.create_road(p11x11, p10x18) self.create_road(p11x11, p11x6) self.create_road(p11x11, p19x17) self.create_road(p11x11, p17x12) self.create_road(p11x11, p20x8) self.create_road(p11x6, p14x1) self.create_road(p14x1, p27x1) self.create_road(p27x1, p24x8) self.create_road(p24x8, p20x8) self.create_road(p24x8, p24x13) self.create_road(p24x8, p27x13) self.create_road(p20x8, p19x5) self.create_road(p20x8, p17x12) self.create_road(p19x17, p24x13) self.create_road(p28x19, p24x13) self.create_road(p28x19, p27x13) places_storage.places.update_version() roads_storage.update_version() for place in places_storage.places.all(): for i in xrange(random.randint(2, 6)): places_logic.add_person_to_place(place) persons_storage.persons.update_version() terrain = [] for y in xrange(0, map_settings.HEIGHT): # pylint: disable=W0612 row = [] terrain.append(row) for x in xrange(0, map_settings.WIDTH): # pylint: disable=W0612 row.append(TERRAIN.PLANE_GREENWOOD) map_info_storage.set_item( MapInfoPrototype.create(turn_number=0, width=map_settings.WIDTH, height=map_settings.HEIGHT, terrain=terrain, world=WorldInfoPrototype.create( w=map_settings.WIDTH, h=map_settings.HEIGHT))) map_info_storage.update_version()
def setUp(self): super(QuestsTestBase, self).setUp() self.p1, self.p2, self.p3 = create_test_map() # add more persons, to lower conflicts places_logic.add_person_to_place(self.p1) places_logic.add_person_to_place(self.p1) places_logic.add_person_to_place(self.p2) places_logic.add_person_to_place(self.p2) places_logic.add_person_to_place(self.p3) places_logic.add_person_to_place(self.p3) account = self.accounts_factory.create_account(is_fast=True) self.storage = LogicStorage() self.storage.load_account_data(account) self.hero = self.storage.accounts_to_heroes[account.id] self.action_idl = self.hero.actions.current_action self.hero.money += 1 self.hero.preferences.set(heroes_relations.PREFERENCE_TYPE.MOB, mobs_storage.mobs.all()[0]) self.hero.preferences.set(heroes_relations.PREFERENCE_TYPE.PLACE, self.p1) self.hero.preferences.set(heroes_relations.PREFERENCE_TYPE.FRIEND, self.p1.persons[0]) self.hero.preferences.set(heroes_relations.PREFERENCE_TYPE.ENEMY, self.p2.persons[0]) self.hero.preferences.set(heroes_relations.PREFERENCE_TYPE.EQUIPMENT_SLOT, heroes_relations.EQUIPMENT_SLOT.PLATE) self.hero.position.set_place(self.p3) heroes_logic.save_hero(self.hero) self.p2.set_modifier(places_modifiers.CITY_MODIFIERS.HOLY_CITY) places_logic.save_place(self.p2) self.p1.persons[0].type = PERSON_TYPE.BLACKSMITH persons_logic.save_person(self.p1.persons[0])
def create_map(self): # pylint: disable=R0914, R0915 places_models.Place.objects.all().delete() roads_models.Road.objects.all().delete() map_info_storage.set_item(MapInfoPrototype.create(turn_number=0, width=map_settings.WIDTH, height=map_settings.HEIGHT, terrain=[ [TERRAIN.PLANE_GREENWOOD for j in xrange(map_settings.WIDTH)] for i in xrange(map_settings.HEIGHT)], world=WorldInfoPrototype.create(w=map_settings.WIDTH, h=map_settings.HEIGHT))) p1x1 = self.create_place(1, 1, size=1) p14x1 = self.create_place(14, 1, size=1) p27x1 = self.create_place(27, 1, size=6) p5x3 = self.create_place(5, 3, size=5) p1x9 = self.create_place(1, 9, size=6) p5x12 = self.create_place(5, 12, size=1) p3x17 = self.create_place(3, 17, size=10) p10x18 = self.create_place(10, 18, size=3) p11x11 = self.create_place(11, 11, size=4) p11x6 = self.create_place(11, 6, size=4) p19x5 = self.create_place(19, 5, size=3) p20x8 = self.create_place(20, 8, size=9) p24x8 = self.create_place(24, 8, size=10) p17x12 = self.create_place(17, 12, size=2) p19x17 = self.create_place(19, 17, size=8) p24x13 = self.create_place(24, 13, size=1) p27x13 = self.create_place(27, 13, size=1) p28x19 = self.create_place(28, 19, size=3) self.create_road(p1x1, p5x3) self.create_road(p5x3, p1x9) self.create_road(p5x3, p11x6) self.create_road(p1x9, p5x12) self.create_road(p5x12, p3x17) self.create_road(p5x12, p11x11) self.create_road(p3x17, p10x18) self.create_road(p11x11, p10x18) self.create_road(p11x11, p11x6) self.create_road(p11x11, p19x17) self.create_road(p11x11, p17x12) self.create_road(p11x11, p20x8) self.create_road(p11x6, p14x1) self.create_road(p14x1, p27x1) self.create_road(p27x1, p24x8) self.create_road(p24x8, p20x8) self.create_road(p24x8, p24x13) self.create_road(p24x8, p27x13) self.create_road(p20x8, p19x5) self.create_road(p20x8, p17x12) self.create_road(p19x17, p24x13) self.create_road(p28x19, p24x13) self.create_road(p28x19, p27x13) places_storage.places.update_version() roads_storage.update_version() for place in places_storage.places.all(): for i in xrange(random.randint(2, 6)): places_logic.add_person_to_place(place) persons_storage.persons.update_version() terrain = [] for y in xrange(0, map_settings.HEIGHT): # pylint: disable=W0612 row = [] terrain.append(row) for x in xrange(0, map_settings.WIDTH): # pylint: disable=W0612 row.append(TERRAIN.PLANE_GREENWOOD) map_info_storage.set_item(MapInfoPrototype.create(turn_number=0, width=map_settings.WIDTH, height=map_settings.HEIGHT, terrain=terrain, world=WorldInfoPrototype.create(w=map_settings.WIDTH, h=map_settings.HEIGHT))) map_info_storage.update_version()
def setUp(self): super(QuestsTestBase, self).setUp() self.p1, self.p2, self.p3 = create_test_map() # add more persons, to lower conflicts places_logic.add_person_to_place(self.p1) places_logic.add_person_to_place(self.p1) places_logic.add_person_to_place(self.p2) places_logic.add_person_to_place(self.p2) places_logic.add_person_to_place(self.p3) places_logic.add_person_to_place(self.p3) persons_logic.sync_social_connections() result, account_id, bundle_id = register_user('test_user') self.storage = LogicStorage() self.storage.load_account_data(AccountPrototype.get_by_id(account_id)) self.hero = self.storage.accounts_to_heroes[account_id] self.action_idl = self.hero.actions.current_action self.hero.money += 1 self.hero.preferences.set_mob(mobs_storage.all()[0]) self.hero.preferences.set_place(self.p1) self.hero.preferences.set_friend(self.p1.persons[0]) self.hero.preferences.set_enemy(self.p2.persons[0]) self.hero.preferences.set_equipment_slot(EQUIPMENT_SLOT.PLATE) self.hero.position.set_place(self.p3) heroes_logic.save_hero(self.hero) self.p2.set_modifier(places_modifiers.CITY_MODIFIERS.HOLY_CITY) places_logic.save_place(self.p2) self.p1.persons[0].type = PERSON_TYPE.BLACKSMITH persons_logic.save_person(self.p1.persons[0])
def setUp(self): super(QuestsTestBase, self).setUp() self.p1, self.p2, self.p3 = create_test_map() # add more persons, to lower conflicts places_logic.add_person_to_place(self.p1) places_logic.add_person_to_place(self.p1) places_logic.add_person_to_place(self.p2) places_logic.add_person_to_place(self.p2) places_logic.add_person_to_place(self.p3) places_logic.add_person_to_place(self.p3) account = self.accounts_factory.create_account(is_fast=True) self.storage = LogicStorage() self.storage.load_account_data(account) self.hero = self.storage.accounts_to_heroes[account.id] self.action_idl = self.hero.actions.current_action self.hero.money += 1 self.hero.preferences.set_mob(mobs_storage.all()[0]) self.hero.preferences.set_place(self.p1) self.hero.preferences.set_friend(self.p1.persons[0]) self.hero.preferences.set_enemy(self.p2.persons[0]) self.hero.preferences.set_equipment_slot(EQUIPMENT_SLOT.PLATE) self.hero.position.set_place(self.p3) heroes_logic.save_hero(self.hero) self.p2.set_modifier(places_modifiers.CITY_MODIFIERS.HOLY_CITY) places_logic.save_place(self.p2) self.p1.persons[0].type = PERSON_TYPE.BLACKSMITH persons_logic.save_person(self.p1.persons[0])