Browse Source

Interp update

master
Josh Gordon 3 years ago
parent
commit
2851ef2960
  1. 32
      app/routes.py
  2. 14
      app/templates/interp.html

32
app/routes.py

@ -27,7 +27,7 @@ app = Flask(__name__)
def index():
featureType = choice(["Item","Place","Spell"])
item = choice(get_items("../"+featureType+"s/*"))
links = [("marches","West Marches"),("dungeon","Dungeon Generator"),("about","About")]
links = [("marches","West Marches"),("dungeon","Dungeon Generator"),("about","About"),("interp","Interp")]
return render_template('index.html',featureType=featureType,featureText=item,links=links,new=get_new_items())
@ -199,5 +199,35 @@ def campaign_info():
def design_philosophy():
return render_template('design.html')
@app.route("/interp")
def interp():
roll = 0
cost = 0
return render_template('interp.html',cost=cost,roll=roll)
@app.route("/interproll",methods=["POST"])
def interproll():
lower = 0
upper = 0
r = request.form['type']
if(r == "common"):
lower = 50
upper = 100
elif(r == "uncommon"):
lower = 101
upper = 500
elif(r == "rare"):
lower = 501
upper = 5000
elif(r == "very rare"):
lower = 5001
upper = 50000
elif(r == "legendary"):
lower = 50001
upper = 100000
roll = choice(range(1,100))
price = lower*(1-0.01*roll) + upper*(0.01*roll)
return render_template('interp.html',price=price,roll=roll)
if __name__ == "__main__":
app.run()

14
app/templates/interp.html

@ -0,0 +1,14 @@
{% extends "base.html" %}
{% block content %}
<form action="/interproll" method="post">
<select name="type">
<option value="common">Common</option>
<option value="uncommon">Uncommon</option>
<option value="rare">Rare</option>
<option value="very rare">Very Rare</option>
<option value="legendary">Legendary</option>
</select>
<input type="submit" value="roll!">
</form>
<p>Your roll was {{roll}} and the price is {{price}}!</p>
{% endblock %}
Loading…
Cancel
Save