summaryrefslogtreecommitdiff
path: root/dealconvert/formats/rzd.py
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2019-05-23 01:12:47 +0200
committeremkael <emkael@tlen.pl>2019-05-23 01:12:47 +0200
commit0e6fa8cb43d147ce6437c920eab1b76337c34ade (patch)
treee06ec5384c03ea0d6653546ddaf3bd66ce6a77d6 /dealconvert/formats/rzd.py
parent3980223e145e2664fbe0e4b199a2172154dec76e (diff)
CDS format based on RZD
Diffstat (limited to 'dealconvert/formats/rzd.py')
-rw-r--r--dealconvert/formats/rzd.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/dealconvert/formats/rzd.py b/dealconvert/formats/rzd.py
index d400eae..d6cbc5e 100644
--- a/dealconvert/formats/rzd.py
+++ b/dealconvert/formats/rzd.py
@@ -10,12 +10,12 @@ class RZDFormat(DealFormat):
def suffix(self):
return '.rzd'
- def parse_deal(self, data):
+ def parse_deal(self, data, offset=0):
deal = dto.Deal()
for card, byte in enumerate(data):
byte = ord(byte)
for suit in range(3, -1, -1):
- deal.hands[byte%4][suit].append(self.cards[card])
+ deal.hands[(byte%4 - offset)%4][suit].append(self.cards[card])
byte /= 4
return deal.hands
@@ -42,7 +42,7 @@ class RZDFormat(DealFormat):
number += 1
return dealset
- def dump_deal(self, deal):
+ def dump_deal(self, deal, offset=0):
value = ''
values = [None] * 52
for i, hand in enumerate(deal.hands):
@@ -53,7 +53,7 @@ class RZDFormat(DealFormat):
except ValueError:
print 'ERROR: invalid card: %s' % (card)
sys.exit()
- values[idx*4+suit] = i
+ values[idx*4+suit] = (i + offset)%4
for i in range(0, 13):
byte = 0
for j in range(0, 4):