def pokemon_create(): form = PokemonForm(request.form) fastlist = Move.allFastMoves() chargelist = Move.allChargedMoves() form.fastmove.choices = [(f.id, f.name) for f in fastlist] form.chargemove.choices = [(c.id, c.name) for c in chargelist] form.firsttype.choices = [(t.value, t.name) for t in Type] form.secondtype.choices = [(t.value, t.name) for t in Type] if not form.validate(): return render_template("pokemon/new_pokemon.html", form=form) fastmove = request.form.get("fastmove") chargemove = request.form.get("chargemove") fastmove_id = fastmove[0] chargemove_id = chargemove[0] firsttypenum = request.form.get("firsttype") secondtypenum = request.form.get("secondtype") p = Pokemon(request.form.get("name"), int(request.form.get("cp")), int(request.form.get("iv")), fastmove_id, chargemove_id, firsttypenum, secondtypenum) p.account_id = current_user.id db.session().add(p) db.session().commit() return redirect(url_for("index"))
def pokemon_update_form(pokemon_id): pokemon = Pokemon.query.get(pokemon_id) fastlist = Move.allFastMoves() chargelist = Move.allChargedMoves() form = PokemonForm() form.name.data = pokemon.name form.cp.data = pokemon.cp form.iv.data = pokemon.iv form.fastmove.choices = [(f.id, f.name) for f in fastlist] form.fastmove.data = pokemon.fastmove_id form.chargemove.choices = [(c.id, c.name) for c in chargelist] form.chargemove.data = pokemon.chargemove_id form.firsttype.choices = [(t.value, t.name) for t in Type] form.firsttype.data = pokemon.first_type_id form.secondtype.choices = [(t.value, t.name) for t in Type] form.secondtype.data = pokemon.second_type_id return render_template("pokemon/update_pokemon.html", form=form, pokemon=pokemon)
def pokemon_update(pokemon_id): form = PokemonForm(request.form) fastlist = Move.allFastMoves() chargelist = Move.allChargedMoves() form.fastmove.choices = [(f.id, f.name) for f in fastlist] form.chargemove.choices = [(c.id, c.name) for c in chargelist] form.firsttype.choices = [(t.value, t.name) for t in Type] form.secondtype.choices = [(t.value, t.name) for t in Type] if not form.validate(): return render_template("pokemon/update_pokemon.html", form=form) fastmove = request.form.get("fastmove") chargemove = request.form.get("chargemove") fastmove_id = fastmove[0] chargemove_id = chargemove[0] firsttypenum = request.form.get("firsttype") secondtypenum = request.form.get("secondtype") p = Pokemon.query.get(pokemon_id) p.name = request.form.get("name") p.cp = request.form.get("cp") p.iv = request.form.get("iv") p.fastmove_id = fastmove_id p.chargemove_id = chargemove_id p.first_type_id = firsttypenum p.second_type_id = secondtypenum db.session().commit() return redirect(url_for("index"))
def pokemon_form(): fastlist = Move.allFastMoves() chargelist = Move.allChargedMoves() form = PokemonForm() form.fastmove.choices = [(f.id, f.name) for f in fastlist] form.chargemove.choices = [(c.id, c.name) for c in chargelist] form.firsttype.choices = [(t.value, t.name) for t in Type] form.secondtype.choices = [(t.value, t.name) for t in Type] return render_template("pokemon/new_pokemon.html", form=form)
def move_create(): form = MoveForm(request.form) form.firsttype.choices = [(t.value, t.name) for t in Type] if not form.validate(): return render_template("move/new_move.html", form = form) answer = request.form.get("chargemove") if answer is 'y': answer = 1 else: answer = 0 firsttypenum = request.form.get("firsttype") m = Move(request.form.get("name"), int(request.form.get("damage")), answer, int(request.form.get("bars")), firsttypenum) db.session().add(m) db.session().commit() return redirect(url_for("index"))
def charge_move_name(self): movename = Move.getNameById(self.chargemove_id) return movename
def fast_move_name(self): movename = Move.getNameById(self.fastmove_id) return movename