bridgeobjects 0.1.28__tar.gz → 0.1.30__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/PKG-INFO +16 -3
- bridgeobjects-0.1.30/bridgeobjects/_version.py +1 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/src/call.py +18 -10
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/src/constants.py +4 -2
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/src/contract.py +80 -41
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/src/hand.py +3 -2
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/tests/test_contracts.py +35 -10
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects.egg-info/PKG-INFO +16 -3
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/setup.py +8 -4
- bridgeobjects-0.1.28/bridgeobjects/_version.py +0 -1
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/LICENSE.txt +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/README.md +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/__init__.py +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/src/__init__.py +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/src/_create_pbn_string.py +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/src/_file_constants.py +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/src/_parse_lin_string.py +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/src/_parse_pbn_string.py +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/src/_parse_rbn_string.py +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/src/auction.py +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/src/board.py +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/src/card.py +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/src/denomination.py +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/src/event.py +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/src/file_operations.py +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/src/suit.py +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/src/suit_base.py +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/src/trick.py +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/tests/__init__.py +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/tests/test_auctions.py +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/tests/test_boards.py +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/tests/test_calls.py +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/tests/test_cards.py +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/tests/test_data/lin_input_file_1.lin +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/tests/test_data/pbn_auction_1.pbn +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/tests/test_data/pbn_auction_2.pbn +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/tests/test_data/pbn_input_3.pbn +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/tests/test_data/pbn_input_file_1.pbn +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/tests/test_data/pbn_output_file_1.pbn +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/tests/test_data/rbn_input_file_1.rbn +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/tests/test_data/rbn_output_file_1.rbn +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/tests/test_denominations.py +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/tests/test_events.py +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/tests/test_hands.py +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/tests/test_lin.py +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/tests/test_pbn.py +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/tests/test_rbn.py +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/tests/test_scores.py +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/tests/test_suits.py +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/tests/test_trick.py +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects.egg-info/SOURCES.txt +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects.egg-info/dependency_links.txt +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects.egg-info/top_level.txt +0 -0
- {bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/setup.cfg +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: bridgeobjects
|
|
3
|
-
Version: 0.1.
|
|
4
|
-
Summary: A collection of modules that allows the user to access objects used
|
|
3
|
+
Version: 0.1.30
|
|
4
|
+
Summary: A collection of modules that allows the user to access objects used
|
|
5
5
|
Home-page: https://psionman@bitbucket.org/psionman/bridgeobjects.git
|
|
6
6
|
Download-URL: https://pypi.org/project/bridgeobjects/
|
|
7
7
|
Author: jeff watkins
|
|
8
8
|
Author-email: support@bidforgame.com
|
|
9
9
|
License: MIT
|
|
10
|
-
Keywords: bridge,
|
|
10
|
+
Keywords: bridge,duplicate bridge,contract bridge,hand,board,suit,auction,contract,card
|
|
11
11
|
Description-Content-Type: text/markdown
|
|
12
12
|
License-File: LICENSE.txt
|
|
13
13
|
|
|
@@ -41,12 +41,25 @@ pip install bridgeobjects
|
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
# History
|
|
44
|
+
Version 0.1.30 0715 Apr 2024
|
|
45
|
+
|
|
46
|
+
1. Initailse hand shape
|
|
47
|
+
|
|
48
|
+
------
|
|
49
|
+
|
|
50
|
+
Version 0.1.29 07 Mar 2024
|
|
51
|
+
|
|
52
|
+
1. Rationalise modifier in contract
|
|
53
|
+
|
|
54
|
+
------
|
|
44
55
|
|
|
45
56
|
Version 0.1.28 01 Feb 2024
|
|
46
57
|
|
|
47
58
|
1. Refactor hand
|
|
48
59
|
2. File load pbn to handle BBO files
|
|
49
60
|
|
|
61
|
+
------
|
|
62
|
+
|
|
50
63
|
Version 0.1.27 7 Jan 2024
|
|
51
64
|
|
|
52
65
|
1. Fix calls in Auction
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '0.1.30'
|
|
@@ -32,6 +32,14 @@ class Call(object):
|
|
|
32
32
|
"""
|
|
33
33
|
|
|
34
34
|
def __init__(self, name: str = ''):
|
|
35
|
+
if name == 'X':
|
|
36
|
+
name = 'D'
|
|
37
|
+
if name == 'XX':
|
|
38
|
+
name = 'R'
|
|
39
|
+
|
|
40
|
+
# TODO - why is X acceptable?
|
|
41
|
+
# if name and name.replace('X', '') not in CALLS:
|
|
42
|
+
# raise ValueError(f'{name} is not a Call')
|
|
35
43
|
if name and name.replace('X', '') not in CALLS:
|
|
36
44
|
raise ValueError(f'{name} is not a Call')
|
|
37
45
|
self._name = name
|
|
@@ -46,15 +54,14 @@ class Call(object):
|
|
|
46
54
|
self._is_double = name == 'D'
|
|
47
55
|
self._is_redouble = name == 'R'
|
|
48
56
|
if name:
|
|
49
|
-
if name[1:] in Denomination.SHORT_NAMES:
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
self._level = int(name[0])
|
|
57
|
+
if name[1:] in Denomination.SHORT_NAMES and len(name) <= 3:
|
|
58
|
+
self._denomination = Denomination(name[1:])
|
|
59
|
+
self._is_major = self._denomination.is_major
|
|
60
|
+
self._is_minor = self._denomination.is_minor
|
|
61
|
+
self._is_suit_call = self._is_major or self._is_minor
|
|
62
|
+
self._is_no_trumps = not self._is_suit_call
|
|
63
|
+
self._is_value_call = self._is_suit_call or self._is_no_trumps
|
|
64
|
+
self._level = int(name[0])
|
|
58
65
|
self._is_game = self._set_is_game()
|
|
59
66
|
self.image = None
|
|
60
67
|
self.bitmap = None
|
|
@@ -119,7 +126,8 @@ class Call(object):
|
|
|
119
126
|
|
|
120
127
|
@property
|
|
121
128
|
def level(self) -> int:
|
|
122
|
-
"""Returns the level of the call as an integer
|
|
129
|
+
"""Returns the level of the call as an integer
|
|
130
|
+
(e.g. 1 for '1NT', 3 for '3S')."""
|
|
123
131
|
return self._level
|
|
124
132
|
|
|
125
133
|
@property
|
|
@@ -47,8 +47,10 @@ CALLS = ['1C', '1D', '1H', '1S', '1NT',
|
|
|
47
47
|
def _make_contracts():
|
|
48
48
|
"""Generate valid contract names from CALLS."""
|
|
49
49
|
contracts = [call for call in CALLS if call[0].isnumeric()]
|
|
50
|
-
contracts.extend([''.join([call, 'X'])
|
|
51
|
-
|
|
50
|
+
contracts.extend([''.join([call, 'X'])
|
|
51
|
+
for call in CALLS if call[0].isnumeric()])
|
|
52
|
+
contracts.extend([''.join([call, 'XX'])
|
|
53
|
+
for call in CALLS if call[0].isnumeric()])
|
|
52
54
|
return contracts
|
|
53
55
|
|
|
54
56
|
|
|
@@ -8,13 +8,12 @@ from .suit import Suit
|
|
|
8
8
|
from .auction import Auction
|
|
9
9
|
from .constants import (
|
|
10
10
|
CONTRACTS, SEATS, SUITS,
|
|
11
|
-
UNDER_TRICK_POINTS, UNDER_TRICK_POINTS_DOUBLED,
|
|
12
|
-
CONTRACT_POINTS, CONTRACT_POINTS_DOUBLED,
|
|
13
|
-
OVER_TRICK_POINTS, OVER_TRICK_POINTS_DOUBLED,
|
|
14
|
-
PART_GAME_BONUS, GAME_BONUS,
|
|
11
|
+
UNDER_TRICK_POINTS, UNDER_TRICK_POINTS_DOUBLED,
|
|
12
|
+
UNDER_TRICK_POINTS_REDOUBLED, CONTRACT_POINTS, CONTRACT_POINTS_DOUBLED,
|
|
13
|
+
CONTRACT_POINTS_REDOUBLED, OVER_TRICK_POINTS, OVER_TRICK_POINTS_DOUBLED,
|
|
14
|
+
OVER_TRICK_POINTS_REDOUBLED, PART_GAME_BONUS, GAME_BONUS,
|
|
15
15
|
CONTRACT_THRESHOLD, DOUBLED_BONUS, REDOUBLED_BONUS,
|
|
16
|
-
SLAM_LEVEL, GRAND_SLAM_LEVEL,
|
|
17
|
-
SLAM_BONUS, GRAND_SLAM_BONUS
|
|
16
|
+
SLAM_LEVEL, GRAND_SLAM_LEVEL, SLAM_BONUS, GRAND_SLAM_BONUS
|
|
18
17
|
)
|
|
19
18
|
|
|
20
19
|
__all__ = ['Contract']
|
|
@@ -38,16 +37,19 @@ class Contract(object):
|
|
|
38
37
|
It is also identified (if appropriate) as either major, minor or no trumps.
|
|
39
38
|
"""
|
|
40
39
|
|
|
41
|
-
def __init__(self, name: str = '', declarer: str = '',
|
|
40
|
+
def __init__(self, name: str = '', declarer: str = '',
|
|
41
|
+
auction: Auction | None = None):
|
|
42
42
|
self._initialise(name, declarer, auction)
|
|
43
43
|
|
|
44
44
|
def _initialise(self, name, declarer, auction=None):
|
|
45
45
|
"""Initialise the class."""
|
|
46
|
-
(self._name, self._modifier) = self.
|
|
46
|
+
(self._name, self._modifier) = self._get_name_and_modifier(name)
|
|
47
47
|
self._declarer = declarer
|
|
48
48
|
self.auction = self._analyse_auction(auction)
|
|
49
49
|
self._is_nt = False
|
|
50
50
|
self._denomination = None
|
|
51
|
+
self._doubled = False
|
|
52
|
+
self._redoubled = False
|
|
51
53
|
|
|
52
54
|
# Denomination
|
|
53
55
|
if self._name and self._is_valid(self._name):
|
|
@@ -73,18 +75,18 @@ class Contract(object):
|
|
|
73
75
|
self._target_tricks = 0
|
|
74
76
|
self.game_level = False
|
|
75
77
|
|
|
76
|
-
# Modifier
|
|
77
|
-
self._set_double()
|
|
78
|
-
|
|
79
78
|
def __repr__(self) -> str:
|
|
80
79
|
"""Return the repr string for the object."""
|
|
81
|
-
|
|
80
|
+
name = f'{self._call.name}'
|
|
81
|
+
if self._modifier:
|
|
82
|
+
name = '{self._call.name} {self._modifier}'
|
|
83
|
+
return f'Contract("{name}", "{self._declarer}")'
|
|
82
84
|
|
|
83
85
|
def __str__(self) -> str:
|
|
84
86
|
"""Return the str string for the object."""
|
|
85
87
|
return f'Contract. {self._call.name} by {self._declarer}'
|
|
86
88
|
|
|
87
|
-
def _is_game_level(self):
|
|
89
|
+
def _is_game_level(self) -> bool:
|
|
88
90
|
"""Return True if the contract is at or above game level."""
|
|
89
91
|
if self.denomination.is_minor:
|
|
90
92
|
if self.level >= 5:
|
|
@@ -98,7 +100,7 @@ class Contract(object):
|
|
|
98
100
|
return False
|
|
99
101
|
|
|
100
102
|
@staticmethod
|
|
101
|
-
def
|
|
103
|
+
def _get_name_and_modifier(name: str) -> tuple[str, str]:
|
|
102
104
|
"""Return the name and modifier from the name parameter."""
|
|
103
105
|
if name and name != 'None':
|
|
104
106
|
if len(name) >= 3 and name[-1] in 'DR':
|
|
@@ -106,14 +108,50 @@ class Contract(object):
|
|
|
106
108
|
return (name, '')
|
|
107
109
|
return ('', '')
|
|
108
110
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
self.
|
|
112
|
-
|
|
111
|
+
@property
|
|
112
|
+
def doubled(self) -> bool:
|
|
113
|
+
if self._modifier == 'D':
|
|
114
|
+
self._doubled = True
|
|
115
|
+
return self._doubled
|
|
116
|
+
|
|
117
|
+
@doubled.setter
|
|
118
|
+
def doubled(self, value: bool) -> None:
|
|
119
|
+
self._modifier = ''
|
|
120
|
+
if value:
|
|
121
|
+
self._modifier = 'D'
|
|
122
|
+
self._doubled = value
|
|
123
|
+
|
|
124
|
+
@property
|
|
125
|
+
def redoubled(self) -> bool:
|
|
113
126
|
if self._modifier == 'R':
|
|
114
|
-
self.
|
|
115
|
-
|
|
116
|
-
|
|
127
|
+
self._redoubled = True
|
|
128
|
+
return self._redoubled
|
|
129
|
+
|
|
130
|
+
@redoubled.setter
|
|
131
|
+
def redoubled(self, value: bool) -> None:
|
|
132
|
+
self._modifier = ''
|
|
133
|
+
if value:
|
|
134
|
+
self._modifier = 'R'
|
|
135
|
+
self._redoubled = value
|
|
136
|
+
|
|
137
|
+
@property
|
|
138
|
+
def modifier(self) -> str:
|
|
139
|
+
return self._modifier
|
|
140
|
+
|
|
141
|
+
@modifier.setter
|
|
142
|
+
def modifier(self, value) -> None:
|
|
143
|
+
if value and value not in 'DR':
|
|
144
|
+
assert False, 'Invalid modifier'
|
|
145
|
+
|
|
146
|
+
self._doubled = False
|
|
147
|
+
self._redoubled = False
|
|
148
|
+
if value == 'D':
|
|
149
|
+
self._doubled = True
|
|
150
|
+
self._redoubled = False
|
|
151
|
+
elif value == 'R':
|
|
152
|
+
self._doubled = False
|
|
153
|
+
self._redoubled = True
|
|
154
|
+
self._modifier = value
|
|
117
155
|
|
|
118
156
|
@property
|
|
119
157
|
def declarer(self) -> str:
|
|
@@ -149,7 +187,7 @@ class Contract(object):
|
|
|
149
187
|
self._is_nt = self._denomination.is_nt
|
|
150
188
|
if not self._is_nt:
|
|
151
189
|
self._trump_suit = SUITS[value[1]]
|
|
152
|
-
(self._name, self._modifier) = self.
|
|
190
|
+
(self._name, self._modifier) = self._get_name_and_modifier(value)
|
|
153
191
|
self._level = int(self._name[0])
|
|
154
192
|
self._target_tricks = self._level + CONTRACT_THRESHOLD
|
|
155
193
|
self._call = Call(self._name)
|
|
@@ -171,7 +209,8 @@ class Contract(object):
|
|
|
171
209
|
raise TypeError(f'{value} is not a Call')
|
|
172
210
|
self._call = value
|
|
173
211
|
self._denomination = self._get_denomination(value.name)
|
|
174
|
-
self._is_nt = self._denomination.is_nt or
|
|
212
|
+
self._is_nt = (self._denomination.is_nt or
|
|
213
|
+
self._denomination.is_no_trumps)
|
|
175
214
|
|
|
176
215
|
@property
|
|
177
216
|
def trump_suit(self) -> Suit | None:
|
|
@@ -203,18 +242,18 @@ class Contract(object):
|
|
|
203
242
|
"""Return True if the denomination is NT."""
|
|
204
243
|
return self._is_nt
|
|
205
244
|
|
|
206
|
-
@property
|
|
207
|
-
def modifier(self) -> str:
|
|
208
|
-
|
|
209
|
-
|
|
245
|
+
# @property
|
|
246
|
+
# def modifier(self) -> str:
|
|
247
|
+
# """Return contract's modifier (i.e.: '', 'D' or 'R')."""
|
|
248
|
+
# return self._modifier
|
|
210
249
|
|
|
211
|
-
@modifier.setter
|
|
212
|
-
def modifier(self, value: str):
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
250
|
+
# @modifier.setter
|
|
251
|
+
# def modifier(self, value: str):
|
|
252
|
+
# """Set contract's modifier (i.e.: '', 'D' or 'R')."""
|
|
253
|
+
# if value in ['D', 'R']:
|
|
254
|
+
# self._modifier = value
|
|
255
|
+
# else:
|
|
256
|
+
# self._modifier = ''
|
|
218
257
|
|
|
219
258
|
@property
|
|
220
259
|
def target_tricks(self) -> int:
|
|
@@ -349,20 +388,20 @@ class Contract(object):
|
|
|
349
388
|
|
|
350
389
|
if self.doubled:
|
|
351
390
|
if vulnerable:
|
|
352
|
-
|
|
391
|
+
over_points = OVER_TRICK_POINTS_DOUBLED['vulnerable']
|
|
353
392
|
else:
|
|
354
|
-
|
|
393
|
+
over_points = OVER_TRICK_POINTS_DOUBLED['non-vulnerable']
|
|
355
394
|
elif self.redoubled:
|
|
356
395
|
if vulnerable:
|
|
357
|
-
|
|
396
|
+
over_points = OVER_TRICK_POINTS_REDOUBLED['vulnerable']
|
|
358
397
|
else:
|
|
359
|
-
|
|
398
|
+
over_points = OVER_TRICK_POINTS_REDOUBLED['non-vulnerable']
|
|
360
399
|
else:
|
|
361
|
-
|
|
400
|
+
over_points = OVER_TRICK_POINTS[name]
|
|
362
401
|
|
|
363
402
|
if True:
|
|
364
|
-
for
|
|
365
|
-
score +=
|
|
403
|
+
for _ in range(declarer_tricks-CONTRACT_THRESHOLD-self.level):
|
|
404
|
+
score += over_points
|
|
366
405
|
return score
|
|
367
406
|
|
|
368
407
|
def _slam_points(self, vulnerable: bool) -> int:
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
from .card import Card
|
|
4
4
|
from .denomination import Denomination
|
|
5
5
|
from .suit import Suit, Spades, Hearts, Diamonds, Clubs
|
|
6
|
-
from .constants import (SUIT_NAMES, RANKS, SUITS, HONOUR_POINTS,
|
|
6
|
+
from .constants import (SUIT_NAMES, RANKS, SUITS, HONOUR_POINTS, SEATS,
|
|
7
7
|
BALANCED_SHAPES, SEMI_BALANCED_SHAPES,
|
|
8
8
|
CARD_NAMES, DISPLAY_SUIT_ORDER)
|
|
9
9
|
|
|
@@ -13,6 +13,7 @@ __all__ = ['Hand']
|
|
|
13
13
|
CANDIDATES_4441 = {'S': SUITS['H'], 'H': SUITS['S'],
|
|
14
14
|
'D': SUITS['H'], 'C': SUITS['S']}
|
|
15
15
|
|
|
16
|
+
|
|
16
17
|
class Hand(object):
|
|
17
18
|
"""
|
|
18
19
|
A hand object for the bridgeobjects module.
|
|
@@ -57,7 +58,7 @@ class Hand(object):
|
|
|
57
58
|
|
|
58
59
|
# attributes set once the cards are known for the hand
|
|
59
60
|
self._high_card_points = -1
|
|
60
|
-
self._shape: list[int] = []
|
|
61
|
+
self._shape: list[int] = [0 for seat in SEATS]
|
|
61
62
|
self._equal_long_suits = False
|
|
62
63
|
self._suits_by_length = None
|
|
63
64
|
self._longest_suit = None
|
|
@@ -13,8 +13,8 @@ def test_contract_name_valid():
|
|
|
13
13
|
|
|
14
14
|
def test_contract_name_invalid():
|
|
15
15
|
"""Ensure that the contract name is correct: invalid names."""
|
|
16
|
-
with pytest.raises(ValueError)
|
|
17
|
-
|
|
16
|
+
with pytest.raises(ValueError):
|
|
17
|
+
Contract('1Q')
|
|
18
18
|
assert True
|
|
19
19
|
|
|
20
20
|
|
|
@@ -23,7 +23,7 @@ def test_contract_is_nt():
|
|
|
23
23
|
assert not Contract('1S').is_nt
|
|
24
24
|
assert Contract('3NT')
|
|
25
25
|
contract = Contract()
|
|
26
|
-
assert contract.is_nt
|
|
26
|
+
assert contract.is_nt is False
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
def test_contract_repr():
|
|
@@ -41,7 +41,7 @@ def test_contract_str():
|
|
|
41
41
|
def test_contract_name_setter():
|
|
42
42
|
"""Ensure that the contract name is correct: invalid names."""
|
|
43
43
|
contract = Contract()
|
|
44
|
-
with pytest.raises(ValueError)
|
|
44
|
+
with pytest.raises(ValueError):
|
|
45
45
|
contract.name = '1Q'
|
|
46
46
|
assert True
|
|
47
47
|
|
|
@@ -65,19 +65,19 @@ def test_contract_call_setter_valid():
|
|
|
65
65
|
def test_contract_call_setter_invalid_type():
|
|
66
66
|
"""Ensure that the contract call is correct."""
|
|
67
67
|
contract = Contract()
|
|
68
|
-
with pytest.raises(TypeError)
|
|
68
|
+
with pytest.raises(TypeError):
|
|
69
69
|
contract.call = None
|
|
70
70
|
|
|
71
71
|
|
|
72
72
|
def test_contract_call_setter_invalid():
|
|
73
73
|
"""Ensure that the contract call is correct."""
|
|
74
74
|
contract = Contract()
|
|
75
|
-
with pytest.raises(ValueError)
|
|
75
|
+
with pytest.raises(ValueError):
|
|
76
76
|
contract.call = 'W'
|
|
77
77
|
assert True
|
|
78
|
-
with pytest.raises(ValueError)
|
|
78
|
+
with pytest.raises(ValueError):
|
|
79
79
|
contract.call = Call('8NT')
|
|
80
|
-
with pytest.raises(ValueError)
|
|
80
|
+
with pytest.raises(ValueError):
|
|
81
81
|
contract.call = Call('0S')
|
|
82
82
|
assert True
|
|
83
83
|
|
|
@@ -87,6 +87,8 @@ def test_contract_call_setter_valid_double():
|
|
|
87
87
|
contract = Contract()
|
|
88
88
|
contract.call = '3C'
|
|
89
89
|
assert contract.call == Call('3C')
|
|
90
|
+
|
|
91
|
+
# TODO why is this here?
|
|
90
92
|
contract.call = Call('3NTX')
|
|
91
93
|
assert contract.call.name == '3NTX'
|
|
92
94
|
|
|
@@ -106,7 +108,7 @@ def test_contract_trump_suit_setter_valid():
|
|
|
106
108
|
def test_contract_trump_suit_setter_invalid():
|
|
107
109
|
"""Ensure that the contract trump suit is correct."""
|
|
108
110
|
contract = Contract()
|
|
109
|
-
with pytest.raises(TypeError)
|
|
111
|
+
with pytest.raises(TypeError):
|
|
110
112
|
contract.trump_suit = 'W'
|
|
111
113
|
assert True
|
|
112
114
|
|
|
@@ -121,6 +123,29 @@ def test_contract_denomination_valid():
|
|
|
121
123
|
def test_contract_declarer_invalid():
|
|
122
124
|
"""Ensure that the contract trump suit is correct."""
|
|
123
125
|
contract = Contract()
|
|
124
|
-
with pytest.raises(ValueError)
|
|
126
|
+
with pytest.raises(ValueError):
|
|
125
127
|
contract.declarer = 'M'
|
|
126
128
|
assert True
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def test_contract_modifier():
|
|
132
|
+
contract = Contract('5C')
|
|
133
|
+
contract.modifier = ''
|
|
134
|
+
assert contract.doubled is False
|
|
135
|
+
assert contract.redoubled is False
|
|
136
|
+
|
|
137
|
+
contract.modifier = 'D'
|
|
138
|
+
assert contract.doubled is True
|
|
139
|
+
assert contract.redoubled is False
|
|
140
|
+
|
|
141
|
+
contract.modifier = 'R'
|
|
142
|
+
assert contract.doubled is False
|
|
143
|
+
assert contract.redoubled is True
|
|
144
|
+
|
|
145
|
+
contract.modifier = ''
|
|
146
|
+
assert contract.doubled is False
|
|
147
|
+
assert contract.redoubled is False
|
|
148
|
+
|
|
149
|
+
with pytest.raises(AssertionError):
|
|
150
|
+
contract.modifier = 'E'
|
|
151
|
+
assert True
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: bridgeobjects
|
|
3
|
-
Version: 0.1.
|
|
4
|
-
Summary: A collection of modules that allows the user to access objects used
|
|
3
|
+
Version: 0.1.30
|
|
4
|
+
Summary: A collection of modules that allows the user to access objects used
|
|
5
5
|
Home-page: https://psionman@bitbucket.org/psionman/bridgeobjects.git
|
|
6
6
|
Download-URL: https://pypi.org/project/bridgeobjects/
|
|
7
7
|
Author: jeff watkins
|
|
8
8
|
Author-email: support@bidforgame.com
|
|
9
9
|
License: MIT
|
|
10
|
-
Keywords: bridge,
|
|
10
|
+
Keywords: bridge,duplicate bridge,contract bridge,hand,board,suit,auction,contract,card
|
|
11
11
|
Description-Content-Type: text/markdown
|
|
12
12
|
License-File: LICENSE.txt
|
|
13
13
|
|
|
@@ -41,12 +41,25 @@ pip install bridgeobjects
|
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
# History
|
|
44
|
+
Version 0.1.30 0715 Apr 2024
|
|
45
|
+
|
|
46
|
+
1. Initailse hand shape
|
|
47
|
+
|
|
48
|
+
------
|
|
49
|
+
|
|
50
|
+
Version 0.1.29 07 Mar 2024
|
|
51
|
+
|
|
52
|
+
1. Rationalise modifier in contract
|
|
53
|
+
|
|
54
|
+
------
|
|
44
55
|
|
|
45
56
|
Version 0.1.28 01 Feb 2024
|
|
46
57
|
|
|
47
58
|
1. Refactor hand
|
|
48
59
|
2. File load pbn to handle BBO files
|
|
49
60
|
|
|
61
|
+
------
|
|
62
|
+
|
|
50
63
|
Version 0.1.27 7 Jan 2024
|
|
51
64
|
|
|
52
65
|
1. Fix calls in Auction
|
|
@@ -18,12 +18,16 @@ if mo:
|
|
|
18
18
|
else:
|
|
19
19
|
raise RuntimeError(f'Unable to find version string in {VERSION_FILE}.')
|
|
20
20
|
|
|
21
|
+
keywords_list = [
|
|
22
|
+
'bridge', 'duplicate bridge', 'contract bridge', 'hand',
|
|
23
|
+
'board', 'suit', 'auction', 'contract', 'card'
|
|
24
|
+
]
|
|
21
25
|
setup_args = dict(
|
|
22
26
|
name='bridgeobjects',
|
|
23
27
|
version=version_string,
|
|
24
28
|
description="""
|
|
25
|
-
A collection of modules that allows the user to access objects used
|
|
26
|
-
for example, a board or a contract.
|
|
29
|
+
A collection of modules that allows the user to access objects used
|
|
30
|
+
in bridge games, for example, a board or a contract.
|
|
27
31
|
""",
|
|
28
32
|
long_description_content_type="text/markdown",
|
|
29
33
|
long_description=README + '\n\n' + HISTORY,
|
|
@@ -31,7 +35,7 @@ setup_args = dict(
|
|
|
31
35
|
packages=find_packages(),
|
|
32
36
|
author='jeff watkins',
|
|
33
37
|
author_email='support@bidforgame.com',
|
|
34
|
-
keywords=
|
|
38
|
+
keywords=', '.join(keywords_list),
|
|
35
39
|
url='https://psionman@bitbucket.org/psionman/bridgeobjects.git',
|
|
36
40
|
download_url='https://pypi.org/project/bridgeobjects/'
|
|
37
41
|
)
|
|
@@ -50,4 +54,4 @@ if __name__ == '__main__':
|
|
|
50
54
|
include_package_data=True,
|
|
51
55
|
**setup_args,
|
|
52
56
|
install_requires=install_requires
|
|
53
|
-
|
|
57
|
+
)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = '0.1.28'
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/tests/test_data/lin_input_file_1.lin
RENAMED
|
File without changes
|
{bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/tests/test_data/pbn_auction_1.pbn
RENAMED
|
File without changes
|
{bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/tests/test_data/pbn_auction_2.pbn
RENAMED
|
File without changes
|
|
File without changes
|
{bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/tests/test_data/pbn_input_file_1.pbn
RENAMED
|
File without changes
|
{bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/tests/test_data/pbn_output_file_1.pbn
RENAMED
|
File without changes
|
{bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/tests/test_data/rbn_input_file_1.rbn
RENAMED
|
File without changes
|
{bridgeobjects-0.1.28 → bridgeobjects-0.1.30}/bridgeobjects/tests/test_data/rbn_output_file_1.rbn
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|