def test_boardcomplexitem(self): bic = pgl_board_items.BoardComplexItem( size=[3, 3], null_sprixel=pgl_board_items.core.Sprixel()) self.assertIsInstance(bic.item(1, 1), pgl_board_items.BoardItemVoid) with self.assertRaises( pgl_board_items.base.PglOutOfItemBoundException): bic.item(5, 6)
def test_boardcomplexitem(self): bic = board_items.BoardComplexItem( size=[3, 3], null_sprixel=board_items.core.Sprixel() ) self.assertIsInstance(bic.sprite, gfx_core.Sprite) self.assertIsInstance(bic.item(1, 1), board_items.BoardItemVoid) with self.assertRaises(board_items.base.PglOutOfItemBoundException): bic.item(5, 6) data = bic.serialize() data["has_inventory"] = False self.assertEqual(bic.size, data["size"]) bic2 = board_items.BoardComplexItem.load(data) self.assertEqual(bic.size, bic2.size)
def test_textitem(self): with self.assertRaises(board_items.base.PglInvalidTypeException): board_items.TextItem(text=board_items.TextItem(text="crash")) bi = board_items.TextItem(text="test") self.assertEqual(bi.text.text, "test") bi = board_items.TextItem(text=board_items.base.Text("test")) self.assertEqual(bi.text.text, "test") bi.text = "value change" self.assertEqual(bi.text.text, "value change") bi.text = board_items.base.Text("value change") self.assertEqual(bi.text.text, "value change") with self.assertRaises(board_items.base.PglInvalidTypeException): bi.text = board_items.BoardComplexItem()
def test_textitem(self): with self.assertRaises(board_items.base.PglInvalidTypeException): board_items.TextItem(text=board_items.TextItem(text="crash")) bi = board_items.TextItem(text="test") self.assertEqual(bi.text.text, "test") bi = board_items.TextItem(text=board_items.base.Text("test")) self.assertEqual(bi.text.text, "test") bi.text = "value change" self.assertEqual(bi.text.text, "value change") bi.text = board_items.base.Text("value change") self.assertEqual(bi.text.text, "value change") with self.assertRaises(board_items.base.PglInvalidTypeException): bi.text = board_items.BoardComplexItem() data = bi.serialize() data["has_inventory"] = False bi2 = board_items.TextItem.load(data) self.assertEqual(bi.text.text, bi2.text.text)