self.sendData("\x14" + "\x14",[str(self.shopcheese),self.shoplist,self.look,self.shopitems]) if itemcategory==3: looklist[3]=str(item) self.look=json.dumps(looklist) self.look = self.look.strip('[]') self.look = self.look.replace("\"","") self.look = self.look.replace(" ","") self.sendData("\x14" + "\x14",[str(self.shopcheese),self.shoplist,self.look,self.shopitems]) if itemcategory==4: looklist[4]=str(item) self.look=json.dumps(looklist) self.look = self.look.strip('[]') self.look = self.look.replace("\"","") self.look = self.look.replace(" ","") self.sendData("\x14" + "\x14",[str(self.shopcheese),self.shoplist,self.look,self.shopitems]) if eventToken2 == "\x13": #buy item itemcat0 = {3:20, 5:100, 2:200, 4:200, 1:500, 6:500, 7:200, 8:300, 9:500, 10:100, 11:500, 12:200, 13:500, 14:300, 15:200, 16:300, 17:200, 18:300, 19:300, 20:500, 21:200, 22:300, 23:400, 24:50, 25:250, 26:300, 27:800, 28:300, 29:500, 30:200, 31:300, 32:800, 33:150, 34:400, 35:1000, 36:500, 37:200, 38:800, 39:200, 40:500, 41:800, 42:500, 43:200, 44:250, 45:300, 46:100, 47:1500} #39:1000000, 40:1000000, 41:1000000, 42:1000000, itemcat1 = {1:200, 2:200, 4:200, 3:200, 5:300, 6:800, 7:50} itemcat2 = {1:100, 2:50, 3:20, 4:20} #{1:100, 2:1000000, 3:\1000000, 4:20} itemcat3 = {1:100, 2:25, 3:150, 4:400, 5:300, 6:300, 7:300} itemcat4 = {1:200, 2:200, 3:200, 4:50} #{1:200, 2:200, 3:1000000, 4:50} fullitem = str(values[0]) if int(values[0])>=100 and int(values[0]) <=199: itemcategory=1 item=fullitem[1:] item=int(item) item=str(item) elif int(values[0])>=200 and int(values[0]) <=299: itemcategory=2 item=fullitem[1:] item=int(item) item=str(item) elif int(values[0])>=300 and int(values[0]) <=399: itemcategory=3 item=fullitem[1:] item=int(item) item=str(item) elif int(values[0])>=400 and int(values[0]) <=499: itemcategory=4 item=fullitem[1:] item=int(item) item=str(item) else: itemcategory=0 item=values[0] shopcheese = int(self.shopcheese) looklist = self.look.split(",") if itemcategory==0: if shopcheese < itemcat0[int(item)]: self.sendData("\x14" + "\x06", []) if shopcheese >= itemcat0[int(item)]: if self.shopitems=="": self.shopitems=str(fullitem) self.shopcheese=self.shopcheese-itemcat0[int(item)] looklist[0]=str(item) self.look=json.dumps(looklist) self.look = self.look.strip('[]') self.look = self.look.replace("\"","") self.look = self.look.replace(" ","") self.sendData("\x14" + "\x14",[str(self.shopcheese),self.shoplist,self.look,self.shopitems]) else: self.shopitems=self.shopitems+","+str(fullitem) self.shopcheese=self.shopcheese-itemcat0[int(item)] looklist[0]=str(item) self.look = json.dumps(looklist) self.look = self.look.strip('[]') self.look = self.look.replace("\"","") self.look = self.look.replace(" ","") self.sendData("\x14" + "\x14",[str(self.shopcheese),self.shoplist,self.look,self.shopitems]) elif itemcategory==1: if shopcheese < itemcat1[int(item)]: self.sendData("\x14" + "\x06", []) if shopcheese >= itemcat1[int(item)]: if self.shopitems=="": self.shopitems=str(fullitem) self.shopcheese=self.shopcheese-itemcat1[int(item)] looklist[1]=str(item) self.look=json.dumps(looklist) self.look = self.look.strip('[]') self.look = self.look.replace("\"","") self.look = self.look.replace(" ","") self.sendData("\x14" + "\x14",[str(self.shopcheese),self.shoplist,self.look,self.shopitems]) else: self.shopitems=self.shopitems+","+str(fullitem) self.shopcheese=self.shopcheese-itemcat1[int(item)] looklist[1]=str(item) self.look = json.dumps(looklist) self.look = self.look.strip('[]') self.look = self.look.replace("\"","") self.look = self.look.replace(" ","") self.sendData("\x14" + "\x14",[str(self.shopcheese),self.shoplist,self.look,self.shopitems]) elif itemcategory==2: if shopcheese < itemcat2[int(item)]: self.sendData("\x14" + "\x06", []) if shopcheese >= itemcat2[int(item)]: if self.shopitems=="": self.shopitems=str(fullitem) self.shopcheese=self.shopcheese-itemcat2[int(item)] looklist[2]=str(item) self.look=json.dumps(looklist) self.look = self.look.strip('[]') self.look = self.look.replace("\"","") self.look = self.look.replace(" ","") self.sendData("\x14" + "\x14",[str(self.shopcheese),self.shoplist,self.look,self.shopitems]) else: self.shopitems=self.shopitems+","+str(fullitem) self.shopcheese=self.shopcheese-itemcat2[int(item)] looklist[2]=str(item) self.look = json.dumps(looklist) self.look = self.look.strip('[]') self.look = self.look.replace("\"","") self.look = self.look.replace(" ","") self.sendData("\x14" + "\x14",[str(self.shopcheese),self.shoplist,self.look,self.shopitems]) elif itemcategory==3: if shopcheese < itemcat3[int(item)]: self.sendData("\x14" + "\x06", []) if shopcheese >= itemcat3[int(item)]: if self.shopitems=="": self.shopitems=str(fullitem) self.shopcheese=self.shopcheese-itemcat3[int(item)] looklist[3]=str(item) self.look=json.dumps(looklist) self.look = self.look.strip('[]') self.look = self.look.replace("\"","") self.look = self.look.replace(" ","") self.sendData("\x14" + "\x14",[str(self.shopcheese),self.shoplist,self.look,self.shopitems]) else: self.shopitems=self.shopitems+","+str(fullitem) self.shopcheese=self.shopcheese-itemcat3[int(item)] looklist[3]=str(item) self.look = json.dumps(looklist) self.look = self.look.strip('[]') self.look = self.look.replace("\"","") self.look = self.look.replace(" ","") self.sendData("\x14" + "\x14",[str(self.shopcheese),self.shoplist,self.look,self.shopitems]) elif itemcategory==4: if shopcheese < itemcat4[int(item)]: self.sendData("\x14" + "\x06", []) if shopcheese >= itemcat4[int(item)]: if self.shopitems=="": self.shopitems=str(fullitem) self.shopcheese=self.shopcheese-itemcat4[int(item)] looklist[4]=str(item) self.look=json.dumps(looklist) self.look = self.look.strip('[]') self.look = self.look.replace("\"","") self.look = self.look.replace(" ","") self.sendData("\x14" + "\x14",[str(self.shopcheese),self.shoplist,self.look,self.shopitems]) else: self.shopitems=self.shopitems+","+str(fullitem) self.shopcheese=self.shopcheese-itemcat4[int(item)] looklist[4]=str(item) self.look = json.dumps(looklist) self.look = self.look.strip('[]') self.look = self.look.replace("\"","") self.look = self.look.replace(" ","") self.sendData("\x14" + "\x14",[str(self.shopcheese),self.shoplist,self.look,self.shopitems]) else: pass elif eventToken1 == "\x18": if eventToken2 == "\x0F": #open forums pass else: logging.warning("Unimplemented %r" % eventTokens) #raise NotImplementedError, eventTokens elif eventToken1 == "\x08": if eventToken2 == "\x0D": #open friends #if room == "Offline": #self.sendData("\x1A" + "\x04", ["[Serveur] %s is offline." % (username)]) #else: #self.sendData("\x1A" + "\x04", ["[Serveur] %s -> %s" % (username, room)]) #room = self.server.findPlayer(username) #room = self.server.findPlayer(username) friendsList = self.server.getUserFriends(self.username).split(",") sendList