Пример #1
0
def wildPokeID2Name(pID):
    con = db.mySqlCon()
    cursor = con.cursor()
    query = "select pName from wild_pokemon where pID like "+str(pID)
    cursor.execute(query)
    result = cursor.fetchone()
    return result[0]
Пример #2
0
def trainerPokeID2Name(pID):
    con = db.mySqlCon()
    cursor = con.cursor()
    query = "select personalName from wild_pokemon_caught_by_trainers where trainers_tID like "+str(settings.trainerID)+" and pokemonID like "+str(pID)
    cursor.execute(query)
    result = cursor.fetchone()
    return result[0]
Пример #3
0
def trainerItemID2Name(iID):
    con = db.mySqlCon()
    cursor = con.cursor()
    query = "select items_itemID from trainers_has_items where itemNum like "+str(iID)
    cursor.execute(query)
    result = cursor.fetchone()
    return itemID2Name(result[0])
Пример #4
0
def itemID2Name(iID):
    con = db.mySqlCon()
    cursor = con.cursor()
    query = "select itemName from items where itemID like "+str(iID)
    cursor.execute(query)
    result = cursor.fetchone()
    return result[0]
Пример #5
0
def tID2Name(tID):
    con = db.mySqlCon()
    cursor = con.cursor()
    query = "select townName from towns where townID like "+str(tID)
    cursor.execute(query)
    result = cursor.fetchone()
    cursor.close()
    con.close()
    return result[0]
Пример #6
0
def travel(tID):
    listTowns()
    ans = input("Please enter the number for the location you'd like to travel to: ")
    print(ans)
    con = db.mySqlCon()
    cursor = con.cursor()
    query = "UPDATE `pokemon`.`trainers` SET `towns_townID`='"+str(ans)+"' WHERE `tID`='"+str(tID)+"';"
    cursor.execute(query)
    con.commit()
    return
Пример #7
0
def listLocation(tID):
    con = db.mySqlCon()
    cursor = con.cursor()
    query = "select towns_townID from trainers where tID like "+str(tID)
    cursor.execute(query)
    result = cursor.fetchone()
    print ("Current location: ", tID2Name(result[0]))
    cursor.close()
    con.close()
    return result[0]
Пример #8
0
def addItem2Inventory(itemID):
    inventorySize = db.returnItemCount(settings.trainerID)
    con = db.mySqlCon()
    cursor = con.cursor()
    query = "INSERT INTO `pokemon`.`trainers_has_items` (`itemNum`, `tID`, `items_itemID`) VALUES ('"+str(inventorySize+1)+"',"+str(settings.trainerID)+", '"+str(itemID)+"');"
    cursor.execute(query)
    con.commit()
    cursor.close()
    con.close()
    return
Пример #9
0
def listTowns():
    con = db.mySqlCon()
    cursor = con.cursor()
    cursor.execute("SELECT townName from towns")
    result = cursor.fetchall()
    print("Towns you can travel to: ")
    i=0
    for city in result:
        print("\t"+str(i)+": "+city[0])
        i=i+1
    return result
Пример #10
0
def returnPokesItem(pID):
    query = "select trainers_itemNum from wild_pokemon_caught_by_trainers where trainers_tID like "+str(settings.trainerID)+" and pokemonID like "+str(pID)
    con = db.mySqlCon()
    cursor = con.cursor()
    cursor.execute(query)
    results = cursor.fetchone()
    cursor.close()
    con.close()
    if results[0] == "None":
        return "No item"
    item = trainerItemID2Name(results[0])
    return item
Пример #11
0
def listLocalPokemon(tID):
    location = listLocation(tID)
    query = "SELECT wild_pokemon_pID from wild_pokemon_found_in_towns where towns_townID like "+str(location)
    con = db.mySqlCon()
    cursor = con.cursor()
    cursor.execute(query)
    result = cursor.fetchall()
    cursor.close()
    con.close()
    print("Pokemon that can be found here: ")
    for poke in result:
        print("\t"+wildPokeID2Name(poke[0]))
    return result
Пример #12
0
def giveItemToPoke():
    selection = pokeDetails()
    listInventory()
    item = input("Please select an item you'd like to give to "+trainerPokeID2Name(selection)+": ")
    print(trainerItemID2Name(item))
    query = "UPDATE wild_pokemon_caught_by_trainers SET `trainers_itemNum`='"+str(item)+"' WHERE `pokemonID`='"+str(selection)+"' and`trainers_tID`='"+str(settings.trainerID)+"';"
    con = db.mySqlCon()
    cursor = con.cursor()
    cursor.execute(query)
    con.commit()
    cursor.close()
    con.close()

    return
Пример #13
0
def listInventory():
    con = db.mySqlCon()
    cursor = con.cursor()
    query = "select items_itemID from trainers_has_items where tID like "+str(settings.trainerID)
    cursor.execute(query)
    results = cursor.fetchall()
    if len(results) < 1:
        print("Your inventory is empty!")
    else:
        print("Inventory: ")
        i = 1
        for item in results:
            print("\t"+str(i)+") "+ itemID2Name(item[0]))
            i=i+1

    return 0
Пример #14
0
def trainerCatchesPokemon(pID, name):
    con = db.mySqlCon()
    cursor = con.cursor()
    if random.randrange(10) < 5:
        gender = "M"
    else:
        gender = "F"
    count = db.returnTrainerCatchCount(settings.trainerID)
    print("current count: "+str(count))
    query = "INSERT INTO `wild_pokemon_caught_by_trainers` (`pokemonID`, `wild_pokemon_pID`, `trainers_tID`, `pGender`, `pLevel`, `personalName`, `pokeHP`, `pokeHPMAX`) VALUES ("+str(count)+","+str(pID)+","+str(settings.trainerID)+", '"+gender+"', 1, '"+name+"',100,100)"
    cursor.execute(query)
    con.commit()
    cursor.close()
    con.close()
    db.incrementTrainerCatchCount(settings.trainerID)
    return
Пример #15
0
def pokeDetails():
    listCaughtPokemon(settings.trainerID)
    selection = input("Select a pokemon to display its detailed information: ")
    con = db.mySqlCon()
    cursor = con.cursor()
    query = "select * from wild_pokemon_caught_by_trainers where pokemonID like "+str(selection)+" and trainers_tID like "+str(settings.trainerID)
    cursor.execute(query)
    results = cursor.fetchone()
    cursor.close()
    con.close()
    print("Pokemon, NickName, Level, current HP, MAX HP, item")
    if str(results[8]) == "None":
        print(str(wildPokeID2Name(results[1]))+", "+str(results[5])+", "+str(results[4])+", "+str(results[6])+", "+str(results[7]) + ", "+"none")
    else:
        print(str(wildPokeID2Name(results[1]))+", "+str(results[5])+", "+str(results[4])+", "+str(results[6])+", "+str(results[7]) + ", "+str(trainerItemID2Name(results[8])))
    return selection
Пример #16
0
def listCaughtPokemon(tID):
    con = db.mySqlCon()
    cursor = con.cursor()
    query = "select pokemonID from wild_pokemon_caught_by_trainers where trainers_tID like "+str(tID)
    cursor.execute(query)
    result = cursor.fetchall()
    if len(result) < 1:
        print("You have not caught any pokemon!")
    else:
        print("here is all your pokemans: ")
        i = 1
        for poke in result:
            print("\t"+str(i)+") "+trainerPokeID2Name(poke[0]))
            i=i+1

    cursor.close()
    con.close()
    return