summaryrefslogtreecommitdiff
path: root/bcdd/BCalcWrapper.py
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2018-04-10 21:19:40 +0200
committeremkael <emkael@tlen.pl>2018-04-10 21:19:40 +0200
commit1afbf5f2c2286b00109cbfcfd4d4c661f33fcd27 (patch)
treef5cfe04ac2f4b507bd8890a1e92059d4418a73a7 /bcdd/BCalcWrapper.py
parentaaab3f1022ad97cedf2134c7ef973d28a793af16 (diff)
Cdebase ported to Python
Diffstat (limited to 'bcdd/BCalcWrapper.py')
-rw-r--r--bcdd/BCalcWrapper.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/bcdd/BCalcWrapper.py b/bcdd/BCalcWrapper.py
new file mode 100644
index 0000000..9337809
--- /dev/null
+++ b/bcdd/BCalcWrapper.py
@@ -0,0 +1,32 @@
+'''
+Wrapper class for libbcalcDDS.dll
+'''
+
+from ctypes import cdll
+
+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):
+ return getattr(self.libbcalcdds, 'bcalcDDS_' + attrname)(*args)
+ return _dynamic_method
+
+ def declarerToLeader(self, player):
+ return (player + 1) % 4