def test_random(self):
     a = actuators.RandomActuator([constants.UP])
     self.assertEqual(a.moveset, [constants.UP])
     self.assertEqual(a.next_move(), constants.UP)
     data = a.serialize()
     self.assertEqual(data["moveset"], [constants.UP])
     al = actuators.RandomActuator.load(data)
     self.assertEqual(al.moveset, [constants.UP])
     self.assertEqual(al.moveset, a.moveset)
 def test_complexnpc(self):
     sprite = gfx_core.Sprite(
         name="test_sprite",
         sprixels=[
             [
                 gfx_core.Sprixel(" ", gfx_core.Color(255, 0, 0)),
                 gfx_core.Sprixel(" ", gfx_core.Color(255, 0, 0)),
             ]
         ],
     )
     n = board_items.ComplexNPC(name="Test NPC", sprite=sprite)
     n.actuator = actuators.RandomActuator()
     data = n.serialize()
     self.assertEqual(n.name, data["name"])
     self.assertEqual(n.sprite.name, data["sprite"]["name"])
     n2 = board_items.ComplexNPC.load(data)
     self.assertEqual(n.name, n2.name)
 def test_player(self):
     p = board_items.Player(inventory=board_items.engine.Inventory())
     self.assertFalse(p.pickable())
     self.assertTrue(p.has_inventory())
     sprite = gfx_core.Sprite(
         name="test_sprite",
         sprixels=[
             [
                 gfx_core.Sprixel(" ", gfx_core.Color(255, 0, 0)),
                 gfx_core.Sprixel(" ", gfx_core.Color(255, 0, 0)),
             ]
         ],
     )
     n = board_items.ComplexPlayer(name="Test Player", sprite=sprite)
     n.actuator = actuators.RandomActuator()
     data = n.serialize()
     self.assertEqual(n.name, data["name"])
     self.assertEqual(n.sprite.name, data["sprite"]["name"])
     n2 = board_items.ComplexPlayer.load(data)
     self.assertEqual(n.name, n2.name)
Beispiel #4
0
 def test_random(self):
     a = actuators.RandomActuator([constants.UP])
     self.assertEqual(a.moveset, [constants.UP])
     self.assertEqual(a.next_move(), constants.UP)
 def test_random_empty(self):
     a = actuators.RandomActuator()
     self.assertEqual(a.moveset, [])
     self.assertEqual(a.next_move(), constants.NO_DIR)