def sendGift(this, packet): p = ByteArray(packet) username, isShamanItem, fullItem, message = p.readUTF(), p.readBool( ), p.readShort(), p.readUTF() if not this.server.checkExistingUser(username): this.sendGiftResult(1, username) else: player = this.server.players.get(username) if player != None: found = player.shopModule.checkInShamanShop( fullItem ) if isShamanItem else player.shopModule.checkInShop(fullItem) if found: this.sendGiftResult(2, username) else: this.server.lastGiftID += 1 player.sendPacket( Identifiers.send.Shop_Gift, ByteArray().writeInt(this.server.lastGiftID).writeUTF( this.client.Username).writeUTF( this.client.playerLook).writeBool(isShamanItem) .writeShort(fullItem).writeUTF(message).toByteArray(), True) this.sendGiftResult(0, username) this.server.shopGifts[this.server.lastGiftID] = [ this.client.Username, isShamanItem, fullItem ] this.client.shopFraises -= this.getShamanShopItemPrice( fullItem) if isShamanItem else this.getShopItemPrice( fullItem) this.sendShopList(False) else: found = this.checkInPlayerShop( "ShamanItems" if isShamanItem else "ShopItems", username, fullItem) if found: this.sendGiftResult(2, username) else: this.Cursor.execute( "select LastReceivedGifts from Users where Username = ?", [username]) rs = this.Cursor.fetchone() lastReceivedGifts = rs["LastReceivedGifts"] lastReceivedGifts = ("" if lastReceivedGifts == "" else lastReceivedGifts + "/") + "[" + "|".join( map(str, [ this.client.Username, this.client.playerLook, isShamanItem, fullItem, message ])) this.Cursor.execute( "update Users set LastReceivedGifts = ? where Username = ?", [lastReceivedGifts, username])
def buyItem(this, packet): p = ByteArray(packet) fullItem = p.readShort() withFraises = p.readBool() itemStr = str(fullItem) itemCat = (0 if fullItem / 10000 == 1 else fullItem / 10000) if len(itemStr) > 4 else fullItem / 100 item = int(itemStr[2 if len(itemStr) > 3 else 1:] ) if len(itemStr) >= 3 else fullItem itemCheck = str(itemCat) + "|" + str(item) this.client.shopItems += str( fullItem) if this.client.shopItems == "" else "," + str(fullItem) price = this.getItemPromotion( itemCat, item, this.server.shopListCheck[str(itemCat) + "|" + str(item)][1 if withFraises else 0]) if withFraises: this.client.shopFraises -= price else: this.client.shopCheeses -= price this.sendItemBuy(fullItem) this.sendShopList(True) this.client.sendAnimZelda(0, fullItem) this.checkUnlockShopTitle() this.checkUnlockShopBadge(fullItem)
def buyClothe(this, packet): p = ByteArray(packet) clotheID, withFraises = p.readByte(), p.readBool() this.client.clothes.append( "%02d/%s/%s/%s" % (clotheID, "1;0,0,0,0,0,0,0,0,0", "78583a", "fade55" if this.client.shamanSaves >= 1000 else "95d9d6")) if withFraises: this.client.shopFraises -= 5 if clotheID == 0 else 50 if clotheID == 1 else 100 else: this.client.shopFraises -= 40 if clotheID == 0 else 1000 if clotheID == 1 else 2000 if clotheID == 2 else 4000 this.sendShopList(False)
def parseSkillPacket(this, skill, packet): p = ByteArray(packet) if this.client.isShaman: if skill == "fly": fly = p.readBool() this.sendShamanFly(fly) elif skill == "projection": posX = p.readShort() posY = p.readShort() dir = p.readShort() this.sendProjectionSkill(posX, posY, dir) elif skill == "demoliton": objectID = p.readInt() this.sendDemolitionSkill(objectID) elif skill == "convert": objectID = p.readInt() this.sendConvertSkill(objectID) elif skill == "recycling": id = p.readShort() this.sendRecyclingSkill(id) elif skill == "antigravity": objectID = p.readInt() this.sendAntigravitySkill(objectID) elif skill == "restorative": objectID = p.readInt() id = p.readInt() this.sendRestorativeSkill(objectID, id) elif skill == "handymouse": handyMouseByte = p.readByte() objectID = p.readInt() if this.client.room.lastHandymouse[0] == -1: this.client.room.lastHandymouse = [objectID, handyMouseByte] else: this.sendHandymouseSkill(handyMouseByte, objectID) this.client.room.sendAllBin(Identifiers.send.Skill, chr(77) + chr(1)) this.client.room.lastHandymouse = [-1, -1] elif skill == "gravitational": id = p.readInt() this.sendGravitationalSkill(0, id)
def customShamanItemBuy(this, packet): p = ByteArray(packet) fullItem, withFraises = p.readShort(), p.readBool() items = this.client.shamanItems.split(",") for shopItem in items: item = shopItem.split("_")[0] if "_" in shopItem else shopItem if fullItem == int(item): items[items.index(shopItem)] = shopItem + "_" break this.client.shamanItems = ",".join(items) if withFraises: this.client.shopFraises -= 150 else: this.client.shopCheeses -= 4000 this.sendShopList(False)
def buyShamanItem(this, packet): p = ByteArray(packet) fullItem, withFraises = p.readShort(), p.readBool() itemStr = str(fullItem) itemCat = int(itemStr[len(itemStr) - 2:]) item = int(itemStr[:len(itemStr) - 2]) price = this.server.shamanShopListCheck[itemStr][ 1 if withFraises else 0] this.client.shamanItems += str( fullItem) if this.client.shamanItems == "" else "," + str(fullItem) if withFraises: this.client.shopFraises -= price else: this.client.shopCheeses -= price this.sendShopList(False) this.client.sendAnimZelda(1, fullItem)
def giftResult(this, packet): p = ByteArray(packet) loc1, giftID, isOpen, message, loc2 = p.readShort(), p.readShort( ), p.readBool(), p.readUTF(), p.readByte() if isOpen: values = this.server.shopGifts[int(giftID)] player = this.server.players.get(str(values[0])) if player != None: player.sendMessageLangue("$DonItemRecu", this.client.Username) isShamanItem = bool(values[1]) fullItem = int(values[2]) if isShamanItem: itemStr = str(fullItem) itemCat = int(itemStr[len(itemStr) - 2:]) item = int(itemStr[:len(itemStr) - 2]) this.client.shamanItems += str( fullItem ) if this.client.shamanItems == "" else "," + str(fullItem) this.sendShopList(False) this.client.sendAnimZelda(1, fullItem) else: itemStr = str(fullItem) itemCat = (0 if fullItem / 10000 == 1 else fullItem / 10000) if len(itemStr) > 4 else fullItem / 100 item = int(itemStr[2 if len(itemStr) > 3 else 1:] ) if len(itemStr) >= 3 else fullItem this.client.shopItems += str( fullItem ) if this.client.shopItems == "" else "," + str(fullItem) this.client.sendAnimZelda(itemCat, item) this.checkUnlockShopTitle() this.checkUnlockShopBadge(fullItem) elif not message == "": values = this.server.shopGifts[int(giftID)] player = this.server.players.get(str(values[0])) if player != None: player.sendPacket( Identifiers.send.Shop_GIft_Message, ByteArray().writeShort(0).writeShort(giftID).writeUTF( this.client.Username).writeBool(bool( values[1])).writeShort(int( values[2])).writeUTF(message).writeUTF( this.client.playerLook).toByteArray(), True) else: this.Cursor.execute( "select LastReceivedMessages from Users where Username = ?", [str(values[0])]) rs = this.Cursor.fetchone() lastReceivedMessages = rs["LastReceivedMessages"] lastReceivedMessages = ( "" if lastReceivedMessages == "" else lastReceivedMessages + "/") + "[" + "|".join( map(str, [ this.client.Username, values[1], values[2], this.client.playerLook, message ])) + "]" this.Cursor.execute( "update Users set LastReceivedMessages = ? where Username = ?", [lastReceivedMessages, str(values[0])])