-
Notifications
You must be signed in to change notification settings - Fork 0
/
views.py
44 lines (33 loc) · 1.13 KB
/
views.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
class GameView:
def intro(self):
return '\nTic Tac Toe\n'
def newlines(self, amount=1):
return '\n' * amount
def number_of_players(self):
return 'Enter number of players (1-2): '
def number_of_players_error(self):
return '\nPlease enter 1 or 2'
def board(self, board):
return '''
╔═══╦═══╦═══╗
║ {0} ║ {1} ║ {2} ║
╠═══╬═══╬═══╣
║ {3} ║ {4} ║ {5} ║
╠═══╬═══╬═══╣
║ {6} ║ {7} ║ {8} ║
╚═══╩═══╩═══╝
'''.format(*[x or (i + 1) for i, x in enumerate(board)])
def win_player(self, player):
return 'Player {} won!'.format(player)
def draw(self):
return '\nGame ended in draw.'
@property
def play_again(self):
return '\nPlay again? (Y/n): '
def next_move(self, player, move=''):
return 'Player {}: {}'.format(player, move)
@property
def move_not_valid(self):
return 'Not a valid move'