def selectProductByPayOrder(gameId, userId, clientId, payOrder): if ftlog.is_debug(): ftlog.debug('hallproductselector.selectProductByPayOrder gameId=', gameId, 'userId=', userId, 'clientId=', clientId, 'payOrder=', payOrder) return hallstore.findProductByPayOrder(gameId, userId, clientId, payOrder)
def sendMasterGiftTodoTask(userId, gameId, clientId, pic, pay_order, roomId): """ 推送高手礼包弹窗 @param pay_order 挑选商品模板 """ if not TYPlayer.isHuman(userId): return product, _ = hallstore.findProductByPayOrder(gameId, userId, clientId, pay_order) if not product: ftlog.error('userId =', userId, 'clientId =', clientId, 'pay_order =', pay_order, 'can not find suitable product!') return todotask = TodoTaskPayOrder(product) task = { 'action': 'cache_wnd_gaoshou', 'params': { 'pic': pic, 'tasks': [todotask.toDict()] } } mo = MsgPack() mo.setCmd('majiang_todotasks') mo.setResult('gameId', gameId) mo.setResult('userId', userId) mo.setResult('tasks', [task]) router.sendToUser(mo, userId)
def _doChangeNameTry(self, userId, clientId, newName): # renameConf = hallconf.getClientRenameConf(clientId) # if (renameConf # and not renameConf.get('containsSensitive', 1) # and keywords.isContains(newName)): # info = TodoTaskShowInfo(hallrename.stringRenameContainsSensitive) # return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, info) code, info = hallrename.tryRename(HALL_GAMEID, userId, newName) if ftlog.is_debug(): ftlog.debug('hallrename._doChangeNameTry->', code, info) if code == -3: # name not changed !! pass elif code == -2: # 没有改名卡 info = TodoTaskShowInfo(hallrename.stringRenameCardRequired, True) if hallrename.payOrder: product, _ = hallstore.findProductByPayOrder( HALL_GAMEID, userId, clientId, hallrename.payOrder) if product: info.setSubCmd(TodoTaskPayOrder(product)) return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, info) elif code == 0: # 改名成功 return TodoTaskHelper.sendTodoTask( HALL_GAMEID, userId, TodoTaskPopTip(hallrename.stringRenameSuccessed)) else: # SDK改名失败 return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, TodoTaskPopTip(info))
def _handleSigninFeeNotEnoughException(cls, room, ex, uid, mo): payOrder = ex.fee.getParam('payOrder') clientId = sessiondata.getClientId(uid) clientOs, _clientVer, _ = strutil.parseClientId(clientId) msg = runcmd.getMsgPack() ddzver = msg.getParam('ddzver', 0) if msg else 0 ftlog.debug("groupmatch._handleSigninFeeNotEnoughException", "userId", uid, "_clientVer=", _clientVer) if ddzver >= 3.772: cls._handleSigninFeeNotEnoughException_V3_772(room, ex, uid, mo) return if payOrder: clientOs = clientOs.lower() product, _shelves = hallstore.findProductByPayOrder(room.gameId, uid, clientId, payOrder) if product: buyType = '' btnTxt = '' if ex.fee.assetKindId == hallitem.ASSET_CHIP_KIND_ID and clientOs == 'winpc': user_diamond = userdata.getAttrInt(uid, 'diamond') if user_diamond >= int(product.priceDiamond): buyType = 'consume' btnTxt = '兑换' else: buyType = 'charge' btnTxt = '去充值' orderShow = TodoTaskOrderShow.makeByProduct(ex.fee.failure, '', product, buyType) orderShow.setParam('sub_action_btn_text', btnTxt) mo = TodoTaskHelper.makeTodoTaskMsg(room.gameId, uid, orderShow) router.sendToUser(mo, uid) return True mo = TodoTaskHelper.makeTodoTaskMsg(room.gameId, uid, TodoTaskShowInfo(ex.fee.failure)) router.sendToUser(mo, uid)
def selectProduct(gameId, userId, clientId, templateName, action): template = hallconf.getChargeLeadTemplate(templateName) if not template: return None, None payOrder = template.get(action) if not payOrder: if ftlog.is_debug(): ftlog.debug('hallproductselector.selectProduct gameId=', gameId, 'userId=', userId, 'clientId=', clientId, 'templateName=', templateName, 'template=', template, 'action=', action, 'err=', 'EmptyPayOrder') return None, None if ftlog.is_debug(): ftlog.debug('hallproductselector.selectProduct gameId=', gameId, 'userId=', userId, 'clientId=', clientId, 'templateName=', templateName, 'template=', template, 'action=', action, 'payOrder=', payOrder) return hallstore.findProductByPayOrder(gameId, userId, clientId, payOrder)
def recommendProductIfCan(self, gameId, userId): # 没有配置推荐商品,则不推荐 payOrder = Tool.dictGet(self._clientConf, 'config.server.payOrder') if not payOrder: return False clientId = sessiondata.getClientId(userId) product, _ = hallstore.findProductByPayOrder(gameId, userId, clientId, payOrder) ftlog.debug('FunAct.recommendProductIfCan:', 'userId=', userId, 'product=', product) # 没有在货架中找到商品 if not product: return False translateMap = { 'product.displayName': product.displayName, 'product.price': product.price, 'count': payOrder.get('contains', {}).get('count', 0) } desc = Tool.dictGet(self._clientConf, 'config.server.lessBuyChipDesc') note = Tool.dictGet(self._clientConf, 'config.server.lessBuyChipNote') desc = strutil.replaceParams(desc, translateMap) note = strutil.replaceParams(note, translateMap) todotask = TodoTaskLessBuyOrder(desc, None, note, product) TodoTaskHelper.sendTodoTask(gameId, userId, todotask) return True
def _handleSigninFeeNotEnoughException_V3_772(cls, room, ex, uid, mo): payOrder = ex.fee.getParam('payOrder') clientId = sessiondata.getClientId(uid) ftlog.debug("groupmatch._handleSigninFeeNotEnoughException_V3_772", "userId", uid, "fee.itemId=", ex.fee.assetKindId, "fee.params=", ex.fee.params) ftlog.debug("groupmatch._handleSigninFeeNotEnoughException_V3_772, userId=", uid, "payOrder=", payOrder) if payOrder: product, _shelves = hallstore.findProductByPayOrder(room.gameId, uid, clientId, payOrder) if not product: cls.sendDizhuFailureMsg(room.gameId, uid, '报名失败', ex.fee.failure, None) return buyType = '' btnTxt = '' if ex.fee.assetKindId == hallitem.ASSET_CHIP_KIND_ID: # 金币是报名费 orderShow = TodoTaskOrderShow.makeByProduct(ex.fee.failure, '', product, buyType) orderShow.setParam('sub_action_btn_text', btnTxt) mo = TodoTaskHelper.makeTodoTaskMsg(room.gameId, uid, orderShow) router.sendToUser(mo, uid) return ## 其他报名费/gotoshop todotask = ex.fee.getParam('todotask') todotask_str = None button_title = None ftlog.debug("groupmatch._handleSigninFeeNotEnoughException_V3_772, userId=", uid, "todotask=", todotask) if todotask: button_title = "去商城" todotask_str = hallpopwnd.decodeTodotaskFactoryByDict(todotask).newTodoTask(room.gameId, uid, clientId).toDict() cls.sendDizhuFailureMsg(room.gameId, uid, '报名失败', ex.fee.failure, todotask_str, button_title)
def sendBuyDiamondTodoTask(userId, gameId, clientId, pay_order): """ 幸运大抽奖,钻石购买 @param pay_order 挑选商品模板 """ if not TYPlayer.isHuman(userId): return product, _ = hallstore.findProductByPayOrder(gameId, userId, clientId, pay_order) if not product: ftlog.error('userId =', userId, 'clientId =', clientId, 'pay_order =', pay_order, 'can not find suitable product!') return try: product = product.clone() except: product = strutil.cloneData(product) desc = u'您的钻石不够哦~\n现在' + unicode(product.price) + u'元立得' + unicode( product.priceDiamond) + u'钻石!' product.content.desc = str(product.priceDiamond) + '钻石' client_ver = sessiondata.getClientIdVer(userId) if client_ver < 3.74: # 客户端bug,小于3.74的版本转换一下 product.priceDiamond = product.price todotasks = TodoTaskOrderShow.makeByProduct(desc, '', product) TodoTaskHelper.sendTodoTask(gameId, userId, todotasks)
def _doChangeNameTry(self, userId, clientId, newName): # renameConf = hallconf.getClientRenameConf(clientId) # if (renameConf # and not renameConf.get('containsSensitive', 1) # and keywords.isContains(newName)): # info = TodoTaskShowInfo(hallrename.stringRenameContainsSensitive) # return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, info) code, info = hallrename.tryRename(HALL_GAMEID, userId, newName) if ftlog.is_debug(): ftlog.debug('hallrename._doChangeNameTry->', code, info) if code == -3: # name not changed !! pass elif code == -2: # 没有改名卡 info = TodoTaskShowInfo(hallrename.stringRenameCardRequired, True) if hallrename.payOrder: product, _ = hallstore.findProductByPayOrder(HALL_GAMEID, userId, clientId, hallrename.payOrder) if product: info.setSubCmd(TodoTaskPayOrder(product)) return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, info) elif code == 0: # 改名成功 return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, TodoTaskPopTip(hallrename.stringRenameSuccessed)) else: # SDK改名失败 return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, TodoTaskPopTip(info))
def buildUpLevelTodoTasks(cls, gameId, userVip, clientId): deltaExp = userVip.deltaExpToNextLevel() if deltaExp > 0: payOrder = strutil.cloneData(hallvip.vipSystem.getLevelUpPayOrder()) payOrder['priceDiamond'] = {'count': deltaExp, 'minCount': 0, 'maxCount': -1} product, _ = hallstore.findProductByPayOrder(gameId, userVip.userId, clientId, payOrder) if product: return TodoTaskHelper.encodeTodoTasks(TodoTaskPayOrder(product)) return []
def _doChangeNameCheck(self, userId, clientId): canRename, desc = hallrename.checkRename(HALL_GAMEID, userId) if canRename: return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, TodoTaskRename(desc)) else: info = TodoTaskShowInfo(desc, True) if hallrename.payOrder: product, _ = hallstore.findProductByPayOrder(HALL_GAMEID, userId, clientId, hallrename.payOrder) if product: info.setSubCmd(TodoTaskPayOrder(product)) return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, info)
def _newTodoTask(self, gameId, userId, clientId, timestamp, **kwargs): product, _ = hallstore.findProductByPayOrder(gameId, userId, clientId, self.payOrder) if product: from hall.entity.hallstore import storeSystem canBuy = storeSystem.canBuyProduct(DIZHU_GAMEID, userId, clientId, product, 1) if not canBuy: if ftlog.is_debug(): ftlog.debug('DizhuTodoTaskLuckyBoxTemplate._newTodoTask not canBuy') return return TodoTaskLuckyBox(product) return None
def _doChangeNameTry(self, userId, clientId, newName): # renameConf = hallconf.getClientRenameConf(clientId) # if (renameConf # and not renameConf.get('containsSensitive', 1) # and keywords.isContains(newName)): # info = TodoTaskShowInfo(hallrename.stringRenameContainsSensitive) # return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, info) code, info = hallrename.tryRename(HALL_GAMEID, userId, newName) if ftlog.is_debug(): ftlog.debug('hallrename._doChangeNameTry->', code, info) CLIENT_VER = 4.57 _, clientVer, _ = strutil.parseClientId(clientId) if ftlog.is_debug(): ftlog.debug("_doChangeNameTry clientVer", userId, clientId, newName, code, info, clientVer) reInfo = "" if code == -3 : reInfo = "昵称没有变化" elif code == -2 : # 没有改名卡 info = TodoTaskShowInfo(hallrename.stringRenameCardRequired, True) if hallrename.payOrder: product, _ = hallstore.findProductByPayOrder(HALL_GAMEID, userId, clientId, hallrename.payOrder) if product: info.setSubCmd(TodoTaskPayOrder(product)) return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, info) elif code == 0 : reInfo = "昵称修改成功" # 改名成功 if clientVer < CLIENT_VER: if ftlog.is_debug(): ftlog.debug("_doChangeNameTry ok", userId, clientId, newName, code, info, clientVer) return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, TodoTaskPopTip(hallrename.stringRenameSuccessed)) else: #reInfo = "修改昵称失败,请重试" reInfo = info # SDK改名失败 if clientVer < CLIENT_VER: if ftlog.is_debug(): ftlog.debug("_doChangeNameTry fail", userId, clientId, newName, code, info, clientVer) return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, TodoTaskPopTip(info)) mo = MsgPack() mo.setCmd('change_name') mo.setResult('action', 'try') mo.setResult('userId', userId) mo.setResult('code', code) mo.setResult('reInfo', reInfo) router.sendToUser(mo, userId) if ftlog.is_debug(): ftlog.debug("_doChangeNameTry result",userId, clientId, newName, code, reInfo)
def getPray(cls, userId, foodId): ''' 获取奖励 ''' food = cls.getFood(foodId) if not food: return None, None if not cls.consumeExpenses(userId, food): ftlog.warn('WorshipHelper.getPray', 'userId=', userId, 'foodId=', foodId, 'userChip=', userchip.getChip(userId), 'consumeChip=', food.chip) payOrder = { "contains": { "count": userchip.getChip(userId), "itemId": "user:chip" }, "shelves": [ "lessbuychip" ] } clientId = sessiondata.getClientId(userId) product, _shelves = hallstore.findProductByPayOrder(DIZHU_GAMEID, userId, clientId, payOrder) if not product: Alert.sendNormalAlert(DIZHU_GAMEID, userId, '金币不足', '金币不足了, 请去充值吧', None, None) return None, None buyType = '' orderShow = TodoTaskOrderShow.makeByProduct('金币不足', '', product, buyType) orderShow.setParam('sub_action_btn_text', '确定') mo = TodoTaskHelper.makeTodoTaskMsg(DIZHU_GAMEID, userId, orderShow) router.sendToUser(mo, userId) return None, None # 更新用户花费 cls.updateUserCost(userId, food.chip) # 拜到的奖励 prayChip = food.choiceReward() UserBag.sendAssetsToUser(DIZHU_GAMEID, userId, {'itemId': 'user:chip', 'count': prayChip}, 'DDZ_WORSHIP_SYSTEM') # 保存的消息 msg = cls.getMessageByFoodId(foodId) cls.pushRecord(strutil.dumps({ 'userId': userId, 'msg': msg, 'chip': prayChip, 'costChip': food.chip, })) return {'chip': prayChip, 'msg': msg, 'costChip': food.chip}, userchip.getChip(userId)
def newTodoTask(self, gameId, userId, clientId, timestamp, **kwargs): subMemberStatus = kwargs.get( 'subMemberStatus') or hallsubmember.loadSubMemberStatus(userId) if subMemberStatus.isSub: todotask = TodoTaskMemberBuy(self.descForMember, self.pic) todotask.setParam('tip_bottom', self.tipForSubMember) return todotask memberInfo = kwargs.get('memberInfo') or hallitem.getMemberInfo( userId, timestamp) remainDays = memberInfo[0] todotask = None subActionText = None product, _ = hallstore.findProductByPayOrder(gameId, userId, clientId, self.payOrder) if not product: return None if remainDays > 0: todotask = TodoTaskMemberBuy(self.descForMember, self.pic) tipForMember = strutil.replaceParams(self.tipForMember, {'remainDays': str(remainDays)}) todotask.setParam('tip_bottom_left', tipForMember) todotask.setParam('sub_action_text', self.subActionTextForMember) else: price = product.price priceUnits = '元' if product.buyType == 'consume': price = product.priceDiamond priceUnits = '钻石' params = { 'product.price': str(price), 'product.priceUnits': priceUnits } if product.content and product.content.desc: params['product.content.desc'] = product.content.desc desc = strutil.replaceParams(self.desc, params) todotask = TodoTaskMemberBuy(desc, self.pic) todotask.setSubText(self.subActionText) todotask.setParam('sub_action_text', self.subActionText) todotask.setSubCmdWithText(TodoTaskPayOrder(product), subActionText) if remainDays <= 0 and self.closeAction: closeAction = decodeTodotaskFactoryByDict( self.closeAction).newTodoTask(gameId, userId, clientId, **kwargs) if closeAction: todotask.setParam('sub_action_close', closeAction) return todotask
def _handleSigninFeeNotEnoughException_V3_772(self, ex, userId, mo): payOrder = ex.fee.getParam('payOrder') clientId = sessiondata.getClientId(userId) if ftlog.is_debug(): ftlog.debug('DizhuCtrlRoomGroupMatch._handleSigninFeeNotEnoughException_V3_772', 'roomId=', self.roomId, 'userId=', userId, 'feeItem=', ex.fee.assetKindId, 'feeParams=', ex.fee.params) if payOrder: product, _shelves = hallstore.findProductByPayOrder(self.gameId, userId, clientId, payOrder) if not product: self.sendDizhuFailureMsg(self.gameId, userId, '报名失败', ex.fee.failure, None) return buyType = '' btnTxt = '' if ex.fee.assetKindId == hallitem.ASSET_CHIP_KIND_ID or ex.fee.assetKindId == hallitem.ASSET_DIAMOND_KIND_ID: buyType = 'charge' btnTxt = '确定' orderShow = TodoTaskOrderShow.makeByProduct(ex.fee.failure, '', product, buyType, ex.fee.count, ex.fee.assetKindId) orderShow.setParam('sub_action_btn_text', btnTxt) mo = TodoTaskHelper.makeTodoTaskMsg(self.gameId, userId, orderShow) router.sendToUser(mo, userId) return ## 其他报名费/gotoshop title = '报名失败' todotask = ex.fee.getParam('todotask') todotask_str = None button_title = None if todotask: button_title = "去商城" todotaskObj = hallpopwnd.decodeTodotaskFactoryByDict(todotask).newTodoTask(self.gameId, userId, clientId) if todotaskObj: todotask_str = todotaskObj.toDict() itemCount = 0 itemName = '' itemDes = '' itemUrl = '' if 'item' in ex.fee.assetKindId and ex.fee.count > 0: assetKind = hallitem.itemSystem.findAssetKind(ex.fee.assetKindId) if assetKind: title = '道具不足' itemCount = ex.fee.count itemName = assetKind.displayName itemDes = assetKind.desc itemUrl = assetKind.pic self.sendDizhuFailureMsg(self.gameId, userId, title, ex.fee.failure, todotask_str, button_title, itemCount, itemName, itemDes, itemUrl)
def handleItemBindingsException(self, itemId, gameId, userId, clientId, e): showInfo = TodoTaskShowInfo(e.message) payOrder = e.itemBindings.getParam('payOrder') if payOrder: product, shelves = hallstore.findProductByPayOrder(gameId, userId, clientId, payOrder) if product: showInfo.setSubCmd(TodoTaskGotoShop(shelves.name)) else: todotask = e.itemBindings.getParam('todotask') if todotask: todotask = TodoTaskRegister.decodeFromDict(todotask).newTodoTask(gameId, userId, clientId) TodoTaskHelper.sendTodoTask(gameId, userId, todotask) return TodoTaskHelper.sendTodoTask(gameId, userId, showInfo)
def buildUpLevelTodoTasks(cls, gameId, userVip, clientId): deltaExp = userVip.deltaExpToNextLevel() if deltaExp > 0: payOrder = strutil.cloneData( hallvip.vipSystem.getLevelUpPayOrder()) payOrder['priceDiamond'] = { 'count': deltaExp, 'minCount': 0, 'maxCount': -1 } product, _ = hallstore.findProductByPayOrder( gameId, userVip.userId, clientId, payOrder) if product: return TodoTaskHelper.encodeTodoTasks( TodoTaskPayOrder(product)) return []
def handleItemBindingsException(self, itemId, gameId, userId, clientId, e): showInfo = TodoTaskShowInfo(e.message) payOrder = e.itemBindings.getParam('payOrder') if payOrder: product, shelves = hallstore.findProductByPayOrder( gameId, userId, clientId, payOrder) if product: showInfo.setSubCmd(TodoTaskGotoShop(shelves.name)) else: todotask = e.itemBindings.getParam('todotask') if todotask: todotask = TodoTaskRegister.decodeFromDict( todotask).newTodoTask(gameId, userId, clientId) TodoTaskHelper.sendTodoTask(gameId, userId, todotask) return TodoTaskHelper.sendTodoTask(gameId, userId, showInfo)
def handleItemActionConditionException(self, itemId, gameId, userId, clientId, e): showInfo = TodoTaskShowInfo(e.message) payOrder = e.condition.getParam('payOrder') if payOrder: product, shelves = hallstore.findProductByPayOrder(gameId, userId, clientId, payOrder) if product: showInfo.setSubCmd(TodoTaskGotoShop(shelves.name)) else: todotask = e.condition.getParam('todotask') if todotask: factory = hallpopwnd.decodeTodotaskFactoryByDict(todotask) if factory: todotask = factory.newTodoTask(gameId, userId, clientId) TodoTaskHelper.sendTodoTask(gameId, userId, todotask) return TodoTaskHelper.sendTodoTask(gameId, userId, showInfo)
def doQuickBuyGetInfo(self, gameId, userId): clientId = sessiondata.getClientId(userId) toStoreTodotask = TodoTaskGotoShop('coin') if hallstore.storeSystem.isCloseLastBuy(clientId): TodoTaskHelper.sendTodoTask(gameId, userId, toStoreTodotask) return lastBuyProduct, _lastBuyClientId = hallstore.storeSystem.getLastBuyProduct( gameId, userId) if (not lastBuyProduct or not lastBuyProduct.recordLastBuy or not hallstore.storeSystem.canBuyProduct( gameId, userId, clientId, lastBuyProduct, 1)): if hallstore.storeSystem.lastBuyConf.payOrder: product, _ = hallstore.findProductByPayOrder( gameId, userId, clientId, hallstore.storeSystem.lastBuyConf.payOrder) if product: payOrderTodoTask = TodoTaskPayOrder(product) desc = strutil.replaceParams( hallstore.storeSystem.lastBuyConf.desc2, { 'product.displayName': product.displayName, 'product.price': product.price }) popInfoTodoTask = TodoTaskShowInfo(desc, True) popInfoTodoTask.setSubCmd(payOrderTodoTask) TodoTaskHelper.sendTodoTask(gameId, userId, popInfoTodoTask) return TodoTaskHelper.sendTodoTask(gameId, userId, toStoreTodotask) return payOrderTodoTask = TodoTaskPayOrder(lastBuyProduct) desc = strutil.replaceParams( hallstore.storeSystem.lastBuyConf.desc, { 'product.displayName': lastBuyProduct.displayName, 'product.price': lastBuyProduct.price }) popInfoTodoTask = TodoTaskShowInfo(desc, True) popInfoTodoTask.setSubCmd(payOrderTodoTask) popInfoTodoTask.setSubText(hallstore.storeSystem.lastBuyConf.subText) popInfoTodoTask.setSubCmdExt(toStoreTodotask) popInfoTodoTask.setSubTextExt( hallstore.storeSystem.lastBuyConf.subTextExt) TodoTaskHelper.sendTodoTask(gameId, userId, popInfoTodoTask)
def getConfigForClient(self, gameId, userId, clientId): """ 预期实现功能。配置中,配置payOrder后台自动生成该商品的todotask """ clientConf = strutil.cloneData(self._clientConf) payOrder = clientConf["config"]["button"]["payOrder"] product, _ = hallstore.findProductByPayOrder(gameId, userId, clientId, payOrder) ftlog.debug("TYActivitySale product: ", product) payOrder = TodoTaskPayOrder(product) ftlog.debug("TYActivitySale params: ", payOrder) try: clientConf["config"]["button"]["todoTask"] = payOrder.toDict() except: ftlog.exception("getConfigForClient error, can not set todotask, clientId:", clientId) return None return clientConf
def handleItemActionConditionException(self, itemId, gameId, userId, clientId, e): showInfo = TodoTaskShowInfo(e.message) payOrder = e.condition.getParam('payOrder') if payOrder: product, shelves = hallstore.findProductByPayOrder( gameId, userId, clientId, payOrder) if product: showInfo.setSubCmd(TodoTaskGotoShop(shelves.name)) else: todotask = e.condition.getParam('todotask') if todotask: factory = hallpopwnd.decodeTodotaskFactoryByDict(todotask) if factory: todotask = factory.newTodoTask(gameId, userId, clientId) TodoTaskHelper.sendTodoTask(gameId, userId, todotask) return TodoTaskHelper.sendTodoTask(gameId, userId, showInfo)
def newTodoTask(self, gameId, userId, clientId, timestamp, **kwargs): subMemberStatus = kwargs.get('subMemberStatus') or hallsubmember.loadSubMemberStatus(userId) if subMemberStatus.isSub: todotask = TodoTaskMemberBuy(self.descForMember, self.pic) todotask.setParam('tip_bottom', self.tipForSubMember) return todotask memberInfo = kwargs.get('memberInfo') or hallitem.getMemberInfo(userId, timestamp) remainDays = memberInfo[0] todotask = None subActionText = None product, _ = hallstore.findProductByPayOrder(gameId, userId, clientId, self.payOrder) if not product: return None if remainDays > 0: todotask = TodoTaskMemberBuy(self.descForMember, self.pic) tipForMember = strutil.replaceParams(self.tipForMember, {'remainDays': str(remainDays)}) todotask.setParam('tip_bottom_left', tipForMember) todotask.setParam('sub_action_text', self.subActionTextForMember) else: price = product.price priceUnits = '元' if product.buyType == 'consume': price = product.priceDiamond priceUnits = '钻石' params = {'product.price': str(price), 'product.priceUnits': priceUnits} if product.content and product.content.desc: params['product.content.desc'] = product.content.desc desc = strutil.replaceParams(self.desc, params) todotask = TodoTaskMemberBuy(desc, self.pic) todotask.setSubText(self.subActionText) todotask.setParam('sub_action_text', self.subActionText) todotask.setSubCmdWithText(TodoTaskPayOrder(product), subActionText) if remainDays <= 0 and self.closeAction: closeAction = decodeTodotaskFactoryByDict(self.closeAction).newTodoTask(gameId, userId, clientId, **kwargs) if closeAction: todotask.setParam('sub_action_close', closeAction) return todotask
def payOrder(payOrderParams, userId, failure): ''' 比赛报名费不足的充值引导 ''' ftlog.debug('userId:', userId , ' payOrderParams:', payOrderParams , ' failure:', failure) clientId = sessiondata.getClientId(userId) product, _shelves = hallstore.findProductByPayOrder(DIZHU_GAMEID, userId, clientId, payOrderParams) ftlog.debug('product:', product , ' shelves:', _shelves) if not product: return False orderShow = TodoTaskOrderShow.makeByProduct(failure, '', product, '') mo = TodoTaskHelper.makeTodoTaskMsg(DIZHU_GAMEID, userId, orderShow) router.sendToUser(mo, userId) return True
def recommendProductIfNeed(self, gameId, userId, chip): # 当前金币足够则不用推荐商品 curchip = userchip.getChip(userId) ftlog.debug('BetGuess.recommendProductIfNeed:', 'userId=', userId, 'curchip=', curchip, 'chip=', chip) if curchip >= chip: return False # 没有配置推荐商品,则不推荐 payOrderMap = Tool.dictGet(self._clientConf, 'config.server.payOrderMap') if not payOrderMap: return False # 没有找到推荐商品配置,则不推荐 payOrder = payOrderMap.get(str(int(chip))) ftlog.debug('BetGuess.recommendProductIfNeed:', 'userId=', userId, 'payOrder=', payOrder) if not payOrder: return False clientId = sessiondata.getClientId(userId) product, _ = hallstore.findProductByPayOrder(gameId, userId, clientId, payOrder) ftlog.debug('BetGuess.recommendProductIfNeed:', 'userId=', userId, 'product=', product) # 没有在货架中找到商品 if not product: return False translateMap = { 'product.displayName': product.displayName, 'product.price': product.price, 'betchip': chip, } desc = Tool.dictGet(self._clientConf, 'config.server.lessBuyChipDesc') note = Tool.dictGet(self._clientConf, 'config.server.lessBuyChipNote') desc = strutil.replaceParams(desc, translateMap) note = strutil.replaceParams(note, translateMap) todotask = TodoTaskLessBuyOrder(desc, None, note, product) TodoTaskHelper.sendTodoTask(gameId, userId, todotask) return True
def _handleSigninFeeNotEnoughException(self, ex, userId, mo): payOrder = ex.fee.getParam('payOrder') clientId = sessiondata.getClientId(userId) clientOs, _clientVer, _ = strutil.parseClientId(clientId) msg = runcmd.getMsgPack() ddzver = msg.getParam('ddzver', 0) if msg else 0 if ftlog.is_debug(): ftlog.debug( 'DizhuErdayiMatchCtrlRoom._handleSigninFeeNotEnoughException', 'roomId=', self.roomId, 'userId=', userId, 'feeItem=', ex.fee.assetKindId, 'feeParams=', ex.fee.params) if ddzver >= 3.772: self._handleSigninFeeNotEnoughException_V3_772(ex, userId, mo) return if payOrder: clientOs = clientOs.lower() product, _shelves = hallstore.findProductByPayOrder( self.gameId, userId, clientId, payOrder) if product: buyType = '' btnTxt = '' if ex.fee.assetKindId == hallitem.ASSET_CHIP_KIND_ID and clientOs == 'winpc': user_diamond = userdata.getAttrInt(userId, 'diamond') if user_diamond >= int(product.priceDiamond): buyType = 'consume' btnTxt = '兑换' else: buyType = 'charge' btnTxt = '去充值' orderShow = TodoTaskOrderShow.makeByProduct( ex.fee.failure, '', product, buyType) orderShow.setParam('sub_action_btn_text', btnTxt) mp = TodoTaskHelper.makeTodoTaskMsg(self.gameId, userId, orderShow) router.sendToUser(mp, userId) return True mp = TodoTaskHelper.makeTodoTaskMsg(self.gameId, userId, TodoTaskShowInfo(ex.fee.failure)) router.sendToUser(mp, userId)
def _caleLuckyItemArgsByUser(userId, bigRoomId, winUserIds, winStreak, slam, chuntian, clientId): lucky_args = {} if userId in winUserIds: conf = dizhuconf.getRoomWinLosePayInfo(bigRoomId, clientId) if not conf: conf = {} payOrder = None if chuntian > 1 and ('spring' in conf): payOrder = conf['spring'] if winStreak >= 3 and ('winstreak' in conf): payOrder = conf['winstreak'] if slam == 1 and ('slam' in conf): payOrder = conf['slam'] if payOrder: product, _ = hallstore.findProductByPayOrder( DIZHU_GAMEID, userId, clientId, payOrder) if product: lucky_args = TodoTaskHelper.getParamsByProduct(product) return lucky_args
def _handleSigninFeeNotEnoughException_V3_772(self, ex, userId, mo): payOrder = ex.fee.getParam('payOrder') clientId = sessiondata.getClientId(userId) if ftlog.is_debug(): ftlog.debug( 'DizhuErdayiMatchCtrlRoomProtocol._handleSigninFeeNotEnoughException_V3_772', 'roomId=', self.roomId, 'userId=', userId, 'feeItem=', ex.fee.assetKindId, 'feeParams=', ex.fee.params) if payOrder: product, _shelves = hallstore.findProductByPayOrder( self.gameId, userId, clientId, payOrder) if not product: self._sendDizhuFailureMsg(self.gameId, userId, '报名失败', ex.fee.failure, None) return buyType = '' btnTxt = '' if ex.fee.assetKindId == hallitem.ASSET_CHIP_KIND_ID or ex.fee.assetKindId == hallitem.ASSET_DIAMOND_KIND_ID: buyType = 'charge' btnTxt = '确定' orderShow = TodoTaskOrderShow.makeByProduct( ex.fee.failure, '', product, buyType) orderShow.setParam('sub_action_btn_text', btnTxt) mo = TodoTaskHelper.makeTodoTaskMsg(self.gameId, userId, orderShow) router.sendToUser(mo, userId) return ## 其他报名费/gotoshop todotask = ex.fee.getParam('todotask') todotask_str = None button_title = None if todotask: button_title = "去商城" todotaskObj = hallpopwnd.decodeTodotaskFactoryByDict( todotask).newTodoTask(self.gameId, userId, clientId) if todotaskObj: todotask_str = todotaskObj.toDict() self._sendDizhuFailureMsg(self.gameId, userId, '报名失败', ex.fee.failure, todotask_str, button_title)
def sendBuyDiamondTodoTask(userId, gameId, clientId, pay_order): """ 幸运大抽奖,钻石购买 @param pay_order 挑选商品模板 """ if not TYPlayer.isHuman(userId): return product, _ = hallstore.findProductByPayOrder(gameId, userId, clientId, pay_order) if not product: ftlog.error('userId =', userId, 'clientId =', clientId, 'pay_order =', pay_order, 'can not find suitable product!') return try: product = product.clone() except: product = strutil.cloneData(product) desc = u'您的钻石不够哦~\n现在' + unicode(product.price) +u'元立得' + unicode(product.priceDiamond) +u'钻石!' product.content.desc = str(product.priceDiamond) + '钻石' client_ver = sessiondata.getClientIdVer(userId) if client_ver < 3.74: # 客户端bug,小于3.74的版本转换一下 product.priceDiamond = product.price todotasks = TodoTaskOrderShow.makeByProduct(desc, '', product) TodoTaskHelper.sendTodoTask(gameId, userId, todotasks)
def doQuickBuyGetInfo(self, gameId, userId): clientId = sessiondata.getClientId(userId) toStoreTodotask = TodoTaskGotoShop('coin') if hallstore.storeSystem.isCloseLastBuy(clientId): TodoTaskHelper.sendTodoTask(gameId, userId, toStoreTodotask) return lastBuyProduct, _lastBuyClientId = hallstore.storeSystem.getLastBuyProduct(gameId, userId) if (not lastBuyProduct or not lastBuyProduct.recordLastBuy or not hallstore.storeSystem.canBuyProduct(gameId, userId, clientId, lastBuyProduct, 1)): if hallstore.storeSystem.lastBuyConf.payOrder: product, _ = hallstore.findProductByPayOrder(gameId, userId, clientId, hallstore.storeSystem.lastBuyConf.payOrder) if product: payOrderTodoTask = TodoTaskPayOrder(product) desc = strutil.replaceParams(hallstore.storeSystem.lastBuyConf.desc2, {'product.displayName': product.displayName, 'product.price': product.price}) popInfoTodoTask = TodoTaskShowInfo(desc, True) popInfoTodoTask.setSubCmd(payOrderTodoTask) TodoTaskHelper.sendTodoTask(gameId, userId, popInfoTodoTask) return TodoTaskHelper.sendTodoTask(gameId, userId, toStoreTodotask) return payOrderTodoTask = TodoTaskPayOrder(lastBuyProduct) desc = strutil.replaceParams(hallstore.storeSystem.lastBuyConf.desc, {'product.displayName': lastBuyProduct.displayName, 'product.price': lastBuyProduct.price}) popInfoTodoTask = TodoTaskShowInfo(desc, True) popInfoTodoTask.setSubCmd(payOrderTodoTask) popInfoTodoTask.setSubText(hallstore.storeSystem.lastBuyConf.subText) popInfoTodoTask.setSubCmdExt(toStoreTodotask) popInfoTodoTask.setSubTextExt(hallstore.storeSystem.lastBuyConf.subTextExt) TodoTaskHelper.sendTodoTask(gameId, userId, popInfoTodoTask)
def getFishReward(cls, userId, baitId): # 钓到没钓到标志 rewardCount = 0 record = '' fishPic = '' couponFishPic = '' exchangeDes = '' deltaChip = 0 deltaCouponCount = 0 # 检查用户Id, baitId 是否匹配, 获取 bait 消费金币 userName = str(userdata.getAttrs(userId, ['name'])[0]) bait = cls.getBait(baitId) consumeChip = bait.chip if bait else 0 if not consumeChip or not cls.consumeExpenses( userId, TYContentItem.decodeFromDict({ 'itemId': 'user:chip', 'count': consumeChip })): ftlog.warn('FishHelper.getFishReward', 'userId=', userId, 'baitId=', baitId, 'userChip=', userchip.getChip(userId), 'consumeChip=', consumeChip) payOrder = { "contains": { "count": userchip.getChip(userId), "itemId": "user:chip" }, "shelves": ["lessbuychip"] } clientId = sessiondata.getClientId(userId) product, _shelves = hallstore.findProductByPayOrder( DIZHU_GAMEID, userId, clientId, payOrder) if not product: Alert.sendNormalAlert(DIZHU_GAMEID, userId, '金币不足', '金币不足了, 请去充值吧', None, None) return buyType = '' orderShow = TodoTaskOrderShow.makeByProduct( '金币不足', '', product, buyType) orderShow.setParam('sub_action_btn_text', '确定') mo = TodoTaskHelper.makeTodoTaskMsg(DIZHU_GAMEID, userId, orderShow) router.sendToUser(mo, userId) return # 随机获得珍珠, 存入数据库 couponFish = cls.getCouponFishList()[0] # 判断鱼饵有没有奖券鱼的配置 item = dizhu_util.getItemByWeight( bait.couponFishRewards) if bait.couponFishRewards else None couponCount = item.count if item else 0 count = loadUserFishingCount(userId, couponFish.id) if couponCount: assetKind = hallitem.itemSystem.findAssetKind('user:coupon') couponCount = couponCount * 1.0 / assetKind.displayRate couponCount = int(couponCount) if couponCount.is_integer( ) else round(couponCount, 2) rewardCount += 1 count += 1 couponFishPic = couponFish.pic if count >= couponFish.needNum: count = 0 # 发送奖券 dictionary = { 'zhenzhu_count': couponFish.needNum, 'coupon_count': couponCount } record = json.dumps( cls.getRealUserMail(cls.getMail(couponFish, True, False), dictionary)) exchangeDes = json.dumps( cls.getRealUserMail(cls.getMail(couponFish, True, True), dictionary)) dictionary2 = { 'user_name': userName, 'zhenzhu_count': couponFish.needNum, 'coupon_count': couponCount } record2 = json.dumps( cls.getRealUserMail(cls.getMail(couponFish, False, True), dictionary2)) saveUserFishingCount(userId, couponFish.id, count) UserBag.sendAssetsToUser(DIZHU_GAMEID, userId, { 'itemId': item.assetKindId, 'count': item.count }, 'DDZ_FISHING_SYSTEM') deltaCouponCount = item.count cls.pushRecord(record2) if ftlog.is_debug(): ftlog.debug('FishHelper.getFishReward coupon exchangeDes', 'userId=', userId, 'fishId=', couponFish.id, 'exchangeDes=', exchangeDes) else: # 获得一个奖券鱼 dictionary = { 'zhenzhu_count': couponFish.needNum, 'coupon_count': couponCount } record = json.dumps( cls.getRealUserMail(cls.getMail(couponFish, True, False), dictionary)) dictionary2 = { 'user_name': userName, 'zhenzhu_count': couponFish.needNum, 'coupon_count': couponCount } record2 = json.dumps( cls.getRealUserMail(cls.getMail(couponFish, False, False), dictionary2)) saveUserFishingCount(userId, couponFish.id, count) cls.pushRecord(record2) if ftlog.is_debug(): ftlog.debug('FishHelper.getFishReward coupon', 'userId=', userId, 'fishId=', couponFish.id, 'record=', record) # 随机获取金币奖励,对应bait下普通鱼 userBaits = filter(lambda x: x.id == baitId, _fishingConf.baits) fish = userBaits[0].choiceFish() if fish.id: # 钓到鱼了 reward = fish.choiceReward() chip = reward.count if chip: rewardCount += 1 bigFish = cls.getSuperFishList()[0] bigReward = dizhu_util.getItemByWeight( bait.superFishRewards) if bait.superFishRewards else None if bigReward and bigReward.count and fish.id == bait.fishList[ -1].id: # roll 大鱼的机会 fish = bigFish chip = bigReward.count fishPic = fish.pic dictionary = { 'random_message': cls.getMessageByFishId(fish.id), 'fish_name': fish.name, 'chip_count': chip } if rewardCount == 2: record = json.dumps( cls.getRealUserMail(cls.getCombinationMail(), dictionary)) else: record = json.dumps( cls.getRealUserMail(cls.getMail(fish, True), dictionary)) dictionary2 = { 'user_name': userName, 'fish_name': fish.name, 'chip_count': chip, 'random_message': cls.getMessageByFishId(fish.id) } record2 = json.dumps( cls.getRealUserMail(cls.getMail(fish, False), dictionary2)) UserBag.sendAssetsToUser(DIZHU_GAMEID, userId, { 'itemId': 'user:chip', 'count': chip }, 'DDZ_FISHING_SYSTEM') cls.pushRecord(record2) deltaChip = chip if ftlog.is_debug(): ftlog.debug('FishHelper.getFishReward', 'userId=', userId, 'fishId=', fish.id, 'record=', record) return { 'rewardCount': rewardCount, 'desc': json.loads(record) if rewardCount and record else cls.getailureMail(), 'couponFishPic': couponFishPic, 'fishPic': fishPic, 'exchangeDes': json.loads(exchangeDes) if exchangeDes else '', 'finalCouponCount': userdata.getAttr(userId, 'coupon'), 'finalChip': userchip.getChip(userId), 'couponFishCount': count, 'deltaChip': deltaChip, 'deltaCouponCount': deltaCouponCount }
def _do_room__revival(self, msg): userId = msg.getParam('userId') isOK = msg.getParam('isOk', 0) player = self.match.findPlayer(userId) reviveCondition = player.stage.stageConf.reviveCondition if player and reviveCondition: itemId = reviveCondition.get('fee', {}).get('itemId') count = reviveCondition.get('fee', {}).get('count') if itemId and count and isOK: userAssets = hallitem.itemSystem.loadUserAssets(player.userId) timestamp = pktimestamp.getCurrentTimestamp() balance = userAssets.balance(HALL_GAMEID, itemId, timestamp) if balance and balance >= count: _, consumeCount, _ = userAssets.consumeAsset(DIZHU_GAMEID, itemId, count, timestamp, 'MATCH_REVIVE', 0) if consumeCount == count: # 消费成功, 考虑锁的关系,时间竞争 ret = self.match.currentInstance.doUserRevive(player, True) if not ret: # 退费 userAssets.addAsset(DIZHU_GAMEID, itemId, count, timestamp, 'MATCH_REVIVE', 0) ftlog.info('DizhuCtrlRoomArenaMatch._do_room__m_revive returnFee', 'gameId=', self.gameId, 'roomId=', self.roomId, 'userId=', userId, 'stageIndex=', player.stage.index, 'reviveCondition=', reviveCondition) if ret: # 日志记录 try: sequence = int(player.matchInst.instId.split('.')[1]) matchutil.report_bi_game_event('MATCH_REVIVE', player.userId, player.matchInst.matchId, 0, sequence, 0, 0, 0, [int(player.mixId) if player.mixId else 0, player.stage.index, count], 'match_revive') ftlog.info('DizhuCtrlRoomArenaMatch._do_room__m_revive success', 'gameId=', self.gameId, 'roomId=', self.roomId, 'userId=', userId, 'stageIndex=', player.stage.index, 'reviveCondition=', reviveCondition) except Exception, e: ftlog.error('DizhuCtrlRoomArenaMatch._do_room__m_revive', 'gameId=', self.gameId, 'userId=', userId, 'err=', e.message) else: # 发送不够的todotask payOrder = reviveCondition.get('fee', {}).get('params', {}).get('payOrder') failure = reviveCondition.get('fee', {}).get('params', {}).get('failure') mo = TodoTaskHelper.makeTodoTaskMsg(self.gameId, player.userId, TodoTaskShowInfo(failure)) if payOrder: clientId = sessiondata.getClientId(player.userId) product, _shelves = hallstore.findProductByPayOrder(self.gameId, player.userId, clientId, payOrder) if product: orderShow = TodoTaskOrderShow.makeByProduct(failure, '', product, 'charge', reviveCondition.get('fee', {}).get('count', 0), reviveCondition.get('fee', {}).get('itemId', '')) orderShow.setParam('sub_action_btn_text', '购买') mo = TodoTaskHelper.makeTodoTaskMsg(self.gameId, player.userId, orderShow) router.sendToUser(mo, userId) else: self.match.currentInstance.doUserRevive(player, False)
def _openCardNote(self, seat): # 比赛场局记牌器在下发此消息时扣除背包金币,非比赛场局记牌器在结算时扣除带入金币 #self.isMatch or self.table.runConf.cardNoteChipConsumeUserChip: if seat.player.getCardNoteCount() <= 0: cardNoteDiamondCount = seat.player.mixConf.get( 'tableConf', {}).get('cardNoteDiamond', 0) try: if cardNoteDiamondCount == 0: trueDelta, _final = user_remote.incrUserChip( seat.userId, self.table.gameId, -seat.player.mixConf.get('tableConf', {}).get( 'cardNoteChip', 0), 'MATCH_CARDNOTE_BETCHIP', 0, seat.player.clientId) if ftlog.is_debug(): ftlog.debug( 'DizhuTableCtrlMix._openCardNote', 'tableId=', self.tableId, 'userId=', seat.userId, 'cardNoteChip=', seat.player.mixConf.get('tableConf', {}).get('cardNoteChip', 0), 'chip=', seat.player.datas.get('chip')) if trueDelta != -seat.player.mixConf.get( 'tableConf', {}).get('cardNoteChip', 0): if ftlog.is_debug(): ftlog.warn('DizhuTableCtrlMix._openCardNote', 'tableId=', self.tableId, 'userId=', seat.userId, 'cardNoteCount=', seat.player.getCardNoteCount(), 'chip=', seat.player.datas.get('chip'), 'err=', 'ChipNotEnough') return else: # 钻石购买 10钻石 = 1日记牌器 # 兼容pc端 clientOs, clientVer, _ = strutil.parseClientId( seat.player.clientId) clientOs = clientOs.lower() if clientOs == 'winpc': self._sendTodoTaskToUser(seat.player.userId) return # 大厅版本4.56以上直接弹出贵族月卡购买弹窗 if clientVer > 4.56: userId = seat.player.userId clientId = sessiondata.getClientId(userId) template, templateName = findTodotaskTemplate( DIZHU_GAMEID, userId, clientId, 'monthlyBuy') todoTaskObj = template.newTodoTask( DIZHU_GAMEID, userId, clientId) if template else None if ftlog.is_debug(): ftlog.debug( 'mixTable.findTodotaskTemplate.monthlyBuy', 'userId=', userId, 'template=', template, 'templateName=', templateName, 'templateDict=', todoTaskObj.toDict() if todoTaskObj else None) if todoTaskObj: TodoTaskHelper.sendTodoTask( DIZHU_GAMEID, userId, todoTaskObj) return consumeCount, final = user_remote.consumeAsset( DIZHU_GAMEID, seat.player.userId, ASSET_DIAMOND_KIND_ID, cardNoteDiamondCount, 'MATCH_CARDNOTE_BETDIAMOND', seat.player.mixConf.get('roomId') or self.roomId) if consumeCount != cardNoteDiamondCount: # 弹出提示商城购买钻石todotask clientId = sessiondata.getClientId(seat.player.userId) payOrder = { "priceDiamond": { "count": cardNoteDiamondCount, "minCount": cardNoteDiamondCount, "maxCount": -1 }, "buyTypes": ["charge"] } product, _shelves = hallstore.findProductByPayOrder( self.gameId, seat.player.userId, clientId, payOrder) if product: buyType = 'charge' btnTxt = '确定' orderShow = TodoTaskOrderShow.makeByProduct( '您的钻石不足%s个,请去商城购买' % cardNoteDiamondCount, '', product, buyType) orderShow.setParam('sub_action_btn_text', btnTxt) mo = TodoTaskHelper.makeTodoTaskMsg( self.gameId, seat.player.userId, orderShow) router.sendToUser(mo, seat.player.userId) return # 获得一日记牌器 user_remote.addAsset( DIZHU_GAMEID, seat.player.userId, 'item:' + str(ITEM_CARD_NOTE_KIND_ID), 1, 'MATCH_CARDNOTE_BETDIAMOND', seat.player.mixConf.get('roomId') or self.roomId) except: if ftlog.is_debug(): ftlog.error('DizhuTableCtrlMix._openCardNote', 'tableId=', self.tableId, 'userId=', seat.userId, 'cardNoteCount=', seat.player.getCardNoteCount(), 'chip=', seat.player.datas.get('chip')) return if seat.player.openCardNote(): ftlog.info('DizhuTableCtrlMix._openCardNote', 'tableId=', self.tableId, 'userId=', seat.userId, 'cardNoteCount=', seat.player.getCardNoteCount(), 'buyinChip=', seat.player.datas.get('chip')) self.table.fire(CardNoteOpenedEvent(self.table, seat))
def makeClientConf(self, clientconf, gameId, userId, clientId): ''' 构造客户端的活动协议配置 ''' conf = strutil.cloneData(clientconf) activateconf = conf.get("config", {}).get("activate", {}) subconf = conf.get('config', {}) task = self._taskWrapper # New: 要统计的房间列表 roomid_tocount = activateconf.get('countRoomId', []) roomids_tocount = [roomid_tocount] if isstring(roomid_tocount) else roomid_tocount key_tocount = activateconf.get('countByKey') finish_taskcount = task.getFinishTaskCount(gameId, userId, clientconf) gain_taskcount = task.getRecvTaskCount(gameId, userId) total_tablecount = task.getTablePlayCount(userId) # New: 统计多个房间的数量 roomid_tablecount = 0 for roomid in roomids_tocount: roomid_tablecount += task.getRoomTablePlayCount(userId, roomid) is_activited = ActivityDdzFund.loadFundStatus(userId).isActivated ftlog.debug("TYActivityFund.makeClientConf: userId=", userId, "roomids_tocount=",roomids_tocount, "total_tablecount=", total_tablecount, "finish_taskcount=", finish_taskcount, "roomid_tablecount=", roomid_tablecount, "gain_taskcount=", gain_taskcount, "is_activited=",is_activited, 'key_tocount=', key_tocount) # subconf['overCnt'] = finish_taskcount # 已经完成的任务数量 if key_tocount: subconf['overCnt'] = task.getPlayCountByKey(userId, key_tocount) elif len(roomids_tocount) > 0: subconf['overCnt'] = roomid_tablecount # 已经完成的局数 else: subconf['overCnt'] = total_tablecount # 已经完成的局数 subconf['getRewardYetCnt'] = gain_taskcount # 已经领取的任务数量 subconf['isActive'] = is_activited # 是否已经激活基金活动 subconf['activeYetHint'] = strutil.replaceParams(subconf.get("activeYetHint",""), { "finishcount":subconf['overCnt'], "finishcount_room": str(roomid_tablecount), }) reward_btn_map = subconf.get('rewardButton', {}) normal_tip = reward_btn_map.get('normalTip', '') activate_map = subconf.get('activate', {}) reward_list = activate_map.get('reward', []) if len(reward_list)>gain_taskcount: desc = reward_list[gain_taskcount].get('desc', '') reward_btn_map['normalTip'] = strutil.replaceParams(normal_tip, {"assets":desc}) # TodoTask activatebtn_map = subconf.get("activateButton", {}) todotask = activatebtn_map.get("todoTask", {}) payOrder = todotask.get("payOrder") ftlog.debug("TYActivityFund.makeClientConf: userId=", userId, "payOrder=", payOrder) if payOrder: product, _ = hallstore.findProductByPayOrder(gameId, userId, clientId, payOrder) ftlog.debug("TYActivityFund.makeClientConf: userId=", userId, "product=", product) payOrder = TodoTaskPayOrder(product) ftlog.debug("TYActivityFund.makeClientConf: userId=", userId, "params=", payOrder) activatebtn_map["todoTask"] = payOrder.toDict() # 激活日期限制 ok = self.checkCanActivateDate(conf) activateconf['isOutdate'] = not ok if ok: activateconf['outdateTip'] = None ftlog.debug("TYActivityFund.makeClientConf: userId=", userId, "isOutdate", activateconf['isOutdate']) ftlog.debug("TYActivityFund.makeClientConf: userId=", userId, "conf=", conf) return conf
def _newTodoTask(self, gameId, userId, clientId, timestamp, **kwargs): product, _ = hallstore.findProductByPayOrder(gameId, userId, clientId, self.payOrder) return TodoTaskLoseStreakBuffGift(product) if product else None
def _doFlipcard(self, userId, gameId, clientId, activityId, coin): result = {} key = "TYActivity:%d:%d:%s:%s" % (gameId, userId, clientId, activityId) ftlog.debug("_doFlipcard key:", key) conf = { "design": { "1": { "name": "豹子A", "payrate": 20, "probability": 0.0001 }, "2": { "name": "豹子", "payrate": 20, "probability": 0.0012 }, "3": { "name": "同花顺", "payrate": 15, "probability": 0.001 }, "4": { "name": "同花", "payrate": 3, "probability": 0.01 }, "5": { "name": "顺子", "payrate": 3, "probability": 0.01 }, "6": { "name": "对子", "payrate": 1.5, "probability": 0.1 }, "7": { "name": "K以上单张", "payrate": 1.2, "probability": 0.3 }, "8": { "name": "单张", "payrate": 0, "probability": 0.5777 } } } # 判断用户金币是否足够 chipNow = userchip.getChip(userId) if coin == 1000 and chipNow < 5000: payOrder = { "shelves": ["coin"], "buyTypes": ["direct"], "priceDiamond": { "count": 20, "minCount": 0, "maxCount": -1 } } product, _ = hallstore.findProductByPayOrder(gameId, userId, clientId, payOrder) payOrder = TodoTaskPayOrder(product) result["tip"] = payOrder.toDict() return result elif coin == 5000 and chipNow < 50000: payOrder = { "shelves": ["coin"], "buyTypes": ["direct"], "priceDiamond": { "count": 80, "minCount": 0, "maxCount": -1 } } product, _ = hallstore.findProductByPayOrder(gameId, userId, clientId, payOrder) payOrder = TodoTaskPayOrder(product) result["tip"] = payOrder.toDict() return result elif coin == 10000 and chipNow < 50000: payOrder = { "shelves": ["coin"], "buyTypes": ["direct"], "priceDiamond": { "count": 80, "minCount": 0, "maxCount": -1 } } product, _ = hallstore.findProductByPayOrder(gameId, userId, clientId, payOrder) payOrder = TodoTaskPayOrder(product) result["tip"] = payOrder.toDict() return result elif coin == 50000 and chipNow < 300000: payOrder = { "shelves": ["coin"], "buyTypes": ["direct"], "priceDiamond": { "count": 300, "minCount": 0, "maxCount": -1 } } product, _ = hallstore.findProductByPayOrder(gameId, userId, clientId, payOrder) payOrder = TodoTaskPayOrder(product) result["tip"] = payOrder.toDict() return result else: result = doFlipCard(conf) ftlog.debug("_doFlipcard result..cardtype:", result["cardtype"]) # 减金币操作 coinDel = 0 - coin userchip.incrChip(userId, gameId, coinDel, daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO, 'HALL_FLIPCARD', 0, clientId) datachangenotify.sendDataChangeNotify(gameId, userId, 'chip') ftlog.info("用户名,用户减少了金币,", userId, coinDel) if result["cardtype"] != '8': design = conf.get('design', {}) cardTypeNumber = design[result["cardtype"]].get('payrate', 0) # 加金币操作 coinAdd = int(coin * cardTypeNumber) cardText = "恭喜你赢得了%d" % coinAdd + "金币" ftlog.debug("_doFlipcard get money:", cardText) userchip.incrChip(userId, gameId, coinAdd, daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO, 'HALL_FLIPCARD', 0, clientId) datachangenotify.sendDataChangeNotify(gameId, userId, 'chip') ftlog.info("用户名,用户增加了金币,", userId, coinAdd) result["todoTask"] = {"action": "pop_tip", "params": { "text": cardText, "duration": 2 } } return result else: cardText = "再接再厉,下次就会赢哦"; result["todoTask"] = {"action": "pop_tip", "params": { "text": cardText, "duration": 2 } } ftlog.debug("_doFlipcard key over:", key) return result '''
def _doFlipcard(self, userId, gameId, clientId, activityId, coin): result = {} key = "TYActivity:%d:%d:%s:%s" % (gameId, userId, clientId, activityId) ftlog.debug("_doFlipcard key:", key) conf = { "design": { "1": { "name": "豹子A", "payrate": 20, "probability": 0.0001 }, "2": { "name": "豹子", "payrate": 20, "probability": 0.0012 }, "3": { "name": "同花顺", "payrate": 15, "probability": 0.001 }, "4": { "name": "同花", "payrate": 3, "probability": 0.01 }, "5": { "name": "顺子", "payrate": 3, "probability": 0.01 }, "6": { "name": "对子", "payrate": 1.5, "probability": 0.1 }, "7": { "name": "K以上单张", "payrate": 1.2, "probability": 0.3 }, "8": { "name": "单张", "payrate": 0, "probability": 0.5777 } } } # 判断用户金币是否足够 chipNow = userchip.getChip(userId) if coin == 1000 and chipNow < 5000: payOrder = { "shelves": ["coin"], "buyTypes": ["direct"], "priceDiamond": { "count": 20, "minCount": 0, "maxCount": -1 } } product, _ = hallstore.findProductByPayOrder( gameId, userId, clientId, payOrder) payOrder = TodoTaskPayOrder(product) result["tip"] = payOrder.toDict() return result elif coin == 5000 and chipNow < 50000: payOrder = { "shelves": ["coin"], "buyTypes": ["direct"], "priceDiamond": { "count": 80, "minCount": 0, "maxCount": -1 } } product, _ = hallstore.findProductByPayOrder( gameId, userId, clientId, payOrder) payOrder = TodoTaskPayOrder(product) result["tip"] = payOrder.toDict() return result elif coin == 10000 and chipNow < 50000: payOrder = { "shelves": ["coin"], "buyTypes": ["direct"], "priceDiamond": { "count": 80, "minCount": 0, "maxCount": -1 } } product, _ = hallstore.findProductByPayOrder( gameId, userId, clientId, payOrder) payOrder = TodoTaskPayOrder(product) result["tip"] = payOrder.toDict() return result elif coin == 50000 and chipNow < 300000: payOrder = { "shelves": ["coin"], "buyTypes": ["direct"], "priceDiamond": { "count": 300, "minCount": 0, "maxCount": -1 } } product, _ = hallstore.findProductByPayOrder( gameId, userId, clientId, payOrder) payOrder = TodoTaskPayOrder(product) result["tip"] = payOrder.toDict() return result else: result = doFlipCard(conf) ftlog.debug("_doFlipcard result..cardtype:", result["cardtype"]) # 减金币操作 coinDel = 0 - coin userchip.incrChip(userId, gameId, coinDel, daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO, 'HALL_FLIPCARD', 0, clientId) datachangenotify.sendDataChangeNotify(gameId, userId, 'chip') ftlog.info("用户名,用户减少了金币,", userId, coinDel) if result["cardtype"] != '8': design = conf.get('design', {}) cardTypeNumber = design[result["cardtype"]].get('payrate', 0) # 加金币操作 coinAdd = int(coin * cardTypeNumber) cardText = "恭喜你赢得了%d" % coinAdd + "金币" ftlog.debug("_doFlipcard get money:", cardText) userchip.incrChip(userId, gameId, coinAdd, daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO, 'HALL_FLIPCARD', 0, clientId) datachangenotify.sendDataChangeNotify(gameId, userId, 'chip') ftlog.info("用户名,用户增加了金币,", userId, coinAdd) result["todoTask"] = { "action": "pop_tip", "params": { "text": cardText, "duration": 2 } } return result else: cardText = "再接再厉,下次就会赢哦" result["todoTask"] = { "action": "pop_tip", "params": { "text": cardText, "duration": 2 } } ftlog.debug("_doFlipcard key over:", key) return result '''