| | |
| | |
|
| | | return 0
|
| | |
|
| | | def GetMoneyReal(curPlayer, moneyType):
|
| | | ## 获取货币实际值,支持负值
|
| | | moneyMinus = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MoneyMinus % moneyType)
|
| | | if moneyMinus != 0:
|
| | | return -moneyMinus
|
| | | return GetMoney(curPlayer, moneyType)
|
| | |
|
| | | def SetMoney(curPlayer, moneyType, value):
|
| | | ## 设置货币值,支持负值
|
| | | if moneyType in ShareDefine.MoneyMinusRefreshDict:
|
| | | moneyMinus = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MoneyMinus % moneyType)
|
| | | if value < 0:
|
| | | if moneyMinus != value:
|
| | | SetMoneyMinus(curPlayer, moneyType, value)
|
| | | value = 0
|
| | | else:
|
| | | if moneyMinus != 0:
|
| | | SetMoneyMinus(curPlayer, moneyType, 0)
|
| | | |
| | | #金子
|
| | | if moneyType == IPY_GameWorld.TYPE_Price_Gold_Money:
|
| | | curPlayer.SetGold(value)
|
| | | |
| | | #金票
|
| | | elif moneyType == IPY_GameWorld.TYPE_Price_Gold_Paper:
|
| | | curPlayer.SetGoldPaper(value)
|
| | | |
| | | #银子
|
| | | elif moneyType == IPY_GameWorld.TYPE_Price_Silver_Money:
|
| | | SetSilver(curPlayer, value)
|
| | | |
| | | #银票
|
| | | elif moneyType == IPY_GameWorld.TYPE_Price_Silver_Paper:
|
| | | curPlayer.SetSilverPaper(value)
|
| | | |
| | | #自定义货币
|
| | | elif moneyType in ShareDefine.TYPE_Price_CurrencyDict:
|
| | | SetPlayerCurrency(curPlayer, moneyType, value)
|
| | | |
| | | return
|
| | |
|
| | | def SetMoneyMinus(curPlayer, moneyType, value):
|
| | | value = abs(value) # 存值及通知使用正数
|
| | | NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_MoneyMinus % moneyType, value)
|
| | | #通知客户端
|
| | | if moneyType not in ShareDefine.MoneyMinusRefreshDict:
|
| | | return
|
| | | refreshType = ShareDefine.MoneyMinusRefreshDict[moneyType]
|
| | | if refreshType != None:
|
| | | SendPropertyRefresh(curPlayer, refreshType, value)
|
| | | return
|
| | |
|
| | | ## 获取玩家仓库金钱数
|
| | | # @param curPlayer: 玩家实例
|
| | | # @param moneyType: 金钱类型
|
| | |
| | | # @param costType ,消费点类型
|
| | | # @param infoDict ,扩展信息, 子消费对象可以通过设置ChConfig.Def_Cost_Reason_SonKey key值
|
| | | # @param quantity ,数量
|
| | | # @param isMinus ,是否允许扣成负值
|
| | | # @return 返回值真, 付款成功
|
| | | # @remarks 玩家付款
|
| | | def PayMoney(curPlayer, type_Price, price, costType=ChConfig.Def_Cost_Unknown, infoDict={}, quantity=1, costVIPGold= -1, isNotify=True):
|
| | | def PayMoney(curPlayer, type_Price, price, costType=ChConfig.Def_Cost_Unknown, infoDict={}, quantity=1, costVIPGold= -1, isNotify=True, isMinus=False):
|
| | | if price == 0:
|
| | | return True
|
| | | if price < 0:
|
| | |
| | |
|
| | | #金子支付
|
| | | if type_Price == IPY_GameWorld.TYPE_Price_Gold_Money:
|
| | | curPlayerGold = curPlayer.GetGold()
|
| | | if curPlayerGold < price:
|
| | | curPlayerGold = GetMoneyReal(curPlayer, type_Price)
|
| | | if curPlayerGold < price and not isMinus:
|
| | | NotifyCode(curPlayer, "GoldErr")
|
| | | return False
|
| | | updPlayerGold = curPlayerGold - price
|
| | | curPlayer.SetGold(updPlayerGold)
|
| | | SetMoney(curPlayer, type_Price, updPlayerGold)
|
| | |
|
| | | curBourseMoney = GetMoney(curPlayer, ShareDefine.TYPE_Price_BourseMoney)
|
| | | updBourseMoney = curBourseMoney
|
| | |
| | | #其他如果当前金子比交易额度还少,则强制调整交易额度为当前金子数(这种情况一般是非交易所消费的,需要同步扣除交易所可购买额度)
|
| | | elif updPlayerGold < updBourseMoney:
|
| | | updBourseMoney = updPlayerGold
|
| | | updBourseMoney = max(0, updBourseMoney)
|
| | | if updBourseMoney != curBourseMoney:
|
| | | SetPlayerCurrency(curPlayer, ShareDefine.TYPE_Price_BourseMoney, updBourseMoney)
|
| | | infoDict["BourseMoney"] = updBourseMoney
|
| | |
|
| | | #金票支付
|
| | | elif type_Price == IPY_GameWorld.TYPE_Price_Gold_Paper:
|
| | | curPlayerGoldPaper = curPlayer.GetGoldPaper()
|
| | | if curPlayerGoldPaper < price:
|
| | | curPlayerGoldPaper = GetMoneyReal(curPlayer, type_Price)
|
| | | if curPlayerGoldPaper < price and not isMinus:
|
| | | NotifyCode(curPlayer, "GoldPaperErr")
|
| | | return False
|
| | | curPlayer.SetGoldPaper(curPlayerGoldPaper - price)
|
| | | |
| | | updGoldPaper = curPlayerGoldPaper - price
|
| | | SetMoney(curPlayer, type_Price, updGoldPaper)
|
| | | |
| | | #银子支付
|
| | | elif type_Price == IPY_GameWorld.TYPE_Price_Silver_Money:
|
| | | curPlayerSilver = GetSilver(curPlayer)
|
| | |
| | | return True
|
| | |
|
| | | if priceType == IPY_GameWorld.TYPE_Price_Gold_Money:
|
| | | if curPlayer.GetGold() + value > ChConfig.Def_PlayerTotalMoney_Gold:
|
| | | updPlayerGold = GetMoneyReal(curPlayer, priceType) + value
|
| | | if updPlayerGold > ChConfig.Def_PlayerTotalMoney_Gold:
|
| | | #超过金钱上限
|
| | | NotifyCode(curPlayer, "MoneyIsFull", [priceType])
|
| | | return
|
| | | SetMoney(curPlayer, priceType, updPlayerGold)
|
| | |
|
| | | curPlayer.SetGold(curPlayer.GetGold() + value)
|
| | | if isGiveBourseMoney and updPlayerGold > 0:
|
| | | GiveMoney(curPlayer, ShareDefine.TYPE_Price_BourseMoney, min(value, updPlayerGold))
|
| | | addDataDict["BourseMoney"] = GetMoney(curPlayer, ShareDefine.TYPE_Price_BourseMoney)
|
| | |
|
| | | if isGiveBourseMoney:
|
| | | GiveMoney(curPlayer, ShareDefine.TYPE_Price_BourseMoney, value)
|
| | | addDataDict["BourseMoney"] = GetMoney(curPlayer, ShareDefine.TYPE_Price_BourseMoney)
|
| | | |
| | | elif priceType == IPY_GameWorld.TYPE_Price_Gold_Paper:
|
| | | if curPlayer.GetGoldPaper() + value > ChConfig.Def_PlayerTotalMoney_Gold:
|
| | | updPlayerGoldPaper = GetMoneyReal(curPlayer, priceType) + value
|
| | | if updPlayerGoldPaper > ChConfig.Def_PlayerTotalMoney_Gold:
|
| | | #超过金钱上限
|
| | | NotifyCode(curPlayer, "MoneyIsFull", [priceType])
|
| | | return
|
| | | |
| | | curPlayer.SetGoldPaper(curPlayer.GetGoldPaper() + value)
|
| | | SetMoney(curPlayer, priceType, updPlayerGoldPaper)
|
| | |
|
| | | elif priceType == IPY_GameWorld.TYPE_Price_Silver_Money:
|
| | | # 金钱支持超过20亿, 暂不做上限控制
|