Esempio n. 1
0
 def __init__(self, tamagotchi):
     self.poke = pokemon.ListPokemon()
     self.tamagotchi = tamagotchi
     self.happy = []
     self.hunger = []
     self.health = []
     self.status = ObjetoStatus()
Esempio n. 2
0
def index():
    sessao = Session()
    user = sessao.get_logged_user()
    if user:
        poke = pokemon.ListPokemon()

        return render_template('tamagotchi.html', titulo="Tamagotchi", pokemons=poke.sale())
    else:
        return redirect(url_for('.login'))
Esempio n. 3
0
    def engine(self):
        if self.findstatus('Morto'):
            return

        health = 0.1
        hunger = 0.1
        happy = 0.1

        delta = (datetime.now() - self.tamagotchi.last_update).total_seconds()

        # Atualiza taxa de decaimento dos status
        if self.findstatus('Triste'):
            happy = 0.5

        if self.findstatus('Doente'):
            health = 0.5

        if self.findstatus('Faminto'):
            hunger = 0.5

        # Evolução
        pokelist = pokemon.ListPokemon()
        poke = pokelist.loadDatabasebyName(self.tamagotchi.name_pokemon,
                                           self.tamagotchi.user_id)
        poke = poke[0].pokemon

        if poke.evolucao and (datetime.now() -
                              poke.selected).total_seconds() > 60 * 30:
            pokelist.saveDatabase(poke.evolucao, self.tamagotchi.user_id)
            self.tamagotchi.name_pokemon = poke.evolucao

        # atualiza barras
        self.health.append(-1 * delta * health)
        self.happy.append(-1 * delta * happy)
        self.hunger.append(-1 * delta * hunger)

        # atualuza status
        if self.tamagotchi.health <= 0 or self.tamagotchi.hunger <= 0 or self.tamagotchi.happy <= 0:
            self.setstatus('Morto')

        if self.tamagotchi.health < 50:
            self.setstatus('Doente')
        else:
            self.unsetstatus('Doente')

        if self.tamagotchi.hunger < 50:
            self.setstatus('Faminto')
        else:
            self.unsetstatus('Faminto')

        if self.tamagotchi.happy < 50:
            self.setstatus('Triste')
            self.setstatus('Doente')
        else:
            self.unsetstatus('Doente')
            self.unsetstatus('Triste')
Esempio n. 4
0
def buy():
    PRICE = float(request.form['price'])
    IMAGEM = str(request.form['poke'])

    poke = pokemon.ListPokemon()

    user = usuario.ListUsuario().get_logged_user()

    if user.money > PRICE:
        poke.buy(PRICE, IMAGEM, user.id)
    else:
        flash("Voce so tem $ " + str(user.money) + " falta $ " + str(PRICE - user.money) + ".")
    return redirect(url_for('.index'))
Esempio n. 5
0
        def cadastro(self, username, password, imagem):
            s = sessionmaker(bind=engine)()
            user = User(username=username, password=password, imagem=imagem)
            s.add(user)
            s.commit()

            pokemons = pokemon.ListPokemon()

            pokemons.saveDatabase('Bulbasaur', user.id)
            pokemons.saveDatabase('Charmander', user.id)
            pokemons.saveDatabase('Squirtle', user.id)

            self.set_usuario(user)
            return True
Esempio n. 6
0
 def get_my_pokemons(self):
     poke = pokemon.ListPokemon()
     user = self.get_logged_user()
     if user:
         return poke.loadDatabase(user.id)
     return []