def test_generate_artifact(self): from the_tale.game.mobs.prototypes import MobPrototype, MobRecordPrototype self.hero.level = 5 mob_record = MobRecordPrototype.create_random(uuid='bandit', level=2, state=mobs_relations.MOB_RECORD_STATE.ENABLED) mob = MobPrototype(record_id=mob_record.id, level=3) artifact_1 = ArtifactRecordPrototype.create_random('bandit_loot', mob=mob_record, type_=relations.ARTIFACT_TYPE.USELESS, state=relations.ARTIFACT_RECORD_STATE.ENABLED) artifact_2 = ArtifactRecordPrototype.create_random('bandit_artifact', mob=mob_record, type_=relations.ARTIFACT_TYPE.HELMET, state=relations.ARTIFACT_RECORD_STATE.ENABLED) with mock.patch('the_tale.game.heroes.objects.Hero.artifacts_probability', lambda self, mob: 1.0): with mock.patch('the_tale.game.heroes.objects.Hero.loot_probability', lambda self, mob: 1.0): artifact = artifacts_storage.generate_loot(self.hero, mob) self.assertEqual(artifact.level, mob.level) self.assertFalse(artifact.type.is_USELESS) self.assertEqual(artifact_2.id, artifact.record.id) with mock.patch('the_tale.game.heroes.objects.Hero.artifacts_probability', lambda self, mob: 0.0): with mock.patch('the_tale.game.heroes.objects.Hero.loot_probability', lambda self, mob: 1.0): artifact = artifacts_storage.generate_loot(self.hero, mob) self.assertEqual(artifact.level, mob.record.level) self.assertTrue(artifact.type.is_USELESS) self.assertEqual(artifact_1.id, artifact.record.id) with mock.patch('the_tale.game.heroes.objects.Hero.artifacts_probability', lambda self, mob: 0.0): with mock.patch('the_tale.game.heroes.objects.Hero.loot_probability', lambda self, mob: 0.0): self.assertEqual(artifacts_storage.generate_loot(self.hero, mob), None)
def test_disabled_artifacts(self): loot = ArtifactRecordPrototype.create_random( 'disabled_loot', type_=relations.ARTIFACT_TYPE.USELESS, state=relations.ARTIFACT_RECORD_STATE.DISABLED) artifact = ArtifactRecordPrototype.create_random( 'disabled_artifact', type_=relations.ARTIFACT_TYPE.HELMET, state=relations.ARTIFACT_RECORD_STATE.DISABLED) self.assertFalse( set(['disabled_loot', 'disabled_artifact']) & set(a.uuid for a in artifacts_storage.artifacts)) self.assertFalse( set(['disabled_loot', 'disabled_artifact']) & set(a.uuid for a in artifacts_storage.loot)) self.assertFalse( set(['disabled_loot', 'disabled_artifact']) & set( artifacts_storage.artifacts_for_type([ relations.ARTIFACT_TYPE.USELESS, relations.ARTIFACT_TYPE.HELMET ]))) self.assertEqual( artifacts_storage.generate_artifact_from_list( [loot, artifact], level=1, rarity=relations.RARITY.NORMAL), None)
def test_generate_artifact__rarity(self): from the_tale.game.mobs.prototypes import MobPrototype, MobRecordPrototype self.hero.level = 5 mob_record = MobRecordPrototype.create_random( uuid='bandit', level=2, state=mobs_relations.MOB_RECORD_STATE.ENABLED) mob = MobPrototype(record_id=mob_record.id, level=3) ArtifactRecordPrototype.create_random( 'bandit_artifact', mob=mob_record, type_=relations.ARTIFACT_TYPE.HELMET, state=relations.ARTIFACT_RECORD_STATE.ENABLED) with mock.patch( 'the_tale.game.artifacts.storage.ArtifactsStorage.get_rarity_type', lambda self, hero: relations.RARITY.NORMAL): artifact = artifacts_storage.generate_loot(self.hero, mob) self.assertTrue(artifact.rarity.is_NORMAL) with mock.patch( 'the_tale.game.artifacts.storage.ArtifactsStorage.get_rarity_type', lambda self, hero: relations.RARITY.RARE): artifact = artifacts_storage.generate_loot(self.hero, mob) self.assertTrue(artifact.rarity.is_RARE) with mock.patch( 'the_tale.game.artifacts.storage.ArtifactsStorage.get_rarity_type', lambda self, hero: relations.RARITY.EPIC): artifact = artifacts_storage.generate_loot(self.hero, mob) self.assertTrue(artifact.rarity.is_EPIC)
def test_mobs_without_artifacts(self): self.request_login(self.account_2.email) from the_tale.game.mobs.prototypes import MobRecordPrototype from the_tale.game.artifacts.prototypes import ArtifactRecordPrototype mob_without_loot = MobRecordPrototype.create_random('no_loot') mob_without_artifact = MobRecordPrototype.create_random('no_artifact') mob_without_loot_on_first_level = MobRecordPrototype.create_random( 'no_loot_on_1_level') mob_without_artifact_on_firs_level = MobRecordPrototype.create_random( 'no_artifact_on_1_level') ArtifactRecordPrototype.create_random( 'not_first_loot', mob=mob_without_loot_on_first_level, level=mob_without_loot_on_first_level.level + 1) ArtifactRecordPrototype.create_random( 'not_first_artifact', mob=mob_without_artifact_on_firs_level, level=mob_without_artifact_on_firs_level.level + 1) self.check_html_ok(self.request_html( reverse('portal:developers-info:mobs-and-artifacts')), texts=[ mob_without_loot.name, mob_without_artifact.name, mob_without_loot_on_first_level.name, mob_without_artifact_on_firs_level.name ])
def test_generate_artifact__rarity(self): from the_tale.game.mobs.prototypes import MobPrototype, MobRecordPrototype self.hero.level = 5 mob_record = MobRecordPrototype.create_random( uuid="bandit", level=2, state=mobs_relations.MOB_RECORD_STATE.ENABLED ) mob = MobPrototype(record_id=mob_record.id, level=3) ArtifactRecordPrototype.create_random( "bandit_artifact", mob=mob_record, type_=relations.ARTIFACT_TYPE.HELMET, state=relations.ARTIFACT_RECORD_STATE.ENABLED, ) with mock.patch( "the_tale.game.artifacts.storage.ArtifactsStorage.get_rarity_type", lambda self, hero: relations.RARITY.NORMAL, ): artifact = artifacts_storage.generate_loot(self.hero, mob) self.assertTrue(artifact.rarity.is_NORMAL) with mock.patch( "the_tale.game.artifacts.storage.ArtifactsStorage.get_rarity_type", lambda self, hero: relations.RARITY.RARE ): artifact = artifacts_storage.generate_loot(self.hero, mob) self.assertTrue(artifact.rarity.is_RARE) with mock.patch( "the_tale.game.artifacts.storage.ArtifactsStorage.get_rarity_type", lambda self, hero: relations.RARITY.EPIC ): artifact = artifacts_storage.generate_loot(self.hero, mob) self.assertTrue(artifact.rarity.is_EPIC)
def test_artifacts_without_mobs(self): self.request_login('*****@*****.**') from the_tale.game.artifacts.prototypes import ArtifactRecordPrototype no_mob_loot = ArtifactRecordPrototype.create_random('no_mob_loot', level=1) no_mob_artifact = ArtifactRecordPrototype.create_random('no_mob_artifact', level=1) self.check_html_ok(self.request_html(reverse('portal:developers-info:mobs-and-artifacts')), texts=[no_mob_loot.name, no_mob_artifact.name])
def test_disabled_artifacts(self): loot = ArtifactRecordPrototype.create_random('disabled_loot', type_=relations.ARTIFACT_TYPE.USELESS, state=relations.ARTIFACT_RECORD_STATE.DISABLED) artifact = ArtifactRecordPrototype.create_random('disabled_artifact', type_=relations.ARTIFACT_TYPE.HELMET, state=relations.ARTIFACT_RECORD_STATE.DISABLED) self.assertFalse(set(['disabled_loot', 'disabled_artifact']) & set(a.uuid for a in artifacts_storage.artifacts)) self.assertFalse(set(['disabled_loot', 'disabled_artifact']) & set(a.uuid for a in artifacts_storage.loot)) self.assertFalse(set(['disabled_loot', 'disabled_artifact']) & set(artifacts_storage.artifacts_for_type([relations.ARTIFACT_TYPE.USELESS, relations.ARTIFACT_TYPE.HELMET]))) self.assertEqual(artifacts_storage.generate_artifact_from_list([loot, artifact], level=1, rarity=relations.RARITY.NORMAL), None)
def test_artifacts_attributes(self): ArtifactRecordPrototype.create(uuid='bandit_loot', level=1, utg_name=names.generator().get_test_name('artifact'), description='bandit loot description', type_=relations.ARTIFACT_TYPE.HELMET, power_type=relations.ARTIFACT_POWER_TYPE.NEUTRAL) loot = ArtifactPrototype(record_id=artifacts_storage.get_by_uuid('bandit_loot').id, level=1) self.assertFalse(loot.is_useless)
def test_generate_artifact(self): from the_tale.game.mobs.prototypes import MobPrototype, MobRecordPrototype self.hero.level = 5 mob_record = MobRecordPrototype.create_random( uuid='bandit', level=2, state=mobs_relations.MOB_RECORD_STATE.ENABLED) mob = MobPrototype(record_id=mob_record.id, level=3) artifact_1 = ArtifactRecordPrototype.create_random( 'bandit_loot', mob=mob_record, type_=relations.ARTIFACT_TYPE.USELESS, state=relations.ARTIFACT_RECORD_STATE.ENABLED) artifact_2 = ArtifactRecordPrototype.create_random( 'bandit_artifact', mob=mob_record, type_=relations.ARTIFACT_TYPE.HELMET, state=relations.ARTIFACT_RECORD_STATE.ENABLED) with mock.patch( 'the_tale.game.heroes.objects.Hero.artifacts_probability', lambda self, mob: 1.0): with mock.patch( 'the_tale.game.heroes.objects.Hero.loot_probability', lambda self, mob: 1.0): artifact = artifacts_storage.generate_loot(self.hero, mob) self.assertEqual(artifact.level, mob.level) self.assertFalse(artifact.type.is_USELESS) self.assertEqual(artifact_2.id, artifact.record.id) with mock.patch( 'the_tale.game.heroes.objects.Hero.artifacts_probability', lambda self, mob: 0.0): with mock.patch( 'the_tale.game.heroes.objects.Hero.loot_probability', lambda self, mob: 1.0): artifact = artifacts_storage.generate_loot(self.hero, mob) self.assertEqual(artifact.level, mob.record.level) self.assertTrue(artifact.type.is_USELESS) self.assertEqual(artifact_1.id, artifact.record.id) with mock.patch( 'the_tale.game.heroes.objects.Hero.artifacts_probability', lambda self, mob: 0.0): with mock.patch( 'the_tale.game.heroes.objects.Hero.loot_probability', lambda self, mob: 0.0): self.assertEqual( artifacts_storage.generate_loot(self.hero, mob), None)
def test_artifacts_without_mobs(self): self.request_login(self.account_2.email) from the_tale.game.artifacts.prototypes import ArtifactRecordPrototype no_mob_loot = ArtifactRecordPrototype.create_random('no_mob_loot', level=1) no_mob_artifact = ArtifactRecordPrototype.create_random( 'no_mob_artifact', level=1) self.check_html_ok(self.request_html( reverse('portal:developers-info:mobs-and-artifacts')), texts=[no_mob_loot.name, no_mob_artifact.name])
def test_artifacts_attributes(self): ArtifactRecordPrototype.create( uuid='bandit_loot', level=1, utg_name=names.generator.get_test_name('artifact'), description='bandit loot description', type_=relations.ARTIFACT_TYPE.HELMET, power_type=relations.ARTIFACT_POWER_TYPE.NEUTRAL) loot = ArtifactPrototype( record_id=artifacts_storage.get_by_uuid('bandit_loot').id, level=1) self.assertFalse(loot.is_useless)
def setUp(self): super(ReceiveArtifactsChoicesTests, self).setUp() self.assertTrue(any(artifact.power_type.is_NEUTRAL for artifact in artifacts_storage.artifacts)) self.hero.level = 100 self.base_artifacts = list(artifacts_storage.artifacts) self.artifact_most_magic = ArtifactRecordPrototype.create_random('most_magic', power_type=artifacts_relations.ARTIFACT_POWER_TYPE.MOST_MAGICAL, level=1, type_=artifacts_relations.ARTIFACT_TYPE.PLATE) self.artifact_magic = ArtifactRecordPrototype.create_random('magic', power_type=artifacts_relations.ARTIFACT_POWER_TYPE.MAGICAL, level=2, type_=artifacts_relations.ARTIFACT_TYPE.HELMET) self.artifact_neutral = ArtifactRecordPrototype.create_random('neutral', power_type=artifacts_relations.ARTIFACT_POWER_TYPE.NEUTRAL, level=3, type_=artifacts_relations.ARTIFACT_TYPE.MAIN_HAND) self.artifact_physic = ArtifactRecordPrototype.create_random('physic', power_type=artifacts_relations.ARTIFACT_POWER_TYPE.PHYSICAL, level=4, type_=artifacts_relations.ARTIFACT_TYPE.OFF_HAND) self.artifact_most_physic = ArtifactRecordPrototype.create_random('most_physic', power_type=artifacts_relations.ARTIFACT_POWER_TYPE.MOST_PHYSICAL, level=5, type_=artifacts_relations.ARTIFACT_TYPE.CLOAK)
def setUp(self): super(ReceiveArtifactsChoicesTests, self).setUp() self.assertTrue(any(artifact.power_type.is_NEUTRAL for artifact in artifacts_storage.artifacts)) self.hero._model.level = 100 self.base_artifacts = list(artifacts_storage.artifacts) self.artifact_most_magic = ArtifactRecordPrototype.create_random('most_magic', power_type=artifacts_relations.ARTIFACT_POWER_TYPE.MOST_MAGICAL, level=1, type_=artifacts_relations.ARTIFACT_TYPE.PLATE) self.artifact_magic = ArtifactRecordPrototype.create_random('magic', power_type=artifacts_relations.ARTIFACT_POWER_TYPE.MAGICAL, level=2, type_=artifacts_relations.ARTIFACT_TYPE.HELMET) self.artifact_neutral = ArtifactRecordPrototype.create_random('neutral', power_type=artifacts_relations.ARTIFACT_POWER_TYPE.NEUTRAL, level=3, type_=artifacts_relations.ARTIFACT_TYPE.MAIN_HAND) self.artifact_physic = ArtifactRecordPrototype.create_random('physic', power_type=artifacts_relations.ARTIFACT_POWER_TYPE.PHYSICAL, level=4, type_=artifacts_relations.ARTIFACT_TYPE.OFF_HAND) self.artifact_most_physic = ArtifactRecordPrototype.create_random('most_physic', power_type=artifacts_relations.ARTIFACT_POWER_TYPE.MOST_PHYSICAL, level=5, type_=artifacts_relations.ARTIFACT_TYPE.CLOAK)
def test_linguistics_restriction_on_create(self): with mock.patch('the_tale.linguistics.logic.sync_restriction') as sync_restriction: artifact = ArtifactRecordPrototype.create_random(uuid='bandit_loot') self.assertEqual(sync_restriction.call_args_list, [mock.call(group=linguistics_relations.TEMPLATE_RESTRICTION_GROUP.ARTIFACT, external_id=artifact.id, name=artifact.name)])
def test_generate_artifact__rarity_with_normal_probabilities(self): from the_tale.game.mobs.prototypes import MobPrototype, MobRecordPrototype self.hero.level = 5 mob_record = MobRecordPrototype.create_random(uuid='bandit', level=2, state=mobs_relations.MOB_RECORD_STATE.ENABLED) mob = MobPrototype(record_id=mob_record.id, level=3) ArtifactRecordPrototype.create_random('bandit_artifact', mob=mob_record, type_=relations.ARTIFACT_TYPE.HELMET, state=relations.ARTIFACT_RECORD_STATE.ENABLED) rarities = set() for i in range(10000): artifact = artifacts_storage.generate_loot(self.hero, mob) rarities.add(artifact.rarity) self.assertEqual(rarities, set(relations.RARITY.records))
def test_mobs_without_artifacts(self): self.request_login('*****@*****.**') from the_tale.game.mobs.prototypes import MobRecordPrototype from the_tale.game.artifacts.prototypes import ArtifactRecordPrototype mob_without_loot = MobRecordPrototype.create_random('mob_without_loot') mob_without_artifact = MobRecordPrototype.create_random('mob_without_artifact') mob_without_loot_on_first_level = MobRecordPrototype.create_random('mob_without_loot_on_first_level') mob_without_artifact_on_firs_level = MobRecordPrototype.create_random('mob_without_artifact_on_firs_level') ArtifactRecordPrototype.create_random('not_first_loot', mob=mob_without_loot_on_first_level, level=mob_without_loot_on_first_level.level+1) ArtifactRecordPrototype.create_random('not_first_artifact', mob=mob_without_artifact_on_firs_level, level=mob_without_artifact_on_firs_level.level+1) self.check_html_ok(self.request_html(reverse('portal:developers-info:mobs-and-artifacts')), texts=[mob_without_loot.name, mob_without_artifact.name, mob_without_loot_on_first_level.name, mob_without_artifact_on_firs_level.name])
def test_linguistics_restriction_version_update_on_save(self): artifact = ArtifactRecordPrototype.create_random(uuid='bandit_loot') artifact.set_utg_name(names.generator().get_test_name('new-name')) with mock.patch('the_tale.linguistics.logic.sync_restriction') as sync_restriction: artifact.save() self.assertEqual(sync_restriction.call_args_list, [mock.call(group=linguistics_relations.TEMPLATE_RESTRICTION_GROUP.ARTIFACT, external_id=artifact.id, name=artifact.name)])
def test_change_uuid(self): loot = ArtifactRecordPrototype.create_random('some_loot', type_=relations.ARTIFACT_TYPE.USELESS, state=relations.ARTIFACT_RECORD_STATE.DISABLED) form = ModerateArtifactRecordForm(self.get_form_data(loot)) self.assertTrue(form.is_valid()) self.assertEqual(loot.uuid, artifacts_storage.get_by_uuid(loot.uuid).uuid) loot.update_by_moderator(form) self.assertEqual(loot.uuid, artifacts_storage.get_by_uuid(loot.uuid).uuid)
def test_linguistics_restriction_on_create(self): with mock.patch('the_tale.linguistics.logic.sync_restriction' ) as sync_restriction: artifact = ArtifactRecordPrototype.create_random( uuid='bandit_loot') self.assertEqual(sync_restriction.call_args_list, [ mock.call(group=linguistics_relations.TEMPLATE_RESTRICTION_GROUP. ARTIFACT, external_id=artifact.id, name=artifact.name) ])
def test_generate_artifact_from_list(self): helmet_2 = ArtifactRecordPrototype.create_random( 'helmet_2', type_=relations.ARTIFACT_TYPE.HELMET) plate_2 = ArtifactRecordPrototype.create_random( 'plate_2', type_=relations.ARTIFACT_TYPE.PLATE) boots_2 = ArtifactRecordPrototype.create_random( 'boots_2', type_=relations.ARTIFACT_TYPE.BOOTS) helmet_3 = ArtifactRecordPrototype.create_random( 'helmet_3', type_=relations.ARTIFACT_TYPE.HELMET) plate_3 = ArtifactRecordPrototype.create_random( 'plate_3', type_=relations.ARTIFACT_TYPE.PLATE) boots_3 = ArtifactRecordPrototype.create_random( 'boots_3', type_=relations.ARTIFACT_TYPE.BOOTS) artifacts = [helmet_2, plate_2, boots_2] artifacts_ids = [artifact.uuid for artifact in artifacts] for i in xrange(100): artifact = artifacts_storage.generate_artifact_from_list( artifacts, 1, rarity=relations.RARITY.NORMAL) self.assertTrue(artifact.id in artifacts_ids + heroes_relations.EQUIPMENT_SLOT.default_uids()) artifacts = [helmet_3, plate_3, boots_3] artifacts_ids = [artifact.uuid for artifact in artifacts] for i in xrange(100): artifact = artifacts_storage.generate_artifact_from_list( artifacts, 1, rarity=relations.RARITY.NORMAL) self.assertTrue(artifact.id in artifacts_ids + heroes_relations.EQUIPMENT_SLOT.default_uids())
def test_generate_artifact__rarity_with_normal_probabilities(self): from the_tale.game.mobs.prototypes import MobPrototype, MobRecordPrototype from the_tale.game.mobs.models import MOB_RECORD_STATE self.hero._model.level = 5 mob_record = MobRecordPrototype.create_random( uuid='bandit', level=2, state=MOB_RECORD_STATE.ENABLED) mob = MobPrototype(record_id=mob_record.id, level=3) ArtifactRecordPrototype.create_random( 'bandit_artifact', mob=mob_record, type_=relations.ARTIFACT_TYPE.HELMET, state=relations.ARTIFACT_RECORD_STATE.ENABLED) rarities = set() for i in xrange(10000): artifact = artifacts_storage.generate_loot(self.hero, mob) rarities.add(artifact.rarity) self.assertEqual(rarities, set(relations.RARITY.records))
def test_linguistics_restriction_version_update_on_save(self): artifact = ArtifactRecordPrototype.create_random(uuid='bandit_loot') artifact.set_utg_name(names.generator.get_test_name('new-name')) with mock.patch('the_tale.linguistics.logic.sync_restriction' ) as sync_restriction: artifact.save() self.assertEqual(sync_restriction.call_args_list, [ mock.call(group=linguistics_relations.TEMPLATE_RESTRICTION_GROUP. ARTIFACT, external_id=artifact.id, name=artifact.name) ])
def test_change_uuid(self): loot = ArtifactRecordPrototype.create_random( 'some_loot', type_=relations.ARTIFACT_TYPE.USELESS, state=relations.ARTIFACT_RECORD_STATE.DISABLED) form = ModerateArtifactRecordForm(self.get_form_data(loot)) self.assertTrue(form.is_valid()) self.assertEqual(loot.uuid, artifacts_storage.get_by_uuid(loot.uuid).uuid) loot.update_by_moderator(form) self.assertEqual(loot.uuid, artifacts_storage.get_by_uuid(loot.uuid).uuid)
def test_generate_artifact_from_list(self): helmet_2 = ArtifactRecordPrototype.create_random('helmet_2', type_=relations.ARTIFACT_TYPE.HELMET) plate_2 = ArtifactRecordPrototype.create_random('plate_2', type_=relations.ARTIFACT_TYPE.PLATE) boots_2 = ArtifactRecordPrototype.create_random('boots_2', type_=relations.ARTIFACT_TYPE.BOOTS) helmet_3 = ArtifactRecordPrototype.create_random('helmet_3', type_=relations.ARTIFACT_TYPE.HELMET) plate_3 = ArtifactRecordPrototype.create_random('plate_3', type_=relations.ARTIFACT_TYPE.PLATE) boots_3 = ArtifactRecordPrototype.create_random('boots_3', type_=relations.ARTIFACT_TYPE.BOOTS) artifacts = [helmet_2, plate_2, boots_2] artifacts_ids = [artifact.uuid for artifact in artifacts] for i in range(100): artifact = artifacts_storage.generate_artifact_from_list(artifacts, 1, rarity=relations.RARITY.NORMAL) self.assertTrue(artifact.id in artifacts_ids + heroes_relations.EQUIPMENT_SLOT.default_uids()) artifacts = [helmet_3, plate_3, boots_3] artifacts_ids = [artifact.uuid for artifact in artifacts] for i in range(100): artifact = artifacts_storage.generate_artifact_from_list(artifacts, 1, rarity=relations.RARITY.NORMAL) self.assertTrue(artifact.id in artifacts_ids + heroes_relations.EQUIPMENT_SLOT.default_uids())
def test_storage_version_update_on_save(self): artifact = ArtifactRecordPrototype.create_random(uuid='bandit_loot') old_version = artifacts_storage.version artifact.save() self.assertNotEqual(old_version, artifacts_storage.version)
def test_storage_version_update_on_create(self): old_version = artifacts_storage.version ArtifactRecordPrototype.create_random(uuid="bandit_loot") self.assertNotEqual(old_version, artifacts_storage.version)
def create_test_map(): linguistics_logic.sync_static_restrictions() map_logic.create_test_my_info() p1 = PlacePrototype.create( x=1, y=1, size=1, utg_name=names.generator.get_test_name(name='1x1')) p2 = PlacePrototype.create( x=3, y=3, size=3, utg_name=names.generator.get_test_name(name='10x10')) p3 = PlacePrototype.create( x=1, y=3, size=3, utg_name=names.generator.get_test_name(name='1x10')) for place in places_storage.all(): place.sync_persons(force_add=True) RoadPrototype.create(point_1=p1, point_2=p2).update() RoadPrototype.create(point_1=p2, point_2=p3).update() update_waymarks() 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) ArtifactRecordPrototype.create_random(DEFAULT_HERO_EQUIPMENT.PANTS, type_=ARTIFACT_TYPE.PANTS) ArtifactRecordPrototype.create_random(DEFAULT_HERO_EQUIPMENT.BOOTS, type_=ARTIFACT_TYPE.BOOTS) ArtifactRecordPrototype.create_random(DEFAULT_HERO_EQUIPMENT.PLATE, type_=ARTIFACT_TYPE.PLATE) ArtifactRecordPrototype.create_random(DEFAULT_HERO_EQUIPMENT.GLOVES, type_=ARTIFACT_TYPE.GLOVES) ArtifactRecordPrototype.create_random(DEFAULT_HERO_EQUIPMENT.WEAPON, type_=ARTIFACT_TYPE.MAIN_HAND) 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_storage_version_update_on_save(self): artifact = ArtifactRecordPrototype.create_random(uuid='bandit_loot') old_version = artifacts_storage.version artifact.save() self.assertNotEqual(old_version, artifacts_storage.version)
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 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 create_test_map(): linguistics_logic.sync_static_restrictions() map_logic.create_test_my_info() p1 = PlacePrototype.create( x=1, y=1, size=1, utg_name=names.generator.get_test_name(name='1x1')) p2 = PlacePrototype.create( x=3, y=3, size=3, utg_name=names.generator.get_test_name(name='10x10')) p3 = PlacePrototype.create( x=1, y=3, size=3, utg_name=names.generator.get_test_name(name='1x10')) for place in places_storage.all(): place.sync_persons(force_add=True) RoadPrototype.create(point_1=p1, point_2=p2).update() RoadPrototype.create(point_1=p2, point_2=p3).update() update_waymarks() 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) ArtifactRecordPrototype.create_random(DEFAULT_HERO_EQUIPMENT.PANTS, type_=ARTIFACT_TYPE.PANTS) ArtifactRecordPrototype.create_random(DEFAULT_HERO_EQUIPMENT.BOOTS, type_=ARTIFACT_TYPE.BOOTS) ArtifactRecordPrototype.create_random(DEFAULT_HERO_EQUIPMENT.PLATE, type_=ARTIFACT_TYPE.PLATE) ArtifactRecordPrototype.create_random(DEFAULT_HERO_EQUIPMENT.GLOVES, type_=ARTIFACT_TYPE.GLOVES) ArtifactRecordPrototype.create_random(DEFAULT_HERO_EQUIPMENT.WEAPON, type_=ARTIFACT_TYPE.MAIN_HAND) 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