Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/tic_tac_toe/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from src.tic_tac_toe.utils import ask_for_name
from src.tic_tac_toe.utils import GameState, ask_for_name, turn

def main():
print("=== Tic Tac Toe ===")
Expand All @@ -7,5 +7,11 @@ def main():
name2 = ask_for_name("player #2")
print(f"Starting game for {name1} and {name2}")

state = None #todo: initialize state
p1_turn = True
while state.state() == GameState.UNFINISHED:
turn(state, p1_turn)
p1_turn = not p1_turn

if __name__ == "__main__":
main()
26 changes: 26 additions & 0 deletions src/tic_tac_toe/utils.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,28 @@
import enum
import typing


def ask_for_name(player_tag) -> str:
return input(f"Enter name of {player_tag}:")

class GameState(enum.EnumType):
PLAYER_1 = 1
PLAYER_2 = 2
DRAW = 3
UNFINISHED = 4

class State:
def __init__(self, board, p1_name, p2_name):
self.board = board
self.p1_name = p1_name
self.p2_name = p2_name
def state(self) -> GameState:
# todo
return GameState.UNFINISHED

def print_state(state: State):
# todo
pass
def turn(state: State, p1_turn: bool):
# todo
pass