Example #1
0
File: main.py Project: smath17/P6
def createTeam():
    # Create a list of players
    team1 = [Player(teamname1, True)]
    for x in range(10):
        team1.append(Player(teamname1))

    return team1
Example #2
0
    def test_goalie_connect(self):
        self.goalie = Player("Test", True)
        assert self.goalie.stamina == 0
        assert self.goalie.serverAddressPort[1] != 6000

        self.goalie.disconnect()
        self.goalie.stop_connection()
Example #3
0
    def test_player_connect(self):
        self.player = Player("Test")
        # loop through initial server info
        for x in range(25):
            self.player.update_info()
        assert self.player.stamina == 8000
        assert self.player.game_status == "before_kick_off", "was: {}".format(
            self.player.game_status)

        self.player.disconnect()
        self.player.stop_connection()
Example #4
0
class MyTestCase(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        # Change working dir to source
        path = os.getcwd()
        new_path = path[:-6]
        os.chdir(new_path)

    # Create player, connect to server and receive update
    def test_player_connect(self):
        self.player = Player("Test")
        # loop through initial server info
        for x in range(25):
            self.player.update_info()
        assert self.player.stamina == 8000
        assert self.player.game_status == "before_kick_off", "was: {}".format(
            self.player.game_status)

        self.player.disconnect()
        self.player.stop_connection()

    def test_goalie_connect(self):
        self.goalie = Player("Test", True)
        assert self.goalie.stamina == 0
        assert self.goalie.serverAddressPort[1] != 6000

        self.goalie.disconnect()
        self.goalie.stop_connection()

    # Create online coach
    def test_coach_connect(self):
        testmsg = '(ok look'
        player = Player("Test")
        self.coach = Coach("Test")

        # Catch up the init messages
        #for x in range(20):
        #self.coach.rec_msg()
        recmsg = self.coach.send_action("(look)")[0:8]
        assert recmsg == testmsg, "Coach received: {}, but expected: {}".format(
            recmsg, testmsg)

        self.coach.disconnect()
        self.coach.stop_connection()
        player.disconnect()
        player.stop_connection()
Example #5
0
    def test_coach_connect(self):
        testmsg = '(ok look'
        player = Player("Test")
        self.coach = Coach("Test")

        # Catch up the init messages
        #for x in range(20):
        #self.coach.rec_msg()
        recmsg = self.coach.send_action("(look)")[0:8]
        assert recmsg == testmsg, "Coach received: {}, but expected: {}".format(
            recmsg, testmsg)

        self.coach.disconnect()
        self.coach.stop_connection()
        player.disconnect()
        player.stop_connection()
Example #6
0
 def createGoalie(self):
     goalie = Player(self.teamname, True)
Example #7
0
 def createPlayer(self):
     player = Player(self.teamname)
Example #8
0
File: main.py Project: smath17/P6
    return team1


if __name__ == "__main__":

    teamname1 = "Simon"

    # Check for args, argv[0] is the script
    # TODO: improve parameters (multiple)
    if len(sys.argv) > 1:
        if sys.argv[1] == "-trainer":
            team1 = createTeam()
            coach = Coach(teamname1, True)
        elif sys.argv[1] == "-coach":
            team1 = createTeam()
            coach = Coach(teamname1)
        elif sys.argv[1] == "-k":
            team1 = createTeam()
            controller = KeyboardControl()
            controller.keymap(team1)
        elif sys.argv[1] == "-simplescore":
            team1 = createTeam()
            controller = KeyboardControl()
            controller.simple_auto_score(team1)
        elif sys.argv[1] == "-multiprocess":
            team = TeamSetup(teamname1)
        elif sys.argv[1] == "-basetrain":
            player = Player(teamname1)
            coach = Coach(teamname1, True)
            coach.goal_basic_training(player, teamname1)
Example #9
0
 def setUp(self):
     self.parser = Parser()
     self.player = Player("TestTeam", False, False)
Example #10
0
from ObjectMover import moveObj
from Puzzle import puzzle

pygame.init()

# game window initialization
timer = pygame.time.Clock()
window = pygame.display.set_mode((screenWidth, screenHeight))
pygame.display.set_caption("Dungeon Knight")
pygame.mouse.set_visible(False)
pointerImg = pygame.image.load('pointer.png')
pointerImg = pygame.transform.scale(pointerImg, (50, 50))
pointerRect = pointerImg.get_rect()

# object instantiation
player = Player(300, 300, 64, 64)
javelins = []

rightSwitch = RoomSwitch(screenWidth - 5, (screenHeight / 2) - 75, 5, 100,
                         'right', [mainRoom, room2, room4])
leftSwitch = RoomSwitch(0, (screenHeight / 2) - 75, 5, 100, 'left',
                        [mainRoom, room3, room5])
bottomSwitch = RoomSwitch(screenWidth / 2 - 75, screenHeight - 5, 150, 5,
                          'down', [mainRoom, room1, room2, room4, room5])
topSwitch = RoomSwitch(screenWidth / 2 - 75, 0, 150, 5, 'up',
                       [mainRoom, room7, room6, room4, room8])
roomSwitches = [rightSwitch, leftSwitch, topSwitch, bottomSwitch]

yeti = Enemy(100, 300, 64, 64, 'spr_ape_yeti.png')
enemy_list = pygame.sprite.Group()
enemies = [yeti]