Get correct duals in Rogue Duel
This commit is contained in:
parent
6b91cbb1b9
commit
fd201b7fa7
3 changed files with 21 additions and 4 deletions
|
|
@ -14,6 +14,7 @@ import cubecobra_csv
|
||||||
class Card:
|
class Card:
|
||||||
name: str
|
name: str
|
||||||
color_category: str
|
color_category: str
|
||||||
|
colors: List[str]
|
||||||
tags: List[str]
|
tags: List[str]
|
||||||
|
|
||||||
def __post_init__(self):
|
def __post_init__(self):
|
||||||
|
|
@ -54,6 +55,9 @@ class CubePool:
|
||||||
self.remove_cards([card_taken], color_category)
|
self.remove_cards([card_taken], color_category)
|
||||||
return card_taken
|
return card_taken
|
||||||
|
|
||||||
|
def get_category(self, color_category: str) -> List[Card]:
|
||||||
|
return self._categories[color_category]
|
||||||
|
|
||||||
|
|
||||||
def load_pools(csv_path: str, pool_tags: Set[str]) -> Dict[str, CubePool]:
|
def load_pools(csv_path: str, pool_tags: Set[str]) -> Dict[str, CubePool]:
|
||||||
pools = defaultdict(CubePool)
|
pools = defaultdict(CubePool)
|
||||||
|
|
@ -75,7 +79,9 @@ def load_pools(csv_path: str, pool_tags: Set[str]) -> Dict[str, CubePool]:
|
||||||
(pool_tag,) = pool_tags_for_card
|
(pool_tag,) = pool_tags_for_card
|
||||||
color_category = cubecobra_csv.get_color_category(line)
|
color_category = cubecobra_csv.get_color_category(line)
|
||||||
# print(f'{card_name} {color_category}')
|
# print(f'{card_name} {color_category}')
|
||||||
card = Card(card_name, color_category, tags)
|
colors = cubecobra_csv.get_colors(line)
|
||||||
|
print(f'{card_name} {colors}')
|
||||||
|
card = Card(card_name, color_category, colors, tags)
|
||||||
pools[pool_tag].add_card(card)
|
pools[pool_tag].add_card(card)
|
||||||
return pools
|
return pools
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,3 +64,9 @@ def get_color_category(line: List) -> str:
|
||||||
color_category = line[COLUMNS['Color Category']]
|
color_category = line[COLUMNS['Color Category']]
|
||||||
assert color_category in _COLOR_CATEGORIES, f'color_category "{color_category}" unknown'
|
assert color_category in _COLOR_CATEGORIES, f'color_category "{color_category}" unknown'
|
||||||
return _COLOR_CATEGORIES[color_category]
|
return _COLOR_CATEGORIES[color_category]
|
||||||
|
|
||||||
|
|
||||||
|
def get_colors(line: List) -> str:
|
||||||
|
colors = line[COLUMNS['Color']]
|
||||||
|
#assert color_category in _COLOR_CATEGORIES, f'color_category "{color_category}" unknown'
|
||||||
|
return sorted(colors.lower())
|
||||||
|
|
|
||||||
|
|
@ -105,18 +105,23 @@ def _fill_with_lands(state: RogueDuelState):
|
||||||
player_state.deck.append(rainbow_land)
|
player_state.deck.append(rainbow_land)
|
||||||
# Add two duals
|
# Add two duals
|
||||||
duals = _fetch_duals(state, player_state.colors)
|
duals = _fetch_duals(state, player_state.colors)
|
||||||
#assert len(duals) == 2, f'Found duals {duals} for colors {player_state.colors}'
|
assert len(duals) == 2, f'Found duals {duals} for colors {player_state.colors}'
|
||||||
player_state.deck.extend(duals)
|
player_state.deck.extend(duals)
|
||||||
|
|
||||||
|
|
||||||
def _basic_for_color(color: str) -> str:
|
def _basic_for_color(color: str) -> str:
|
||||||
name = {'w': 'Plains', 'u': 'Island', 'b': 'Swamp', 'r': 'Mountain', 'g': 'Forest'}[color]
|
name = {'w': 'Plains', 'u': 'Island', 'b': 'Swamp', 'r': 'Mountain', 'g': 'Forest'}[color]
|
||||||
return cube_pool.Card(name, '0', color)
|
return cube_pool.Card(name, '0', color, [])
|
||||||
|
|
||||||
|
|
||||||
def _fetch_duals(state: RogueDuelState, colors: List[str]) -> List[str]:
|
def _fetch_duals(state: RogueDuelState, colors: List[str]) -> List[cube_pool.Card]:
|
||||||
|
colors = sorted(colors)
|
||||||
duals = []
|
duals = []
|
||||||
# Get duals
|
# Get duals
|
||||||
|
core_lands: List[cube_pool.Card] = state.pools['core'].get_category('l')
|
||||||
|
for land in core_lands:
|
||||||
|
if land.colors == colors:
|
||||||
|
duals.append(land)
|
||||||
state.pools['core'].remove_cards(duals, 'l')
|
state.pools['core'].remove_cards(duals, 'l')
|
||||||
return duals
|
return duals
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue