Skip to content

Commit

Permalink
Update layout.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmaister committed Mar 2, 2020
1 parent b24b889 commit c9b70c8
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 69 deletions.
47 changes: 32 additions & 15 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,42 +52,59 @@ group by type

# TODO:

## Ravager Wurm

/name/ fights target creature you don't control. • Destroy target land with an activated ability that isn't a mana ability.

## Escape

Pharika's Spawn
Escape—{5}{B}, Exile three other cards from your graveyard. (You may cast this card from your graveyard for its escape cost.)

## Jump start
## Jump start (10)

Jump-start (You may cast this card from your graveyard by discarding a card in addition to paying its other costs. Then exile this card.)

## Create copy
## Create copy (24)

Quasiduplicate
Create a token that's a copy of target creature you control.


## Counters
## Counters (85)

+1/+1 counter
with an additional +1/+1 counter on it
/name/ escapes with a +1/+1 counter on it.
Woe Strider escapes with two +1/+1 counters on it.


## Adamant
## Adamant (17)

Adamant - if at least...

## Sacrifice
## Sacrifice (168)

sacrifice /name/

## Fight
## Fight (20)

Polukranos, Unchained
{1}{B}{G}: /name/ fights another target creature.

## Counter spell (25)

Counter target spell

## Destroy (105)

Destroy target tapped creature
Destroy target permanent an opponent controls
Destroy target creature
Destroy target artifact
Destroy target land

# Exile (190)

Exile target card from a graveyard

## Pay more mana (76)

"pays" or "pay"

Quench
unless its controller pays {2}

Archon of Absolution
unless their controller pays {1} for
40 changes: 22 additions & 18 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,45 +32,49 @@ def main():

return render_template('index.html', stats=stats)

@app.route("/search", methods = ['GET', 'POST'])
@app.route("/search", methods = ['GET'])
def get_search():
conn = database.get_db(g)

import json
searchstr = json.dumps(request.form)
searchstr = json.dumps(request.args)
app.logger.info("Search [%s]", searchstr)
app.logger.info("Search2 [%s]", request)

database.save_history(request, conn, "SEARCH", searchstr)

sql = """SELECT * FROM cards AS c, cardlabels AS cl
WHERE c.uuid = cl.uuid """
params = []

if request.method == 'POST':
if 'cardname' in request.form and request.form['cardname'] != "":
if request.method == 'GET':
if 'cardname' in request.args and request.args['cardname'] != "":
sql += "AND lower(c.name) like lower(?) "
params.append('%' + request.form['cardname'] + '%')
if 'text' in request.form and request.form['text'] != "":
params.append('%' + request.args['cardname'] + '%')
if 'text' in request.args and request.args['text'] != "":
sql += "AND lower(c.text) like lower(?) "
params.append('%' + request.form['text'] + '%')
if 'trigger' in request.form and request.form['trigger'] != "":
params.append('%' + request.args['text'] + '%')
if 'trigger' in request.args:
triggers = request.args.getlist("trigger")
app.logger.info("trigger [%s]", triggers)
for tr in triggers:
sql += "AND lower(cl.labels) like lower(?) "
params.append('%' + tr + '%')
if 'effect' in request.args and request.args['effect'] != "":
sql += "AND lower(cl.labels) like lower(?) "
params.append('%' + request.form['trigger'] + '%')
if 'effect' in request.form and request.form['effect'] != "":
sql += "AND lower(cl.labels) like lower(?) "
params.append('%' + request.form['effect'] + '%')
params.append('%' + request.args['effect'] + '%')

if 'colormode' in request.form:
colormode = request.form['colormode']
if 'colormode' in request.args:
colormode = request.args['colormode']
colors = ['R', 'U', 'G', 'W', 'B']
if colormode == 'any':
anyfilter = False
sql += "AND ( "
if "color_NULL" in request.form:
if "color_C" in request.args:
sql += "( c.colors IS NULL ) OR "
anyfilter = True
for c in colors:
if 'color_' + c in request.form:
if 'color_' + c in request.args:
sql += "(c.colors like '%" +c+ "%') OR "
anyfilter = True

Expand All @@ -83,11 +87,11 @@ def get_search():
elif colormode == 'all':
anyfilter = False
sql += "AND ( "
if "color_NULL" in request.form:
if "color_C" in request.args:
sql += "( c.colors IS NULL ) AND "
anyfilter = True
for c in colors:
if 'color_' + c in request.form:
if 'color_' + c in request.args:
sql += "(c.colors like '%" +c+ "%') AND "
anyfilter = True

Expand Down
18 changes: 18 additions & 0 deletions static/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ body {
height: 15px;
width: 15px;
}
.search_icon {
height: 25px;
width: 25px;
vertical-align: bottom;
}

.cardname {
font-weight: bold;
Expand Down Expand Up @@ -88,4 +93,17 @@ body {

.beta {
color: red;
}

.scroll {
height: 350px;
overflow-y: auto;
border: 1px solid black;
padding: 5px;
padding-left: 10px;
}

.card_tag_box {
width: 80%;
margin: 0 auto;
}
93 changes: 57 additions & 36 deletions templates/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,65 @@

{% block content %}
<h2>Search</h2>
<form class="pure-form" method="POST" action="/search" >
<div>Format: <b>Standard (More are coming...)</b></div>
<div>Name (partial): <input name="cardname" placeholder="Card name" value="{{ request.form['cardname'] }}" /> </div>
<div>Text (partial): <input name="text" placeholder="Card text" value="{{ request.form['text'] }}" /> </div>
<div>Card trigger:
<select name="trigger">
<option value="" {% if request.form['trigger'] == '' %} selected="selected"{% endif %}> - empty -</option>
{% for tr in data.triggers|sort %}
<option value="{{tr}}" {% if request.form['trigger'] == tr %} selected="selected"{% endif %}>{{tr}}</option>
{% endfor %}
</select>
</div>
<div>Card effect:
<select name="effect">
<option value="" {% if request.form['effect'] == '' %} selected="selected"{% endif %}> - empty -</option>
{% for tr in data.effects|sort %}
<option value="{{tr}}" {% if request.form['effect'] == tr %} selected="selected"{% endif %}>{{tr}}</option>
{% endfor %}
</select>
</div>
<div>
<h3>Color</h3>
<form class="pure-form pure-form-stacked" method="GET" action="/search" >
<fieldset>
<label for="format">Format</label>
<input id="format" name="format" disabled value="Standard (More are coming...)" />

<label for="cardname">Name (partial)</label>
<input id="cardname" name="cardname" placeholder="Card name" value="{{ request.args['cardname'] }}" />

<label for="text">Text (partial)</label>
<input id="text" name="text" placeholder="Card text" value="{{ request.args['text'] }}" />

<div class="pure-g card_tag_box">
<div class="pure-u-1-1 pure-u-md-1-2">
<h3>Card triggers</h3>
<div class="scroll">
{% for tr in data.triggers|sort %}
<label for="id_tr_{{tr}}">
<input id="id_tr_{{tr}}" type="checkbox" name="trigger" value="{{tr}}" {% if tr in request.args.getlist('trigger') %} checked="true"{% endif %}>{{tr}}</option>
</label>
{% endfor %}
</div>
</div>
<div class="pure-u-1-1 pure-u-md-1-2">
<h3>Card effects</h3>
<div class="scroll">
{% for tr in data.effects|sort %}
<label for="id_ef_{{tr}}" class="pure-checkbox">
<input id="id_ef_{{tr}}" type="checkbox" name="effect" value="{{tr}}" {% if tr in request.args.getlist('effect') %} checked="true"{% endif %}>{{tr}}</option>
</label>
{% endfor %}
</div>
</div>
</div>

<div>
<select name="colormode">
<option value="any" {% if request.form['label'] == 'any' %} selected="selected"{% endif %}>Any of these colors</option>
<option value="all" {% if request.form['label'] == 'all' %} selected="selected"{% endif %}>All of these colors</option>
</select>
<h3>Color</h3>
<div>
<select name="colormode">
<option value="all" {% if request.args['colormode'] == 'all' %} selected="selected"{% endif %}>All of these colors</option>
<option value="any" {% if request.args['colormode'] == 'any' %} selected="selected"{% endif %}>Any of these colors</option>
</select>
</div>

{% set colors = ['R', 'U', 'G', 'W', 'B', 'C'] %}
<div class="pure-g">
{% for c in colors %}
<div class="pure-u-1-1 pure-u-sm-1-6">
<label for="id_color_{{c}}">
<input type="checkbox" id="id_color_{{c}}" name="color_{{c}}" {% if request.args['color_'+c] == 'on' %} checked {% endif %} />
<img class="search_icon" src="/img/{{c}}.svg" >
</label>
</div>
{% endfor %}
</div>
</div>
<div>Red: <input type="checkbox" name="color_R" {% if request.form['color_R'] == 'on' %} checked {% endif %}/></div>
<div>Blue: <input type="checkbox" name="color_U" {% if request.form['color_U'] == 'on' %} checked {% endif %}/></div>
<div>Green: <input type="checkbox" name="color_G" {% if request.form['color_G'] == 'on' %} checked {% endif %}/></div>
<div>White: <input type="checkbox" name="color_W" {% if request.form['color_W'] == 'on' %} checked {% endif %}/></div>
<div>Black: <input type="checkbox" name="color_B" {% if request.form['color_B'] == 'on' %} checked {% endif %}/></div>
<div>Uncolored: <input type="checkbox" name="color_NULL" {% if request.form['color_NULL'] == 'on' %} checked {% endif %}/></div>
</div>
<p>
<button class="pure-button pure-button-primary" type="submit">Search</button>
</p>
<p>
<button class="pure-button pure-button-primary" type="submit">Search</button>
</p>
</fieldset>
</form>

<h3>{{rows|length}} Results:</h3>
Expand Down

0 comments on commit c9b70c8

Please sign in to comment.