Exemplo n.º 1
0
 def test_contestant_can_switch(self):
     door_1, door_2, door_3 = Door(False), Door(True), Door(False)
     game = Game(door_1, door_2, door_3)
     game.contestant_guess = door_1
     game.contestant_switch()
     self.assertNotEqual(door_1, game.contestant_guess)
     self.assertIsInstance(game.contestant_guess, Door)
Exemplo n.º 2
0
 def test_case_where_contestant_guesses_correctly(self):
     door_1, door_2, door_3 = Door(False), Door(True), Door(False)
     game = Game(door_1, door_2, door_3)
     game.contestant_guess = door_2
     game.host_open_door()
     self.assertEqual(False, door_2.is_open)
     self.assertEqual(True, door_1.is_open ^ door_3.is_open)
Exemplo n.º 3
0
    def __init__(self):
        """ read in the config files """
        with open("conf/t1.yaml", "rb") as stream:
            try:
                self._t1 = yaml.safe_load(stream)
            except yaml.YAMLError as exc:
                print(exc)

        with open("conf/d1.yaml", "rb") as stream:
            try:
                self._d1 = yaml.safe_load(stream)
            except yaml.YAMLError as exc:
                print(exc)

        with open("conf/d2.yaml", "rb") as stream:
            try:
                self._d2 = yaml.safe_load(stream)
            except yaml.YAMLError as exc:
                print(exc)

        with open("conf/d3.yaml", "rb") as stream:
            try:
                self._d3 = yaml.safe_load(stream)
            except yaml.YAMLError as exc:
                print(exc)

        self.rooms = []

        self._trap = Trap()

        self._door = Door()

        self._key = Key()

        _armor = Armor()

        _weapon = Weapon()

        _gear = Gear()

        _magic = Magic()

        _service = Service()

        # armor shop
        self._t1[6]["items"] = _armor.armors

        # weapon shop
        self._t1[7]["items"] = _weapon.weapons

        # adventure gear shop
        self._t1[10]["items"] = [
            x for x in _gear.gears if x['etype'] == 'gear'
        ]

        # temple
        self._t1[9]["items"] = [
            x for x in _service.services if x['etype'] == 'temple'
        ]

        # tavern
        self._t1[11]["items"] = [
            x for x in _service.services if x['etype'] == 'tavern'
        ]

        # magic shop
        self._t1[5]["items"] = [
            x for x in _gear.gears if x['etype'] == 'magic'
        ]

        # guildhall
        self._t1[2]["items"] = [
            x for x in _service.services if x['etype'] == 'guild'
        ]

        self._t1[2]["spells"] = _magic.magics

        self._d0 = []
        self._d9 = []
        self._d0.append(self._t1[0])
        self._d9.append(self._t1[0])

        self.rooms.append(self._d0)
        self.rooms.append(self._t1)
        self.rooms.append(self._d1)
        self.rooms.append(self._d2)
        self.rooms.append(self._d3)
        self.rooms.append(self._d9)
Exemplo n.º 4
0
 def test_calling_open_twice_doesnt_close_the_door(self):
     door = Door(False)
     door.open()
     door.open()
     self.assertEqual(True, door.is_open)
Exemplo n.º 5
0
 def test_door_can_be_opened(self):
     door = Door(False)
     door.open()
     self.assertEqual(True, door.is_open)
Exemplo n.º 6
0
 def test_first_round(self):
     door_1, door_2, door_3 = Door(False), Door(False), Door(True)
     game = Game(door_1, door_2, door_3)
     game.contestant_guess = door_1
     game.host_open_door()
     self.assertEqual(True, door_2.is_open)
Exemplo n.º 7
0
 def test_correct_win(self):
     door_1, door_2, door_3 = Door(False), Door(True), Door(False)
     game = Game(door_1, door_2, door_3)
     game.contestant_guess = door_2
     self.assertEqual(True, game.contestant_has_won())
Exemplo n.º 8
0
 def test_door_has_correct_prize_status_after_creation(self):
     door = Door(False)
     self.assertEqual(False, door.has_prize)
Exemplo n.º 9
0
 def test_door_is_open_after_creation(self):
     door = Door(False)
     self.assertEqual(False, door.is_open)
Exemplo n.º 10
0
 def test_calling_open_twice_doesnt_close_the_door(self):
     door = Door(False)
     door.open()
     door.open()
     self.assertEqual(True, door.is_open)
Exemplo n.º 11
0
 def test_door_can_be_opened(self):
     door = Door(False)
     door.open()
     self.assertEqual(True, door.is_open)