Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import random
# import random
# TODO: replace random with pythonsdk random

class Card( object ):
import asyncio
from dataclasses import dataclass

from temporalio import workflow
from temporalio.client import Client
from temporalio.worker import Worker

@dataclass
class Card(object):
def __init__(self, name, value, suit, symbol):
self.value = value
self.suit = suit
Expand Down Expand Up @@ -47,7 +56,7 @@ def __init__(self):
symbol = str(values[name])+symbolIcon
else:
symbol = name[0]+symbolIcon
self.cards.append( Card(name, values[name], suit, symbol) )
self.cards.append(Card(name, values[name], suit, symbol))

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


class PokerScorer(object):
def __init__(self, cards):
# Number of cards
if not len(cards) == 5:
return "Error: Wrong number of cards"

self.cards = cards

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

if not len( set(values)) == 5:
if not len(set(values)) == 5:
return False

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

return False

def Poker():
def Poker(ctx workflow.Context):
player = Player()

# Initial Score
# Initial Amount
points = 100

# Cost per hand
Expand Down Expand Up @@ -210,13 +217,13 @@ def Poker():
pairs = score.pairs()

# Royal flush
if straight and flush and straight == 14:
if straight and flush == 14:
print("Royal Flush!!!")
print("+2000")
points += 2000

# Straight flush
elif straight and flush:
elif straight and flush != 14:
print("Straight Flush!")
print("+250")
points += 250
Expand Down