Skip to content

Commit

Permalink
Add rules for counters +1/+1
Browse files Browse the repository at this point in the history
  • Loading branch information
jmaister committed Mar 28, 2020
1 parent 15caf23 commit 91a9b89
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
13 changes: 13 additions & 0 deletions TODO.md
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ Polukranos, Unchained
## Counter spell (25)

Counter target spell
Counter that spell

## Destroy (105)

Expand Down Expand Up @@ -142,6 +143,18 @@ Add one mana of any color

create a token that's a copy of /name/ .

## Block

That creature can't be blocked this turn.

## Adventure (6)

Whenever you cast a creature spell that has an Adventure

## Mentor (13)

Mentor (Whenever this creature attacks, put a +1/+1 counter on target attacking creature with lesser power.)


# SEO

Expand Down
4 changes: 4 additions & 0 deletions env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

source magicsearch/bin/activate

30 changes: 28 additions & 2 deletions rules.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ def create_pattern(str):

{"label": "RIOT,A", "pattern": create_pattern("riot")},
{"label": "RIOT,B", "pattern": create_pattern("( this creature enter the battlefield with Lyour choice of a +1/+1 counter or haste . )")},
{"label": "RIOT,C", "pattern": create_pattern("( Lthey enter the battlefield with Lyour choice of a +1/+1 counter or haste . )")},

{"label": "FLYING,A", "pattern": create_pattern("Lflying ( this creature can not be block except by creature with fly or reach . )")},
{"label": "FLYING,Z", "pattern": [{"LOWER": "flying"}]},
Expand Down Expand Up @@ -310,7 +311,28 @@ def create_pattern(str):

{"label": "ON_SACRIFICE_PERMANENT,A", "pattern": create_pattern("whenever Lyou sacrifice another permanent")},


{"label": "COUNTER_PUT,A", "pattern": create_pattern("put ? +1/+1 counter on each creature Lyou control")},
{"label": "COUNTER_PUT,B1", "pattern": create_pattern("put ? +1/+1 counter on target ? Lyou control")},
{"label": "COUNTER_PUT,B2", "pattern": create_pattern("put ? +1/+1 counter on target creature")},
{"label": "COUNTER_PUT,B3", "pattern": create_pattern("put a +1/+1 counter on up to N target creature Lyou control")},
{"label": "COUNTER_PUT,B4", "pattern": create_pattern("put a +1/+1 counter on each of those creature")},
{"label": "COUNTER_PUT,C1", "pattern": create_pattern("put ? +1/+1 counter on each of up to N target creature")},
{"label": "COUNTER_PUT,C2", "pattern": create_pattern("put N +1/+1 counter on up to one target creature")},
{"label": "COUNTER_PUT,D1", "pattern": create_pattern("/name/ enter the battlefield with ? +1/+1 counter on Lit")},
{"label": "COUNTER_PUT,D2", "pattern": create_pattern("/name/ enter the battlefield with a number of +1/+1 counter on Lit")},
{"label": "COUNTER_PUT,D3", "pattern": create_pattern("enter the battlefield with an additional +1/+1 counter on Lit")},
{"label": "COUNTER_PUT,D4", "pattern": create_pattern("enter with an additional +1/+1 counter on Lit")},
{"label": "COUNTER_PUT,E", "pattern": create_pattern("put ? +1/+1 counter on Lit")},
{"label": "COUNTER_PUT,F", "pattern": create_pattern("put ? +1/+1 counter on /name/")},
{"label": "COUNTER_PUT,H", "pattern": create_pattern("put that many +1/+1 counter on /name/")},
{"label": "COUNTER_PUT,I", "pattern": create_pattern("distribute ? +1/+1 counter among ? ? ? ? ? ? target creature")},
{"label": "COUNTER_PUT,J", "pattern": create_pattern("double the number of +1/+1 counter on each of those creature")},
{"label": "COUNTER_PUT,K1", "pattern": create_pattern("put ? +1/+1 counter on target land Lyou control")},
{"label": "COUNTER_PUT,K2", "pattern": create_pattern("put ? +1/+1 counter on up to one target noncreature land Lyou control")},
{"label": "COUNTER_PUT,L", "pattern": create_pattern("move ? +1/+1 counter from /name/ onto target creature")},


{"label": "COUNTER_REMOVE,A", "pattern": create_pattern("remove that many +1/+1 counter from /name/")},

]

Expand Down Expand Up @@ -404,12 +426,15 @@ def clean_label(label):
def clean_text(text, name):
if text is not None:
text = text.replace(name, '/name/')
text = text.replace("/name/.", "/name/ .")
# Fix names that contain comma and can be reference as both
# i.e. "Roalesk, Apex Hybrid"
if name.find(",") > 0:
shortname = name[0:name.find(",")]
text = text.replace(shortname, '/name/')

# Fix name at the end of phrase
text = text.replace("/name/.", "/name/ .")

# Remove dash
text = text.replace('—', ' - ')

Expand Down Expand Up @@ -465,6 +490,7 @@ def get_card_analysis(nlp, card, forDisplay):
t = ""
if card['text'] is not None:
t = clean_text(card['text'], name)

doc = nlp(t)

# print([(ent.text, ent.label_) for ent in doc.ents])
Expand Down
1 change: 1 addition & 0 deletions templates/index.html
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ <h3 class="title is-3">Stats</h3>
<h2 class="title is-2">Changelog</h2>

<div>
<p>2020-03-28 Recognized 49.8% of total text. Counters +1/+1.</p>
<p>2020-03-27 Recognized 47.6% of total text. Show card type and card set.</p>
<p>2020-03-01 Recognized 45.2% of total text.</p>
<p>2020-02-28 Recognized 38.8% of total text.</p>
Expand Down

0 comments on commit 91a9b89

Please sign in to comment.