Compare commits

..

No commits in common. "69ce05886d3bff4531aab41d75cf4adcdbc96610" and "d329c0f7ab378164498c943ade1bc52dbbf029e9" have entirely different histories.

5 changed files with 27 additions and 29 deletions

View File

@ -1,6 +1,7 @@
from datetime import datetime, time
from GameMap import *
from Player import *
from Timer import *
class GameLogic():
@ -10,7 +11,13 @@ class GameLogic():
self.playerList = playerList
self.winRowLength = winRowLength
self.individualMoves = individualMoves
self.timer = Timer()
self.score = 0
self.wait_for_input()
def wait_for_input(self):
pass
def check_who_win(self):
# Should have used vectors instead of committing tuples mithosis,
@ -25,11 +32,11 @@ class GameLogic():
directions = ((0, 1), (1, 0), (1,1), (-1, 1))
for mark in markList:
for direction in directions:
if self._is_line(markList, mark, direction):
if self.is_line(markList, mark, direction):
return player
return False
def _is_line(self, markList, mark, direction):
def is_line(self, markList, mark, direction): # INTERNAL, I guess.
for i in range(1, self.winRowLength):
seeked = (mark[0] + direction[0] * i, mark[1] + direction[1] * i)
if seeked in markList:
@ -37,3 +44,14 @@ class GameLogic():
else:
return False
return True
def get_time(self):
return str(datetime.now() - self.startTime)
def reset_time(self):
self.startTime = datetime.now()
def get_score(self):
return self.score

View File

@ -1,8 +1,7 @@
from tkinter import *
from GameLogic import *
VERSION_NUMBER = "0.1"
root = Tk()
root.title("Tic-Far-Toe v{}".format(VERSION_NUMBER))
root.title("Tic-Far-Toe v0.1")
root.mainloop()

View File

@ -1,9 +1,8 @@
class Player():
def __init__(self, name, personalScore=0):
def __init__(self, name):
self.name = name
self.markList = []
self.personalScore = personalScore
def __str__(self):
return "Player " + self.name + ': ' + "\n " + str(self.markList)
@ -19,7 +18,7 @@ class Player():
def add_mark(self, x, y):
self.markList.append((x, y))
self.personalScore += 10
def clear_mark_list():
self.markList = []

View File

@ -1,18 +0,0 @@
from datetime import datetime, time
class Timer():
def __init__(self):
self.startTime = 0
def has_second_passed(self):
return self.get_time() > 1
def get_time(self):
return str(datetime.now() - self.startTime)
def reset_time(self):
self.startTime = datetime.now()

View File

@ -20,7 +20,7 @@ glogic = GameLogic(GameMap, playerList)
print(glogic.check_who_win())
# AAAAAAAAAAAA I AM GOING INSANE OVER THIS BULLSHIELD
# Outdated this message is, I will just work with tuple[0] and tuple[1].
# Outdated this message is, I just work with tuple[0] and tuple[1].
# ----
# Anyway, a reminder when you'll get to the web - figure out how to manipulate
# tuples (or replace them altogether) so they'll behave like math matrices -