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


Python Gcore.getMod方法代码示例

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


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

示例1: BuyItemEquip

# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getMod [as 别名]
    def BuyItemEquip(self, param={}):
        '''商城购买装备或道具'''
        optId = 20006
        
        ieSaleId = param['IeSaleId']
        ieSaleCfg = Gcore.getCfg('tb_cfg_shop_ie_sale', ieSaleId)
        if ieSaleCfg is None:
            return Gcore.error(optId, -20006001)#商品不存在
        modCoin = Gcore.getMod('Coin', self.uid)
        modBag = Gcore.getMod('Bag', self.uid)
        if not modBag.inclueOrNot(ieSaleCfg['SaleType'], ieSaleCfg['GoodsId'], ieSaleCfg['OnceNum']):
            return Gcore.error(optId, -20006002)#背包空间不足
        
        classMethod = '%s,%s'%(self.__class__.__name__,sys._getframe().f_code.co_name)
        res = modCoin.PayCoin(optId, 1, ieSaleCfg['Price'], classMethod, param)

        if res == -2:
            return Gcore.error(optId, -20006994)#货币不足
        if res < 0:
            return Gcore.error(optId, -20006995)#支付失败或者非法操作

        modBag = Gcore.getMod('Bag', self.uid)
        buyId = modBag.addGoods(ieSaleCfg['SaleType'], ieSaleCfg['GoodsId'], ieSaleCfg['OnceNum'], addLog=optId)
        
        recordData = {'uid': self.uid, 'ValType': ieSaleCfg['GoodsId'], 'Val': ieSaleCfg['OnceNum'], 'GoodsType': ieSaleCfg['SaleType']}#成就、任务记录 
        return Gcore.out(optId, {'Result': buyId}, mission = recordData)
开发者ID:fycheung,项目名称:misc,代码行数:28,代码来源:ItemUI.py

示例2: GetSpawnNum

# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getMod [as 别名]
    def GetSpawnNum(self, param={}):
        '''获取当前时刻,兵营或工坊的新兵数量'''
        optId = 15030

        BuildingId = param['BuildingId']
        TimeStamp = param['ClientTime']
        
        modBuilding = Gcore.getMod('Building', self.uid)
        BuildingInfo = modBuilding.getBuildingById(BuildingId, TimeStamp=TimeStamp)
        if not BuildingInfo:
            return Gcore.error(optId, -15030001) #玩家没有该建筑
        if BuildingInfo['BuildingState'] == 1:
            return Gcore.error(optId, -15030002) #建筑正在建造
        if BuildingInfo['BuildingType'] not in (6, 8):
            return Gcore.error(optId, -15030003) #建筑不是兵营或工坊
        
        print '建筑ID', BuildingId
        print '建筑类型', BuildingInfo['BuildingType']
        print '建筑等级', BuildingInfo['BuildingLevel']

        modCamp = Gcore.getMod('Building_camp', self.uid) 
        spawn_detail= modCamp.getSoldierStorage(BuildingInfo, TimeStamp)
        body = {}
        body['StorageNum'] = spawn_detail['StorageNum']
        body['LastChangedTime'] = spawn_detail['LastChangedTime']

        return Gcore.out(optId, body=body)
开发者ID:fycheung,项目名称:misc,代码行数:29,代码来源:Building_campUI.py

示例3: Exchange

# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getMod [as 别名]
    def Exchange(self, para={}):
        '''货币兑换  by Lizr'''
        optId = 20001
        CoinType =  para['CoinType']
        CoinValue = para['CoinValue']
        if CoinType not in (2, 3):
            return Gcore.error(optId, -20001998) #非法操作
        if type(CoinValue) not in (int, long) or CoinValue <= 0:
            return Gcore.error(optId, -20001998) #非法操作
        
        storageSpace = Gcore.getMod('Building', self.uid).cacStorageSpace(CoinType)
        addPercent = CoinValue / storageSpace
        rateInfos = Gcore.getCfg('tb_cfg_shop_res_sale')
        rateInfoList = filter(lambda dic:dic['AddPercent'] <= addPercent and dic['CoinType'] == CoinType, rateInfos.values())
        rateInfo = max(rateInfoList, key=lambda sale:sale['AddPercent'])

        rate = rateInfo['kPrice1'] * (storageSpace ** rateInfo['kPrice2'])
        GoldValue = int(math.ceil(CoinValue * rate))
#         rate = Gcore.loadCfg(2001).get('exchange').get(str(CoinType))
#         GoldValue = math.ceil(CoinValue/rate)
        modCoin = Gcore.getMod('Coin', self.uid)
        classMethod = '%s.%s' % (self.__class__.__name__, sys._getframe().f_code.co_name)
        pay = modCoin.PayCoin(optId, 1, GoldValue, classMethod, para)
        if pay < 0:
            return Gcore.error(optId, -20001995) #支付失败
        else:
            #GainValue = GoldValue*rate
            #GainValue = int(math.ceil(GoldValue / rate))
            #result = modCoin.GainCoin(optId, CoinType, GainValue, classMethod, para)
            result = modCoin.GainCoin(optId, CoinType, CoinValue, classMethod, para)
            body = {"CoinType": CoinType, "CoinValue": CoinValue, "GoldUsed": pay}
            return Gcore.out(optId, body)    
开发者ID:fycheung,项目名称:misc,代码行数:34,代码来源:ItemUI.py

示例4: BuyMap

# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getMod [as 别名]
    def BuyMap(self,p={}):
        '''购买地图'''

        optId = 14002
        if 'x' not in p or 'y' not in p:
            return Gcore.error(optId,-14002001) #非法参数 
        
        x = p['x']
        y = p['y']
        if not self.mod.checkBuyStartCoord(x,y):
            print self.mod.db.sql
            return Gcore.error(optId,-14002002) #所传的坐标非可购买坐标的起点
            
        if self.mod.checkHadBuy(x,y):
            return Gcore.error(optId,-14002003) #你已经购买过此坐标
        
        MapBuyTimes = Gcore.getMod('Player',self.uid).getMapBuyTimes()
        CostValue = Gcore.getCfg('tb_cfg_map_cost',MapBuyTimes,'Cost')
        print CostValue
        #开始支付
        modCoin = Gcore.getMod('Coin',self.uid)
        classMethod = '%s.%s' % (self.__class__.__name__, sys._getframe().f_code.co_name)
        pay = modCoin.PayCoin(optId, 3, CostValue, classMethod, p)
        achieve = {'uid':self.uid,'ValType':0,'Val':1}#成就记录
        if pay < 0:
            Gcore.error(optId, -14002995) #支付失败
        else:
            if not self.mod.doBuyMap(x,y):
                return Gcore.error(optId,-14002004) #购买失败
            else:
                return Gcore.out(optId,achieve=achieve)
开发者ID:fycheung,项目名称:misc,代码行数:33,代码来源:MapUI.py

示例5: CleanWallDefense

# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getMod [as 别名]
  def CleanWallDefense(self,p={}):
      '''回收损毁的防御工事'''
      optId = 92012
      CoinValue = self.mod.clearWallDefense()
      if CoinValue:
          Gcore.getMod('Coin',self.uid).GainCoin(optId,2,CoinValue,'WallUI.CleanWallDefense',p)#返回军资
          reward = self.mod.getWallBoxReward() #获取遗落宝箱的奖励
          if reward:#有奖励
              rewardType = reward['RewardType']
              goodsId = reward['GoodsId']
              goodsNum = reward['GoodsNum']
              ids = Gcore.getMod('Reward',self.uid).reward(optId,p,rewardType,goodsId,goodsNum)
              #reward['WillGet'] = 1
              if rewardType==1:
                  if isinstance(ids,list):
                      reward['EquipIds'] = ids
                  else:
                      reward['EquipIds'] = []
              
          else:#无奖励
              #reward = {'WillGet':0}
              reward = {}
 
          recordData = {'uid':self.uid,'ValType':0,'Val':1,'WillGet':reward.get('WillGet')}
          body = {"CoinType":2,"CoinValue":CoinValue,"Reward":reward}
          return Gcore.out(optId,body,mission=recordData)
      else:
          return Gcore.error(optId,-92012001) #没有可回收的防御工事
开发者ID:fycheung,项目名称:misc,代码行数:30,代码来源:WallUI.py

示例6: CheckMissionStatus

# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getMod [as 别名]
 def CheckMissionStatus(self ,p={}):
     '''检查任务状态'''
     optId = 22005
     self.mod.updateAllMissions()
     
     Gcore.getMod('Building_home',self.uid).updateAllAchieves()
     return Gcore.out(optId)
开发者ID:fycheung,项目名称:misc,代码行数:9,代码来源:MissionUI.py

示例7: getLatestGeneralInfo

# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getMod [as 别名]
    def getLatestGeneralInfo(self, Generals=None, TimeStamp=None, UserLevel=None, 
                             GeneralIds=None, fields='*', IsClubTech=True):
        '''获取玩家武将的最新信息'''
        # 参数:
        # + Generals - 武将表中所有武将的信息
        # + fields - 已取消,兼容以前的程序,现返回所有的字段
        # + GeneralIds - 要查询的武将
        # + + int, long, str - 查询单个武将的信息
        # + + list, tuple - 查询多个武将的信息
        # + + None - 查询玩家所有武将的信息
        # + IsClubTech - 是否加上军团科技和宝物对武将四维属性的加成
        
        # 返回值:
        # + 单个武将:dict or None
        # + 多个武将:list
        # + 都不是:False

        if not TimeStamp:TimeStamp = time.time()
        if not Generals:Generals = self.getMyGenerals()
        if not UserLevel:UserLevel = self.getUserLevel()
        
        #加上武馆训练的经验
        modGround = Gcore.getMod('Building_ground', self.uid)
        _, Generals = modGround.touchPractise(Generals, TimeStamp, UserLevel)
        
        if IsClubTech: #四维属性加上各种加成
            # + 军团科技影响
            modClub = Gcore.getMod('Building_club', self.uid)
            club_tech_effects = modClub.getClubTechAdd()

            # + 宝物影响
            treasure_effects = self.getEquipExEffect([General['GeneralId'] for General in Generals])

            # + 四维加上各种加成
            for General in Generals:
                General["ForceValue"] += int(club_tech_effects[1])
                General["WitValue"] += int(club_tech_effects[2])
                General["LeaderValue"] += int(club_tech_effects[3])
                General["SpeedValue"] += int(club_tech_effects[4])

                treasure_effect = treasure_effects[General['GeneralId']]
                General["ForceValue"] += int(General["ForceValue"] * treasure_effect['force'])
                General["WitValue"] += int(General["WitValue"] * treasure_effect['wit'])
                General["SpeedValue"] += int(General["SpeedValue"] * treasure_effect['speed'])
                General["LeaderValue"] += int(General["LeaderValue"] * treasure_effect['leader'])

        if not GeneralIds: #返回所有武将的信息
            return Generals
        elif isinstance(GeneralIds, (int, long, str)): #返回单个武将的信息
            for General in Generals:
                if General["GeneralId"] == int(GeneralIds):
                    return General
            return None
        elif isinstance(GeneralIds, (list, tuple)): #返回多个武将的信息
            ret = []
            for General in Generals:
                if General["GeneralId"] in map(int, GeneralIds):
                    ret.append(General)
            return ret
        return False
开发者ID:fycheung,项目名称:misc,代码行数:62,代码来源:GeneralMod.py

示例8: getWallGeneralList

# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getMod [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

示例9: GetBaseInfo

# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getMod [as 别名]
 def GetBaseInfo(self,param={}):
     optId = 13003
     userId=param['UserId']
     modPlay=Gcore.getMod('Player',userId)
     
     fileds=['NickName','UserLevel','VipLevel','UserIcon','UserHonour','UserCamp','UserExp']
     result= modPlay.getUserBaseInfo(fileds)
     if result is None:
         return Gcore.error(optId,-13003001)#用户不存在
     
     result['Rank']=modPlay.getHonRankNum(result)
     
     buildingClub = Gcore.getMod('Building_club',userId)
     cId=buildingClub.getUserClubId()
     clubInfo=buildingClub.getClubInfo(cId,'ClubName')
     if clubInfo:
         result['ClubName']=clubInfo['ClubName']     #获得军团名字
     else:
         result['ClubName']=''
         
     general=Gcore.getMod('General', userId)
     generalNum=general.getMyGenerals('count(1) as gNum')
     result['GeneralNum']=generalNum[0]['gNum'] #获得武将个数
     
     modFriend=Gcore.getMod('Friend',userId)
     buildingNum=modFriend.getBuildingCount(userId)
     result['BuildingNum']=buildingNum 
     
     return Gcore.out(optId,result)
开发者ID:fycheung,项目名称:misc,代码行数:31,代码来源:PlayerUI.py

示例10: CancelBuilding

# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getMod [as 别名]
    def CancelBuilding(self, param={}):
        '''通用:取消建筑建造或升级'''
        optId = 15003

        BuildingId = param["BuildingId"]
        TimeStamp = param['ClientTime']

        BuildingInfo = self.mod.getBuildingById(BuildingId, 
                                                ['BuildingPrice', 
                                                 'BuildingType', 
                                                 'CoinType',
                                                 'LastOptType'], 
                                                TimeStamp=TimeStamp)
        if not BuildingInfo:
            return Gcore.error(optId, -15003003) #用户没有该建筑
        
        #BuildingType < 100 是建筑;大于100是装饰;
        if BuildingInfo['BuildingType'] < 100 and \
        BuildingInfo['BuildingState'] == 0:
            return Gcore.error(optId, -15003004) #建筑已建造或升级完成,不能取消。
        
        BuildingType = BuildingInfo['BuildingType']
        CostValue = BuildingInfo["BuildingPrice"]
        CostType = BuildingInfo["CoinType"]
        
        #返钱
        CancelReturn = Gcore.loadCfg(
            Gcore.defined.CFG_BUILDING)["CancelReturn"] #返还比例
        modCoin = Gcore.getMod('Coin', self.uid)
        classMethod = '%s.%s' % (self.__class__.__name__, 
                                 sys._getframe().f_code.co_name)
        gain = modCoin.GainCoin(optId, CostType, 
                                int(CostValue * CancelReturn), 
                                classMethod, param)
        if gain < 0:
            return Gcore.error(optId, -15003005) #增加货币失败

        #建筑正在建造 :如果是装饰,删掉。
        if BuildingInfo['BuildingType'] > 100 or \
        BuildingInfo['BuildingState'] == 1:
            self.mod.deleteBuildingById(BuildingId)
        else:
            #更新建筑表
            UpInfo = {}
            UpInfo['CompleteTime'] = TimeStamp
            UpInfo['BuildingLevel'] = BuildingInfo['BuildingRealLevel']
            UpInfo['LastOptType'] = 2
            self.mod.updateBuildingById(UpInfo, BuildingId)
        #不同类型的建筑进行不同的操作
        # + todo
        if BuildingType in (6, 7, 8): #校场 兵营 工坊:计算士兵
            modCamp = Gcore.getMod('Building_camp', self.uid)
            modCamp.TouchAllSoldiers(TimeStamp=TimeStamp)
            if BuildingType in (6, 8): #兵营 工坊 回复生产
                update_dic = {'LastChangedTime':TimeStamp, 
                              'BuildingLevel':BuildingInfo['BuildingRealLevel']}
                modCamp.updateProcessById(update_dic, BuildingId)
        return Gcore.out(optId, 
                         {'Coin%s'%CostType:modCoin.getCoinNum(CostType), 
                          "RetValue":int(CostValue * CancelReturn)})
开发者ID:fycheung,项目名称:misc,代码行数:62,代码来源:BuildingUI.py

示例11: vipAddTotal

# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getMod [as 别名]
 def vipAddTotal(self, optId, goldNum):
     '''
     :玩家充值黄金,增加玩家累积黄金,更新Vip等级
     @param goldNum:增加的黄金数量
     '''
     userInfo = self.getUserInfo(['VipLevel','VipTotalPay'])
     curLevel = userInfo.get('VipLevel')
     curVipTotal = userInfo.get('VipTotalPay')
     
     totalPay = goldNum+curVipTotal
     levelCfg = Gcore.getCfg('tb_cfg_vip_up')
     levelUp = max([levelCfg[level]['VipLevel'] for level in levelCfg if totalPay>=levelCfg[level]['TotalPay']])
     data = {'VipTotalPay':totalPay,'VipLevel':levelUp}
     self.db.update('tb_user',data,'UserId=%s'%self.uid)
     if levelUp>curLevel:#VIP升级
         interMod = Gcore.getMod('Inter',self.uid)
         interMod.updateInterVip()#更新VIP内政加成
         Gcore.setUserData(self.uid,{'VipLevel':levelUp}) #更新用户缓存  Lizr
         Gcore.push(107,self.uid,{'VipLevel':levelUp}) #推送给前端升级 Lizr
     if curVipTotal==0:
         #增加首冲奖励
         Gcore.getMod('Activity',self.uid).insertGifts(1,0)
     #发送系统邮件
     mailMod = Gcore.getMod('Mail', self.uid)
     mailMod.sendSystemMail(self.uid, [], optId, other=[goldNum,])
     
     return levelUp
开发者ID:fycheung,项目名称:misc,代码行数:29,代码来源:PlayerMod.py

示例12: CheckFriend

# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getMod [as 别名]
    def CheckFriend(self, param={}):
        """查看好友"""
        optId = 19007
        friendUserId = param["FriendUserId"]
        if not self.mod.validateUser(friendUserId):
            return Gcore.error(optId, -19007001)  # 用户不存在

        player = Gcore.getMod("Player", friendUserId)
        fileds = ["UserId", "NickName", "UserLevel", "VipLevel", "UserIcon", "UserHonour", "UserCamp"]
        result = player.getUserBaseInfo(fileds)  # 获得基本信息
        result["Rank"] = player.getHonRankNum(result)

        buildingClub = Gcore.getMod("Building_club", friendUserId)
        cId = buildingClub.getUserClubId()
        clubInfo = buildingClub.getClubInfo(cId, "ClubName")
        if clubInfo:
            result["ClubName"] = clubInfo["ClubName"]  # 获得军团名字
        else:
            result["ClubName"] = ""
        general = Gcore.getMod("General", friendUserId)
        generalNum = general.getMyGenerals("count(1) as gNum")
        result["GeneralNum"] = generalNum[0]["gNum"]  # 获得武将个数

        buildingNum = self.mod.getBuildingCount(friendUserId)
        result["BuildingNum"] = buildingNum  # 获得建筑数量

        return Gcore.out(optId, result)
开发者ID:fycheung,项目名称:misc,代码行数:29,代码来源:FriendUI.py

示例13: freed

# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getMod [as 别名]
 def freed(self, huid, hsid): #玩家达到一定要求,被释放。
     '''被释放 , 玩家使用调解卡时调用,释放自己
     @param huid: 主人的用户ID
     @param hsid: 主人的服务器ID
     '''
     if hsid == self.serverid: #占领者在本服
         
         Data = Gcore.getMod('Building_resource',self.uid).collectAll() #将地里的资源以被占领的身份收集一次
         Data['HoldEndTime'] = 0
         Gcore.push(112, self.uid, Data,Type=0)
         
         #查出进贡的钱
         row = self.db.out_fields('tb_hold', ["JcoinGive", "GcoinGive"],\
                            'GiverId="%s" AND HolderId="%s"'%(self.uid, huid))
         if row:
             ja, ga = row["JcoinGive"], row["GcoinGive"]
             
             modCoin = Gcore.getMod('Coin', huid)
             j = modCoin.GainCoin(0, 2, ja, 'Building_holdMod.freed', {'hsid':hsid, 'huid':huid})
             g = modCoin.GainCoin(0, 3, ga, 'Building_holdMod.freed', {'hsid':hsid, 'huid':huid})
         
         dic = {'HolderId':0,'HolderServerId':0,'HoldEndTime':0}
         self.db.update('tb_user', dic, 'UserId="%s"' % self.uid)
         self.db.execute('DELETE FROM `tb_hold` WHERE GiverId="%s" AND HolderId="%s"' % (self.uid, huid))
         self.db.execute('DELETE FROM `tb_hold_log` WHERE UserId="%s"' % self.uid)
         self.db.execute('DELETE FROM `tb_hold_revenge` WHERE UserId="%s"' % self.uid)
         
     else: #占领者不在本服
         Gcore.sendmq(3, hsid, {'HolderId':huid,
                       'GiverServerId':self.serverid,
                       'GiverId':self.uid})
     #删除自己的藩国redis
     Gcore.redisM.hdel("sgHold", '%s.%s' % (self.serverid, self.uid))
     return 1
开发者ID:fycheung,项目名称:misc,代码行数:36,代码来源:Building_holdMod.py

示例14: SpeedRapidPractise

# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getMod [as 别名]
 def SpeedRapidPractise(self, param={}):
     '''加速突飞训练的冷却时间'''
     optId = 15094
     
     IsSpeed = param.get('IsSpeed')
     TimeStamp = param['ClientTime']
     
     TodayDate = time.strftime('%Y-%m-%d', time.localtime(TimeStamp))
     modGround = Gcore.getMod('Building_ground', self.uid)
     RapidRecord = modGround.getRapidRecord(TodayDate)
     
     if not RapidRecord:
         RapidCount = 0
         IsOverFlow = 0
         
         CDValue = 0
     else:
         RapidCount = RapidRecord['PractiseCount']
         IsOverFlow = RapidRecord['IsOverFlow']
         
         TotalCD = RapidRecord['CDValue']
         SecondsPast = TimeStamp - RapidRecord['LastRapidTime']
         CDValue = max(TotalCD - SecondsPast, 0)
         if CDValue <= 0:
             IsOverFlow = 0
     
     if not IsSpeed: #不是加速
         body = {}
         body['TimeStamp'] = TimeStamp
         body['IsOverFlow'] = IsOverFlow
         body['CDValue'] = CDValue
         body['RapidCout'] = RapidCount
         return Gcore.out(optId, body=body)
     
     #加速冷却时间
     if CDValue <= 0:
         return Gcore.error(optId, -15094001) #冷却时间为0
     
     CoinType = 1
     CoinValue = calSpeedCost(4, CDValue)
     
     #扣钱
     modCoin = Gcore.getMod('Coin', self.uid)
     classMethod = '%s.%s' % (self.__class__.__name__, sys._getframe().f_code.co_name)
     pay = modCoin.PayCoin(optId, CoinType, CoinValue, classMethod, param)
     if pay < 0:
         return Gcore.error(optId, -15094002) #扣钱失败
     
     #更新突飞记录表
     modGround.speedCD()
     
     body = {}
     body['GoldenCost'] = pay
     body['CDValue'] = 0
     body['SpeedTime'] = CDValue
     body['IsOverFlow'] = 0
     body['TimeStamp'] = TimeStamp
     return Gcore.out(optId, body=body)
开发者ID:fycheung,项目名称:misc,代码行数:60,代码来源:Building_groundUI.py

示例15: CreateWallDefense

# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getMod [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


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