-
Notifications
You must be signed in to change notification settings - Fork 0
/
cards.py
70 lines (58 loc) · 2.58 KB
/
cards.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
# -*- coding: utf-8 -*-
from __future__ import division
from inputs import input_for_confirmation, input_for_choice
def King(player, board):
'The King receives three gold coins from the bank.'
player.gold += 3
def Queen(player, board):
'The Queen receives two gold coins from the bank.'
player.gold += 2
def Bishop(player, board):
'The Bishop takes two gold coins from the richest of the other players. In case of a tie, the Bishop chooses from which player the two coins are taken.'
ps_gold = filter(lambda (name, gold): name != player.name, board.max_rich_player(True))
richest_vec = filter(lambda x: x.val == ps_gold[0].val, ps_gold)
if len(richest_vec) == 1:
name_richest = richest_vec[0].name
elif len(richest_vec) > 1:
richest_vec = map(lambda (name, gold): name, richest_vec)
name_richest = input_for_choice(player, 'bishop_who', richest_vec, 'Which player?')
else:
raise ValueError('Not enough players.')
board.players[name_richest].gold -= 2
player.gold += 2
def Judge(player, board):
'''The Judge takes all the coins (fines) currently on the courthouse board.
Clarification: If players have falsely claimed to be the Judge and must pay a fine, that fine is paid after the Judge’s power is resolved, and therefore those fines will not be claimed by the Judge during this turn.
The Judge is the only mandatory character in each game.
'''
player.gold += board.court
board.court = 0
def Thief(player, board):
board.before_player.gold -= 1
board.next_player.gold -= 1
player.gold += 2
def Cheat(player, board):
'If they have 10 gold coins or more, the Cheat wins the game.'
board.check_end_condition(cheat_player = player)
def Witch(player, board):
'The Witch can swap all of her fortune with that of another player of their choice.'
second_player = input_for_choice(player, 'witch_who', board.players_names, 'Which player?')
second_player = board.players[second_player]
player.gold, second_player.gold = second_player.gold, player.gold
def Spy(player, board):
# przepisac z potential_exchange_handler
second_player = input_for_choice(player, 'spy_swap_who', board.players_names, 'Which player?')
execute = input_for_confirmation(player, 'spy_swap_exe', question='Execute?')
board.potential_exchange(second_player, execute)
cards = {
'King' : King,
'Queen' : Queen,
'Bishop' : Bishop,
'Judge' : Judge,
'Thief' : Thief,
'Cheat' : Cheat,
'Witch' : Witch,
'Spy' : Spy,
}
for name, card in cards.iteritems():
card.name = name