Skip to content

Commit 4f2f8a7

Browse files
authored
Merge pull request #7 from rainleander/rainleander-patch-1
Update main.py
2 parents f8369b4 + 5bf12bc commit 4f2f8a7

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

main.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1-
import random
1+
# import random
2+
# TODO: replace random with pythonsdk random
23

3-
class Card( object ):
4+
import asyncio
5+
from dataclasses import dataclass
6+
7+
from temporalio import workflow
8+
from temporalio.client import Client
9+
from temporalio.worker import Worker
10+
11+
@dataclass
12+
class Card(object):
413
def __init__(self, name, value, suit, symbol):
514
self.value = value
615
self.suit = suit
@@ -47,7 +56,7 @@ def __init__(self):
4756
symbol = str(values[name])+symbolIcon
4857
else:
4958
symbol = name[0]+symbolIcon
50-
self.cards.append( Card(name, values[name], suit, symbol) )
59+
self.cards.append(Card(name, values[name], suit, symbol))
5160

5261
def __repr__(self):
5362
return "Standard deck of cards:{0} remaining".format(len(self.cards))
@@ -62,13 +71,11 @@ def cardCount(self):
6271
def addCard(self, card):
6372
self.cards.append(card)
6473

65-
6674
class PokerScorer(object):
6775
def __init__(self, cards):
6876
# Number of cards
6977
if not len(cards) == 5:
7078
return "Error: Wrong number of cards"
71-
7279
self.cards = cards
7380

7481
def flush(self):
@@ -81,7 +88,7 @@ def straight(self):
8188
values = [card.value for card in self.cards]
8289
values.sort()
8390

84-
if not len( set(values)) == 5:
91+
if not len(set(values)) == 5:
8592
return False
8693

8794
if values[4] == 14 and values[0] == 2 and values[1] == 3 and values[2] == 4 and values[3] == 5:
@@ -145,10 +152,10 @@ def fullHouse(self):
145152

146153
return False
147154

148-
def Poker():
155+
def Poker(ctx workflow.Context):
149156
player = Player()
150157

151-
# Initial Score
158+
# Initial Amount
152159
points = 100
153160

154161
# Cost per hand
@@ -210,13 +217,13 @@ def Poker():
210217
pairs = score.pairs()
211218

212219
# Royal flush
213-
if straight and flush and straight == 14:
220+
if straight and flush == 14:
214221
print("Royal Flush!!!")
215222
print("+2000")
216223
points += 2000
217224

218225
# Straight flush
219-
elif straight and flush:
226+
elif straight and flush != 14:
220227
print("Straight Flush!")
221228
print("+250")
222229
points += 250

0 commit comments

Comments
 (0)