- player id added to Player action parameters

This commit is contained in:
acarlier 2019-03-22 12:17:39 +01:00
parent 0bfec9f0e7
commit 6e4ee1ef19
1 changed files with 7 additions and 3 deletions

View File

@ -14,6 +14,7 @@ class Direction(Enum):
DOWN = 3
LEFT = 4
class Player:
"""
This is the base class for decisions.
@ -35,7 +36,7 @@ class Player:
if direction == Direction.LEFT:
return ((current_position[0], current_position[1] - 1), direction)
def action(self, game):
def action(self, game, id):
"""
This function is called each time to ask the player his action.
@ -52,6 +53,7 @@ class Player:
"""
pass
class Mode(Enum):
"""
The different type of interaction for the keyboard controls.
@ -61,6 +63,7 @@ class Mode(Enum):
ARROWS = 1
ZQSD = 2
class KeyboardPlayer(Player):
""""
This is the key board interaction.
@ -118,12 +121,13 @@ class KeyboardPlayer(Player):
if event.key == self.down():
self.direction = Direction.DOWN
def action(self, game):
def action(self, game, id):
"""
Returns the direction of the tron.
"""
return self.direction
class ConstantPlayer(Player):
"""
This is a class that always returns the same decision.
@ -132,5 +136,5 @@ class ConstantPlayer(Player):
super(ConstantPlayer, self).__init__()
self.direction = direction
def action(self, game):
def action(self, game, id):
return self.direction