more clean
This commit is contained in:
parent
b316210184
commit
fb2e4040db
2 changed files with 19 additions and 19 deletions
|
@ -40,7 +40,7 @@ def main():
|
||||||
|
|
||||||
kill = False
|
kill = False
|
||||||
ui = CLI()
|
ui = CLI()
|
||||||
ui.intro()
|
print(ui.intro)
|
||||||
|
|
||||||
num_decks = ui.get_decks()
|
num_decks = ui.get_decks()
|
||||||
if num_decks == 'q':
|
if num_decks == 'q':
|
||||||
|
|
34
src/io.py
34
src/io.py
|
@ -12,6 +12,9 @@ o8YooP' 8 .oPYo. .oPYo. 8 .o 8 .oPYo. .oPYo. 8 .o
|
||||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::'''
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::'''
|
||||||
|
|
||||||
|
self.clear = '\033c'
|
||||||
|
self.intro = self.clear + self.title
|
||||||
|
|
||||||
self.deck = '''\
|
self.deck = '''\
|
||||||
┌────────┐┐┐┐┐┐
|
┌────────┐┐┐┐┐┐
|
||||||
│░░░░░░░░││││││
|
│░░░░░░░░││││││
|
||||||
|
@ -72,28 +75,25 @@ o8YooP' 8 .oPYo. .oPYo. 8 .o 8 .oPYo. .oPYo. 8 .o
|
||||||
card_stack[0] = self.hidden_part
|
card_stack[0] = self.hidden_part
|
||||||
|
|
||||||
card_slices = [card.splitlines() for card in card_stack]
|
card_slices = [card.splitlines() for card in card_stack]
|
||||||
|
card_height = len(card_slices[0])
|
||||||
|
|
||||||
lines = []
|
buffer = ''
|
||||||
for i in range(7):
|
for i in range(card_height):
|
||||||
lines.append(''.join([card_slice[i] for card_slice in card_slices]) + '\n')
|
buffer += ''.join([card_slice[i] for card_slice in card_slices])+'\n'
|
||||||
return ''.join(lines)
|
|
||||||
|
|
||||||
def clear(self):
|
return buffer[:-1]
|
||||||
print('\033c')
|
|
||||||
|
|
||||||
def intro(self):
|
def show_players(self, game):
|
||||||
self.clear()
|
buffer = ''
|
||||||
print(self.title)
|
for player in game.players:
|
||||||
|
buffer += f"\n {player.name}{37*' '}Score: {player.score(game)}\n{self.draw_player_hand(player, game)}"
|
||||||
|
|
||||||
|
return buffer
|
||||||
|
|
||||||
def update(self, game):
|
def update(self, game):
|
||||||
self.clear()
|
print(self.clear + self.title +
|
||||||
print(self.title)
|
self.show_players(game) +\
|
||||||
for player in game.players:
|
('\n'+game.score() if not game.active else ''))
|
||||||
print(' '+player.name,'''\
|
|
||||||
Score:''', player.score(game))
|
|
||||||
print(self.draw_player_hand(player, game))
|
|
||||||
if not game.active:
|
|
||||||
print(game.score())
|
|
||||||
|
|
||||||
def get_decks(self):
|
def get_decks(self):
|
||||||
return input('How many decks? (1-8): ')
|
return input('How many decks? (1-8): ')
|
||||||
|
|
Loading…
Add table
Reference in a new issue