Export decks from Rogue Duel
This commit is contained in:
parent
51e21e10cf
commit
182b6a273b
2 changed files with 19 additions and 1 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -2,6 +2,7 @@ cards_in_draft.txt
|
||||||
oracle_cards.json
|
oracle_cards.json
|
||||||
cube_temp.json
|
cube_temp.json
|
||||||
oracle_cards_clean.json
|
oracle_cards_clean.json
|
||||||
|
decks/
|
||||||
scryfall/
|
scryfall/
|
||||||
|
|
||||||
# Byte-compiled / optimized / DLL files
|
# Byte-compiled / optimized / DLL files
|
||||||
|
|
@ -134,4 +135,3 @@ dmypy.json
|
||||||
# Pyre type checker
|
# Pyre type checker
|
||||||
.pyre/
|
.pyre/
|
||||||
.idea/workspace.xml
|
.idea/workspace.xml
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@
|
||||||
# improving their decks between games.
|
# improving their decks between games.
|
||||||
|
|
||||||
import random
|
import random
|
||||||
|
from collections import Counter
|
||||||
|
from pathlib import Path
|
||||||
from typing import Dict, List
|
from typing import Dict, List
|
||||||
|
|
||||||
import cube_json
|
import cube_json
|
||||||
|
|
@ -34,6 +36,7 @@ def main():
|
||||||
_fill_with_lands(state)
|
_fill_with_lands(state)
|
||||||
print(state.player1.deck)
|
print(state.player1.deck)
|
||||||
print(state.player2.deck)
|
print(state.player2.deck)
|
||||||
|
_export_decks(state)
|
||||||
|
|
||||||
|
|
||||||
def _decide_colors(state: RogueDuelState):
|
def _decide_colors(state: RogueDuelState):
|
||||||
|
|
@ -126,5 +129,20 @@ def _fetch_duals(state: RogueDuelState, colors: List[str]) -> List[cube_pool.Car
|
||||||
return duals
|
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__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue