blob: d7ed7cd0035e0e05896cc0b4e08c064193b16edc (
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
|
'''
Wrapper class for libbcalcDDS.dll
'''
from ctypes import cdll, c_void_p
from .Exceptions import DllNotFoundException
class BCalcWrapper(object):
DENOMINATIONS = [ 'C', 'D', 'H', 'S', 'N' ]
PLAYERS = [ 'N', 'E', 'S', 'W' ]
def __init__(self):
try:
self.libbcalcdds = cdll.LoadLibrary('./libbcalcdds.dll')
except OSError:
try:
self.libbcalcdds = cdll.LoadLibrary('./libbcalcdds.so')
except OSError:
self.libbcalcdds = None
if self.libbcalcdds is None:
raise DllNotFoundException()
def __getattr__(self, attrname):
def _dynamic_method(*args):
function = getattr(self.libbcalcdds, 'bcalcDDS_' + attrname)
if attrname == 'new':
function.restype = c_void_p
else:
function.argtypes = [c_void_p]
return function(*args)
return _dynamic_method
def declarerToLeader(self, player):
return (player + 1) % 4
|