Example #1
0
def say(*args):
    inputlist = parse.checkArgs(args,"Say what?","","say")
    
    if inputlist:
        name = find.nameFromID(["player"],"people")
        print(name[0],"says \""+parse.liToStr(inputlist)+"\"")
        action.say(inputlist,find.plLoc())
Example #2
0
def take(*args):
    inputlist = parse.checkArgs(args, "Take what?", "", "take")

    if inputlist:
        charid = "player"
        itemid = parse.removeDuplicates(find.idFromName(inputlist, "item"))

        while len(itemid) > 1:
            itemid = ask.which(itemid, "item")

        if len(itemid) != 0 and itemid[0] == "altar":
            print("\"That is way too heavy to carry, let alone move.\"")

        elif itemid:
            slot = find.invSlotByItemID(None)

            if g.debug:
                print("[DBG] take TO SLOT:", slot)

            if slot != 0:
                db.cur.execute(
                    "update item set locid = \"INV\" where itemid = \"" +
                    itemid[0] + "\";")
                db.cur.execute("update inventory set item" + str(slot) +
                               " = \"" + itemid[0] + "\" where charid = \"" +
                               charid + "\";")
                print(find.nameFromID(itemid, "item")[0] + " taken.")
                action.take(itemid[0])
            else:
                print("Your inventory is full.")
        else:
            print(parse.liToStr(inputlist) + " is not here.")
Example #3
0
def topics(charid):
    db.cur.execute("select topic from dialogue where charid = \"" + charid[0] +
                   "\";")
    result = parse.noneStrip(parse.multiTupleListToList(db.cur.fetchall()))

    if g.debug:
        print("[DBG] get.topics:", charid, result)

    #print("DEBUG TOPICS:",result)

    #if "Greet" in result:
    #    i = result.index("Greet")
    #    del result[i]
    #print("DEBUG TOPICS2:",result)

    if len(result) > 0:
        print("You can talk to " +
              parse.liToStr(find.nameFromID(charid, "people")) + " about " +
              parse.naturalList(result, "and") + ".")
Example #4
0
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\";")
Example #5
0
def drop(*args):
    inputlist = parse.checkArgs(args, "Drop what?", "", "drop")

    if inputlist:
        charid = "player"
        itemid = parse.removeDuplicates(
            find.idFromName(inputlist, "item", ["player"]))

        while len(itemid) > 1:
            itemid = ask.which(itemid, "item", ["player"])

        if itemid:
            if len(itemid) != 0:
                slot = find.invSlotByItemID(itemid)
                loc = find.plLoc()
                db.cur.execute("update inventory set item" + str(slot) +
                               " = NULL where charid = \"" + charid + "\";")
                db.cur.execute("update item set locid = \"" + loc +
                               "\" where itemid = \"" + itemid[0] + "\";")
                print(find.nameFromID(itemid, "item")[0] + " dropped.")
            else:
                print("You do not have " + " ".join(inputlist) + ".")
        else:
            print("You do not have " + parse.liToStr(inputlist) + ".")
Example #6
0
def rent(*args):
    if find.plLoc() in g.rentlocs:
        inputlist = parse.checkArgs(args, "Rent what?", "", "rent")

        if g.debug:
            print("[DBG] rent INPUTLIST:", inputlist)

        if inputlist:
            count = 0
            seller = [g.rentppl[g.rentlocs.index(find.plLoc())]]

            if g.debug:
                print("[DBG] rent ARGS:", seller, find.plLoc())

            if find.plLoc() == "grinn1":
                if inputlist[0] == "room":
                    if action.checkTopic("kolrule") and item.valTrans(
                            100, ["player"], ["grinnkee"], " to rent a room"
                    ):  # Player has spoken to Kolbiorn and has enough money.
                        db.cur.execute(
                            "update people set val = val - 100 where charid = \"player\";"
                        )
                        db.cur.execute(
                            "update people set val = val + 100 where charid = \""
                            + seller[0] + "\";")

                        action.rent("", seller[0], True)
                        count += 1
                else:
                    if count < 1:  # Not an elegant solution but it works. (When found many items.)
                        print("There is no", parse.liToStr(inputlist),
                              "to rent here.")
                    count += 1

            elif seller[0] == "grportma":
                if action.getVis("grbay"):  # Player knows about ship.
                    itemid = parse.removeDuplicates(
                        find.idFromName(inputlist, "item", seller, False))

                    if g.debug:
                        print("[DBG] rent SELLER HAS:", itemid)

                    while len(itemid) > 1:
                        itemid = ask.which(itemid, "item", seller)

                    if g.debug:
                        print("[DBG] rent BUYING:", itemid)

                    if len(itemid) == 1:
                        fromSlot = find.invSlotByItemID(itemid, seller)

                        if fromSlot != 0:  # Found item in inventory.
                            val = find.listValueByID(itemid, "item")[0]
                            string = " to rent " + find.nameFromID(
                                itemid, "item")[0]

                            if item.valTrans(
                                    val, ["player"], seller,
                                    string):  # Player has enough money.
                                item.transfer(itemid, ["player"], seller,
                                              "rent", val)
                                action.rent(itemid[0], seller[0])
                                count += 1
                else:
                    if count < 1:  # Not an elegant solution but it works. (When found many items.)
                        print(
                            "\"What would I need that for?\" you think to yourself."
                        )
                    count += 1

                    if g.debug:
                        print("[DBG] rent BAY VIS:", action.getVis("grbay"))
        else:
            if count < 1:  # Not an elegant solution but it works. (When found many items.)
                print("There is no", parse.liToStr(inputlist), "to rent here.")
            count += 1
    else:
        print("There's nothing to rent here.")
Example #7
0
def say(inputlist, loc):
    if loc == "grfornw":
        words = ["mother", "father", "master", "leader", "chief"]
        if inputlist[0] in words:
            if g.wolvesGuided == "0":
                print(
                    "\nYou say the words \"" + parse.liToStr(inputlist) +
                    "\". The ears of both wolves perk up and they freeze. They slowly walk towards you and the other one lets out a slight howl. They brush your knees as they walk past you towards the edge of the crater. You turn around and see the wolves staring at you, waiting.\n"
                )
                db.cur.execute(
                    "update save set val = 1 where var = \"wolvesGuided\";")
                g.update()
                db.cur.execute(
                    "update people set locid = \"gredgecr\" where name = \"Tribal Wolf\";"
                )
                setVis("grlair1", 1)

    if inputlist[0] == "cheat":
        if len(inputlist) > 1:
            if inputlist[1] == "loadsamoney":
                print("MONEY MONEY MONEY")
                db.cur.execute(
                    "update people set val = val + 1000000 where charid = \"player\";"
                )
                #g.cheatsUsed += 1

    if inputlist[0] == "dev":
        #if inputlist[0] == "eval":
        #    eval(input("EVAL: "))

        #if inputlist[0] == "exec":
        #    exec(input("EXEC: "))

        if inputlist[1] == "debug":
            g.toggleDebug()
            print("[DEV] Debug messages toggled.")

        if inputlist[1] == "win":
            gameOver.End("immortality")

        if inputlist[1] == "tele":
            db.cur.execute("select locid from location;")
            ids = parse.multiTupleListToList(db.cur.fetchall())

            if inputlist[2] in ids:
                print("WOOPWOOPWOOP")
                db.cur.execute("update people set locid = \"" + inputlist[2] +
                               "\" where charid = \"player\";")
                cmd.look()
                #g.cheatsUsed += 1
            else:
                print("[DEV] locid \"" + inputlist[2] + "\" not found.")

        if inputlist[1] == "get":
            print("GET OVER HERE")
            empty = find.invSlotByItemID(None)

            db.cur.execute("select itemid from item;")
            ids = parse.multiTupleListToList(db.cur.fetchall())

            if inputlist[2] in ids:
                if empty != 0:
                    db.cur.execute("update inventory set item" + str(empty) +
                                   " = \"" + inputlist[2] + "\";")
                    #g.cheatsUsed += 1
                else:
                    print("[DEV] INVENTORY FULL")
            else:
                print("[DEV] itemid \"" + inputlist[2] + "\" not found.")

        if inputlist[1] == "vis":
            print("ICANSEEDEADPEOPLE")
            db.cur.execute("update location set vis = 1;")
            print("[DEV] All locations visible.")