def home(): whattype = request.form['type'] if (whattype == 'grass'): poke = "Bulbasaur" img = pokepy.getImage("Bulbasaur") if (whattype == 'fire'): poke = "Charmander" img = pokepy.getImage("Charmander") if (whattype == 'water'): poke = "Squirtle" img = pokepy.getImage("Squirtle") return render_template("pick2.html", pokemon=poke, pokeimg=img)
def inventory(): if 'username' in session: username = session['username'] pokemon = [] print(search.getPokemon(username)) print(pokepy.getImage(13)) for each in search.getPokemon(username): print(each[0]) print(pokepy.getPokemon(each[0])) pokemon.append(pokepy.getImage(pokepy.getPokemon(each[0]))) return render_template('inventory.html', pokeList=pokemon) else: return redirect(url_for('authPage'))
def home(): builder.main() if search.entriesExist() == False: plist = pokepy.getAllPokemon() for poke in plist: update.addimage(poke, pokepy.getRarity(poke), pokepy.getImage(poke)) rand = random.randint(1, 100) if rand <= 75: pokemons = search.getPokeByRarity("Common") poke = random.choice(pokemons) poke = poke[0] image = search.getImageOfPoke(poke) image = image[0][0] return render_template("random.html", pokemon=poke, img=image) elif rand <= 95: pokemons = search.getPokeByRarity("Uncommon") poke = random.choice(pokemons) poke = poke[0] image = search.getImageOfPoke(poke) image = image[0][0] return render_template("random.html", pokemon=poke, img=image) elif rand <= 100: pokemons = search.getPokeByRarity("Rare") poke = random.choice(pokemons) poke = poke[0] image = search.getImageOfPoke(poke) image = image[0][0] return render_template("random.html", pokemon=poke, img=image) '''
def starter(): if 'username' in session: username = session['username'] whattype = request.form['type'] if (whattype == 'grass'): poke = "Bulbasaur" img = pokepy.getImage("Bulbasaur") update.addpokemon(username, 44) if (whattype == 'fire'): poke = "Charmander" img = pokepy.getImage("Charmander") update.addpokemon(username, 46) if (whattype == 'water'): poke = "Squirtle" img = pokepy.getImage("Squirtle") update.addpokemon(username, 63) update.updateavatar(username, poke) return render_template("pick2.html", pokemon=poke, pokeimg=img) else: return redirect(url_for('home'))
def authPage(): ''' Authenticates user signing in. Checks to see if password is correct or not; if correct, logs user in. If not, flashes "incorrect credentials" ''' if 'username' in session: username = session['username'] userNames = [] tasks = search.getTask(username) difficulty = search.getDifficulty(username) category = search.getCategory(username) info = [] for length in range(0, len(tasks)): row = [] row.append((tasks[length])[0]) row.append((difficulty[length])[0]) row.append((category[length])[0]) info.append(row) if search.getAvatar(username) == [('', )]: return redirect(url_for('pick')) #if search.getTask(username)==[]: #return redirect(url_for('pick')) else: gold = search.getGold(username) return render_template('home.html', avatar=pokepy.getImage( search.getAvatar(username)[0][0]), username=username, names=userNames, info=info, gold=gold) else: try: username = request.form['username'] #username password = search.password( username) #password that matches the username if password == None: #if credentials are incorrect flash('Wrong Username or Password!') return redirect(url_for('home')) #redirects elif sha256_crypt.verify( request.form['password'], password[0]): #if password is correct, login session['username'] = username return redirect(url_for('authPage')) else: #else credentials are wrong flash('Wrong Username or Password!') return redirect(url_for('home')) except: return redirect(url_for('home'))
def gacha(): if 'username' in session: username = session['username'] gold = search.getGold(username) if gold >= 100: update.updategold(username, gold, "subtract", 100) if search.entriesExist() == False: plist = pokepy.getAllPokemon() for poke in plist: update.addimage(poke, pokepy.getRarity(poke), pokepy.getImage(poke)) rand = random.randint(1, 100) if rand <= 75: pokemons = search.getPokeByRarity("Common") poke = random.choice(pokemons) poke = poke[0] image = search.getImageOfPoke(poke) image = image[0][0] update.addpokemon(username, pokepy.getID(poke)[6:]) return render_template("random.html", pokemon=poke, img=image) elif rand <= 95: pokemons = search.getPokeByRarity("Uncommon") poke = random.choice(pokemons) poke = poke[0] image = search.getImageOfPoke(poke) image = image[0][0] update.addpokemon(username, pokepy.getID(poke)[6:]) return render_template("random.html", pokemon=poke, img=image) elif rand <= 100: pokemons = search.getPokeByRarity("Rare") poke = random.choice(pokemons) poke = poke[0] image = search.getImageOfPoke(poke) image = image[0][0] update.addpokemon(username, pokepy.getID(poke)[6:]) return render_template("random.html", pokemon=poke, img=image) else: flash("Not enough gold") return redirect(url_for('home')) else: return redirect(url_for('home'))