def restart(): print("Recreate database from scratch and restart the game? (Y/N)") if ask.yn( ): # The yes/no check is done in a function that returns True for a positive answer and False for a negative answer. initialize.Database() initialize.Data() cmd.quitgame(True)
def askPlayerName(): # Ask the player character's name. invalid = True # Go into the loop. while invalid: plname = [] # Reset old player name. plname = parse.sanitize(str(input("Character Name: ")),True) newname = parse.liToStr(plname) # Concatenate list into a single string with item separated by space. if len(newname) == 0: # Nothing was input, use default. plname = "Andrea Álvarez" print("Do you wish to be called "+str(plname)+"? (Y/N)") if ask.yn(): # The yes/no check is done in a function that returns True for a positive answer and False for a negative answer. invalid = False elif len(newname) > 64: print("Name must be under 64 characters.") else: print("Do you wish to be called "+str(newname)+"? (Y/N)") if ask.yn(): # The yes/no check is done in a function that returns True for a positive answer and False for a negative answer. invalid = False db.cur.execute("update people set name = \""+str(newname)+"\" where charid = \"player\";")
def save(*args): if len(args) == 0: print("Would you like to save your game? (Y/N)") if ask.yn(): db.cur.execute( "update save set val = 1 where var = \"gameSaved\";") g.update() db.db.commit() print("\nGame saved.") else: print("Game not saved.") else: # Force save print("\nGame saved.") db.cur.execute("update save set val = 1 where var = \"gameSaved\";") g.update() db.db.commit()
def quitgame(*args): if len(args) == 0: print("Save before quitting? (Y/N)") if ask.yn(): # The yes/no check is done in a function that returns True for a positive answer and False for a negative answer. cmd.save(True) else: db.db.rollback() print("Game not saved.") else: # Force quit and do not save if quitgame was called with any arguments. db.db.rollback() print("Game not saved.") print("\nQuitting game.") g.killLoop() db.db.close()
def talk(charid, dlgid): if g.debug: print("[DBG] action.talk:", charid, dlgid) if charid == "spgorka": if dlgid == "gorhelp": if ask.yn(): if "budagger" in find.listInvItemIDs(): print(get.dlg("gorhhold")) if ask.yn(): print(get.dlg("gorhh2")) print(get.text("gordagg")) topicSwitch("gorhelp") if g.spletterDropped == "0": db.cur.execute( "update save set val = 1 where var = \"spletterDropped\";" ) g.update() db.cur.execute("update item set locid = \"" + find.plLoc() + "\" where itemid = \"zlatlett\";") else: print(get.dlg("gorhh3")) print(get.text("gordagg")) topicSwitch("gorhelp") if g.spletterDropped == "0": db.cur.execute( "update save set val = 1 where var = \"spletterDropped\";" ) g.update() db.cur.execute("update item set locid = \"" + find.plLoc() + "\" where itemid = \"zlatlett\";") else: print(get.dlg("gornodag")) else: print(get.dlg("gorsigh")) if dlgid == "gorlet2": db.cur.execute( "update people set val = val + 4125 where charid = \"player\";" ) topicSwitch("gorlet2") topicSwitch("gorgreet", "gorgre2", "Greet") setVis("buairpor", 1) if dlgid == "gordone": if ask.yn(): print(get.dlg("gormore")) else: gameOver.End("artifacts") if charid == "bugeorgi": if dlgid == "georgi1": # Traveling if item.valTrans(10, ["player"], ["bugeorgi"], " to take the cab"): db.cur.execute( "update people set locid = \"bueleusa\" where charid = \"player\";" ) db.cur.execute( "update people set locid = \"bueleusa\" where charid = \"bugeorgi\";" ) topicSwitch("georgi1", "georgi2", "Airport") cmd.look() if dlgid == "georgi2": if item.valTrans(10, ["player"], ["bugeorgi"], " to take the cab"): db.cur.execute( "update people set locid = \"buairpor\" where charid = \"player\";" ) db.cur.execute( "update people set locid = \"buairpor\" where charid = \"bugeorgi\";" ) topicSwitch("georgi2", "georgi1", "Eleusa Monastery") cmd.look() if charid == "bumonica": if dlgid == "monica2": setVis("inairpor", 1) if charid == "timonk2": if dlgid == "monk2": setVis("timonyar", 1) if charid == "tizlatin": if dlgid == "zlagem": if ask.yn(): print(get.dlg("zlamyth")) else: print(get.dlg("zlanmyth")) item.transfer(["vikbok2"], ["player"], ["tizlatin"], "give") topicSwitch("zlagem", "zlapet", "Fjörsteinn") if dlgid == "zlapet": setVis("taairpor", 1) setVis("taport", 1) if charid == "taneema": if dlgid == "neema": db.cur.execute( "update people set locid = \"taarusha\" where charid = \"player\";" ) db.cur.execute( "update people set locid = \"taarusha\" where charid = \"taneema\";" ) topicSwitch("neema", "neema1", "Airport") cmd.look() if dlgid == "neema1": db.cur.execute( "update people set locid = \"taoutair\" where charid = \"player\";" ) db.cur.execute( "update people set locid = \"taoutair\" where charid = \"taneema\";" ) topicSwitch("neema1", "neema", "Lake Natron") cmd.look() if charid == "tachief": if dlgid == "chief2": item.transfer(["pet"], ["player"], ["tachief"], "give") topicSwitch("chief2") db.cur.execute( "update save set val = 1 where var = \"backToIndia\";") g.update() if charid == "grjens": if dlgid == "jensword": if ask.yn(): if item.valTrans(1200, ["player"], ["grjens"], " to buy the sword"): item.transfer(["kolbswor"], ["player"], ["grjens"], "buy", 1200) print(get.dlg("jensty")) topicSwitch("jensword") if g.Chapters == "1": print( "\n ---- Chapter VII: Call of the Inca ----\n" ) # Oh my goodness I didn't even realize the pun when I came up with this title. else: print(get.dlg("jensalt")) if g.Chapters == "1": print( "\n ---- Chapter VI: Necklace of a Shaman ----\n" ) if charid == "grsailor": if dlgid == "grsail2": # Traveling if item.valTrans(70, ["player"], ["grsailor"], " to sail"): db.cur.execute( "update people set locid = \"grbay\" where charid = \"player\";" ) db.cur.execute( "update people set locid = \"grbay\" where charid = \"grsailor\";" ) topicSwitch("grsail2", "grsail3", "Back to Port") cmd.look() print(get.text("shiphere")) if dlgid == "grsail3": db.cur.execute( "update people set locid = \"grport\" where charid = \"player\";" ) db.cur.execute( "update people set locid = \"grport\" where charid = \"grsailor\";" ) topicSwitch("grsail3", "grsail2", "Melville Bay") cmd.look() if charid == "grkolbio": if dlgid == "kolrule": # Tell about stolen sword. db.cur.execute( "update people set locid = NULL where charid = \"grlone\";") topicSwitch("", "innlone", "Lone Patron") if dlgid == "kolexch": # Player asks about stuff. db.cur.execute( "update people set locid = NULL where charid = \"grkolbio\";") topicSwitch("kolexch") setVis("peport", 1) if charid == "grinnkee": if dlgid == "innlone": # Tell about Jens. topicSwitch("", "innroom1", "Room") if charid == "pecook": if dlgid == "deusexma": # LET THERE BE TREASURE! topicSwitch("deusexma") setVis("pecave2", 1) # Why would you pick it up?
def give(itemid, charid): if g.debug: print("[DBG] action.give:", itemid, charid) if itemid == "budagger": if charid == "spgorka": print(get.dlg("gornotme")) item.transfer(["budagger"], ["player"], ["spgorka"], "give") if itemid == "zlatlett": if charid == "spgorka": print(get.dlg("gorsupr")) topicSwitch("gorhelp", "gorlet2", "Letter") if g.spletterRead == "0": print(get.dlg("gorwoah")) print(get.text("letter")) db.cur.execute( "update save set val = 1 where var = \"spletterRead\";") g.update() setVis("grport", 1) if itemid == "martenit": if charid == "bumonica": print(get.dlg("moniretu")) topicSwitch("monica3") topicSwitch("mongreet", "monica2", "Zlatin Panayotov") if itemid == "fishnet": if charid == "tifisher": print(get.dlg("tifithan")) topicSwitch("fisher1") setVis("tipumqu1", 1) if itemid == "pet": if charid == "tizlatin": print(get.dlg("zlapet2")) topicSwitch("zlapet") item.transfer(["fjorstei"], ["player"], ["tizlatin"], "give") if itemid == "kolbswor": if charid == "grkolbio": print(get.dlg("kolthank")) topicSwitch("kolrule", "kolexch", "Hrosskell") if itemid == "mead": if charid == "grlone": print(get.dlg("lonesea1")) print(get.dlg("lonep1")) print(get.dlg("lonemor1")) if itemid == "mead2": if charid == "grlone": print(get.dlg("lonesea2")) print(get.dlg("lonep2")) print(get.dlg("lonemor2")) if itemid == "mead3": if charid == "grlone": print(get.dlg("lonesea3")) print(get.dlg("lonep3")) topicSwitch("", "grsail2", "Melville Bay") setVis("grbay", 1) if g.debug: print("[DBG] GRBAY VIS:", getVis("grbay")) if itemid == "linskin": if charid == "grvolur": item.transfer(["necklace"], ["player"], ["grvolur"], "give") topicSwitch("volneck") if itemid == "necklace": if charid == "grjens": if "kolbswor" in find.listInvItemIDs(["grjens"]): print(get.dlg("jensgive")) item.transfer(["kolbswor"], ["player"], ["grjens"], "give") topicSwitch("jensword") if g.Chapters == "1": print( "\n ---- Chapter VII: Call of the Inca ----\n" ) if itemid == "divesuit": if charid == "grportma": print(get.dlg("grmawork")) db.cur.execute( "update people set val = val - 500 where charid = \"grportma\";" ) db.cur.execute( "update people set val = val + 500 where charid = \"player\";") if itemid == "fjorstei": if charid == "spgorka": print(get.dlg("gorfjo")) if ask.yn(): print(get.dlg("gormore")) topicSwitch("", "gordone", "Artifacts") else: print( "\n ---- Chapter IX: Fame & Glory ----\n" ) gameOver.End("artifacts") if itemid == "guthjorr": if charid == "spgorka": print(get.dlg("gorgut")) if ask.yn(): print(get.dlg("gormore")) topicSwitch("", "gordone", "Artifacts") else: print( "\n ---- Chapter IX: Fame & Glory ----\n" ) gameOver.End("artifacts") if itemid == "viksword": if charid == "spgorka": print(get.dlg("gorrep")) if ask.yn(): print(get.dlg("gormore")) topicSwitch("", "gordone", "Artifacts") else: print( "\n ---- Chapter IX: Fame & Glory ----\n" ) gameOver.End("artifacts") if itemid == "necklace": if charid == "spgorka": print(get.dlg("gornec")) if ask.yn(): print(get.dlg("gormore")) topicSwitch("", "gordone", "Artifacts") else: print( "\n ---- Chapter IX: Fame & Glory ----\n" ) gameOver.End("artifacts")