| | |
| | |
|
| | |
|
| | | #------------------------------------------------------
|
| | | # A1 20 货币兑换 #tagCMMoneyExchange
|
| | |
|
| | | class tagCMMoneyExchange(Structure):
|
| | | _pack_ = 1
|
| | | _fields_ = [
|
| | | ("Cmd", c_ubyte),
|
| | | ("SubCmd", c_ubyte),
|
| | | ("SrcMoneyType", c_ubyte), # 源货币类型
|
| | | ("TagMoneyType", c_ubyte), # 目标货币类型
|
| | | ("ExchangeValue", c_int), # 兑换数量(消耗源货币的数量)
|
| | | ]
|
| | |
|
| | | def __init__(self):
|
| | | self.Clear()
|
| | | self.Cmd = 0xA1
|
| | | self.SubCmd = 0x20
|
| | | return
|
| | |
|
| | | def ReadData(self, stringData, _pos=0, _len=0):
|
| | | self.Clear()
|
| | | memmove(addressof(self), stringData[_pos:], self.GetLength())
|
| | | return _pos + self.GetLength()
|
| | |
|
| | | def Clear(self):
|
| | | self.Cmd = 0xA1
|
| | | self.SubCmd = 0x20
|
| | | self.SrcMoneyType = 0
|
| | | self.TagMoneyType = 0
|
| | | self.ExchangeValue = 0
|
| | | return
|
| | |
|
| | | def GetLength(self):
|
| | | return sizeof(tagCMMoneyExchange)
|
| | |
|
| | | def GetBuffer(self):
|
| | | return string_at(addressof(self), self.GetLength())
|
| | |
|
| | | def OutputString(self):
|
| | | DumpString = '''// A1 20 货币兑换 //tagCMMoneyExchange:
|
| | | Cmd:%s,
|
| | | SubCmd:%s,
|
| | | SrcMoneyType:%d,
|
| | | TagMoneyType:%d,
|
| | | ExchangeValue:%d
|
| | | '''\
|
| | | %(
|
| | | self.Cmd,
|
| | | self.SubCmd,
|
| | | self.SrcMoneyType,
|
| | | self.TagMoneyType,
|
| | | self.ExchangeValue
|
| | | )
|
| | | return DumpString
|
| | |
|
| | |
|
| | | m_NAtagCMMoneyExchange=tagCMMoneyExchange()
|
| | | ChNetPackDict[eval("0x%02x%02x"%(m_NAtagCMMoneyExchange.Cmd,m_NAtagCMMoneyExchange.SubCmd))] = m_NAtagCMMoneyExchange
|
| | |
|
| | |
|
| | | #------------------------------------------------------
|
| | | # A1 01 玩家电脑信息 #tagCMPCInfo
|
| | |
|
| | | class tagCMPCInfo(Structure):
|
| | |
| | | Writer = hxp
|
| | | Releaser = hxp
|
| | | RegType = 0
|
| | | RegisterPackCount = 24
|
| | | RegisterPackCount = 25
|
| | |
|
| | | PacketCMD_1 = 0xA5
|
| | | PacketSubCMD_1 = 0x04
|
| | |
| | | PacketSubCMD_24=0x21
|
| | | PacketCallFunc_24=OnChangeJob
|
| | |
|
| | | PacketCMD_25=0xA1
|
| | | PacketSubCMD_25=0x20
|
| | | PacketCallFunc_25=OnMoneyExchange
|
| | |
|
| | | ;购买相关的
|
| | | [BuySomething]
|
| | | ScriptName = Event\EventSrc\Operate_PlayerBuyZhenQi.py
|
| | |
| | |
|
| | |
|
| | | #------------------------------------------------------
|
| | | # A1 20 货币兑换 #tagCMMoneyExchange
|
| | |
|
| | | class tagCMMoneyExchange(Structure):
|
| | | _pack_ = 1
|
| | | _fields_ = [
|
| | | ("Cmd", c_ubyte),
|
| | | ("SubCmd", c_ubyte),
|
| | | ("SrcMoneyType", c_ubyte), # 源货币类型
|
| | | ("TagMoneyType", c_ubyte), # 目标货币类型
|
| | | ("ExchangeValue", c_int), # 兑换数量(消耗源货币的数量)
|
| | | ]
|
| | |
|
| | | def __init__(self):
|
| | | self.Clear()
|
| | | self.Cmd = 0xA1
|
| | | self.SubCmd = 0x20
|
| | | return
|
| | |
|
| | | def ReadData(self, stringData, _pos=0, _len=0):
|
| | | self.Clear()
|
| | | memmove(addressof(self), stringData[_pos:], self.GetLength())
|
| | | return _pos + self.GetLength()
|
| | |
|
| | | def Clear(self):
|
| | | self.Cmd = 0xA1
|
| | | self.SubCmd = 0x20
|
| | | self.SrcMoneyType = 0
|
| | | self.TagMoneyType = 0
|
| | | self.ExchangeValue = 0
|
| | | return
|
| | |
|
| | | def GetLength(self):
|
| | | return sizeof(tagCMMoneyExchange)
|
| | |
|
| | | def GetBuffer(self):
|
| | | return string_at(addressof(self), self.GetLength())
|
| | |
|
| | | def OutputString(self):
|
| | | DumpString = '''// A1 20 货币兑换 //tagCMMoneyExchange:
|
| | | Cmd:%s,
|
| | | SubCmd:%s,
|
| | | SrcMoneyType:%d,
|
| | | TagMoneyType:%d,
|
| | | ExchangeValue:%d
|
| | | '''\
|
| | | %(
|
| | | self.Cmd,
|
| | | self.SubCmd,
|
| | | self.SrcMoneyType,
|
| | | self.TagMoneyType,
|
| | | self.ExchangeValue
|
| | | )
|
| | | return DumpString
|
| | |
|
| | |
|
| | | m_NAtagCMMoneyExchange=tagCMMoneyExchange()
|
| | | ChNetPackDict[eval("0x%02x%02x"%(m_NAtagCMMoneyExchange.Cmd,m_NAtagCMMoneyExchange.SubCmd))] = m_NAtagCMMoneyExchange
|
| | |
|
| | |
|
| | | #------------------------------------------------------
|
| | | # A1 01 玩家电脑信息 #tagCMPCInfo
|
| | |
|
| | | class tagCMPCInfo(Structure):
|
| | |
| | | beforeMoney = PlayerControl.GetMoney(curPlayer, priceType)
|
| | | infoDict = {"TotalItemList":totalItemList, "ClientBuyCount":clientBuyCount, "ShopType":shopType,
|
| | | "ShopItemIndex":itemIndex, ChConfig.Def_Cost_Reason_SonKey:mainItemID}
|
| | | PlayerControl.PayMoney(curPlayer, priceType, itemPrice, ChConfig.Def_Cost_BuyStoreItem, infoDict, clientBuyCount)
|
| | | if not PlayerControl.PayMoney(curPlayer, priceType, itemPrice, ChConfig.Def_Cost_BuyStoreItem, infoDict, clientBuyCount):
|
| | | GameWorld.ErrLog("购买商城物品实际扣除货币时失败: itemIndex=%s,clientBuyCount=%s,priceType=%s,itemPrice=%s" |
| | | % (itemIndex, clientBuyCount, priceType, itemPrice))
|
| | | return
|
| | |
|
| | | afterMoney = PlayerControl.GetMoney(curPlayer, priceType)
|
| | |
|
| | |
| | |
|
| | | return
|
| | |
|
| | | #// A1 20 货币兑换 #tagCMMoneyExchange
|
| | | #
|
| | | #struct tagCMMoneyExchange
|
| | | #{
|
| | | # tagHead Head;
|
| | | # BYTE SrcMoneyType; // 源货币类型
|
| | | # BYTE TagMoneyType; // 目标货币类型
|
| | | # DWORD ExchangeValue; // 兑换数量(消耗源货币的数量)
|
| | | #};
|
| | | def OnMoneyExchange(index, clientData, tick):
|
| | | curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
| | | srcMoneyType = clientData.SrcMoneyType
|
| | | tagMoneyType = clientData.TagMoneyType
|
| | | exchangeValue = clientData.ExchangeValue
|
| | | |
| | | exchangeMoneyInfo = IpyGameDataPY.GetFuncEvalCfg("EqualValueMoney", 1, {})
|
| | | if str(srcMoneyType) not in exchangeMoneyInfo:
|
| | | return
|
| | | exchangeInfo = exchangeMoneyInfo[str(srcMoneyType)]
|
| | | if tagMoneyType != exchangeInfo[0]:
|
| | | return
|
| | | multiple = exchangeInfo[1]
|
| | | if exchangeValue <= 0:
|
| | | return
|
| | | |
| | | if not PlayerControl.PayMoney(curPlayer, srcMoneyType, exchangeValue, "MoneyExchange"):
|
| | | return
|
| | | |
| | | tagMoneyAdd = exchangeValue * multiple
|
| | | PlayerControl.GiveMoney(curPlayer, tagMoneyType, tagMoneyAdd, "MoneyExchange")
|
| | | GameWorld.Log("货币兑换: srcMoneyType=%s,exchangeValue=%s,tagMoneyType=%s,tagMoneyAdd=%s" |
| | | % (srcMoneyType, exchangeValue, tagMoneyType, tagMoneyAdd), curPlayer.GetPlayerID())
|
| | | return
|
| | |
|
| | | #// A1 21 תְҵ #tagCMChangeJob
|
| | | #
|
| | | #struct tagCMChangeJob
|
| | |
| | | GameWorld.Log("付费金钱异常 TYPE_Price = %s" % (TYPE_Price), curPlayer.GetPlayerID())
|
| | | return False
|
| | |
|
| | | if needMoneyCount < Price:
|
| | | lackPrice = Price - needMoneyCount # 还缺多少钱
|
| | | tagMoneyInfo = GetEqualMoneyInfo(TYPE_Price, lackPrice)
|
| | | if tagMoneyInfo:
|
| | | tagMoneyType, tagMoneyValue = tagMoneyInfo
|
| | | if HaveMoney(curPlayer, tagMoneyType, tagMoneyValue, False):
|
| | | GameWorld.DebugLog("HaveMoney可使用等价货币补足扣除: TYPE_Price=%s, Price=%s, lackPrice=%s, tagMoneyType=%s, tagMoneyValue=%s" |
| | | % (TYPE_Price, Price, lackPrice, tagMoneyType, tagMoneyValue), curPlayer.GetPlayerID())
|
| | | return True
|
| | | |
| | | #---钱不够 返回假如果需要提示的话 提示信息---
|
| | | if needMoneyCount < Price:
|
| | | if needNotify and notifyCode:
|
| | | NotifyCode(curPlayer, notifyCode)
|
| | | GameWorld.DebugLog("货币不足: TYPE_Price=%s, Price=%s, curMoneyCount=%s" % (TYPE_Price, Price, needMoneyCount))
|
| | | return False
|
| | |
|
| | | return True
|
| | |
|
| | | def GetEqualMoneyInfo(moneyType, needValue):
|
| | | equalMoneyInfo = IpyGameDataPY.GetFuncEvalCfg("EqualValueMoney", 2, {})
|
| | | if str(moneyType) not in equalMoneyInfo:
|
| | | return
|
| | | tagMoneyType = equalMoneyInfo[str(moneyType)]
|
| | | exchangeMoneyInfo = IpyGameDataPY.GetFuncEvalCfg("EqualValueMoney", 1, {})
|
| | | if str(tagMoneyType) not in exchangeMoneyInfo:
|
| | | return
|
| | | exchangeInfo = exchangeMoneyInfo[str(tagMoneyType)]
|
| | | if moneyType != exchangeInfo[0]:
|
| | | return
|
| | | multiple = exchangeInfo[1]
|
| | | tagMoneyValue = int(math.ceil(needValue / float(multiple)))
|
| | | #GameWorld.DebugLog("等价货币信息: moneyType=%s,needValue=%s,multiple=%s,tagMoneyType=%s,tagMoneyValue=%s" |
| | | # % (moneyType, needValue, multiple, tagMoneyType, tagMoneyValue))
|
| | | return tagMoneyType, tagMoneyValue
|
| | |
|
| | | #---------------------------------------------------------------------
|
| | | ##玩家是否有钱款
|
| | |
| | | if price < 0:
|
| | | GameWorld.Log('###---扣钱异常 = %s' % (price), curPlayer.GetPlayerID())
|
| | | return False
|
| | | lostMoney = price
|
| | |
|
| | | #20190917 恢复绑玉
|
| | | # if type_Price == IPY_GameWorld.TYPE_Price_Gold_Paper:
|
| | |
| | | elif type_Price in ShareDefine.TYPE_Price_CurrencyDict:
|
| | | curCurrency = GetPlayerCurrency(curPlayer, type_Price)
|
| | | if curCurrency < price:
|
| | | lostMoney = curCurrency
|
| | | lackPrice = price - curCurrency # 还缺多少钱
|
| | | tagMoneyInfo = GetEqualMoneyInfo(type_Price, lackPrice)
|
| | | if tagMoneyInfo:
|
| | | tagMoneyType, tagMoneyValue = tagMoneyInfo
|
| | | if not PayMoney(curPlayer, tagMoneyType, tagMoneyValue, costType, infoDict, quantity, costVIPGold, isNotify, isMinus):
|
| | | #GameWorld.Log("等价货币也不足")
|
| | | return False
|
| | | GameWorld.Log("等价货币补足扣除: type_Price%s, price=%s, curCurrency=%s, lackPrice=%s, tagMoneyType=%s, tagMoneyValue=%s" |
| | | % (type_Price, price, curCurrency, lackPrice, tagMoneyType, tagMoneyValue), curPlayer.GetPlayerID())
|
| | | else:
|
| | | #GameWorld.Log("没有等价货币,无法扣除")
|
| | | return False
|
| | | #有足够的钱支付
|
| | | SetPlayerCurrency(curPlayer, type_Price, curCurrency - price)
|
| | | SetPlayerCurrency(curPlayer, type_Price, curCurrency - lostMoney)
|
| | | else:
|
| | | GameWorld.Log("付费金钱异常 type_Price = %s" % (type_Price), curPlayer.GetPlayerID())
|
| | | return False
|
| | |
|
| | | #付款以后后续操作
|
| | | __PayMoneyAfter(curPlayer, type_Price, price, costType, infoDict, quantity, costVIPGold)
|
| | | __PayMoneyAfter(curPlayer, type_Price, lostMoney, costType, infoDict, quantity, costVIPGold)
|
| | |
|
| | | #通知客户端失去金钱
|
| | | if isNotify:
|
| | | NotifyCode(curPlayer, "LostMoney", [type_Price, price])
|
| | | NotifyCode(curPlayer, "LostMoney", [type_Price, lostMoney])
|
| | | return True
|
| | |
|
| | | ## 付款以后后续操作
|