Example #1
0
    def test_roll_road(self):
        self.assertEqual(RoadPrototype._roll(5, 4, 13, 8), 'rdrrdrrdrrdr')
        self.assertEqual(RoadPrototype._roll(13, 8, 5, 4), 'llullullullu')
        self.assertEqual(RoadPrototype._roll(5, 8, 13, 4), 'rrurrurrurru')
        self.assertEqual(RoadPrototype._roll(13, 4, 5, 8), 'ldlldlldlldl')

        self.assertEqual(RoadPrototype._roll(0, 4, 0, 8), 'dddd')
        self.assertEqual(RoadPrototype._roll(0, 8, 0, 4), 'uuuu')
        self.assertEqual(RoadPrototype._roll(5, 0, 13, 0), 'rrrrrrrr')
        self.assertEqual(RoadPrototype._roll(13, 0, 5, 0), 'llllllll')

        self.assertEqual(RoadPrototype._roll(5, 12, 3, 17), 'dlddldd')
Example #2
0
    def test_roll_road(self):
        self.assertEqual(RoadPrototype._roll(5, 4, 13, 8), 'rdrrdrrdrrdr')
        self.assertEqual(RoadPrototype._roll(13, 8, 5, 4), 'llullullullu')
        self.assertEqual(RoadPrototype._roll(5, 8, 13, 4), 'rrurrurrurru')
        self.assertEqual(RoadPrototype._roll(13, 4, 5, 8), 'ldlldlldlldl')

        self.assertEqual(RoadPrototype._roll(0, 4, 0, 8), 'dddd')
        self.assertEqual(RoadPrototype._roll(0, 8, 0, 4), 'uuuu')
        self.assertEqual(RoadPrototype._roll(5, 0, 13, 0), 'rrrrrrrr')
        self.assertEqual(RoadPrototype._roll(13, 0, 5, 0), 'llllllll')

        self.assertEqual(RoadPrototype._roll(5, 12, 3, 17), 'dlddldd')
Example #3
0
    def test_add_del_road(self):

        self.assertEqual(Road.objects.all().count(), 2)

        self.r2.exists = False
        self.r2.save()
        r3 = RoadPrototype.create(point_1=self.p1, point_2=self.p3)

        self.assertEqual(Road.objects.all().count(), 3)
        self.assertEqual(Road.objects.filter(exists=False).count(), 1)
        self.assertEqual(Road.objects.filter(exists=True).count(), 2)

        self.assertEqual(Waymark.objects.all().count(), 9)
        waymark = waymarks_storage.look_for_road(point_from=self.p1.id,
                                                 point_to=self.p3.id)
        self.assertEqual(waymark.road.id, self.r1.id)

        update_waymarks()

        self.assertEqual(Waymark.objects.all().count(), 9)
        waymark = waymarks_storage.look_for_road(point_from=self.p1.id,
                                                 point_to=self.p3.id)
        self.assertEqual(waymark.road.id, r3.id)

        self.assertNotEqual(r3.id, self.r1.id)
Example #4
0
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
Example #5
0
    def test_add_del_road(self):

        self.assertEqual(Road.objects.all().count(), 2)

        self.r2.exists = False
        self.r2.save()
        r3 = RoadPrototype.create(point_1=self.p1, point_2=self.p3)

        self.assertEqual(Road.objects.all().count(), 3)
        self.assertEqual(Road.objects.filter(exists=False).count(), 1)
        self.assertEqual(Road.objects.filter(exists=True).count(), 2)

        self.assertEqual(Waymark.objects.all().count(), 9)
        waymark = waymarks_storage.look_for_road(point_from=self.p1.id, point_to=self.p3.id)
        self.assertEqual(waymark.road.id, self.r1.id)

        update_waymarks()

        self.assertEqual(Waymark.objects.all().count(), 9)
        waymark = waymarks_storage.look_for_road(point_from=self.p1.id, point_to=self.p3.id)
        self.assertEqual(waymark.road.id, r3.id)

        self.assertNotEqual(r3.id, self.r1.id)
Example #6
0
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