summaryrefslogtreecommitdiff
path: root/dealconvert/dto.py
blob: 37585d8b4c413b16de0d7f4f516a09440612c754 (plain)
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
POSITION_NORTH = 0
POSITION_EAST = 1
POSITION_SOUTH = 2
POSITION_WEST = 3
SUIT_SPADES = 0
SUIT_HEARTS = 1
SUIT_DIAMONDS = 2
SUIT_CLUBS = 3

class Deal(object):
    event = ''
    number = None
    vulnerable = None
    dealer = None
    hands = None

    def __init__(self):
        self.hands = [[[],[],[],[]],
                      [[],[],[],[]],
                      [[],[],[],[]],
                      [[],[],[],[]]]
        self.vulnerable = {'NS': False, 'EW': False}

    def get_dealer(self, board_no):
        return (board_no - 1) % 4

    def get_vulnerability(self, board_no):
        board_no = board_no % 16
        vuln = {'NS': [False,
                       False, True, False, True,
                       True, False, True, False,
                       False, True, False, True,
                       True, False, True],
                'EW': [True,
                       False, False, True, True,
                       False, True, True, False,
                       True, True, False, False,
                       True, False, False]}
        return { pair: vuln[pair][board_no] for pair in vuln }