当前位置: 首页>>代码示例>>Python>>正文


Python Gcore.getCfg方法代码示例

本文整理汇总了Python中sgLib.core.Gcore.getCfg方法的典型用法代码示例。如果您正苦于以下问题:Python Gcore.getCfg方法的具体用法?Python Gcore.getCfg怎么用?Python Gcore.getCfg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sgLib.core.Gcore的用法示例。


在下文中一共展示了Gcore.getCfg方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: GetActivitiesUI

# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getCfg [as 别名]
 def GetActivitiesUI(self, param={}):
     '''返回参数1首次充值2签到3成长奖励4活跃度礼包5鸿运当头6在线奖励'''
     optId = 23001
     activities = Gcore.getCfg('tb_cfg_act')
     data = {}
     acts = []
     for act in activities:
         if activities[act]['Status'] == 1:
             actId = activities[act]['ActivityId']
             if actId == 1:#首冲活动
                 playerMod = Gcore.getMod('Player',self.uid)
                 vipTotalPay = playerMod.getUserBaseInfo(['VipTotalPay']).get('VipTotalPay')
                 if vipTotalPay:
                     giftState = self.mod.getGift(1, 0, ['isGet']).get('isGet')
                     data['Recharged'] = 1 if giftState == 0 else 0
                 else:
                     data['Recharged'] = 1 #新号要显示首冲活动
                     
                 if not data['Recharged']: #1表示可以领首冲礼包或者新号显示首冲活动,0表示不显示
                     continue
             elif actId == 5:
                 luckyLog = self.mod.getLuckLog()
                 luckyLog['AwardId'] += 1
                 goodLuckCfg = Gcore.getCfg('tb_cfg_act_lucky_award', luckyLog['AwardId'])
                 if not goodLuckCfg:
                     continue
             acts.append(actId)
     data['Activities'] = acts
     return Gcore.out(optId, data)
开发者ID:fycheung,项目名称:misc,代码行数:31,代码来源:ActivityUI.py

示例2: UpgradeClubTech

# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getCfg [as 别名]
    def UpgradeClubTech(self,p={}):
        '''
        :升级军团科技
        #todo加一个升级完返回升级后的等级
        '''
        optId = 15076
        techType = p.get('ClubTechType')
        if techType not in range(1,11):
            return Gcore.error(optId,-15076999)#参数错误
        building = self.mod.getClubBuildingInfo()
        if building is None:
            return  Gcore.error(optId,-15076901)#外史院建筑不存在
        clubId = self.mod.getUserClubId()
        if not clubId:
            return Gcore.error(optId,-15076920)#军团不存在
        clubInfo = self.mod.getClubInfo(clubId)
        clubLevel = clubInfo.get('ClubLevel')
        techLevel = self.mod.getClubTechLevel(techType)
        openLevel = Gcore.getCfg('tb_cfg_club_up',clubLevel,'OpenLevelTech'+str(techType))
        if techLevel >= openLevel:
            return Gcore.error(optId,-15076001)#已达最大等级

        cost = Gcore.getCfg('tb_cfg_club_tech',(techType,techLevel+1),'LearnCost')
        
#         print '科技类型',techType
#         print '科技等级',techLevel
#         print '学习费用',cost
        
        flag = self.mod.payDevote(clubId,cost)#成功返回余额
        if flag<0:
            return Gcore.error(optId,-15076995)#支付失败
        newLevel = self.mod.upgradeClubTech(techType)
        recordData = {'uid':self.uid,'ValType':0,'Val':1,'TechType':techType,'TechLevel':newLevel}#成就记录
        return Gcore.out(optId,{'Left':flag,'ClubTechType':techType,'Level':newLevel},achieve=recordData,mission=recordData)
开发者ID:fycheung,项目名称:misc,代码行数:36,代码来源:Building_clubUI.py

示例3: checkAndUpdate

# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getCfg [as 别名]
 def checkAndUpdate(self, table):
     '''查找并更新数据库中建筑费用为NULL的数据'''
     fields = ['BuildingId', 'UserId', 'BuildingType', 'BuildingLevel', 'CoinType', 'BuildingPrice', 'LastChangedTime', 'CompleteTime']
     where = ' CoinType is NULL or BuildingPrice is NULL or LastChangedTime is NULL OR CoinType = 0 OR BuildingPrice = 0 '
     tmpRows = self.db.out_rows(table, fields, where)
     if tmpRows:
         for row in tmpRows:
             #print '==PrimaryData:',row
             tmpData = json.dumps(row) + '\n'
             self.fd.write(tmpData)
             if not row['CoinType']:
                 row['CoinType'] = Gcore.getCfg('tb_cfg_building', row['BuildingType'], 'CoinType')
             if not row['BuildingPrice']:
                 row['BuildingPrice'] = Gcore.getCfg('tb_cfg_building_up', (row['BuildingType'], row['BuildingLevel']), 'CostValue')
             if not row['LastChangedTime'] and row['LastChangedTime'] != 0:
                 if row['CompleteTime']:
                     row['LastChangedTime'] = row['CompleteTime'] - Gcore.getCfg('tb_cfg_building_up', (row['BuildingType'], row['BuildingLevel']), 'CDValue')
                 else:
                     row['LastChangedTime'] = 0
                 if row['LastChangedTime'] < 0:
                     row['LastChangedTime'] = 0
             where = 'BuildingId=%s'%row['BuildingId']
             data = {'CoinType': row['CoinType'], 'BuildingPrice': row['BuildingPrice'], 'LastChangedTime': row['LastChangedTime']}
             self.db.update(table, data, where)
             #print '==ModifiedData:',data
             tmpData = json.dumps(data) + '\n'
             self.fd.write(tmpData)
开发者ID:fycheung,项目名称:misc,代码行数:29,代码来源:updateBuildingPrice.py

示例4: canAddInBag

# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getCfg [as 别名]
 def canAddInBag(self, goodsList):
     '''判断物品列表是否能够全部添加到当前玩家的背包@qiudx
        @goodsList: [{'GoodsType':xxx, 'GoodsId': xxx, 'GoodsNum': xxx},]
        @返回True or False
     ''' 
     needNum = 0 #统计添加物品列表所需的格子数
     tmpGoodsList = copy.deepcopy(goodsList)
     goods = self.db.out_rows(self.tb_bag(), ['*'], 'UserId=%s'%self.uid)
     for tmpGoods in tmpGoodsList:
         if tmpGoods['GoodsType'] in (1, 4, 5):  #装备,兵书,宝物一个格子只能放一件
             equipMod = Gcore.getMod('Equip', self.uid)
             cfgTable = equipMod.getCfgEquipTB(tmpGoods['GoodsType'])
             equipCfg = Gcore.getCfg(cfgTable, tmpGoods['GoodsId'])
             if not equipCfg:
                 continue
             needNum += tmpGoods['GoodsNum']
         elif tmpGoods['GoodsType'] == 2:        #道具可能一个格子放多个
             itemCfg = Gcore.getCfg('tb_cfg_item', tmpGoods['GoodsId'])
             if not itemCfg:
                 continue
             avlNum = int(itemCfg.get('OverlayNum', 1))
             for good in goods:
                 if good['GoodsType'] == 2 and good['GoodsId'] == tmpGoods['GoodsId']:
                     tmpGoods['GoodsNum'] -= avlNum - good['GoodsNum']
                     if tmpGoods['GoodsNum'] <= 0:
                         break
             needNum += int(math.ceil(float(tmpGoods['GoodsNum']) / avlNum))
     
     maxNum = self.getBagSize()#查询背包容量
     avlBag = self._getAvlInBag(goods, maxNum)#查询可用的格仔
     if len(avlBag) >= needNum:
         return True
     return False
开发者ID:fycheung,项目名称:misc,代码行数:35,代码来源:BagMod.py

示例5: getWallGeneralList

# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getCfg [as 别名]
    def getWallGeneralList(self):
        '''获取布防武将列表  参考getWallGeneralList()  
        @call: WallUI
        @author: by Lizr
        '''
        kLeader = Gcore.loadCfg(Gcore.defined.CFG_BATTLE)["kLeaderAddNum"]
        SoldierTechs =  Gcore.getMod('Book',self.uid).getTechsLevel(1)
        
        InListGeneral = self.db.out_list('tb_wall_general','GeneralId',"UserId=%s"%self.uid) #已布防
        
        fields = ['GeneralId','GeneralType','GeneralLevel','ForceValue',
                  'WitValue','SpeedValue','LeaderValue','TakeType','TakeTypeDefense']
        rows = Gcore.getMod('General',self.uid).getMyGenerals(fields)
        #Gcore.printd( rows )
        GeneralList = []
        for row in rows:
            if not row['TakeTypeDefense']:
                row['TakeTypeDefense'] = row['TakeType']

            row['Skill'] = Gcore.getCfg('tb_cfg_general',row['GeneralType'],'SkillId')
            SoldierType = row['TakeTypeDefense']
            SoldierLevel = SoldierTechs.get( SoldierType )
            row['SoldierType'] = SoldierType
            row['SoldierLevel'] = SoldierLevel
            key = (SoldierType,SoldierLevel)
            SoldierNum = row['LeaderValue']*kLeader
            
            cfg_soldier = Gcore.getCfg('tb_cfg_soldier_up',key)
            if cfg_soldier:
                #row['Life'] = cfg_soldier['Life']* row['LeaderValue']*kLeader
                #row['Attack'] = cfg_soldier['Attack']*row['LeaderValue']*kLeader
                #row['Denfense'] = cfg_soldier['Defense']
                
                row['Life'] = F.getArmyLife(cfg_soldier['Life'], SoldierNum)
                row['Attack'] = F.getArmyAttack(
                                               generalType = row['GeneralType'],
                                               soldierType = row['SoldierType'],
                                               landForm = 4,
                                               soldierAttack = cfg_soldier['Attack'],
                                               soldierNum = SoldierNum,
                                               forceValue = row['ForceValue'],
                                               )
                row['Denfense'] = F.defenseAdd( cfg_soldier['Defense'],row['SpeedValue'],row['GeneralType']) 
            else:
                row['Life'] = 0
                row['Attack'] = 0
                row['Denfense'] = 0
                
            row['InWall'] = row['GeneralId'] in InListGeneral #是否在布防中
            
#            del row['ForceValue']
#            del row['WitValue']
#            del row['SpeedValue']
#            del row['LeaderValue']
            
            del row['TakeType']
            del row['TakeTypeDefense']
           
            GeneralList.append(row)
        return GeneralList
开发者ID:fycheung,项目名称:misc,代码行数:62,代码来源:WallMod.py

示例6: randomName

# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getCfg [as 别名]
    def randomName(self, icon):
        '''随机名称  '''
        SelectNum = 30
        if icon > 2:
            sex = 2
        else:
            sex = 1
        
        pMod = Gcore.getMod('Player', 1001)

        lastnameList = Gcore.getCfg('tb_cfg_nickname').get(0)
        firstnameList = Gcore.getCfg('tb_cfg_nickname').get(sex)
        lastnameList = random.sample(lastnameList,SelectNum)
        firstnameList = random.sample(firstnameList,SelectNum)

        nicknames=[]
        for i in xrange(SelectNum):
            nickname = lastnameList[i]+firstnameList[i]
            nicknames.append(nickname)

        where = pMod.db.inWhere('NickName',nicknames)
        rows = pMod.db.out_rows('tb_user','NickName',where)
        existNickNames = [r['NickName'] for r in rows]
        notExistNickNames = list(set(nicknames)-set(existNickNames))
        
        NickNames = []
        for NickName in notExistNickNames:
            if Gcore.common.filterInput(NickName,2,16)<0:
                pass #过滤敏感词的名称
            else:
                NickNames.append(NickName)
        
        return NickNames[0]
开发者ID:fycheung,项目名称:misc,代码行数:35,代码来源:TestUI.py

示例7: _getDropShowList

# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getCfg [as 别名]
 def _getDropShowList(self):
     '''获得高级掉落物品列表,在打战役前显示'''
     showDict = {}
     for k,rows in Gcore.getCfg('tb_cfg_pve_drop').iteritems():
         DropId,Star = k
         
         if DropId not in showDict:
             showDict[DropId] = []
         for row in rows:
             if row['Ratio'] == 0:
                 continue
             row['RewardType'] = int(row['RewardType'])
             if row['RewardType'] in (1,2,4,5,6):
                 cell = {'RewardType':row['RewardType'],'GoodsId':row['GoodsId']}
                 if row['RewardType'] == 1: #装备
                     Quality = Gcore.getCfg('tb_cfg_equip',row['GoodsId'],'Quality')
                     if Quality>=2: #紫装以上
                         if cell not in showDict[DropId]:
                             showDict[DropId].append(cell)
                 elif row['RewardType'] == 2: #道具
                     Quality = Gcore.getCfg('tb_cfg_item',row['GoodsId'],'ItemQuality')
                     if Quality>0: #全掉 
                         if cell not in showDict[DropId]:
                             showDict[DropId].append(cell)
                 else:
                     if cell not in showDict[DropId]:
                             showDict[DropId].append(cell)
                 
         #break
     for DropId in showDict:
         showDict[DropId] =  Gcore.common.list2dict(showDict[DropId])  
     
     return showDict
开发者ID:fycheung,项目名称:misc,代码行数:35,代码来源:WarMod.py

示例8: HandleApply

# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getCfg [as 别名]
    def HandleApply(self, param={}):
        """处理好友申请"""
        optId = 19003
        timeStamp = param["ClientTime"]
        friendUserIds = param["FriendUserIds"]
        handleType = param["HandleType"]
        recordData = {}  # 任务记录
        if not friendUserIds:
            return Gcore.error(optId, -19003999)  # 参数错误

        if handleType == 0:
            """拒绝添加"""
            # self.mod.updateFriendShip(friendUserIds, self.uid, 0, timeStamp)
            self.mod.refuseApply(friendUserIds, self.uid, timeStamp)
            mailMod = Gcore.getMod("Mail", self.uid)
            nickName = self.mod.getUserInfo("NickName")
            # mailMod.sendMail(friendUserIds, '拒绝好友申请', nickName+'拒绝了你的好友申请', 1)#拒绝好友,调用邮件发送信息给对方
            for toUserId in friendUserIds:
                mailMod.sendSystemMail(toUserId, [], optId, other=[nickName])

        elif handleType == 1:
            """确认添加"""
            # 判断玩家自己的好友数是否已达上限
            uLimitNum = Gcore.getCfg("tb_cfg_friend_limit", self.mod.getUserLevel(), "FriendNumLimit")
            uNowNum = self.mod.countFriend(2)
            if uNowNum >= uLimitNum:
                return Gcore.error(optId, -19003001)  # 好友超过上限
            # 如果对方好友已达上限,则拒绝本次添加请求
            validId = []
            for fid in friendUserIds:
                tmpMod = Gcore.getMod("Friend", fid)
                limitNum = Gcore.getCfg("tb_cfg_friend_limit", tmpMod.getUserLevel(), "FriendNumLimit")
                nowNum = tmpMod.countFriend(2)
                if nowNum >= limitNum:
                    # self.mod.updateFriendShip(fid, self.uid, 0, timeStamp)
                    self.mod.refuseApply(fid, self.uid, timeStamp)
                else:
                    validId.append(fid)

            if len(validId) == 0:
                return Gcore.error(optId, -19003002)
            # 如果玩家添加的好友数多于所能添加的个数,则失败
            if uNowNum + len(validId) > uLimitNum:
                return Gcore.error(optId, -19003001)

            for friendUserId in validId:
                self.mod.insFriendShip(self.uid, friendUserId, 2)
                self.mod.updateFriendShip(friendUserId, self.uid, 2, timeStamp)

                recordData = {"uid": self.uid, "ValType": 0, "Val": 1}
                Gcore.getMod("Mission", friendUserId).missionTrigger(optId)  # 触发被同意好友更新

        else:
            return Gcore.error(optId, -19003999)  # 参数错误

        return Gcore.out(optId, {}, mission=recordData)
开发者ID:fycheung,项目名称:misc,代码行数:58,代码来源:FriendUI.py

示例9: EquipStrengthen

# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getCfg [as 别名]
    def EquipStrengthen(self,p={}):
        '''强化装备'''
        optId = 16001
        equipId = p['EquipId']
        generalId = p['GeneralId']
        building = self.mod.getSmithyInfo()
        if not building:
            return Gcore.error(optId,-16001901)#建筑不存在
        buildingId = building['BuildingId']
        equipInfo = self.mod.getEquipInfo(1,equipId)#装备信息
        if not equipInfo or equipInfo['UserId'] != self.uid:
            return Gcore.error(optId,-16001910)#装备不存在
        generalMod = Gcore.getMod('General',self.uid)
        generalInfo = generalMod.getLatestGeneralInfo(GeneralIds=generalId)
        
        if not generalInfo:
            return Gcore.error(optId,-16001001) #武将不存在
        if equipId not in self.mod.getEquipsByGeneral(generalId).values():
            return Gcore.error(optId,-16001004)#武器不在该武将身上
        
        equipType = equipInfo['EquipType']
        equipCfg = Gcore.getCfg('tb_cfg_equip',equipType)#装备配置
        strengthenLimit =  equipCfg.get('StrengthenLimit')
        equipPart = equipCfg.get('EquipPart')
        
        equipLevel = equipInfo.get('StrengthenLevel')
        generalLevel = generalInfo.get('GeneralLevel')
        free = self.mod.getMaxStrength(buildingId)['Available']
        if free == 0:
            return Gcore.error(optId,-16001002)#强化次数不足
        elif equipLevel >= generalLevel or equipLevel>= strengthenLimit:
            return Gcore.error(optId,-16001003)#已达最大等级
        
        equipUpCfg = Gcore.getCfg('tb_cfg_equip_up',(equipLevel+1,equipPart))#装备强化配置
        costType = equipUpCfg.get('StrengthenCostType')
        cost = equipUpCfg.get('CostQuality%s'%equipCfg.get('Quality'))
#         print '==Pre:',cost
        
        #计算内政对强化花费的影响
        interMod = Gcore.getMod('Inter',self.uid)
        cost = interMod.getInterEffect(8,cost)
#         print '===Reday:',cost
        flag = self.coinMod.PayCoin(optId,costType,cost,'EquipUI.EquipStrengthen',p)
        if flag>0:
            strengthData = {'StrengthenLevel':equipLevel+1,
                            'EnhanceForce':equipInfo['EnhanceForce']+equipCfg['GrowForce'],
                            'EnhanceWit':equipInfo['EnhanceWit']+equipCfg['GrowWit'],
                            'EnhanceSpeed':equipInfo['EnhanceSpeed']+equipCfg['GrowSpeed'],
                            'EnhanceLeader':equipInfo['EnhanceLeader']+equipCfg['GrowLeader']
                            }
            self.mod.equipStrengthen(buildingId, equipId,equipType,strengthData)
            generalMod.changeAttr(generalId,equipCfg['GrowForce'],equipCfg['GrowSpeed'],equipCfg['GrowWit'],equipCfg['GrowLeader'])
            recordData = {'uid':self.uid,'ValType':0,'Val':1,'EquipType':equipType,'EquipLevel':equipLevel+1}#成就、任务记录
            return Gcore.out(optId,achieve=recordData,mission=recordData)
        else:
            return Gcore.error(optId,-16001995) #支付失败 
开发者ID:fycheung,项目名称:misc,代码行数:58,代码来源:EquipUI.py

示例10: CreateWallDefense

# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getCfg [as 别名]
    def CreateWallDefense(self,p={}):
        '''建造防御工事  Lizr'''
        optId = 92001
        defenseType = int(p['DefenseType'])
        x = p['x']
        y = p['y']
        xSize = p['xSize']
        ySize = p['ySize']
        
        buildingInfo = self.mod.getWallInfo()
        if buildingInfo is None:
            return Gcore.error(optId,-92001998)#非法操作
        wallLevel = buildingInfo.get('BuildingRealLevel')
        
        if defenseType/100 != 2: #200~299
            return Gcore.error(optId,-92001998) #非法操作
        
        Size = Gcore.getCfg('tb_cfg_soldier',defenseType,'Size')
        
        if str(xSize)+'*'+str(ySize)!=Size and str(ySize)+'*'+str(xSize)!=Size: #非配置的尺寸 1*3
            return Gcore.error(optId,-92001001) #尺寸不合法
        
#        if not self.mod.checkWallCoord(x,y): #@todo: 加上布防坐标验证
#            return Gcore.error(optId,-92001002) #坐标不合法
        
        maxCount = Gcore.getCfg('tb_cfg_wall',wallLevel,'DefenseType%s'%defenseType)
      
        defenseNum = self.mod.getDefenseNum()
        
        if defenseNum.get(defenseType,0)>=maxCount:
            return Gcore.error(optId,-92001003) #超出最大可建数量
        bookMod = Gcore.getMod('Book',self.uid)
        coinMod = Gcore.getMod('Coin',self.uid)
        defenseLevel = bookMod.getTechsLevel(1).get(defenseType,0)#从书院获取
        if defenseLevel==0:
            defenseLevel=1
        defenseCfg = Gcore.getCfg('tb_cfg_soldier_up',(defenseType,defenseLevel))
        cost = defenseCfg.get('MakeCost')
        costType = defenseCfg.get('MakeCostType')
        payState = coinMod.PayCoin(optId,costType,cost,'WallUI.CreateWallDefense',p)
#        payState = 1
        if payState:
            data={
                  'UserId':self.uid,
                  'SoldierType':defenseType,
                  'SoldierLevel':defenseLevel,
                  'xSize':xSize,'ySize':ySize,
                  'x':x,'y':y,
                  'MakeCost':cost,
                  }
            DefenseId = self.mod.createDefense(data)
            recordData = {'uid':self.uid,'ValType':0,'Val':1,'Level':defenseLevel}
            return Gcore.out(optId,{'WallDefenseId':DefenseId},mission=recordData)

        else:
            Gcore.error(optId,-92001995) #支付失败
开发者ID:fycheung,项目名称:misc,代码行数:58,代码来源:WallUI.py

示例11: OnlineLottory

# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getCfg [as 别名]
    def OnlineLottory(self, param={}):
        '''在线奖励抽奖'''
        optId = 23011
        self.mod.refreashTime()#更新操作时间
        lastLottery = self.mod.getOnlineLottery()
        #获取可抽奖次数(待)
        #timeCfg = Gcore.getCfg('tb_cfg_act_online_limit')
        timeCfg = Gcore.loadCfg(CFG_ACT_ONLINE_LIMIT)
        dt = lastLottery['DayOnlineTime']
        less = 0
        lottoryNum = len(timeCfg.keys())
#         for i in range(1, len(timeCfg.values())+1):
#             if dt >= timeCfg[i]['NeedTime']:
#                 less += 1
#                 dt -= timeCfg[i]['NeedTime']
        for i in xrange(1, lottoryNum + 1):
            if dt >= timeCfg[str(i)]:
                less += 1
                dt -= timeCfg[str(i)]
        less -= lastLottery['LotteryCount']
        if less <= 0:
            return  Gcore.error(optId, -23011001)#可抽奖次数不足
        
        #获取抽到的奖励类型和等级
        typeCfg = Gcore.getCfg('tb_cfg_act_online_type').values()
        typeCfg = filter(lambda dic:dic['Ratio']!=0, typeCfg)#暂时不随机到宝物和兵书
        types = []
        level = 3
        typeValue = random.randint(2, 3)#如果等级是3则在铜钱和军资中随即一个
        for i in range(0, 3):
            theType = common.Choice(typeCfg)
            for j in range(0, len(types)):
                if theType['TypeId'] == types[j]:
                    level -= 1
                    typeValue = theType['TypeId']
                    break
            types.append(theType['TypeId'])
        
        #进行奖励
        awards = Gcore.getCfg('tb_cfg_act_online_award', (typeValue, level))
        
        award = random.choice(awards)
        modReward = Gcore.getMod('Reward', self.uid)
        award['Gain'] = modReward.reward(optId, param, award['AwardType'], award['GoodsId'], award['GoodsNum'])
        
        #更新在线奖励记录
        lastLottery['AwardId'] = award['AwardId']
        lastLottery['LotteryCount'] += 1
        lastLottery['AwardType'] = award['AwardType']
        lastLottery['GoodsId'] = award['GoodsId']
        lastLottery['GoodsNum'] = award['GoodsNum']
        types = [str(t) for t in types]
        lastLottery['LotteryInfo'] = str.join(',',types)
        self.mod.updateOnlineLottery(lastLottery)
        return Gcore.out(optId, {'LotteryInfo': lastLottery['LotteryInfo'], 'Award': award})
开发者ID:fycheung,项目名称:misc,代码行数:57,代码来源:ActivityUI.py

示例12: GetInviteUI

# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getCfg [as 别名]
    def GetInviteUI(self, param={}):
        """招贤馆:招募界面"""
        optId = 15006

        BuildingId = param["BuildingId"]
        RequestTimeStamp = param["ClientTime"]

        InviteInfo = self.mod.getInvite()
        modBuilding = Gcore.getMod("Building", self.uid)
        BuildingInfo = modBuilding.getBuildingById(BuildingId, TimeStamp=RequestTimeStamp)
        if not BuildingInfo:
            return Gcore.error(optId, -15006901)  # 用户没有该建筑
        if BuildingInfo["BuildingState"] == 1:
            return Gcore.error(optId, -15006902)  # 建筑正在建造
        if BuildingInfo["BuildingType"] != 13:
            return Gcore.error(optId, -15006903)  # 该建筑不是招贤馆
        BuildingLevel = BuildingInfo["BuildingRealLevel"]

        if not InviteInfo:
            print "第一次招募"
            ChosenGenerals = self.mod.chooseGenerals(GeneralNum=3, IsFirst=True)
            self.mod.insertInvite(ChosenGenerals, BuildingLevel, RequestTimeStamp)
            RemainedTime = Gcore.getCfg("tb_cfg_building_up", key=(13, BuildingLevel), field="RefreshValue")
            return Gcore.out(
                optId, body={"RemainedTime": RemainedTime, "Generals": ChosenGenerals, "CostValue": 5}
            )  # 系统错误 (招募表中此玩家初始记录)

        print "InviteInfo", InviteInfo

        # SpeedCount = self.mod.cacSpeedCount(InviteInfo['SpeedCount'], InviteInfo['LastSpeedDate'], RequestTimeStamp)
        # SpeedCount += 1
        # CostValue = SpeedCount * 2

        CostValue = 5  # 读配置 - 招贤馆每次刷新所用的黄金数量
        RetDic = {}
        RetDic["CostValue"] = CostValue
        if RequestTimeStamp < InviteInfo["EndTime"]:
            RefreshTimeRemained = InviteInfo["EndTime"] - RequestTimeStamp

            RetDic["RemainedTime"] = RefreshTimeRemained
            RetDic["Generals"] = [InviteInfo["GeneralId1"], InviteInfo["GeneralId2"], InviteInfo["GeneralId3"]]

            return Gcore.out(optId, RetDic)
        else:
            RefreshValue = Gcore.getCfg("tb_cfg_building_up", key=(13, BuildingLevel), field="RefreshValue")
            RefreshTimeRemained = RefreshValue - (RequestTimeStamp - InviteInfo["EndTime"]) % RefreshValue
            RefreshTimeStamp = RequestTimeStamp - (RequestTimeStamp - InviteInfo["EndTime"]) % RefreshValue
            ChosenGenerals = self.mod.chooseGenerals()
            self.mod.updateInvite(ChosenGenerals, BuildingLevel, RefreshTimeStamp)

            RetDic["RemainedTime"] = RefreshTimeRemained
            RetDic["Generals"] = ChosenGenerals
            return Gcore.out(optId, RetDic)
开发者ID:fycheung,项目名称:misc,代码行数:55,代码来源:Building_pubUI.py

示例13: BuyResource

# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getCfg [as 别名]
    def BuyResource(self, param={}):
        '''商城购买资源'''
        optId=20002

        classMethod = '%s,%s'%(self.__class__.__name__,sys._getframe().f_code.co_name)
        
        resSaleId = param['ResSaleId']
        resSaleCfg = Gcore.getCfg('tb_cfg_shop_res_sale', resSaleId)

        coinType = resSaleCfg['CoinType']
        percent = resSaleCfg['AddPercent']

        buildingMod = Gcore.getMod('Building', self.uid)
        maxCoin = buildingMod.cacStorageSpace(coinType)

        modCoin = Gcore.getMod('Coin', self.uid)
        currCoinNum = modCoin.getCoinNum(coinType)

        if percent < 1:
            coinValue = maxCoin*percent#增加货币
            
        elif percent == 1:
            coinValue = maxCoin - currCoinNum#增加货币
            percent = coinValue / maxCoin
            #print 'percent', percent
            resSaleList = Gcore.getCfg('tb_cfg_shop_res_sale')
            resSaleList = filter(lambda dic:dic['AddPercent'] <= percent and dic['CoinType'] == coinType, resSaleList.values())
            resSaleCfg = max(resSaleList, key=lambda sale:sale['AddPercent'])
#             print resSaleList
#             resSaleList.sort(key=lambda sale:sale['AddPercent'])
#             if resSaleList:
#                 resSaleCfg=resSaleList.pop()
                    
        else:
            return Gcore.error(optId, -20002001)#percent错误,大于1
        
        if currCoinNum + coinValue > maxCoin:
            return Gcore.error(optId, -20002002)#超过资源上限

        kPrice1 = resSaleCfg['kPrice1']
        kPrice2 = resSaleCfg['kPrice2']
        #支付黄金
        useCoinValue = int(math.ceil(coinValue*kPrice1*maxCoin**kPrice2))
        re = modCoin.PayCoin(optId, 1, useCoinValue, classMethod, param)
        
        if re > 0:
            re = modCoin.GainCoin(optId, coinType, coinValue, classMethod, param)
            if re:
                return Gcore.out(optId, {'Result':re})
            else:
                return Gcore.error(optId, -20002997)#非法操作
        else:
            return Gcore.error(optId, -20002995)#支付失败
开发者ID:fycheung,项目名称:misc,代码行数:55,代码来源:ItemUI.py

示例14: touchActPoint

# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getCfg [as 别名]
 def touchActPoint(self,oldLevel,newLevel):
     '''更新行动力,升级时调用'''
     newLevelPoint = Gcore.getCfg('tb_cfg_action_point',newLevel,'ActPoint')
     oldLevelPoint = Gcore.getCfg('tb_cfg_action_point',oldLevel,'ActPoint')
     diffPoint = newLevelPoint - oldLevelPoint
     if diffPoint:
         row = self._lastActRecord()
         if row:
             todaytime = Gcore.common.today0time()
             sql = "UPDATE tb_war_action SET ActPoint=ActPoint+%s WHERE UserId=%s AND LastWarTime>=%s" \
             %(diffPoint,self.uid,todaytime)
             self.db.execute(sql) #如果今日有打过 就修正累计记录
开发者ID:fycheung,项目名称:misc,代码行数:14,代码来源:WarMod.py

示例15: _calLevelByCost

# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getCfg [as 别名]
 def _calLevelByCost(self,equipType,currentLevel,cost,levelLimit=None):
     '''根据费用计算装备升级'''
     equipUpCfg = Gcore.getCfg('tb_cfg_equip_up')
     equipCfg = Gcore.getCfg('tb_cfg_equip',equipType)
     eq = equipCfg['Quality']
     ep = equipCfg['EquipPart']
     if levelLimit is None:
         levelLimit = equipCfg['StrengthenLimit']
     toLevelUpCost = equipUpCfg.get((currentLevel+1,ep)).get('CostQuality%s'%eq)
     while currentLevel<levelLimit and cost>=toLevelUpCost:
         currentLevel += 1
         cost -= toLevelUpCost
         toLevelUpCost = equipUpCfg.get((currentLevel+1,ep)).get('CostQuality%s'%eq)
     return (currentLevel,cost)
开发者ID:fycheung,项目名称:misc,代码行数:16,代码来源:EquipUI.py


注:本文中的sgLib.core.Gcore.getCfg方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。