added dynamic rule checking

This commit is contained in:
Jake Pullen
2024-06-08 15:59:43 +01:00
parent 5bbda755af
commit 9258b6a750
8 changed files with 46 additions and 36 deletions
+3 -3
View File
@@ -25,11 +25,11 @@ class RuleEngine:
print(f'Added rule: {rule_json}')
def check_rule(self, card, hand):
commands = []
commands = set()
for game_rule in self.rules:
if (game_rule.suit is not None and game_rule.suit == card.suit) or \
(game_rule.value is not None and game_rule.value == card.value) or \
(game_rule.card_count != 99 and game_rule.card_count == len(hand)):
commands.append(game_rule.command)
return ' and '.join(commands) if commands else ''
commands.add(game_rule.command)
return commands