Compare commits

...

9 Commits

Author SHA1 Message Date
RomulAugustus
97957238fb Create Main.py 2022-07-25 17:51:21 +03:00
RomulAugustus
c7b47b2a87 clearing is now done with a dict. method 2022-07-25 17:51:11 +03:00
RomulAugustus
12c6bd8022 Added a method to remove marks 2022-07-25 17:50:07 +03:00
RomulAugustus
25930cc7fb MERGE WITH PREV COMMIT 2022-07-25 17:49:49 +03:00
RomulAugustus
a465c966a7 added another condition to adding marks 2022-07-25 17:49:19 +03:00
RomulAugustus
8d4b05b5fe renamed a method 2022-07-25 17:48:34 +03:00
RomulAugustus
45b2fa4c43 added get_name() 2022-07-25 17:47:19 +03:00
RomulAugustus
c9b24edd8e fleshed out GameLogic a bit
* added time counting stub
* added score counting stub
* added win check stub
* made it so you pass gameMap to the logic
* you pass the list of players too
(both gameMap and playerList are assumed to be made outside when configuring the game)
*
2022-07-25 17:46:45 +03:00
RomulAugustus
a32d984e0c removed an unnecessary call (moved to gameLogic)
also removed a bunch of spaces
2022-07-25 17:10:43 +03:00
4 changed files with 51 additions and 7 deletions

View File

@ -1,2 +1,35 @@
from GameMap import *
from Player import *
class GameLogic():
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

View File

@ -17,16 +17,21 @@ class GameMap:
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, y) not in self.data:
self.data[(x,y)] = player
player.record_mark(x, y)
else:
errorMessage = "The mark is already busy by the Player" + self.data[(x, y)].get_name()
raise KeyError(errorMessage)
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)
raise IndexError(errorMessage)
def remove_mark(self, x, y):
data.pop((x,y))
def clear_map(self):
self.data = {}
data.clear()

2
Main.py Normal file
View File

@ -0,0 +1,2 @@
import pygame
from GameLogic import *

View File

@ -8,5 +8,9 @@ class Player():
return "Player " + self.name + ': ' + "\n " + str(self.markList)
def get_name(self):
return self.name
def record_mark(self, x, y):
self.markList.append((x, y))