Compare commits
10 Commits
d329c0f7ab
...
69ce05886d
Author | SHA1 | Date | |
---|---|---|---|
69ce05886d | |||
e53fd7236c | |||
cb8036bc6d | |||
00da6deb24 | |||
00daf53fae | |||
446ffba554 | |||
9c9db7aba9 | |||
7b486881d9 | |||
b11f77f7ef | |||
54a0f42137 |
26
GameLogic.py
26
GameLogic.py
@ -1,7 +1,6 @@
|
||||
from datetime import datetime, time
|
||||
|
||||
from GameMap import *
|
||||
from Player import *
|
||||
from Timer import *
|
||||
|
||||
class GameLogic():
|
||||
|
||||
@ -11,13 +10,7 @@ class GameLogic():
|
||||
self.playerList = playerList
|
||||
self.winRowLength = winRowLength
|
||||
self.individualMoves = individualMoves
|
||||
self.score = 0
|
||||
self.wait_for_input()
|
||||
|
||||
|
||||
def wait_for_input(self):
|
||||
pass
|
||||
|
||||
self.timer = Timer()
|
||||
|
||||
def check_who_win(self):
|
||||
# Should have used vectors instead of committing tuples mithosis,
|
||||
@ -32,11 +25,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): # INTERNAL, I guess.
|
||||
def _is_line(self, markList, mark, direction):
|
||||
for i in range(1, self.winRowLength):
|
||||
seeked = (mark[0] + direction[0] * i, mark[1] + direction[1] * i)
|
||||
if seeked in markList:
|
||||
@ -44,14 +37,3 @@ 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
|
3
Main.py
3
Main.py
@ -1,7 +1,8 @@
|
||||
from tkinter import *
|
||||
from GameLogic import *
|
||||
|
||||
VERSION_NUMBER = "0.1"
|
||||
root = Tk()
|
||||
root.title("Tic-Far-Toe v0.1")
|
||||
root.title("Tic-Far-Toe v{}".format(VERSION_NUMBER))
|
||||
|
||||
root.mainloop()
|
@ -1,8 +1,9 @@
|
||||
class Player():
|
||||
|
||||
def __init__(self, name):
|
||||
def __init__(self, name, personalScore=0):
|
||||
self.name = name
|
||||
self.markList = []
|
||||
self.personalScore = personalScore
|
||||
|
||||
def __str__(self):
|
||||
return "Player " + self.name + ': ' + "\n " + str(self.markList)
|
||||
@ -18,7 +19,7 @@ class Player():
|
||||
|
||||
def add_mark(self, x, y):
|
||||
self.markList.append((x, y))
|
||||
|
||||
self.personalScore += 10
|
||||
|
||||
def clear_mark_list():
|
||||
self.markList = []
|
18
Timer.py
Normal file
18
Timer.py
Normal file
@ -0,0 +1,18 @@
|
||||
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()
|
@ -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 just work with tuple[0] and tuple[1].
|
||||
# Outdated this message is, I will 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 -
|
||||
|
Loading…
Reference in New Issue
Block a user