Skip to content

Commit 175a57b

Browse files
committed
update readme
1 parent d0f11d3 commit 175a57b

6 files changed

Lines changed: 179 additions & 65 deletions

File tree

Makefile

Lines changed: 0 additions & 6 deletions
This file was deleted.

README.md

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
## MTGDPC
2+
3+
Magic the Gathering Deck Price Checker (for JPN Players).
4+
Price check is done by crawling [Wisdom Guild](www.wisdom-guild.net) with BeautifulSoup.
5+
6+
### Requirements
7+
8+
- Python 3.6 (or above)
9+
- Beautiful Soup
10+
- lxml
11+
12+
Simply, `pip install -r requirements.txt` to install above modules.
13+
14+
### How to use
15+
16+
#### 1. Prepare decklist
17+
`.txt` file of decklist must fit the following format:
18+
```
19+
<# of cards> <card name>
20+
...
21+
22+
Sideboard
23+
<# of cards> <card name>
24+
...
25+
```
26+
Note that card name must be in English.
27+
`decklist` directory contains some sample `.txt` files.
28+
29+
#### 2. Execute `mtgdpc.py` with argument of prepared `.txt` file
30+
```
31+
$ python mtgdpc.py <.txt file>
32+
------------------------------ MAIN DECK ------------------------------
33+
34+
<price> x <# of cards> = <price of card(s)> <Card Name(JPN)/(EN)>
35+
...
36+
37+
main ) price: < (A) total price of main deck >
38+
39+
------------------------------ SIDEBOARD ------------------------------
40+
41+
<price> x <# of cards> = <price of card(s)> <Card Name(JPN)/(EN)>
42+
...
43+
44+
side ) price: < (B) total price of sideboard >
45+
46+
total price (main + side): (A) + (B)
47+
```
48+
49+
### Sample Decklist & Output
50+
51+
#### `decklist/gorgari_midrange.txt`
52+
```
53+
7 Swamp
54+
5 Forest
55+
4 Overgrown Tomb
56+
4 Woodland Cemetery
57+
4 Llanowar Elves
58+
4 Pelt Collector
59+
4 Stitcher's Supplier
60+
4 Glowspore Shaman
61+
4 Merfolk Branchwalker
62+
2 Graveyard Marshal
63+
2 Kraul Harpooner
64+
4 Charnel Troll
65+
4 Midnight Reaper
66+
4 Plaguecrafter
67+
4 Gruesome Menagerie
68+
69+
Sideboard
70+
3 Kitesail Freebooter
71+
3 Plague Mare
72+
2 Deathgorge Scavenger
73+
1 Reclamation Sage
74+
3 Necrotic Wound
75+
2 Shapers' Sanctuary
76+
1 Mark of the Vampire
77+
```
78+
79+
#### Output
80+
```
81+
------------------------------ MAIN DECK ------------------------------
82+
83+
8 x 8 = 64 森/Forest
84+
8 x 7 = 56 沼/Swamp
85+
666 x 4 = 2664 草むした墓/Overgrown Tomb
86+
550 x 4 = 2200 森林の墓地/Woodland Cemetery
87+
9 x 4 = 36 ラノワールのエルフ/Llanowar Elves
88+
144 x 4 = 576 マーフォークの枝渡り/Merfolk Branchwalker
89+
50 x 3 = 150 探求者の従者/Seekers' Squire
90+
9 x 2 = 18 野茂み歩き/Wildgrowth Walker
91+
980 x 4 = 3920 翡翠光のレインジャー/Jadelight Ranger
92+
9 x 1 = 9 管区の案内人/District Guide
93+
45 x 3 = 135 貪欲なチュパカブラ/Ravenous Chupacabra
94+
9 x 2 = 18 ゴルガリの拾売人/Golgari Findbroker
95+
1580 x 4 = 6320 破滅を囁くもの/Doom Whisperer
96+
14 x 1 = 14 千の目、アイゾーニ/Izoni, Thousand-Eyed
97+
1280 x 2 = 2560 暗殺者の戦利品/Assassin's Trophy
98+
119 x 2 = 238 採取/Find (さいしゅ) 最終/Finality
99+
880 x 2 = 1760 ゴルガリの女王、ヴラスカ/Vraska, Golgari Queen
100+
1180 x 3 = 3540 秘宝探究者、ヴラスカ/Vraska, Relic Seeker
101+
102+
main ) price: 24278
103+
104+
------------------------------ SIDEBOARD ------------------------------
105+
106+
9 x 1 = 9 野茂み歩き/Wildgrowth Walker
107+
14 x 1 = 14 千の目、アイゾーニ/Izoni, Thousand-Eyed
108+
8 x 3 = 24 強迫/Duress
109+
10 x 3 = 30 渇望の時/Moment of Craving
110+
180 x 1 = 180 アルゲールの断血/Arguel's Blood Fast
111+
1280 x 2 = 2560 ヴラスカの侮辱/Vraska's Contempt
112+
30 x 2 = 60 最古再誕/The Eldest Reborn
113+
119 x 1 = 119 採取/Find (さいしゅ) 最終/Finality
114+
2490 x 1 = 2490 ビビアン・リード/Vivien Reid
115+
116+
side ) price: 5486
117+
118+
total price (main + side): 29764
119+
```

main.py

Lines changed: 0 additions & 59 deletions
This file was deleted.

mtgdpc.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import sys
2+
3+
from search import *
4+
5+
deckname = sys.argv[1]
6+
7+
def main():
8+
with open(deckname, 'r') as rf:
9+
main, side = ''.join(r for r in rf).split('\n\nSideboard\n')
10+
11+
main, side = deck(main), deck(side[:-1])
12+
13+
total = printout(main)
14+
15+
s_total = printout(side, mode = "side")
16+
17+
print("\ntotal price (main + side):", total + s_total)
18+
19+
if __name__ == "__main__":
20+
main()

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
beautifulsoup
2+
lxml

search.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,44 @@
22
import lxml
33
from bs4 import BeautifulSoup
44

5+
class Card():
6+
def __init__(self, string):
7+
lst = string.split(' ')
8+
self.num = lst[0]
9+
self.name = ' '.join(s for s in lst[1:])
10+
11+
def print(self):
12+
print(self.num, self.name)
13+
14+
def deck(string):
15+
deck = string.split('\n')
16+
return [Card(card) for card in deck]
17+
18+
def proc(d):
19+
from multiprocessing import Pool
20+
import multiprocessing as multi
21+
22+
maxproc = multi.cpu_count()
23+
24+
with Pool(processes=maxproc) as p:
25+
lst = p.map(search, d)
26+
27+
return lst
28+
29+
def printout(d, mode = "main"):
30+
lst = proc(d)
31+
l = ''.join('-' for _ in range(30))
32+
print(f"\n{l} MAIN DECK {l}\n") if mode == "main" else print(f"\n{l} SIDEBOARD {l}\n")
33+
total = 0
34+
for card, d in zip(d, lst):
35+
price = int(d['price'].replace(',',''))
36+
num = int(card.num)
37+
total += price * num
38+
print(f"{price} x {num} = {price*num}".ljust(20), end=' ')
39+
print(d['name'])
40+
string = 'main' if mode == 'main' else 'side'
41+
print(f"\n{string} ) price:", total)
42+
return total
543
def replacetags(string):
644
string = string.replace('カード名', '')
745
string = string.replace('マナコスト', '')

0 commit comments

Comments
 (0)