Skip to content

Commit f7e7c99

Browse files
committed
Fix shop
1 parent 3f84050 commit f7e7c99

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

shop.py

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# The shop contains:
32
# 5 Colored cards:
43
# - 2 Attack cards, 2 skill cards, and 1 Power card
@@ -31,7 +30,7 @@
3130
from definitions import CardCategory, Rarity
3231
from helper import Displayer, get_attribute
3332
from items import cards, potions, relics
34-
from message_bus_tools import Relic, Potion
33+
from message_bus_tools import Relic, Potion, Card
3534

3635

3736
# Helper functions for displaying cards, potions, and relics.
@@ -141,20 +140,20 @@ def __init__(self, player, items=None):
141140
def initialize_items(self) -> list[SellableItem]:
142141
# TODO: Make this class-specific and include relics and potions
143142
items = []
144-
all_cards = list(cards)
145-
attack_cards = [c for c in all_cards if c["Type"] == "Attack" and c["Class"] != "Colorless"]
146-
skill_cards = [c for c in all_cards if c["Type"] == "Skill" and c["Class"] != "Colorless"]
147-
power_cards = [c for c in all_cards if c["Type"] == "Power" and c["Class"] != "Colorless"]
143+
all_cards:list[Card] = list(cards)
144+
attack_cards = [c for c in all_cards if c.type == "Attack" and c.player_class != "Colorless"]
145+
skill_cards = [c for c in all_cards if c.type == "Skill" and c.player_class != "Colorless"]
146+
power_cards = [c for c in all_cards if c.type == "Power" and c.player_class != "Colorless"]
148147
if len(attack_cards) >= 2:
149148
items.extend(random.sample(attack_cards, 2))
150149
if len(skill_cards) >= 2:
151150
items.extend(random.sample(skill_cards, 2))
152151
if len(power_cards) >= 1:
153152
items.extend(random.sample(power_cards, 1))
154153

155-
colorless_cards = [c for c in all_cards if "Class" in c and c["Class"] == "Colorless"]
156-
colorless_uncommon = [c for c in colorless_cards if c["Rarity"] == Rarity.UNCOMMON]
157-
colorless_rare = [c for c in colorless_cards if c["Rarity"] == Rarity.RARE]
154+
colorless_cards = [c for c in all_cards if c.player_class == "Colorless"]
155+
colorless_uncommon = [c for c in colorless_cards if c.rarity == Rarity.UNCOMMON]
156+
colorless_rare = [c for c in colorless_cards if c.rarity == Rarity.RARE]
158157
if len(colorless_uncommon) >= 1:
159158
items.extend(random.sample(colorless_uncommon, 1))
160159
if len(colorless_rare) >= 1:

tests/test_shop.py

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ class TestSellableItems():
1111
def test_cards(self):
1212
'''See that we can make sellable items out of all cards and that they display correctly'''
1313
all_sellable_cards = list(items.cards)
14-
# all_sellable_cards = [card for card in all_sellable_cards if card["Type"] in ("Attack", "Skill", "Power") and card["Rarity"] not in ("Special")]
1514
for card in all_sellable_cards:
1615
sellable = SellableItem(card)
1716
ansiprint(sellable.valid_string())

0 commit comments

Comments
 (0)