Compare commits
9 Commits
521e767741
...
97957238fb
Author | SHA1 | Date | |
---|---|---|---|
|
97957238fb | ||
|
c7b47b2a87 | ||
|
12c6bd8022 | ||
|
25930cc7fb | ||
|
a465c966a7 | ||
|
8d4b05b5fe | ||
|
45b2fa4c43 | ||
|
c9b24edd8e | ||
|
a32d984e0c |
35
GameLogic.py
35
GameLogic.py
@ -1,2 +1,35 @@
|
|||||||
|
from GameMap import *
|
||||||
|
from Player import *
|
||||||
|
|
||||||
class GameLogic():
|
class GameLogic():
|
||||||
pass
|
|
||||||
|
def __init__(self, gameMap, playerList, winRowLength, individualMoves):
|
||||||
|
|
||||||
|
self.gameMap = gameMap
|
||||||
|
self.playerList = playerList
|
||||||
|
self.winRowLength = winRowLength
|
||||||
|
self.individualMoves = individualMoves
|
||||||
|
self.time = 0 # in seconds
|
||||||
|
self.score = 0
|
||||||
|
|
||||||
|
self.wait_for_input()
|
||||||
|
|
||||||
|
|
||||||
|
def wait_for_input(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def check_for_win(self, playerList):
|
||||||
|
for player in playerList:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def get_time(self):
|
||||||
|
return self.time
|
||||||
|
|
||||||
|
|
||||||
|
def reset_time(self):
|
||||||
|
self.time = 0
|
||||||
|
|
||||||
|
|
||||||
|
def get_score(self):
|
||||||
|
return self.score
|
17
GameMap.py
17
GameMap.py
@ -17,16 +17,21 @@ class GameMap:
|
|||||||
return self.size_y
|
return self.size_y
|
||||||
|
|
||||||
|
|
||||||
def add_player_mark(self, x, y, player):
|
def add_mark(self, x, y, player):
|
||||||
if (x <= self.max_size_x and y <= self.max_size_y) and (x >= 0 and y >= 0):
|
if (x <= self.max_size_x and y <= self.max_size_y) and (x >= 0 and y >= 0):
|
||||||
self.data[(x,y)] = player
|
if (x, y) not in self.data:
|
||||||
player.record_mark(x, y)
|
self.data[(x,y)] = player
|
||||||
|
else:
|
||||||
|
errorMessage = "The mark is already busy by the Player" + self.data[(x, y)].get_name()
|
||||||
|
raise KeyError(errorMessage)
|
||||||
else:
|
else:
|
||||||
errorMessage = "The mark" + str((x,y)) + " is beyond preset max values, max_x - " + str(self.max_size_x) + ", max_y - " + str(self.max_size_y)
|
errorMessage = "The mark" + str((x,y)) + " is beyond preset max values, max_x - " + str(self.max_size_x) + ", max_y - " + str(self.max_size_y)
|
||||||
raise IndexError(errorMessage)
|
raise IndexError(errorMessage)
|
||||||
|
|
||||||
|
|
||||||
|
def remove_mark(self, x, y):
|
||||||
|
data.pop((x,y))
|
||||||
|
|
||||||
|
|
||||||
def clear_map(self):
|
def clear_map(self):
|
||||||
self.data = {}
|
data.clear()
|
||||||
|
|
||||||
|
|
@ -8,5 +8,9 @@ class Player():
|
|||||||
return "Player " + self.name + ': ' + "\n " + str(self.markList)
|
return "Player " + self.name + ': ' + "\n " + str(self.markList)
|
||||||
|
|
||||||
|
|
||||||
|
def get_name(self):
|
||||||
|
return self.name
|
||||||
|
|
||||||
|
|
||||||
def record_mark(self, x, y):
|
def record_mark(self, x, y):
|
||||||
self.markList.append((x, y))
|
self.markList.append((x, y))
|
Loading…
Reference in New Issue
Block a user