Export decks from Rogue Duel

This commit is contained in:
henriquenakashima 2021-02-22 23:37:25 -05:00
parent 51e21e10cf
commit 182b6a273b
2 changed files with 19 additions and 1 deletions

2
.gitignore vendored
View file

@ -2,6 +2,7 @@ cards_in_draft.txt
oracle_cards.json
cube_temp.json
oracle_cards_clean.json
decks/
scryfall/
# Byte-compiled / optimized / DLL files
@ -134,4 +135,3 @@ dmypy.json
# Pyre type checker
.pyre/
.idea/workspace.xml

View file

@ -2,6 +2,8 @@
# improving their decks between games.
import random
from collections import Counter
from pathlib import Path
from typing import Dict, List
import cube_json
@ -34,6 +36,7 @@ def main():
_fill_with_lands(state)
print(state.player1.deck)
print(state.player2.deck)
_export_decks(state)
def _decide_colors(state: RogueDuelState):
@ -126,5 +129,20 @@ def _fetch_duals(state: RogueDuelState, colors: List[str]) -> List[cube_pool.Car
return duals
def _export_decks(state: RogueDuelState):
decks_path = Path('decks')
decks_path.mkdir(exist_ok=True)
for i, player_state in enumerate(state.player_states):
filepath = decks_path / f'player{i + 1}_deck.txt'
_export_deck(player_state.deck, filepath)
def _export_deck(deck: List[cube_pool.Card], filepath: Path):
deck_counter = Counter([card.name for card in deck])
with open(filepath, 'w') as f:
for card_name, quantity in deck_counter.most_common():
f.write(f'{quantity} {card_name}\n')
if __name__ == '__main__':
main()