예제 #1
0
def shoot(*args):
    if "revolver" in find.listInvItemIDs() and "bullets" in find.listInvItemIDs():
        
        objectid = parse.checkArgs(args,"Shoot what?","","shoot")
    
        if objectid:   
            person = find.idFromName(objectid,"people")
                
            while len(person) > 1:
                print(person)
                person = ask.which(person,"people")
            
            if len(person) != 0 and person[0] in g.immortals:
                print("You shot "+find.nameFromID(person, "people")[0]+".")
                action.shoot(person[0])
            elif person:
                if g.debug:
                    print("[DBG] shoot KILL",person)
                
                db.cur.execute("update people set hp = 0 where charid = \""+person[0]+"\";")
                name = find.nameFromID(person, "people")
                print("You shot",name[0], "dead!")
                death.death(person)
                action.shoot(person[0])
                
            else:
                print("Stop shooting like a maniac.")
            
    elif "revolver" and not "bullets" in find.listInvItemIDs():
        print("You don't have any bullets.")
    elif "bullets" and not "revolver" in find.listInvItemIDs():
        print("You don't have your revolver.")
    else:
        print("You cannot shoot without a loaded revolver.")
예제 #2
0
def which(idlist,listType="",charid=[]):
    """When a query returned more than one result and you need to ask which one to use. Returns a list with a single item.
        
        idlist    List: List of IDs.
        listType  String: Type of IDs. Valid values: item/people/location/topic
        charid    List: charid of character whose inventory/topic to search if listType is item or topic."""
    
    if g.debug:
        print("[DBG] ask.which:",idlist,listType,charid)
    
    valid = False
    
    names = find.nameFromID(idlist,listType)
    
    while not valid:
        if g.debug:
            print("[DBG] ask.which NAMES",names)
        
        if len(names) > 1 and len(set(names)) == 1:    # Two things listed, they have the same name -> same type, use the first one.
            if g.debug:
                print("[DBG] ask.which FOUND ONLY ONE UNIQUE IN:",names)
            
            plinput = idlist[:1]
            valid = True
        
        elif len(charid) == 0 and not valid:
            print("Did you mean "+parse.naturalList(names, "or")+"? (empty to cancel)")
            plinput = find.idFromName(parse.sanitize(str(input("> "))),listType)
            
            if g.debug:
                print("[DBG] ask.which PLINPUT:",plinput)
            
            if len(plinput) == 1 or len(plinput) == 0:
                valid = True
            else:
                names = find.nameFromID(plinput,listType)
        
        elif len(charid) > 0 and not valid:
                print("Did you mean "+parse.naturalList(names, "or")+"? (empty to cancel)")
                plinput = find.idFromName(parse.sanitize(str(input("> "))),listType,charid)

                if g.debug:
                    print("[DBG] ask.which PLINPUT:",plinput)
                
                if len(plinput) == 1 or len(plinput) == 0:
                    valid = True
                else:
                    names = find.nameFromID(plinput,listType)
        else:
            sysmsg.show("argerror")
    
    if g.debug:
        print("[DBG] ask.which RETURNS:",plinput)
    
    return plinput
예제 #3
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.")
예제 #4
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())
예제 #5
0
def storeItems(locid):
    """String -> Print"""

    seller = g.buyppl[g.buylocs.index(locid)]
    itemidlist = find.listInvItemIDs([seller])
    itemnamelist = find.nameFromID(itemidlist, "item")
    itemvallist = find.listValueByID(itemidlist, "item")

    if len(seller) == 0:
        print("The store keeper is not here!")
    else:
        print("The storekeeper is " + find.nameFromID([seller], "people")[0] +
              " and has " + str(find.listValueByID([seller], "people")[0]) +
              " money. They sell the following items:")
        for i in range(0, len(itemidlist)):
            print("- " + itemnamelist[i] + " (" + str(itemvallist[i]) + ")")
예제 #6
0
def talk(*args):
    inputlist, i = parse.checkArgs(args, "Talk to who about what?", "about",
                                   "to", "talk")
    valid = True

    if inputlist:
        charid = parse.removeDuplicates(
            find.idFromName(inputlist[:i], "people"))

        while len(charid) > 1:
            charid = ask.which(charid, "people")

        if len(charid) == 0:
            print("That person is not here.")
            valid = False
        elif valid:
            dialogid = parse.removeDuplicates(
                find.idFromName(inputlist[i + 1:], "topic", charid, False))

            while len(dialogid) > 1:
                dialogid = ask.which(dialogid, "topic", charid)

            if len(dialogid) == 0:
                print(
                    find.nameFromID(charid, "people")[0] +
                    " doesn't seem to know anything about that.")
                valid = False
            elif valid:
                print(get.dlg(dialogid[0]))
                action.talk(charid[0], dialogid[0])
예제 #7
0
def greet(charid):
    db.cur.execute(
        "select txt from dialogue where topic = \"Greet\" and charid = \"" +
        charid + "\";")

    try:
        result = parse.tupleListToList(db.cur.fetchall())
        print(result[0])
    except IndexError:
        print(find.nameFromID([charid], "people")[0] + " ignores you.")

    if charid == "grdead":
        if g.grkolbOut == "0":
            db.cur.execute(
                "update save set val = 1 where var = \"grkolbOut\";")
            g.update()
            db.cur.execute(
                "update people set locid = \"grship\" where charid = \"grkolbio\";"
            )
            topicSwitch("grdedgre")

    if charid == "pewayna":
        if checkTopic("waygreet"):
            print(get.dlg("waymyth"))
            topicSwitch("waygreet", "waygre2", "Greet")
            setVis("pevillag", 1)
예제 #8
0
def transfer(itemid, toid, fromid=["player"], action="give", val=""):
    toSlot = find.invSlotByItemID(None, toid)

    if toSlot < 11:
        fromSlot = find.invSlotByItemID(itemid, fromid)

        db.cur.execute("update inventory set item" + str(toSlot) + " = \"" +
                       itemid[0] + "\" where charid = \"" + toid[0] + "\";")
        db.cur.execute("update inventory set item" + str(fromSlot) +
                       " = NULL where charid = \"" + fromid[0] + "\";")
    else:
        print("That character's inventory is full.")

    if action == "give":
        print(
            find.nameFromID(itemid, "item")[0] + " given to " +
            find.nameFromID(toid, "people")[0] + ".")
    elif action == "buy":
        print(
            find.nameFromID(itemid, "item")[0] + " bought from " +
            find.nameFromID(fromid, "people")[0] + " for " + str(val) + ".")
    elif action == "rent":
        print(
            find.nameFromID(itemid, "item")[0] + " rented from " +
            find.nameFromID(fromid, "people")[0] + " for " + str(val) + ".")
    else:
        sysmsg.show("noaction")
예제 #9
0
def inventory(*args):
    itemlistIDs = find.listInvItemIDs()
    itemnamelist = find.nameFromID(itemlistIDs,"item")
    db.cur.execute("select val from people where charid = \"player\";")
    val = db.cur.fetchall()[0][0]
    
    print("You have",val,"money and you are carrying:")
    for i in itemnamelist:
        if i != None:
            print("-", i)
    if g.debug:
        print("[DBG] inventory FULL:",itemlistIDs)
    print()
예제 #10
0
def call(*args):
    if find.plLoc() in g.callLocs:
        inputlist = parse.checkArgs(args,"Call who?","","call")
    
        if inputlist:
            charid = parse.removeDuplicates(find.idFromName(inputlist,"people",[],False))
            
            while len(charid) > 1:
                charid = ask.which(charid,"people")
            
            if g.debug:
                print("[DBG] call CHARID:",charid)
            
            if charid:
                if charid[0] in g.callPeople:
                    print("Calling "+find.nameFromID(charid,"people")[0]+".")
                    action.call(charid[0])
                else:
                    print("You can't call "+find.nameFromID(charid,"people")[0]+".")
            else:
                print("You can't call that person.")
    else:
        print("There is no phone here.")
예제 #11
0
def attack(*args):
    objectid = parse.checkArgs(args,"Who do you want to attack?","","attack")
    
    if objectid:
        person = find.idFromName(objectid,"people")
            
        while len(person) > 1:
            print(person)
            person = ask.which(person,"people")
        
        if person:
            db.cur.execute("update people set hp = hp-10 where charid = \""+person[0]+"\";")
            name = find.nameFromID(person,"people")
            print("You gave",name[0], "a black eye.")
            
        else:
            print("Stop waving your hands around pointlessly!")
예제 #12
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") + ".")
예제 #13
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) + ".")
예제 #14
0
def death(charid):
    if g.debug:
        print("[DBG] death", charid[0])

    db.cur.execute("update people set locid = NULL where charid = \"" +
                   charid[0] + "\";")
    deadinv = parse.noneStrip(find.listInvItemIDs(charid, True))

    db.cur.execute("select val from people where charid = \"" + charid[0] +
                   "\";")
    deadval = parse.tupleListToList(db.cur.fetchall())

    plloc = find.plLoc()

    if g.debug:
        print("DEBUG death DEADINV", deadinv)
        print("DEBUG death DEADVAL", deadval)

    if len(deadinv) > 0:
        for i in range(1, len(deadinv)):
            db.cur.execute("update inventory set item" + str(i) +
                           " = NULL where charid = \"" + charid[0] + "\";")

    if len(deadinv) > 0:
        for a in deadinv:
            db.cur.execute("update item set locid = \"" + plloc +
                           "\" where itemid = \"" + a + "\";")

    print("You found " + str(deadval[0]) + " money on " +
          find.nameFromID(charid, "people")[0] + "\'s body.")
    db.cur.execute("update people set val = val + \"" + str(deadval[0]) +
                   "\" where charid = \"player\";")

    if charid[
            0] in g.essentialPeople:  # This must be at the bottom to prevent errors.
        gameOver.End("essential")
예제 #15
0
def travel(*args):
    inputlist = parse.checkArgs(args, "Travel where?", "", "to")

    if inputlist:
        charid = "player"
        toid = find.idFromName(inputlist, "location", [], True)

        while len(toid) > 1:
            toid = ask.which(toid, "location")

        if toid:
            if get.visCheck(toid[0]):
                if toid[0] in g.worldTravel and find.plLoc() in g.worldTravel:
                    if item.valTrans(
                            200, ["player"], [], " to travel to " +
                            find.nameFromID(toid, "location")[0]):
                        print("You pay the standard fare of 200.")
                        db.cur.execute(
                            "update people set val = val - 200 where charid = \"player\";"
                        )
                        print("Traveling to " +
                              find.nameFromID(toid, "location")[0] + ".")

                        if toid[0] == "buairpor" and g.firstBulgaria == "1" and g.Chapters == "1":
                            print(
                                "\n             ----    Chapter II: Tracking Zlatin Panayotov    ----"
                            )
                            db.cur.execute(
                                "update save set val = 0 where var = \"firstBulgaria\";"
                            )
                            g.update()

                        elif toid[0] == "taport" or toid[
                                0] == "taairpor" and g.firstTanz == "1" and g.Chapters == "1":
                            print(
                                "\n                 ----    Chapter III: Retrieving Beast    ----"
                            )
                            db.cur.execute(
                                "update save set val = 0 where var = \"firstTanz\";"
                            )
                            g.update()

                        elif toid[
                                0] == "inairpor" and g.backToIndia == "1" and g.Chapters == "1":
                            print(
                                "\n                   ----    Chapter IV: The Fjǫrsteinn    ----"
                            )
                            db.cur.execute(
                                "update save set val = 0 where var = \"backToIndia\";"
                            )
                            g.update()

                        elif toid[
                                0] == "grport" and g.grFisherCrater == "0" and g.Chapters == "1":
                            print(
                                "\n                 ----    Chapter V: The Fabled Guðhjǫrr    ----\n"
                            )
                            # Variable update handled in action.

                        elif toid[
                                0] == "peport" and g.firstPeru == "1" and g.Chapters == "1":
                            print(
                                "\n                  ----    Chapter VIII: The Guðhjǫrr    ----"
                            )
                            db.cur.execute(
                                "update save set val = 0 where var = \"firstPeru\";"
                            )
                            g.update()

                        action.travel(find.plLoc(), toid[0])
                        db.cur.execute("update people set locid = \"" +
                                       toid[0] + "\" where charid = \"" +
                                       charid + "\";")
                        cmd.look()

                elif toid[0] == "netoti" or toid[0] == "inbussta":  # Bus fare.
                    if item.valTrans(20, ["player"], ["inbusdri"],
                                     " to take the bus"):
                        print("You pay the bus fare of 20 money.")
                        db.cur.execute(
                            "update people set val = val - 20 where charid = \"player\";"
                        )
                        action.travel(find.plLoc(), toid[0])
                        db.cur.execute("update people set locid = \"" +
                                       toid[0] + "\" where charid = \"" +
                                       charid + "\";")
                        cmd.look()

                elif toid[0] == "pecave2" or toid[
                        0] == "pecave":  # INTO THE PIT WITH YOU!
                    if "flalight" in find.listInvItemIDs(
                    ):  # Flashlight check AKA. FU PL
                        dundundun = True
                    else:
                        dundundun = False

                    if g.debug:
                        print("[DBG] travel FLASHLIGHT CHECK:", dundundun,
                              toid[0])

                    if dundundun:  # Why would you pick it up?
                        action.setVis("pecave2", 0)
                        action.setVis("pecave", 1)
                        print("Traveling to the " +
                              find.nameFromID(["pecave"], "location")[0] + ".")
                        action.travel(find.plLoc(), "pecave")
                        db.cur.execute(
                            "update people set locid = \"pecave\" where charid = \""
                            + charid + "\";")
                        cmd.look()
                    else:
                        action.setVis("pecave", 0)
                        action.setVis("pecave2", 1)
                        print("Traveling to the " +
                              find.nameFromID(["pecave2"], "location")[0] +
                              ".")
                        action.travel(find.plLoc(), "pecave2")
                        db.cur.execute(
                            "update people set locid = \"pecave2\" where charid = \""
                            + charid + "\";")
                        cmd.look()
                else:
                    print("Traveling to " +
                          find.nameFromID(toid, "location")[0] + ".")
                    action.travel(find.plLoc(), toid[0])
                    db.cur.execute("update people set locid = \"" + toid[0] +
                                   "\" where charid = \"" + charid + "\";")
                    cmd.look()
            else:
                print("You can't travel there.")
        else:
            print("You can't travel there.")
예제 #16
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.")