コード例 #1
0
ファイル: FactionTests.py プロジェクト: jaycarson/fun
 def test_gets_correct_id(self):
     expected_1 = 1
     expected_2 = 2
     sut_1 = Faction(faction_id=expected_1)
     sut_2 = Faction(faction_id=expected_2)
     self.assertEqual(expected_1, sut_1.faction_id)
     self.assertEqual(expected_2, sut_2.faction_id)
コード例 #2
0
ファイル: CharacterTests.py プロジェクト: jaycarson/fun
    def setUp(self):
        self._clock = Clock()
        self.locale_id = 1000
        self.book_stat = BookStat()
        self.sut_smithy_weapon = SmithWeapon()
        self.sut_smithy_armor = SmithArmor()
        self.sut_brains = Brains()

        self.sut_faction = Faction(
            experience=0,
            name='Red',
            faction_id='1000',
            clock=self._clock,
            smithy_weapon=self.sut_smithy_weapon,
            smithy_armor=self.sut_smithy_armor,
            brains=self.sut_brains,
        )

        self.sut2_faction = Faction(
            experience=0,
            name='blue',
            faction_id='1001',
            clock=self._clock,
            smithy_weapon=self.sut_smithy_weapon,
            smithy_armor=self.sut_smithy_armor,
            brains=self.sut_brains,
        )

        self.sut = self.sut_faction.create_vpc(name='sut')
        self.sut2 = self.sut2_faction.create_vpc(name='sut2')

        arena = HexMap()
        arena.arena_ground = 'plains'
        arena.arena_height = 10
        arena.create_arena(radius=5)

        self.sut_dm = DungeonMaster(
            clock=Clock(),
            dungeon=arena,
            locale_id=self.locale_id,
        )

        self.sut_dm.add_char(
            member=self.sut,
            faction=self.sut_faction,
            edge='sw',
        )

        self.sut_dm.add_char(
            member=self.sut2,
            faction=self.sut2_faction,
            edge='se',
        )

        weapon_smith = SmithWeapon()
        new_weapon = weapon_smith.create()
        self.sut.rack_weapon.give_weapon(new_weapon)
コード例 #3
0
ファイル: FactionTests.py プロジェクト: jaycarson/fun
    def setUp(self):
        self._clock = Clock()
        self.sut_name = 'sut'
        self.sut_smithy_weapon = SmithWeapon()
        self.sut_smithy_armor = SmithArmor()

        self.sut = Faction(
            experience=0,
            name=self.sut_name,
            faction_id=0,
            clock=self._clock,
            smithy_weapon=self.sut_smithy_weapon,
            smithy_armor=self.sut_smithy_armor,
        )
コード例 #4
0
ファイル: DungeonMasterTests.py プロジェクト: jaycarson/fun
 def create_faction(self, name):
     return Faction(
         experience=0,
         name=name,
         faction_id=name,
         clock=self.sut.clock,
         smithy_weapon=self.smith_weapon,
         smithy_armor=self.smith_armor,
         brains=self.brains,
         )
コード例 #5
0
ファイル: CharacterTests.py プロジェクト: jaycarson/fun
class CharacterTest(unittest.TestCase):
    def setUp(self):
        self._clock = Clock()
        self.locale_id = 1000
        self.book_stat = BookStat()
        self.sut_smithy_weapon = SmithWeapon()
        self.sut_smithy_armor = SmithArmor()
        self.sut_brains = Brains()

        self.sut_faction = Faction(
            experience=0,
            name='Red',
            faction_id='1000',
            clock=self._clock,
            smithy_weapon=self.sut_smithy_weapon,
            smithy_armor=self.sut_smithy_armor,
            brains=self.sut_brains,
        )

        self.sut = self.sut_faction.create_vpc(name='sut')

        arena = HexMap()
        arena.arena_ground = 'plains'
        arena.arena_height = 10
        arena.create_arena(radius=5)

        self.sut_dm = DungeonMaster(
            clock=Clock(),
            dungeon=arena,
            locale_id=self.locale_id,
        )

        self.sut_dm.add_char(
            member=self.sut,
            faction=self.sut_faction,
            edge='sw',
        )

    def test_starts_as_level_0(self):
        expected = 0
        self.assertEqual(expected, self.sut.get_level())

    def test_character_gains_a_level_level(self):
        expected = 1
        self.sut.give_experience(1001)
        self.assertEqual(expected, self.sut.get_level())

    def test_character_gains_a_level_test_skill_points_current(self):
        expected = 1
        self.sut.give_experience(1001)
        self.assertEqual(expected, self.sut.skillable.skill_points_current)

    def test_character_gains_a_level_test_skill_points_total(self):
        expected = 1
        self.sut.give_experience(1001)
        self.assertEqual(expected, self.sut.skillable.skill_points_total)

    def test_starts_with_no_experience(self):
        expected = 0
        self.assertEqual(expected, self.sut.get_experience())

    def test_character_gains_experience(self):
        starting = self.sut.get_experience()
        self.sut.give_experience(1001)
        ending = self.sut.get_experience()
        self.assertGreater(ending, starting)

    def test_gets_correct_id(self):
        expected_1 = 1
        expected_2 = 2
        sut_1 = Character(char_id=expected_1)
        sut_2 = Character(char_id=expected_2)
        self.assertEqual(expected_1, sut_1.char_id)
        self.assertEqual(expected_2, sut_2.char_id)

    def test_gets_name(self):
        expected = 'sut'
        self.assertEqual(expected, self.sut.name)

    def test_character_knows_the_worlds_time(self):
        test_time = 0
        self.assertEqual(test_time, self.sut.faction.get_world_time())
        self._clock.increment_time()

    def test_character_still_knows_the_worlds_time(self):
        test_time = 1
        self._clock.increment_time()
        self.assertEqual(test_time, self.sut.faction.get_world_time())

    def test_character_knows_the_locale_time(self):
        test_locale_id = 1
        test_time = 0
        self._clock.add_locale(locale_id=test_locale_id)
        self.sut.locale_id = test_locale_id
        self.assertEqual(test_time, self.sut.dm.get_time())

    def test_character_still_knows_the_locale_time(self):
        test_locale_id = 1
        test_time = 1
        self.sut.dm.increment_time()
        self.assertEqual(test_time, self.sut.dm.get_time())

    def test_character_has_stats(self):
        base_stat = self.book_stat.get_base_stat()
        stat_list = self.book_stat.get_list()

        for stat in stat_list:
            self.assertEqual(base_stat, self.sut.get_stat(stat))

    def test_character_gets_a_weapon(self):
        weapon_smith = SmithWeapon()
        new_weapon = weapon_smith.create()
        weapon_id = self.sut.rack_weapon.give_weapon(new_weapon)
        self.sut.sets_weapon.equip_weapon_by_id(weapon_id=weapon_id)
        equipped_weapon = self.sut.sets_weapon.get_equipped_weapon()
        self.assertEqual(equipped_weapon, new_weapon)

    def test_character_gets_a_weapon_and_automatically_equips_it(self):
        self.sut.sets_weapon.weapon_sets[1]['main'] = None
        self.sut.sets_weapon.weapon_sets[1]['off'] = None
        self.sut.sets_weapon.weapon_sets[1]['both'] = None
        weapon_smith = SmithWeapon()
        new_weapon = weapon_smith.create()
        self.sut.rack_weapon.give_weapon(new_weapon)
        equipped_weapon = self.sut.sets_weapon.get_equipped_weapon()
        self.assertEqual(equipped_weapon, new_weapon)

    def test_character_gets_an_armor_and_automatically_equips_it(self):
        armor_smith = SmithArmor()
        for piece in armor_smith.armor_pieces:
            self.sut.rack_armor.remove_armor(piece)
        new_armor = armor_smith.create()
        piece = new_armor.piece
        self.sut.rack_armor.give_armor(new_armor)
        equipped_armor = self.sut.rack_armor.get_equipped_armor(piece)
        self.assertEqual(equipped_armor, new_armor)
コード例 #6
0
ファイル: CharacterTests.py プロジェクト: jaycarson/fun
class CharacterCombatTest(unittest.TestCase):
    def setUp(self):
        self._clock = Clock()
        self.locale_id = 1000
        self.book_stat = BookStat()
        self.sut_smithy_weapon = SmithWeapon()
        self.sut_smithy_armor = SmithArmor()
        self.sut_brains = Brains()

        self.sut_faction = Faction(
            experience=0,
            name='Red',
            faction_id='1000',
            clock=self._clock,
            smithy_weapon=self.sut_smithy_weapon,
            smithy_armor=self.sut_smithy_armor,
            brains=self.sut_brains,
        )

        self.sut2_faction = Faction(
            experience=0,
            name='blue',
            faction_id='1001',
            clock=self._clock,
            smithy_weapon=self.sut_smithy_weapon,
            smithy_armor=self.sut_smithy_armor,
            brains=self.sut_brains,
        )

        self.sut = self.sut_faction.create_vpc(name='sut')
        self.sut2 = self.sut2_faction.create_vpc(name='sut2')

        arena = HexMap()
        arena.arena_ground = 'plains'
        arena.arena_height = 10
        arena.create_arena(radius=5)

        self.sut_dm = DungeonMaster(
            clock=Clock(),
            dungeon=arena,
            locale_id=self.locale_id,
        )

        self.sut_dm.add_char(
            member=self.sut,
            faction=self.sut_faction,
            edge='sw',
        )

        self.sut_dm.add_char(
            member=self.sut2,
            faction=self.sut2_faction,
            edge='se',
        )

        weapon_smith = SmithWeapon()
        new_weapon = weapon_smith.create()
        self.sut.rack_weapon.give_weapon(new_weapon)

    def test_weapon_starts_off_cooldown(self):
        weapon = self.sut.sets_weapon.get_equipped_weapon()
        slot = 2
        self.sut.dm.increment_time()
        locale_time = self.sut.dm.get_time()
        self.assertFalse(weapon.on_cooldown(slot, locale_time))

    def test_weapon_goes_on_cooldown(self):
        weapon = self.sut.sets_weapon.get_equipped_weapon()
        slot = 2
        self.sut.dm.increment_time()
        self.sut.target_enemy = self.sut2
        self.sut.attack(slot)
        locale_time = self.sut.dm.get_time()
        self.assertTrue(weapon.on_cooldown(slot, locale_time))
コード例 #7
0
ファイル: FactionTests.py プロジェクト: jaycarson/fun
class FactionTest(unittest.TestCase):
    def setUp(self):
        self._clock = Clock()
        self.sut_name = 'sut'
        self.sut_smithy_weapon = SmithWeapon()
        self.sut_smithy_armor = SmithArmor()

        self.sut = Faction(
            experience=0,
            name=self.sut_name,
            faction_id=0,
            clock=self._clock,
            smithy_weapon=self.sut_smithy_weapon,
            smithy_armor=self.sut_smithy_armor,
        )

    def test_starts_as_level_0(self):
        expected = 0
        self.assertEqual(expected, self.sut.levelable.get_level())

    def test_faction_gains_a_level_level(self):
        expected = 1
        self.sut.give_experience(1001)
        self.assertEqual(expected, self.sut.levelable.get_level())

    def test_faction_gains_a_level_test_skill_points_current(self):
        expected = 1
        self.sut.give_experience(1001)
        self.assertEqual(expected, self.sut.skillable.skill_points_current)

    def test_faction_gains_a_level_test_skill_points_total(self):
        expected = 1
        self.sut.give_experience(1001)
        self.assertEqual(expected, self.sut.skillable.skill_points_total)

    def test_starts_with_no_experience(self):
        expected = 0
        self.assertEqual(expected, self.sut.get_experience())

    def test_faction_gains_experience(self):
        starting = self.sut.get_experience()
        self.sut.give_experience(1001)
        ending = self.sut.get_experience()
        self.assertGreater(ending, starting)

    def test_gets_correct_id(self):
        expected_1 = 1
        expected_2 = 2
        sut_1 = Faction(faction_id=expected_1)
        sut_2 = Faction(faction_id=expected_2)
        self.assertEqual(expected_1, sut_1.faction_id)
        self.assertEqual(expected_2, sut_2.faction_id)

    def test_gets_name(self):
        self.assertEqual(self.sut_name, self.sut.name)

    def test_faction_knows_the_worlds_time(self):
        test_time = 0
        self.assertEqual(test_time, self.sut.get_world_time())
        self._clock.increment_time()

    def test_faction_still_knows_the_worlds_time(self):
        test_time = 1
        self._clock.increment_time()
        self.assertEqual(test_time, self.sut.get_world_time())

    def test_faction_receives_a_weapon(self):
        colors = BookColor().get_list()
        weapon_smith = SmithWeapon()
        new_weapon = weapon_smith.create()
        self.sut.rack_weapon.give_weapon(new_weapon)
        given_wpn = self.sut.rack_weapon.weapons[new_weapon.id]
        self.assertTrue(given_wpn.color in colors)

    def test_faction_receives_an_armor(self):
        colors = BookColor().get_list()
        armor_smith = SmithArmor()
        new_armor = armor_smith.create()
        self.sut.rack_armor.give_armor(new_armor)
        given_arm = self.sut.rack_armor.armors[new_armor.id]
        self.assertTrue(given_arm.color in colors)

    def test_created_character_gets_a_weapon(self):
        vpc = self.sut.create_vpc()