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)
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)
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 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)))
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
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()
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()
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
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)