From c16eb493bb130ad94ece708248235888c9224301 Mon Sep 17 00:00:00 2001
From: MichaƂ Klichowicz <emkael@tlen.pl>
Date: Mon, 2 Oct 2023 22:52:50 +0200
Subject: Lead card import

---
 src/bcdd/PBNBoard.py | 5 +++++
 src/main.py          | 7 ++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

(limited to 'src')

diff --git a/src/bcdd/PBNBoard.py b/src/bcdd/PBNBoard.py
index 6e1abf6..e76252d 100644
--- a/src/bcdd/PBNBoard.py
+++ b/src/bcdd/PBNBoard.py
@@ -166,6 +166,11 @@ class PBNBoard(object):
     def get_auction(self):
         return self.get_extended_raw_field('Auction', with_header=True)
 
+    def get_play_data(self):
+        if self.has_field('Play'):
+            return self.get_extended_raw_field('Play', with_header=False)
+        return None
+
     def get_extended_raw_field(self, field_name, with_header=False):
         field_found = False
         result = []
diff --git a/src/main.py b/src/main.py
index 20b81f6..e90360b 100644
--- a/src/main.py
+++ b/src/main.py
@@ -148,11 +148,16 @@ def get_pbn_score(b):
         contract = contract[0] + ' ' + contract[1:]
         result = int(b.get_field('Result')) - get_digits(contract) - 6
         score = int(b.get_field('Score').replace('NS ', '')) # co z pasami?
+        play_data = b.get_play_data()
+        if play_data:
+            play_data = ' '.join(play_data).split(' ')
+            if play_data:
+                lead = play_data[0].strip()
+                lead = lead[0] + ' ' + lead[1]
     else: # passed-out hand
         contract = contract.upper()
         result = 0
         score = 0
-    lead = '' # wtf?
     return declarer, contract, result, score, lead
 
 
-- 
cgit v1.2.3