def newtool(): global ct if request.method=='GET': return rediect('/') if event_number>=15: return redirect('/final') global dif dif=0 if request.form['choice']=='Run away': if act.values()[0][1]>ct.values()[0][1]:#If the user runs away and their speed is lower than the event's, they lose the difference between the event's speed and their speed, times 10 global ch dif=(act.values()[0][1]-ct.values()[0][1])*10 ch-=dif elif request.form['choice']=='Use tool': if act.values()[0][2]==-1:#If the event has no scavenging (is a fight), and the user uses tool, redirects to route "/fight" global itemUsed itemUsed=False return redirect("/fight") else:#If the event has scavenging (is a store) redirects user to /store route if act.values()[0][2]<=ct.values()[0][2]: return redirect('/store') elif request.form['choice']=='Use potion': return redirect("/inv") if ch<=0: return render_template('lose.html') tool=[] for i in range(3):#Selects 3 new random tools tool.append(util.tool().keys()[0]) tool.append(ct.keys()[0]) ct=util.get(ct.keys()[0]) return render_template('main.html',story='Pick a new tool',tools=tool,ct=ct.keys()[0],att=ct.values()[0][0],spd=ct.values()[0][1],scav=ct.values()[0][2],health=ch,enmHealth=(act.values()[0][3])*10,action="You lost %s health"%dif)
def fight(): global ct global itemUsed if itemUsed==False: if act.values()[0][0]>ct.values()[0][0]: global ch dif=(act.values()[0][0]-ct.values()[0][0])*10 ch-=dif else: ch-=2.5 enmDif=0 enmDif=(ct.values()[0][0]-act.values()[0][0])+0.5 if enmDif<0.5: enmDif=0.5 act.values()[0][3]-=enmDif if ch<=0: return render_template('lose.html') elif act.values()[0][3]>0: ct=util.get(ct.keys()[0]) return render_template('main.html',story=act.keys()[0],instruction='Use your tool or flee',ct=ct.keys()[0],att=ct.values()[0][0],spd=ct.values()[0][1],scav=ct.values()[0][2],opt='yes',health=ch,enmHealth=(act.values()[0][3])*10,photo=act.values()[0][4]) else: tool=[] for i in range(3):#Selects 3 new random tools tool.append(util.tool().keys()[0]) global event_number event_number+=1 if event_number>=10: return redirect('/final') tool.append(ct.keys()[0]) ct=util.get(ct.keys()[0]) return render_template('main.html',story='Pick a new tool',tools=tool,ct=ct.keys()[0],att=ct.values()[0][0],spd=ct.values()[0][1],scav=ct.values()[0][2],health=ch,action="You win!",enmHealth=0.0)
def root(): global event_number event_number=0 global ch ch=100.0 #Sets health to 100 tool=[] for i in range(3): tool.append(util.tool().keys()[0])#Makes a list of 3 random tools return render_template('main.html',story='Dave the superstar sloth has to save the princess in a forest.',instruction='What tool do you pick up?',tools=tool, health=util.get_health(ch),enmHealth=0.0)