Compare commits
13 Commits
d329c0f7ab
...
main
Author | SHA1 | Date | |
---|---|---|---|
71e0247304 | |||
93403cdf83 | |||
a2e0504aa8 | |||
69ce05886d | |||
e53fd7236c | |||
cb8036bc6d | |||
00da6deb24 | |||
00daf53fae | |||
446ffba554 | |||
9c9db7aba9 | |||
7b486881d9 | |||
b11f77f7ef | |||
54a0f42137 |
1
Constants.py
Normal file
1
Constants.py
Normal file
@ -0,0 +1 @@
|
||||
VERSION_NUMBER = "0.1"
|
28
GameLogic.py
28
GameLogic.py
@ -1,23 +1,16 @@
|
||||
from datetime import datetime, time
|
||||
|
||||
from GameMap import *
|
||||
from Player import *
|
||||
from Timer import *
|
||||
|
||||
class GameLogic():
|
||||
|
||||
def __init__(self, gameMap, playerList, winRowLength = 3, individualMoves = 1):
|
||||
def __init__(self, gameMap, playerList, winRowLength=3, individualMoves=1):
|
||||
|
||||
self.gameMap = gameMap
|
||||
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
|
36
Interface.py
Normal file
36
Interface.py
Normal file
@ -0,0 +1,36 @@
|
||||
from tkinter import *
|
||||
import Constants
|
||||
|
||||
def generate_new_settings_window():
|
||||
window = Tk()
|
||||
window.geometry("400x300+300+250")
|
||||
window.title("Tic-Far-Toe v{}".format(Constants.VERSION_NUMBER))
|
||||
main_menu = Menu(tearoff=0)
|
||||
|
||||
file_menu = Menu(tearoff=0)
|
||||
main_menu.add_cascade(label="File", menu=file_menu)
|
||||
|
||||
# TODO - Fix this button that somehow spawns a broken window with no menus
|
||||
file_menu.add_command(label="New", command=generate_new_settings_window)
|
||||
file_menu.add_command(label="Save")
|
||||
file_menu.add_command(label="Save As...")
|
||||
file_menu.add_command(label="Load", command=generate_file_select_window)
|
||||
file_menu.add_separator()
|
||||
file_menu.add_command(label="Exit")
|
||||
|
||||
|
||||
edit_menu = Menu(tearoff=0)
|
||||
main_menu.add_cascade(label="Edit", menu=edit_menu)
|
||||
|
||||
|
||||
view_menu = Menu(tearoff=0)
|
||||
main_menu.add_cascade(label="View", menu=view_menu)
|
||||
|
||||
window.config(menu=main_menu)
|
||||
window.mainloop()
|
||||
|
||||
def generate_new_game_window():
|
||||
pass
|
||||
|
||||
def generate_file_select_window():
|
||||
pass
|
8
Main.py
8
Main.py
@ -1,7 +1,5 @@
|
||||
from tkinter import *
|
||||
from Interface import *
|
||||
from GameLogic import *
|
||||
|
||||
root = Tk()
|
||||
root.title("Tic-Far-Toe v0.1")
|
||||
|
||||
root.mainloop()
|
||||
VERSION_NUMBER = "0.1"
|
||||
generate_new_settings_window()
|
||||
|
@ -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 -
|
||||
|
Reference in New Issue
Block a user