示例#1
0
    def setInitialInteraction(self, dialogLine, choices, title=None):
        self.title = title

        if dialogLine == None:
            self.interactPane.disable()
            return

        con = GetMoMClientDBConnection()

        try:
            text, journalEntryID = con.execute(
                "SELECT text,journal_entry_id FROM dialog_line WHERE id=? LIMIT 1;",
                (dialogLine, )).fetchone()
        except:
            text = None
            journalEntryID = None

        if text:
            self.interactPane.text = ""
            self.interactPane.enable()
            self.interactPane.setInteraction(text, choices)
        else:
            self.interactPane.disable()

        if journalEntryID:
            from journalWnd import JOURNALWND
            journalTopic, journalEntry = con.execute(
                "SELECT topic,entry FROM journal_entry WHERE id = %i LIMIT 1;"
                % journalEntryID).fetchone()
            JOURNALWND.addEntry(journalTopic, journalEntry, text)
示例#2
0
 def setInitialInteraction(self, dialogLine, choices, title=None):
     self.title = title
     
     if dialogLine == None:
         self.interactPane.disable()
         return
     
     con = GetMoMClientDBConnection()
     
     try:
         text,journalEntryID = con.execute("SELECT text,journal_entry_id FROM dialog_line WHERE id=? LIMIT 1;",(dialogLine,)).fetchone()
     except:
         text = None
         journalEntryID = None
     
     if text:
         self.interactPane.text = ""
         self.interactPane.enable()
         self.interactPane.setInteraction(text,choices)
     else:
         self.interactPane.disable()
     
     if journalEntryID:
         from journalWnd import JOURNALWND
         journalTopic,journalEntry = con.execute("SELECT topic,entry FROM journal_entry WHERE id = %i LIMIT 1;"%journalEntryID).fetchone()
         JOURNALWND.addEntry(journalTopic,journalEntry,text)
示例#3
0
 def remote_set(self,text,choices,journalEntryID=None):
     self.setInteraction(text,choices)
     if journalEntryID:
         from journalWnd import JOURNALWND
         con = GetMoMClientDBConnection()
         journalTopic,journalEntry = con.execute("SELECT topic,entry FROM journal_entry WHERE id = %i LIMIT 1;"%journalEntryID).fetchone()
         JOURNALWND.addEntry(journalTopic,journalEntry,text)
示例#4
0
 def remote_set(self, text, choices, journalEntryID=None):
     self.setInteraction(text, choices)
     if journalEntryID:
         from journalWnd import JOURNALWND
         con = GetMoMClientDBConnection()
         journalTopic, journalEntry = con.execute(
             "SELECT topic,entry FROM journal_entry WHERE id = %i LIMIT 1;"
             % journalEntryID).fetchone()
         JOURNALWND.addEntry(journalTopic, journalEntry, text)
 def __init__(self):
     global ADVANCEPANE
     ADVANCEPANE = self
     self.advancePointsText = TGEObject("ADVANCEPANE_ADVANCEPOINTS")
     self.descText = TGEObject("ADVANCEPANE_DESCTEXT")
     self.currentDescText = TGEObject("ADVANCEPANE_CURRENTDESCTEXT")
     self.currentScroll = TGEObject("AdvanceCurrentScroll")
     self.currentTextList = TGEObject("AdvanceCurrentTextList")
     self.availableScroll = TGEObject("AdvanceAvailableScroll")
     self.availableTextList = TGEObject("AdvanceAvailableTextList")
     self.chooseButton = TGEObject("ADVANCEPANE_CHOOSEBUTTON")
     
     self.cinfo = None
     self.currentChoices = []
     self.availableChoices = []
     
     self.advancementCollection = []
     con = GetMoMClientDBConnection()
     for selection in con.execute("SELECT id,name,level,desc,cost,max_rank FROM advancement_proto ORDER BY name;"):
         myid = selection[0]
         exclusions = tuple(item[0] for item in con.execute("SELECT DISTINCT exclude FROM advancement_exclusion WHERE advancement_proto_id = ?;",(myid,)))
         if len(exclusions) > 1:
             exclusionsRedux = tuple(item[0] for item in con.execute("SELECT DISTINCT exclude FROM advancement_exclusion WHERE advancement_proto_id = ? AND exclude NOT IN (SELECT DISTINCT exclude FROM advancement_exclusion WHERE advancement_proto_id IN (SELECT id FROM advancement_proto WHERE name IN (SELECT exclude FROM advancement_exclusion WHERE advancement_proto_id = ?)));",(myid,myid)))
         else:
             exclusionsRedux = exclusions
         
         classReqs = con.execute("SELECT classname,level FROM advancement_class WHERE advancement_proto_id = ?;",(myid,)).fetchall()
         raceReqs = con.execute("SELECT racename,level FROM advancement_race WHERE advancement_proto_id = ?;",(myid,)).fetchall()
         advanceReqs = con.execute("SELECT require,rank FROM advancement_requirement WHERE advancement_proto_id = ?;",(myid,)).fetchall()
         
         self.advancementCollection.append( \
             (selection,(exclusions,exclusionsRedux,classReqs,raceReqs,advanceReqs)))
    def __init__(self):
        global ADVANCEPANE
        ADVANCEPANE = self
        self.advancePointsText = TGEObject("ADVANCEPANE_ADVANCEPOINTS")
        self.descText = TGEObject("ADVANCEPANE_DESCTEXT")
        self.currentDescText = TGEObject("ADVANCEPANE_CURRENTDESCTEXT")
        self.currentScroll = TGEObject("AdvanceCurrentScroll")
        self.currentTextList = TGEObject("AdvanceCurrentTextList")
        self.availableScroll = TGEObject("AdvanceAvailableScroll")
        self.availableTextList = TGEObject("AdvanceAvailableTextList")
        self.chooseButton = TGEObject("ADVANCEPANE_CHOOSEBUTTON")

        self.cinfo = None
        self.currentChoices = []
        self.availableChoices = []

        self.advancementCollection = []
        con = GetMoMClientDBConnection()
        for selection in con.execute(
                "SELECT id,name,level,desc,cost,max_rank FROM advancement_proto ORDER BY name;"
        ):
            myid = selection[0]
            exclusions = tuple(item[0] for item in con.execute(
                "SELECT DISTINCT exclude FROM advancement_exclusion WHERE advancement_proto_id = ?;",
                (myid, )))
            if len(exclusions) > 1:
                exclusionsRedux = tuple(item[0] for item in con.execute(
                    "SELECT DISTINCT exclude FROM advancement_exclusion WHERE advancement_proto_id = ? AND exclude NOT IN (SELECT DISTINCT exclude FROM advancement_exclusion WHERE advancement_proto_id IN (SELECT id FROM advancement_proto WHERE name IN (SELECT exclude FROM advancement_exclusion WHERE advancement_proto_id = ?)));",
                    (myid, myid)))
            else:
                exclusionsRedux = exclusions

            classReqs = con.execute(
                "SELECT classname,level FROM advancement_class WHERE advancement_proto_id = ?;",
                (myid, )).fetchall()
            raceReqs = con.execute(
                "SELECT racename,level FROM advancement_race WHERE advancement_proto_id = ?;",
                (myid, )).fetchall()
            advanceReqs = con.execute(
                "SELECT require,rank FROM advancement_requirement WHERE advancement_proto_id = ?;",
                (myid, )).fetchall()

            self.advancementCollection.append( \
                (selection,(exclusions,exclusionsRedux,classReqs,raceReqs,advanceReqs)))
示例#7
0
    def DisplayMail(self, page):
        from time import time

        #Sets the page we are on.  100 is no change, 0 is the first page, otherwise increase/decrease
        if (page == 0):
            self.inboxPage = 1
        elif (page == 100):
            self.inboxPage = self.inboxPage
        else:
            self.inboxPage += page

        ida = {}

        #Clear screen
        self.clearlite()

        if (self.inboxPage < 1):
            self.inboxPage = 1
        #Show Prev button if we are past page 1
        if (self.inboxPage > 1):
            self.inboxPrev.visible = True
        count = tcount = 1
        scount = (self.inboxPage - 1) * 7 + 1
        ecount = (self.inboxPage) * 7
        for id, mail in self.mailCache.iteritems():
            #Show only 7 items...we are good now
            if (tcount < scount):
                tcount += 1
                continue
            #Show only 7 items...we are good now.
            if (tcount > ecount):
                #More mail left...show next button
                self.inboxNext.visible = True
                #We have items in the ghost cache, so lets get that info
                #if len(ida):
                #    PLAYERMIND.perspective.callRemote("PlayerAvatar","getItemInfo",ida)
                return

            self.inboxFrom[count].setText("<color:007A02>%s" % mail.MAILFROM)
            self.inboxSubject[count].setText("<color:2E5691>%s" % mail.SUBJECT)
            self.inboxTimeLeft[count].setText("%s" %
                                              self.getTimeLeft(mail.TIMEEND))
            if mail.ITEMPROTOID:
                #Connect to local game DB to get item proto information
                con = GetMoMClientDBConnection()
                try:
                    bitmap = con.execute(
                        "SELECT bitmap FROM item_proto WHERE id = %s;" %
                        mail.ITEMPROTOID).fetchone()[0]
                    self.inboxButton[count].SetBitmap(
                        "~/data/ui/items/%s/0_0_0" % bitmap)
                except:
                    self.inboxButton[count].SetBitmap(
                        "~/data/ui/elements/mail")
            elif mail.TIN:
                self.inboxButton[count].SetBitmap(
                    "~/data/ui/elements/coinpile")
            else:
                self.inboxButton[count].SetBitmap("~/data/ui/elements/mail")
            self.inboxButton[count].visible = True
            #Set auction ID on button for reference later
            self.mailButtonId[count] = id
            #Item is not in the ghost Cache...add it
            #if not self.itemCache.has_key(id):
            #    ida[id] = iid
            #else:
            #    if self.itemCache[id].STACKMAX > 1:
            #        self.itemButton[count].number =  self.itemCache[id].STACKCOUNT
            count += 1
            tcount += 1
示例#8
0
def CmdCraft(args, charIndex):
    from mud.client.playermind import formatMLString, GetMoMClientDBConnection
    from partyWnd import PARTYWND

    con = GetMoMClientDBConnection()

    # Check for existance of arguments.
    if not len(args):
        receiveGameText(RPG_MSG_GAME_DENIED,
                        "Please specify a recipe name.\\n")
        return

    # Join the list with spaces to get the desired recipe name.
    recipeName = formatMLString(' '.join(args).replace('\\', '\\\\'))

    # Do a case-insensitive search for the desired recipe name.
    # Replace ' with '' for SQL apostropha handling..replace("'", "''")
    result = con.execute(
        "SELECT id,name,skillname,skill_level,cost_t_p FROM recipe WHERE LOWER(name) = LOWER(\"%s\") LIMIT 1;"
        % (recipeName)).fetchone()

    # If the recipe is not found, print message and return.
    if not result:
        receiveGameText(
            RPG_MSG_GAME_DENIED,
            '%s is not a valid recipe.  Please check the recipe name and try again.\\n'
            % (recipeName))
        return

    # Extract the tuple from the result.
    recipeID, recipeName, skillname, skill_level, costTP = result

    # Get current character info
    if charIndex == None:
        charIndex = PARTYWND.curIndex
    cinfo = PARTYWND.charInfos[charIndex]

    # Check skill requirements
    charSkillLevel = cinfo.SKILLS.get(skillname, 0)
    if charSkillLevel < skill_level:
        receiveGameText(
            RPG_MSG_GAME_DENIED,
            "%s requires a %i skill in <a:Skill%s>%s</a>.\\n" %
            (cinfo.NAME, skill_level, GetTWikiName(skillname), skillname))
        return

    # Check money requirements
    if PARTYWND.mind.rootInfo.TIN < costTP:
        receiveGameText(
            RPG_MSG_GAME_DENIED, "This <a:Skill%s>%s</a> requires %s.\\n" %
            (GetTWikiName(skillname), skillname, GenMoneyText(costTP)))
        return

    # Check for crafting delays.
    if skillname.upper() in cinfo.SKILLREUSE:
        TomeGui.receiveGameTextPersonalized(
            RPG_MSG_GAME_DENIED,
            "$src is still cleaning $srchis tools,\\n$srche can use the <a:Skill%s>%s</a> skill again in about %i seconds.\\n"
            % (GetTWikiName(skillname), skillname,
               cinfo.SKILLREUSE[skillname.upper()]), cinfo)
        return

    # Check for the required craft ingredients
    # (will be done on server again, in case there was a communication issue or hacking attempt)
    ingredients = dict((
        item_proto_id, count
    ) for item_proto_id, count in con.execute(
        "SELECT item_proto_id,count FROM recipe_ingredient WHERE recipe_id=%i AND count!=0"
        % recipeID).fetchall())
    for item in cinfo.ITEMS.itervalues():
        for item_proto_id, count in ingredients.iteritems():
            if item.PROTOID == item_proto_id:
                sc = item.STACKCOUNT
                if not sc:
                    sc = 1
                ingredients[item_proto_id] -= sc
                if ingredients[item_proto_id] <= 0:
                    del ingredients[item_proto_id]
                break
        # If all required ingredients have been found, send craft command to server.
        if not len(ingredients):
            # Schedule sending of actual crafting command.
            PARTYWND.mind.perspective.callRemote("PlayerAvatar", "onCraft",
                                                 charIndex, recipeID)
            return

    missing = dict(
        (con.execute("SELECT name FROM item_proto WHERE id=%i LIMIT 1;" %
                     (protoID)).fetchone()[0], count)
        for protoID, count in ingredients.iteritems())
    receiveGameText(
        RPG_MSG_GAME_DENIED, "%s lacks %s for this craft.\\n" %
        (cinfo.NAME, ', '.join("%i <a:Item%s>%s</a>" %
                               (count, GetTWikiName(name), name)
                               for name, count in missing.iteritems())))
def OnCraft():
    cinfo = CRAFTINGWND.charInfo
    charItems = cinfo.ITEMS
    
    # Get all items present in the crafting window.
    citems = [charItems[slot] for slot in xrange(RPG_SLOT_CRAFTING_BEGIN, RPG_SLOT_CRAFTING_END) if charItems.has_key(slot)]
    # If there are no items present in the crafting window, give a message and return.
    if not len(citems):
        TomeGui.receiveGameText(RPG_MSG_GAME_DENIED,"You first need to put the desired ingredients into the crafting window.\\n")
        return
    
    con = GetMoMClientDBConnection()
    
    # Check if the items in crafting window form a valid recipe.
    recipe = None
    for recipe_id,skillname,skill_level in con.execute("SELECT DISTINCT id,skillname,skill_level FROM recipe WHERE id in (SELECT recipe_id FROM recipe_ingredient WHERE item_proto_id=%i);"%citems[0].PROTOID):
        ingredients = dict((item_proto_id,count) for item_proto_id,count in con.execute("SELECT item_proto_id,count FROM recipe_ingredient WHERE recipe_id=%i AND count!=0"%recipe_id).fetchall())
        
        passed = True
        for item in citems:
            found = False
            for item_proto_id,count in ingredients.iteritems():
                if item.PROTOID == item_proto_id:
                    sc = item.STACKCOUNT
                    if not sc:
                        sc = 1
                    ingredients[item_proto_id] -= sc
                    found = True
                    break
            if not found:
                passed = False
                break
        # All items were found in the current recipe.
        else:
            for x in ingredients.itervalues():
                if x:  # Can be negative if too much
                    passed = False
                    break
            # All ingredients no longer have a required count assigned.
            else:
                recipe = recipe_id
                # Check skill requirements
                charSkillLevel = cinfo.SKILLS.get(skillname,0)
                if charSkillLevel < skill_level:
                    TomeGui.receiveGameText(RPG_MSG_GAME_DENIED,"%s requires a %i skill in <a:Skill%s>%s</a>.\\n"%(cinfo.NAME,skill_level,GetTWikiName(skillname),skillname))
                    return
                # Check for crafting delays
                if skillname.upper() in cinfo.SKILLREUSE:
                    TomeGui.receiveGameTextPersonalized(RPG_MSG_GAME_DENIED,"$src is still cleaning $srchis tools,\\n$srche can use the <a:Skill%s>%s</a> skill again in about %i seconds.\\n"%(GetTWikiName(skillname),skillname,cinfo.SKILLREUSE[skillname.upper()]),cinfo)
                    return
                break
    
    if not recipe and cinfo.SKILLS.get("Scribing",0):
        if "SCRIBING" in cinfo.SKILLREUSE:
            TomeGui.receiveGameTextPersonalized(RPG_MSG_GAME_DENIED,"$src is still cleaning $srchis tools,\\n$srche can use the <a:SkillScribing>Scribing</a> skill again in about %i seconds.\\n"%(cinfo.SKILLREUSE["SCRIBING"]),cinfo)
            return
        
        spellEnhanceLevel = citems[0].spellEnhanceLevel
        name = citems[0].NAME
        passed = True
        if spellEnhanceLevel > 0 and spellEnhanceLevel < 10:
            count = 0
            for item in citems:
                if spellEnhanceLevel != item.spellEnhanceLevel or name != item.NAME:
                    passed = False
                    break
                count += item.STACKCOUNT
            # Player has the correct amount of tomes in crafting window for a merge
            if count == 2 and passed:
                recipe = -1  # Hack for tome merging
    
    if not recipe:
        TomeGui.receiveGameText(RPG_MSG_GAME_DENIED,r'%s is unable to craft anything with these items.\n'%(cinfo.NAME))
    else:
        # Send craft command.
        from partyWnd import PARTYWND
        PARTYWND.mind.perspective.callRemote("PlayerAvatar","onCraft",PARTYWND.curIndex,recipe,True)
    def Search(self, page):
        from mud.client.playermind import PLAYERMIND
        from time import time
        
        #Sets the page we are on.  100 is no change, 0 is the first page, otherwise increase/decrease
        if (page == 0):
            self.searchPage = 1
        elif (page == 100):
            self.searchPage = self.searchPage
        else:
            self.searchPage += page
            
        #Update is due...Do this first and it will call search again with a refreshed DB
        #RPG_AUCTION_SEARCH_REFRESH is stored in defines.py and is a default of 1 minute.
        if (self.lastUpdate + RPG_AUCTION_SEARCH_REFRESH < time()):
            PLAYERMIND.perspective.callRemote("PlayerAvatar","refreshAuctionList", 1)
            return
            
        ida = {}
        #Clear screen
        self.clearresults()

        if (self.searchPage < 1):
            self.searchPage = 1
        #Show Prev button if we are past page 1
        if (self.searchPage > 1):
            self.itemPrev.visible = True
        count=tcount=1
        SearchText = self.searchName.getValue()
        #Validate level values and fix them if there is an issue.
        if (not self.levelLow.getValue().isdigit() or not self.levelHigh.getValue().isdigit()):
            lvllow = 0
            lvlhi = 1000
            self.levelLow.setValue("")
            self.levelHigh.setValue("")
        else:
            lvllow = string.atoi(self.levelLow.getValue())
            lvlhi = string.atoi(self.levelHigh.getValue())
            
        if SearchText == "":
            TGECall("MessageBoxOK","Please type an item name to search for","You need to type an item name to search for.")
            return
        
        #Connect to local game DB to get item proto information
        con = GetMoMClientDBConnection()
        #Connect to AH DB to get AH info
        conn = self.getDBConnection()
        cursor = conn.cursor()
        scount = (self.searchPage-1)*10+1
        ecount = (self.searchPage)*10
        #Query local game DB and then AH DB on the client to get search results
        for iid,name,flags,level,bitmap in con.execute("SELECT id,name,flags,level,bitmap from item_proto WHERE name LIKE '%s%%' AND level >= %i AND level <= %i;"%(SearchText,lvllow,lvlhi)):         
            for id,buyout,cost,item_id,time,bidder_id,char_id in cursor.execute("SELECT id, buyout_cost, cost, item_id, time_left,bidder_id,char_id FROM ItemList WHERE item_id = %s;"%iid):
                #Show only 10 items...we are good now
                if (tcount < scount):
                    tcount += 1
                    continue
                #Show only 10 items...we are good now.  
                if (tcount > ecount):
                    #More items left...show next button
                    self.itemNext.visible = True
                    cursor.close()
                    conn.close()
                    #We have items in the ghost cache, so lets get that info
                    if len(ida):
                        PLAYERMIND.perspective.callRemote("PlayerAvatar","getItemInfo",ida)
                    return
                 
                #setup values to show on the GUI such as name, time left, level, etc   
                self.itemNameColor[count] = GetItemRarity(flags)
                    
                if (time == 4):
                    tleft = "<color:FFFFFF>Very Long"
                elif (time == 3):
                    tleft = "<color:469B00>Long"
                elif (time == 2):
                    tleft = "<color:FFD800>Medium"
                else:
                    tleft = "<color:FF0000>Short"
                    
                self.itemTimeLeft[count].setText(tleft)               
                self.itemName[count].setText("%s%s"%(self.itemNameColor[count],name))
                self.itemLevel[count].setText("<color:FFFFFF>%s"%level)
                self.itemButton[count].SetBitmap("~/data/ui/items/%s/0_0_0"%bitmap)
                self.itemButton[count].visible = True
                self.itemGuiBG[count].visible = True
                cT,cC,cS,cG,cP=CollapseMoney(cost)
                self.itemBidC[count].setText(cC)
                self.itemBidS[count].setText(cS)
                self.itemBidG[count].setText(cG)
                self.itemBidP[count].setText(self.listplat(cP))
                if (buyout > 0):
                    bT,bC,bS,bG,bP=CollapseMoney(buyout)
                    self.itemBuyC[count].setText(bC)
                    self.itemBuyS[count].setText(bS)
                    self.itemBuyG[count].setText(bG)
                    self.itemBuyP[count].setText(self.listplat(bP))
                    self.itemShowBuy[count].visible = True
                    
                if (bidder_id <= 0):
                    self.itemBidInfo[count].visible = True
                    self.itemBidInfo[count].setText("No Bid")
                elif bidder_id == self.auctionCharID:
                    self.itemBidInfo[count].visible = True
                    self.itemBidInfo[count].setText("Curent Bid")
                    self.itemGuiBG[count].setBitmap("~/data/ui/elements/auctionitem_winbid")
                else:
                    self.itemBidInfo[count].visible = True
                    self.itemBidInfo[count].setText("Curent Bid")
                    
                if char_id == self.auctionCharID:
                    self.itemGuiBG[count].setBitmap("~/data/ui/elements/auctionitem_mine")
                    
                #Set auction ID on button for reference later
                self.itemButtonId[count] = id
                #Item is not in the ghost Cache...add it
                if not self.itemCache.has_key(id):
                    ida[id] = iid
                else:
                    if self.itemCache[id].STACKMAX > 1:
                        self.itemButton[count].number =  self.itemCache[id].STACKCOUNT
                    if self.itemCache[id].NAME != self.itemName[count].getText():
                        self.itemName[count].setText("%s%s"%(self.itemNameColor[count],self.itemCache[id].NAME))
                count += 1
                tcount += 1
                
        #We have items in the ghost cache, so lets get that info
        if len(ida):
            PLAYERMIND.perspective.callRemote("PlayerAvatar","getItemInfo",ida)
        cursor.close()
        conn.close()
    def getCharacterSellList(self, page):
        from mud.client.playermind import PLAYERMIND
        from partyWnd import PARTYWND
        from time import time
        
        cinfo = PARTYWND.charInfos[PARTYWND.curIndex]
        
        if (self.auctionCharID <= 0):
            return            
                
        #Sets the page we are on.  100 is no change, 0 is the first page, otherwise increase/decrease
        if (page == 0):
            self.searchPage = 1
        elif (page == 100):
            self.searchPage = self.searchPage
        else:
            self.searchPage += page
        
        if (self.lastUpdate + RPG_AUCTION_SEARCH_REFRESH < time()):
            PLAYERMIND.perspective.callRemote("PlayerAvatar","refreshAuctionList", 2)
            return
            
        ida = {}
        #Clear item list (lite)
        self.clearresultslite()

        if (self.searchPage < 1):
            self.searchPage = 1
        #Show Prev button if we are past page 1
        if (self.searchPage > 1):
            self.itemPrev.visible = True
        count=tcount=1          
        
        #Connect to local game DB to get item proto information
        con = GetMoMClientDBConnection()
        #Connect to AH DB to get AH info
        conn = self.getDBConnection()
        cursor = conn.cursor()
        scount = (self.searchPage-1)*10+1
        ecount = (self.searchPage)*10
        #Query local game DB and then AH DB on the client to get search results
        for id,buyout,cost,item_id,time,bidder_id in cursor.execute("SELECT id, buyout_cost, cost, item_id, time_left,bidder_id FROM ItemList WHERE char_id = %s ORDER BY time_left;"%self.auctionCharID):
            for iid,name,flags,level,bitmap in con.execute("SELECT id,name,flags,level,bitmap from item_proto WHERE id = %s;"%item_id):         
                #Show only 10 items...we are good now
                if (tcount < scount):
                    tcount += 1
                    continue
                #Show only 10 items...we are good now.  
                if (tcount > ecount):
                    #More items left...show next button
                    self.itemNext.visible = True
                    cursor.close()
                    conn.close()
                    #We have items in the ghost cache, so lets get that info
                    if len(ida):
                        PLAYERMIND.perspective.callRemote("PlayerAvatar","getItemInfo",ida)
                    return
                 
                #setup values to show on the GUI such as name, time left, level, etc   
                self.itemNameColor[count] = GetItemRarity(flags)
                    
                if (time == 4):
                    tleft = "<color:FFFFFF>Very Long"
                elif (time == 3):
                    tleft = "<color:469B00>Long"
                elif (time == 2):
                    tleft = "<color:FFD800>Medium"
                else:
                    tleft = "<color:FF0000>Short"
                    
                self.itemTimeLeft[count].setText(tleft)               
                self.itemName[count].setText("%s%s"%(self.itemNameColor[count],name))
                self.itemLevel[count].setText("<color:FFFFFF>%s"%level)
                self.itemButton[count].SetBitmap("~/data/ui/items/%s/0_0_0"%bitmap)
                self.itemButton[count].visible = True
                self.itemGuiBG[count].visible = True
                cT,cC,cS,cG,cP=CollapseMoney(cost)
                self.itemBidC[count].setText(cC)
                self.itemBidS[count].setText(cS)
                self.itemBidG[count].setText(cG)
                self.itemBidP[count].setText(self.listplat(cP))
                if (buyout > 0):
                    bT,bC,bS,bG,bP=CollapseMoney(buyout)
                    self.itemBuyC[count].setText(bC)
                    self.itemBuyS[count].setText(bS)
                    self.itemBuyG[count].setText(bG)
                    self.itemBuyP[count].setText(self.listplat(bP))                    
                    self.itemShowBuy[count].visible = True
                 
                if (bidder_id <= 0):
                    self.itemBidInfo[count].visible = True
                    self.itemBidInfo[count].setText("No Bid")
                else:
                    self.itemBidInfo[count].visible = True
                    self.itemBidInfo[count].setText("Curent Bid")
                    self.itemGuiBG[count].setBitmap("~/data/ui/elements/auctionitem_winbid")
                    
                #Set auction ID on button for reference later
                self.itemButtonId[count] = id
                #Item is not in the ghost Cache...add it
                if not self.itemCache.has_key(id):
                    ida[id] = iid
                else:
                    if self.itemCache[id].STACKMAX > 1:
                        self.itemButton[count].number =  self.itemCache[id].STACKCOUNT
                    if self.itemCache[id].NAME != self.itemName[count].getText():
                        self.itemName[count].setText("%s%s"%(self.itemNameColor[count],self.itemCache[id].NAME))                        
                count += 1
                tcount += 1
                
        #We have items in the ghost cache, so lets get that info
        if len(ida):
            PLAYERMIND.perspective.callRemote("PlayerAvatar","getItemInfo",ida)
        cursor.close()
        conn.close()
示例#12
0
    def Search(self, page):
        from mud.client.playermind import PLAYERMIND
        from time import time

        #Sets the page we are on.  100 is no change, 0 is the first page, otherwise increase/decrease
        if (page == 0):
            self.searchPage = 1
        elif (page == 100):
            self.searchPage = self.searchPage
        else:
            self.searchPage += page

        #Update is due...Do this first and it will call search again with a refreshed DB
        #RPG_AUCTION_SEARCH_REFRESH is stored in defines.py and is a default of 1 minute.
        if (self.lastUpdate + RPG_AUCTION_SEARCH_REFRESH < time()):
            PLAYERMIND.perspective.callRemote("PlayerAvatar",
                                              "refreshAuctionList", 1)
            return

        ida = {}
        #Clear screen
        self.clearresults()

        if (self.searchPage < 1):
            self.searchPage = 1
        #Show Prev button if we are past page 1
        if (self.searchPage > 1):
            self.itemPrev.visible = True
        count = tcount = 1
        SearchText = self.searchName.getValue()
        #Validate level values and fix them if there is an issue.
        if (not self.levelLow.getValue().isdigit()
                or not self.levelHigh.getValue().isdigit()):
            lvllow = 0
            lvlhi = 1000
            self.levelLow.setValue("")
            self.levelHigh.setValue("")
        else:
            lvllow = string.atoi(self.levelLow.getValue())
            lvlhi = string.atoi(self.levelHigh.getValue())

        if SearchText == "":
            TGECall("MessageBoxOK", "Please type an item name to search for",
                    "You need to type an item name to search for.")
            return

        #Connect to local game DB to get item proto information
        con = GetMoMClientDBConnection()
        #Connect to AH DB to get AH info
        conn = self.getDBConnection()
        cursor = conn.cursor()
        scount = (self.searchPage - 1) * 10 + 1
        ecount = (self.searchPage) * 10
        #Query local game DB and then AH DB on the client to get search results
        for iid, name, flags, level, bitmap in con.execute(
                "SELECT id,name,flags,level,bitmap from item_proto WHERE name LIKE '%s%%' AND level >= %i AND level <= %i;"
                % (SearchText, lvllow, lvlhi)):
            for id, buyout, cost, item_id, time, bidder_id, char_id in cursor.execute(
                    "SELECT id, buyout_cost, cost, item_id, time_left,bidder_id,char_id FROM ItemList WHERE item_id = %s;"
                    % iid):
                #Show only 10 items...we are good now
                if (tcount < scount):
                    tcount += 1
                    continue
                #Show only 10 items...we are good now.
                if (tcount > ecount):
                    #More items left...show next button
                    self.itemNext.visible = True
                    cursor.close()
                    conn.close()
                    #We have items in the ghost cache, so lets get that info
                    if len(ida):
                        PLAYERMIND.perspective.callRemote(
                            "PlayerAvatar", "getItemInfo", ida)
                    return

                #setup values to show on the GUI such as name, time left, level, etc
                self.itemNameColor[count] = GetItemRarity(flags)

                if (time == 4):
                    tleft = "<color:FFFFFF>Very Long"
                elif (time == 3):
                    tleft = "<color:469B00>Long"
                elif (time == 2):
                    tleft = "<color:FFD800>Medium"
                else:
                    tleft = "<color:FF0000>Short"

                self.itemTimeLeft[count].setText(tleft)
                self.itemName[count].setText("%s%s" %
                                             (self.itemNameColor[count], name))
                self.itemLevel[count].setText("<color:FFFFFF>%s" % level)
                self.itemButton[count].SetBitmap("~/data/ui/items/%s/0_0_0" %
                                                 bitmap)
                self.itemButton[count].visible = True
                self.itemGuiBG[count].visible = True
                cT, cC, cS, cG, cP = CollapseMoney(cost)
                self.itemBidC[count].setText(cC)
                self.itemBidS[count].setText(cS)
                self.itemBidG[count].setText(cG)
                self.itemBidP[count].setText(self.listplat(cP))
                if (buyout > 0):
                    bT, bC, bS, bG, bP = CollapseMoney(buyout)
                    self.itemBuyC[count].setText(bC)
                    self.itemBuyS[count].setText(bS)
                    self.itemBuyG[count].setText(bG)
                    self.itemBuyP[count].setText(self.listplat(bP))
                    self.itemShowBuy[count].visible = True

                if (bidder_id <= 0):
                    self.itemBidInfo[count].visible = True
                    self.itemBidInfo[count].setText("No Bid")
                elif bidder_id == self.auctionCharID:
                    self.itemBidInfo[count].visible = True
                    self.itemBidInfo[count].setText("Curent Bid")
                    self.itemGuiBG[count].setBitmap(
                        "~/data/ui/elements/auctionitem_winbid")
                else:
                    self.itemBidInfo[count].visible = True
                    self.itemBidInfo[count].setText("Curent Bid")

                if char_id == self.auctionCharID:
                    self.itemGuiBG[count].setBitmap(
                        "~/data/ui/elements/auctionitem_mine")

                #Set auction ID on button for reference later
                self.itemButtonId[count] = id
                #Item is not in the ghost Cache...add it
                if not self.itemCache.has_key(id):
                    ida[id] = iid
                else:
                    if self.itemCache[id].STACKMAX > 1:
                        self.itemButton[count].number = self.itemCache[
                            id].STACKCOUNT
                    if self.itemCache[id].NAME != self.itemName[count].getText(
                    ):
                        self.itemName[count].setText(
                            "%s%s" % (self.itemNameColor[count],
                                      self.itemCache[id].NAME))
                count += 1
                tcount += 1

        #We have items in the ghost cache, so lets get that info
        if len(ida):
            PLAYERMIND.perspective.callRemote("PlayerAvatar", "getItemInfo",
                                              ida)
        cursor.close()
        conn.close()
示例#13
0
    def getCharacterSellList(self, page):
        from mud.client.playermind import PLAYERMIND
        from partyWnd import PARTYWND
        from time import time

        cinfo = PARTYWND.charInfos[PARTYWND.curIndex]

        if (self.auctionCharID <= 0):
            return

        #Sets the page we are on.  100 is no change, 0 is the first page, otherwise increase/decrease
        if (page == 0):
            self.searchPage = 1
        elif (page == 100):
            self.searchPage = self.searchPage
        else:
            self.searchPage += page

        if (self.lastUpdate + RPG_AUCTION_SEARCH_REFRESH < time()):
            PLAYERMIND.perspective.callRemote("PlayerAvatar",
                                              "refreshAuctionList", 2)
            return

        ida = {}
        #Clear item list (lite)
        self.clearresultslite()

        if (self.searchPage < 1):
            self.searchPage = 1
        #Show Prev button if we are past page 1
        if (self.searchPage > 1):
            self.itemPrev.visible = True
        count = tcount = 1

        #Connect to local game DB to get item proto information
        con = GetMoMClientDBConnection()
        #Connect to AH DB to get AH info
        conn = self.getDBConnection()
        cursor = conn.cursor()
        scount = (self.searchPage - 1) * 10 + 1
        ecount = (self.searchPage) * 10
        #Query local game DB and then AH DB on the client to get search results
        for id, buyout, cost, item_id, time, bidder_id in cursor.execute(
                "SELECT id, buyout_cost, cost, item_id, time_left,bidder_id FROM ItemList WHERE char_id = %s ORDER BY time_left;"
                % self.auctionCharID):
            for iid, name, flags, level, bitmap in con.execute(
                    "SELECT id,name,flags,level,bitmap from item_proto WHERE id = %s;"
                    % item_id):
                #Show only 10 items...we are good now
                if (tcount < scount):
                    tcount += 1
                    continue
                #Show only 10 items...we are good now.
                if (tcount > ecount):
                    #More items left...show next button
                    self.itemNext.visible = True
                    cursor.close()
                    conn.close()
                    #We have items in the ghost cache, so lets get that info
                    if len(ida):
                        PLAYERMIND.perspective.callRemote(
                            "PlayerAvatar", "getItemInfo", ida)
                    return

                #setup values to show on the GUI such as name, time left, level, etc
                self.itemNameColor[count] = GetItemRarity(flags)

                if (time == 4):
                    tleft = "<color:FFFFFF>Very Long"
                elif (time == 3):
                    tleft = "<color:469B00>Long"
                elif (time == 2):
                    tleft = "<color:FFD800>Medium"
                else:
                    tleft = "<color:FF0000>Short"

                self.itemTimeLeft[count].setText(tleft)
                self.itemName[count].setText("%s%s" %
                                             (self.itemNameColor[count], name))
                self.itemLevel[count].setText("<color:FFFFFF>%s" % level)
                self.itemButton[count].SetBitmap("~/data/ui/items/%s/0_0_0" %
                                                 bitmap)
                self.itemButton[count].visible = True
                self.itemGuiBG[count].visible = True
                cT, cC, cS, cG, cP = CollapseMoney(cost)
                self.itemBidC[count].setText(cC)
                self.itemBidS[count].setText(cS)
                self.itemBidG[count].setText(cG)
                self.itemBidP[count].setText(self.listplat(cP))
                if (buyout > 0):
                    bT, bC, bS, bG, bP = CollapseMoney(buyout)
                    self.itemBuyC[count].setText(bC)
                    self.itemBuyS[count].setText(bS)
                    self.itemBuyG[count].setText(bG)
                    self.itemBuyP[count].setText(self.listplat(bP))
                    self.itemShowBuy[count].visible = True

                if (bidder_id <= 0):
                    self.itemBidInfo[count].visible = True
                    self.itemBidInfo[count].setText("No Bid")
                else:
                    self.itemBidInfo[count].visible = True
                    self.itemBidInfo[count].setText("Curent Bid")
                    self.itemGuiBG[count].setBitmap(
                        "~/data/ui/elements/auctionitem_winbid")

                #Set auction ID on button for reference later
                self.itemButtonId[count] = id
                #Item is not in the ghost Cache...add it
                if not self.itemCache.has_key(id):
                    ida[id] = iid
                else:
                    if self.itemCache[id].STACKMAX > 1:
                        self.itemButton[count].number = self.itemCache[
                            id].STACKCOUNT
                    if self.itemCache[id].NAME != self.itemName[count].getText(
                    ):
                        self.itemName[count].setText(
                            "%s%s" % (self.itemNameColor[count],
                                      self.itemCache[id].NAME))
                count += 1
                tcount += 1

        #We have items in the ghost cache, so lets get that info
        if len(ida):
            PLAYERMIND.perspective.callRemote("PlayerAvatar", "getItemInfo",
                                              ida)
        cursor.close()
        conn.close()
示例#14
0
    def setFromCharacterInfo(self, cinfo):
        newCharData = False
        if self.cinfo != cinfo:  # on first run, or when switching characters
            newCharData = True
            self.cinfo = cinfo

        self.advancePointsText.setText("Points: %i" % int(cinfo.ADVANCE))

        try:  # duality check
            if not AdvancementsDirty() and not newCharData:
                return

            index = int(self.availableTextList.getSelectedId())
            aprev = ""
            if len(self.availableChoices) > index >= 0:
                aprev = self.availableTextList.getRowText(index)
            atc = self.availableTextList
            atc.setVisible(False)
            atc.clear()
            self.availableChoices = []
            aprevindex = 0
            index = int(self.currentTextList.getSelectedId())
            cprev = ""
            if len(self.currentChoices) > index >= 0:
                cprev = self.currentTextList.getRowText(index)
            ctc = self.currentTextList
            ctc.setVisible(False)
            ctc.clear()
            self.currentChoices = []
            cprevindex = 0

            cinfo.ADVANCEMENTS.sort(key=lambda x: x[0])
            currentNames = [cur[0] for cur in cinfo.ADVANCEMENTS]
            currentExclusions = []
            con = GetMoMClientDBConnection()

            #fill it up
            ci = 0
            for selection, values in self.advancementCollection:
                myid, name, level, desc, cost, maxRank = selection
                exclusions, exclusionsRedux, classReqs, raceReqs, advanceReqs = values

                try:
                    rank = cinfo.ADVANCEMENTS[currentNames.index(name)][1]
                    TGEEval(r'AdvanceCurrentTextList.addRow(%i,"%s" TAB "%s");'% \
                        (ci,name,"(%i/%i)"%(rank,maxRank)))
                    self.currentChoices.append(
                        (name, rank, maxRank, desc, exclusionsRedux))
                    currentExclusions.extend(exclusions)

                    if name in cprev:
                        cprevindex = ci
                    ci += 1

                    if rank >= maxRank:
                        continue
                except ValueError:
                    pass

                if cost > cinfo.ADVANCE or level > cinfo.PLEVEL:
                    continue

                if len(classReqs):
                    for classname, level in classReqs:
                        if (classname == cinfo.PCLASS and level <= cinfo.PLEVEL
                            ) or (classname == cinfo.SCLASS and level <=
                                  cinfo.SLEVEL) or (classname == cinfo.TCLASS
                                                    and level <= cinfo.TLEVEL):
                            break
                    else:
                        continue

                if len(raceReqs):
                    for racename, level in raceReqs:
                        if racename == cinfo.RACE and level <= cinfo.PLEVEL:
                            break
                    else:
                        continue

                passed = True
                if len(advanceReqs):
                    for require, rank in advanceReqs:
                        if require not in currentNames or rank > cinfo.ADVANCEMENTS[
                                currentNames.index(require)][1]:
                            passed = False
                            break

                if passed:
                    self.availableChoices.append( \
                        (name,cost,maxRank,desc,exclusionsRedux))

            ai = 0
            offset = 0
            for i in xrange(len(self.availableChoices)):
                choice = self.availableChoices[i - offset]
                name = choice[0]
                if name in currentExclusions:
                    del self.availableChoices[i - offset]
                    offset += 1
                    continue

                TGEEval(r'AdvanceAvailableTextList.addRow(%i,"%s" TAB "%s");' %
                        (ai, name, "(%i/%i)" % (choice[1], choice[2])))
                if name in aprev:
                    aprevindex = ai
                ai += 1

            atc.setSelectedRow(aprevindex)
            atc.scrollVisible(aprevindex)
            atc.setActive(True)
            atc.setVisible(True)
            ctc.setSelectedRow(cprevindex)
            ctc.scrollVisible(cprevindex)
            ctc.setActive(True)
            ctc.setVisible(True)

            if not len(self.availableChoices):
                self.chooseButton.visible = False
            else:
                self.chooseButton.visible = True

        except:
            traceback.print_exc()
示例#15
0
    def DisplayMail(self, page):
        from time import time
        
        #Sets the page we are on.  100 is no change, 0 is the first page, otherwise increase/decrease
        if (page == 0):
            self.inboxPage = 1
        elif (page == 100):
            self.inboxPage = self.inboxPage
        else:
            self.inboxPage += page
                        
        ida = {}
        
        #Clear screen
        self.clearlite()      

        if (self.inboxPage < 1):
            self.inboxPage = 1
        #Show Prev button if we are past page 1
        if (self.inboxPage > 1):
            self.inboxPrev.visible = True
        count=tcount=1
        scount = (self.inboxPage-1)*7+1
        ecount = (self.inboxPage)*7
        for id,mail in self.mailCache.iteritems():           
            #Show only 7 items...we are good now
            if (tcount < scount):
                tcount += 1
                continue
            #Show only 7 items...we are good now.  
            if (tcount > ecount):
                #More mail left...show next button
                self.inboxNext.visible = True
                #We have items in the ghost cache, so lets get that info
                #if len(ida):
                #    PLAYERMIND.perspective.callRemote("PlayerAvatar","getItemInfo",ida)
                return                 
                    
            self.inboxFrom[count].setText("<color:007A02>%s"%mail.MAILFROM)               
            self.inboxSubject[count].setText("<color:2E5691>%s"%mail.SUBJECT)
            self.inboxTimeLeft[count].setText("%s"%self.getTimeLeft(mail.TIMEEND))
            if mail.ITEMPROTOID:
                #Connect to local game DB to get item proto information
                con = GetMoMClientDBConnection()    
                try:          
                    bitmap = con.execute("SELECT bitmap FROM item_proto WHERE id = %s;"%mail.ITEMPROTOID).fetchone()[0]
                    self.inboxButton[count].SetBitmap("~/data/ui/items/%s/0_0_0"%bitmap)
                except:
                    self.inboxButton[count].SetBitmap("~/data/ui/elements/mail")           
            elif mail.TIN:
                self.inboxButton[count].SetBitmap("~/data/ui/elements/coinpile")  
            else:
                self.inboxButton[count].SetBitmap("~/data/ui/elements/mail")    
            self.inboxButton[count].visible = True 
            #Set auction ID on button for reference later
            self.mailButtonId[count] = id
            #Item is not in the ghost Cache...add it
            #if not self.itemCache.has_key(id):
            #    ida[id] = iid
            #else:
            #    if self.itemCache[id].STACKMAX > 1:
            #        self.itemButton[count].number =  self.itemCache[id].STACKCOUNT
            count += 1
            tcount += 1
示例#16
0
def OnCraft():
    cinfo = CRAFTINGWND.charInfo
    charItems = cinfo.ITEMS

    # Get all items present in the crafting window.
    citems = [
        charItems[slot]
        for slot in xrange(RPG_SLOT_CRAFTING_BEGIN, RPG_SLOT_CRAFTING_END)
        if charItems.has_key(slot)
    ]
    # If there are no items present in the crafting window, give a message and return.
    if not len(citems):
        TomeGui.receiveGameText(
            RPG_MSG_GAME_DENIED,
            "You first need to put the desired ingredients into the crafting window.\\n"
        )
        return

    con = GetMoMClientDBConnection()

    # Check if the items in crafting window form a valid recipe.
    recipe = None
    for recipe_id, skillname, skill_level in con.execute(
            "SELECT DISTINCT id,skillname,skill_level FROM recipe WHERE id in (SELECT recipe_id FROM recipe_ingredient WHERE item_proto_id=%i);"
            % citems[0].PROTOID):
        ingredients = dict((
            item_proto_id, count
        ) for item_proto_id, count in con.execute(
            "SELECT item_proto_id,count FROM recipe_ingredient WHERE recipe_id=%i AND count!=0"
            % recipe_id).fetchall())

        passed = True
        for item in citems:
            found = False
            for item_proto_id, count in ingredients.iteritems():
                if item.PROTOID == item_proto_id:
                    sc = item.STACKCOUNT
                    if not sc:
                        sc = 1
                    ingredients[item_proto_id] -= sc
                    found = True
                    break
            if not found:
                passed = False
                break
        # All items were found in the current recipe.
        else:
            for x in ingredients.itervalues():
                if x:  # Can be negative if too much
                    passed = False
                    break
            # All ingredients no longer have a required count assigned.
            else:
                recipe = recipe_id
                # Check skill requirements
                charSkillLevel = cinfo.SKILLS.get(skillname, 0)
                if charSkillLevel < skill_level:
                    TomeGui.receiveGameText(
                        RPG_MSG_GAME_DENIED,
                        "%s requires a %i skill in <a:Skill%s>%s</a>.\\n" %
                        (cinfo.NAME, skill_level, GetTWikiName(skillname),
                         skillname))
                    return
                # Check for crafting delays
                if skillname.upper() in cinfo.SKILLREUSE:
                    TomeGui.receiveGameTextPersonalized(
                        RPG_MSG_GAME_DENIED,
                        "$src is still cleaning $srchis tools,\\n$srche can use the <a:Skill%s>%s</a> skill again in about %i seconds.\\n"
                        % (GetTWikiName(skillname), skillname,
                           cinfo.SKILLREUSE[skillname.upper()]), cinfo)
                    return
                break

    if not recipe and cinfo.SKILLS.get("Scribing", 0):
        if "SCRIBING" in cinfo.SKILLREUSE:
            TomeGui.receiveGameTextPersonalized(
                RPG_MSG_GAME_DENIED,
                "$src is still cleaning $srchis tools,\\n$srche can use the <a:SkillScribing>Scribing</a> skill again in about %i seconds.\\n"
                % (cinfo.SKILLREUSE["SCRIBING"]), cinfo)
            return

        spellEnhanceLevel = citems[0].spellEnhanceLevel
        name = citems[0].NAME
        passed = True
        if spellEnhanceLevel > 0 and spellEnhanceLevel < 10:
            count = 0
            for item in citems:
                if spellEnhanceLevel != item.spellEnhanceLevel or name != item.NAME:
                    passed = False
                    break
                count += item.STACKCOUNT
            # Player has the correct amount of tomes in crafting window for a merge
            if count == 2 and passed:
                recipe = -1  # Hack for tome merging

    if not recipe:
        TomeGui.receiveGameText(
            RPG_MSG_GAME_DENIED,
            r'%s is unable to craft anything with these items.\n' %
            (cinfo.NAME))
    else:
        # Send craft command.
        from partyWnd import PARTYWND
        PARTYWND.mind.perspective.callRemote("PlayerAvatar", "onCraft",
                                             PARTYWND.curIndex, recipe, True)