-
Notifications
You must be signed in to change notification settings - Fork 1
/
robots.py
45 lines (34 loc) · 1.17 KB
/
robots.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
from core.server import Server, Rabelais, Partie
class Viewer(Rabelais):
def announce(self, message):
super().announce(message)
print(message)
def register(self, player, card, **kwargs):
super().register(player, card, **kwargs)
print('{} plays {}.'.format(player, card))
class Robot(Server):
def __init__(self):
player1 = Rabelais('Barry Lyndon')
player2 = Viewer('Rabelais')
self.players = {player1, player2}
self.partie = Partie(player1, player2)
def report(self, d):
self.announce("{}:\n{}".format(d.elder, d.elder.print_hand()))
self.announce("{}:\n{}".format(d.younger, d.younger.print_hand()))
def play_a_hand(self):
d = self.partie.new_deal()
# The deal
self.announce('---')
d.deal()
self.report(d)
self.exchange(d)
self.report(d)
self.declarations(d)
self.tricks(d)
self.announce('\nDeal: {}'.format(d.score))
input("...")
return d.score
if __name__ == "__main__":
r = Robot()
r.play_a_game()
print('\nWinner: {} with {}'.format(r.partie.winner, r.partie.final_score))