-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUI.py
77 lines (58 loc) · 2.17 KB
/
UI.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# !/usr/bin/python
# coding=utf-8
class UI:
player_character = ["👽","🍋"]
def __init__(self):
self.draw_opener()
def get_player_character(self, player_number_string):
try:
player_number = int(player_number_string)
return self.player_character[player_number-1]
except ValueError:
return ' '
def draw_opener(self):
print("Welcome to TikTakToe OMG a merge conflict\n")
# user input
def get_input_column(self):
return input("Column> ")
def get_input_row(self):
return input("Row> ")
# game field output
def draw_field(self, field):
rowcount = 1
print(" 1 2 3")
print(" ⎡-----⏉ -----⏉ ----⎤")
for row in field:
print " " + str(rowcount) + " │",
print " " + self.get_player_character(row[0]) + " " + self.get_player_character(row[1]) + " " + self.get_player_character(row[2]),
print(" ⎟")
rowcount += 1
if rowcount < 4:
print(" ├⎯⎯⎯⎯⎯┼⎯⎯⎯⎯⎯⎯┼⎯⎯⎯⎯⎯┤")
else:
print(" ⎣-----⏊ -----⏊ ----⎦")
pass
# player related outputs
def draw_players_turn(self, player_number):
if player_number == 1:
print("Player One Input")
elif player_number == 2:
print("Player Two Input")
def draw_players_win(self, player_number):
if player_number == 1:
print("!!! Player One Wins !!!")
elif player_number == 2:
print("!!! Player Two Wins !!!")
# will be used in a later commit
# def __draw_player_text(self, text, player_number):
# Static messages
def draw_line(self):
print("\n\n⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯")
def draw_tie(self):
print("Its a tie")
def draw_invalid_input(self):
print("Invalid Input, Input should be numbers only")
def draw_invalid_number(self):
print("Invalid Numbers")
def draw_field_occupied(self):
print("Field already occupied ")