예제 #1
0
 def test_is_inventory_full_true(self):
     """All items are True."""
     self.macgyver = Angus(self.mappy)
     self.macgyver.ether = True
     self.macgyver.needle = True
     self.macgyver.tube = True
     assert self.macgyver.is_inventory_full() == True
예제 #2
0
    def test_move(self):
        """Test the position after some moves.

        initial: (0, 2)
        UP: (0, 1)
        RIGHT: WALL same position
        UP: (0, 0)
        UP: out of screen same position
        RIGHT: (1, 0)
        """
        self.macgyver = Angus(self.mappy)
        self.macgyver.move("UP")
        self.macgyver.move("RIGHT")
        self.macgyver.move("UP")
        self.macgyver.move("UP")
        self.macgyver.move("RIGHT")
        assert self.mappy.macgyver == (1, 0)
예제 #3
0
class Test_angus():
    """Pytest for item.Angus()."""
    def setup(self):
        """Set up Pytest method."""
        self.mappy = Mappy()

    def teardown(self):
        """Teardown test method."""
        pass

    def test_init(self):
        """Test initial position."""
        self.macgyver = Angus(self.mappy)
        assert self.mappy.macgyver == (0, 2)

    def test_move(self):
        """Test the position after some moves.

        initial: (0, 2)
        UP: (0, 1)
        RIGHT: WALL same position
        UP: (0, 0)
        UP: out of screen same position
        RIGHT: (1, 0)
        """
        self.macgyver = Angus(self.mappy)
        self.macgyver.move("UP")
        self.macgyver.move("RIGHT")
        self.macgyver.move("UP")
        self.macgyver.move("UP")
        self.macgyver.move("RIGHT")
        assert self.mappy.macgyver == (1, 0)

    def test_is_inventory_full_false(self):
        """All 3 items are False."""
        self.macgyver = Angus(self.mappy)
        assert self.macgyver.is_inventory_full() == False

    def test_is_inventory_full_false2(self):
        """1/3 items is True."""
        self.macgyver = Angus(self.mappy)
        self.macgyver.ether = True
        assert self.macgyver.is_inventory_full() == False

    def test_is_inventory_full_true(self):
        """All items are True."""
        self.macgyver = Angus(self.mappy)
        self.macgyver.ether = True
        self.macgyver.needle = True
        self.macgyver.tube = True
        assert self.macgyver.is_inventory_full() == True
예제 #4
0
 def test_is_inventory_full_false2(self):
     """1/3 items is True."""
     self.macgyver = Angus(self.mappy)
     self.macgyver.ether = True
     assert self.macgyver.is_inventory_full() == False
예제 #5
0
 def test_is_inventory_full_false(self):
     """All 3 items are False."""
     self.macgyver = Angus(self.mappy)
     assert self.macgyver.is_inventory_full() == False
예제 #6
0
 def test_init(self):
     """Test initial position."""
     self.macgyver = Angus(self.mappy)
     assert self.mappy.macgyver == (0, 2)
예제 #7
0
def main():
    """Run the main part."""
    mappy = Mappy()
    screen = Display(mappy)
    macgyver = Angus(mappy)

    loop = True  # main loop
    play = True  # allow moves
    while loop:
        for event in pygame.event.get():
            if event.type == 12:  # pygame.QUIT:
                loop = False
            if event.type == 2:
                if event.key == 113:  # Q
                    loop = False
                if play:
                    screen.message = False  # del instruction msg first move
                    if event.key == K_DOWN:
                        macgyver.move("DOWN")
                    if event.key == K_UP:
                        macgyver.move("UP")
                    if event.key == K_RIGHT:
                        macgyver.move("RIGHT")
                    if event.key == K_LEFT:
                        macgyver.move("LEFT")

            # compare items' position to MacGyver's
            if mappy.macgyver == mappy.ether:
                macgyver.ether = True
                mappy.ether = None
            if mappy.macgyver == mappy.needle:
                macgyver.needle = True
                mappy.needle = None
            if mappy.macgyver == mappy.tube:
                macgyver.tube = True
                mappy.tube = None
            if mappy.macgyver == mappy.guardian:
                # test if inventory is full
                if not macgyver.is_inventory_full():
                    screen.message = "LOOSE"
                    play = False
            if mappy.macgyver == mappy.exit:
                screen.message = "WIN"
                play = False

        screen.refresh_screen()