コード例 #1
0
ファイル: test_action.py プロジェクト: iffy/xatrobots
    def test_makeSecondTool(self):
        """
        If you make a tool from a different piece of ore, your existing tool
        is unequipped and the lifesource it was made from is reverted to ore.
        """
        world = World(MagicMock())
        ore1 = world.create('ore')
        ore2 = world.create('ore')

        bot = world.create('bot')
        MakeTool(bot['id'], ore1['id'], 'knife').execute(world)

        MakeTool(bot['id'], ore2['id'], 'butterfly net').execute(world)

        self.assertEqual(bot['tool'], 'butterfly net',
                         "Should equip the new tool")
        self.assertEqual(ore1['kind'], 'ore', "Should revert to ore")
        self.assertEqual(ore2['kind'], 'lifesource')

        # kill original
        world.setAttr(ore1['id'], 'hp', 0)

        self.assertEqual(
            bot['tool'], 'butterfly net', "should not change tool"
            " when the original ore dies")
        self.assertEqual(ore2['kind'], 'lifesource')
コード例 #2
0
 def test_MakeTool(self):
     self.assertSimple(MakeTool('foo', 'bar', 'knife'), {
         'action': 'maketool',
         'subject': 'foo',
         'ore': 'bar',
         'tool': 'knife'
     })
コード例 #3
0
ファイル: test_action.py プロジェクト: iffy/xatrobots
    def test_onlyOre(self):
        """
        Only ore can be turned into tools.
        """
        world = World(MagicMock())
        ore = world.create('flower')
        bot = world.create('bot')

        self.assertRaises(NotAllowed,
                          MakeTool(bot['id'], ore['id'], 'knife').execute,
                          world)
コード例 #4
0
ファイル: test_action.py プロジェクト: iffy/xatrobots
    def test_revertWhenKilled(self):
        """
        If the lifesource is shot to death, then revert to ore and unequip.
        """
        world = World(MagicMock())
        ore = world.create('ore')
        bot = world.create('bot')
        MakeTool(bot['id'], ore['id'], 'knife').execute(world)

        world.setAttr(ore['id'], 'hp', 0)

        self.assertNotIn('tool', bot, "Should unequip the tool")
        self.assertEqual(ore['kind'], 'ore', "Should revert to ore")
コード例 #5
0
ファイル: test_action.py プロジェクト: iffy/xatrobots
    def test_makeTool(self):
        """
        Making a tool will destroy the ore, make a lifesource in its place,
        and equip the maker with the tool.
        """
        world = World(MagicMock())
        ore = world.create('ore')
        bot = world.create('bot')
        MakeTool(bot['id'], ore['id'], 'knife').execute(world)

        self.assertEqual(ore['kind'], 'lifesource', "Should have converted "
                         "the ore into a lifesource")
        self.assertEqual(bot['tool'], 'knife', "Should have given the bot "
                         "the tool")
コード例 #6
0
ファイル: test_action.py プロジェクト: iffy/xatrobots
    def test_revertToOreWhenBotDies(self):
        """
        If the thing dies that made the tool, revert to ore and set the tool
        to None
        """
        world = World(MagicMock())
        ore = world.create('ore')
        bot = world.create('bot')
        MakeTool(bot['id'], ore['id'], 'knife').execute(world)

        # moving to None is death
        Move(bot['id'], None).execute(world)

        self.assertNotIn('tool', bot, "Should unequip the tool")
        self.assertEqual(ore['kind'], 'ore', "Should revert to ore")
コード例 #7
0
ファイル: test_action.py プロジェクト: iffy/xatrobots
 def test_subject(self):
     self.assertEqual(MakeTool('foo', 'ore', 'tool').subject(), 'foo')
コード例 #8
0
ファイル: test_action.py プロジェクト: iffy/xatrobots
 def test_emitters(self):
     self.assertEqual(
         MakeTool('me', 'ore', 'tool').emitters(), ['me', 'ore'])
コード例 #9
0
ファイル: test_action.py プロジェクト: iffy/xatrobots
 def test_IAction(self):
     verifyObject(IAction, MakeTool('me', 'ore', 'tool'))
コード例 #10
0
 def test_MakeTool(self):
     self.assertSimple(MakeTool('foo', 'bar', 'knife'),
                       'foo made bar into knife')