Ejemplo n.º 1
0
class TestDiskPlacement(unittest.TestCase):
    def setUp(self) -> None:
        PLAYER_1 = Player("orange",
                          clues.by_booklet_entry("alpha", 2),
                          teamname="alpha")
        PLAYER_2 = Player("cyan", None, teamname="beta")
        PLAYER_3 = Player("purple", None, teamname="epsilon")

        PLAYERS = [PLAYER_1, PLAYER_2, PLAYER_3]

        self.game = Game(MAP_DESCRIPTOR, PLAYERS, STRUCTURES)

    def test_disk_added_to_player(self) -> None:

        before_placement = len(self.game.players[0].disks)

        self.game.place_disk(1, 1)

        self.assertEqual(len(self.game.players[0].disks), before_placement + 1)

    def test_gametick_advances(self) -> None:

        before_placement = self.game.gametick

        self.game.place_disk(1, 1)

        self.assertEqual(self.game.gametick, before_placement + 1)
Ejemplo n.º 2
0
    while (True):

        cmd = input().lower().strip()

        if cmd.startswith("place") and len(cmd.split(" ")) == 4:

            try:
                (_, mapObject, x, y) = cmd.split(" ")
                (x, y) = (int(x), (int(y)))

                if mapObject == "c":
                    action = game.place_cube(x, y)
                    print("{} placed cube on {}".format(action[0], action[1]))
                elif mapObject == "d":
                    action = game.place_disk(x, y)
                    print("{} placed disk on {}".format(action[0], action[1]))
                else:
                    raise ValueError

            except ValueError:
                pass

        elif cmd.startswith("answer") and len(cmd.split(" ")) == 5:
            # TODO Rewrite this to safer form

            try:
                (_, color, mapObject, x, y) = cmd.split(" ")
                (x, y) = (int(x), (int(y)))

                player = None