def init(): global gDB global gUserDb dbParam = DbInitParam() dbParam.db_config = ffext.getConfig('-db') dbParam.db_conn_prefix = 'db' dbParam.db_sql = 'db.sql' dbParam.db_conn_pool_size = 10 firstList = [] db_ret = initialize_db(firstList, gUserDb, dbParam) if db_ret == False: return False if len(firstList) == 0: return False gDB = firstList[0] global gLogDB global gLogDBList logDbParam = DbInitParam() logDbParam.db_config = ffext.getConfig('-log_db') logDbParam.db_conn_prefix = 'log_db' logDbParam.db_sql = 'game_log.sql' logDbParam.db_conn_pool_size = 5 firstList2 = [] db_ret = initialize_db(firstList2, gLogDBList, logDbParam) if db_ret == False: return False if len(firstList2) == 0: return False gLogDB = firstList2[0] return True
def readdNpcDuibaiCfg(self): db = ffext.allocDbConnection('cfg', ffext.getConfig('-cfg')) ret = db.queryResult('select npc,duibai from npcduibai') name2DuiBai = {} for row in ret.result: name2DuiBai[row[0]] = row[1] return name2DuiBai
def randsuit(session, args): xiongJiaCfgId = 0 xiongJiaItem = session.player.itemCtrl.allEquiped.get( Base.EQUIP_XIONGJIA_POS, None) from handler import ItemHandler if xiongJiaItem: ffext.dump('randsuit...', xiongJiaItem.uid) ItemHandler.processUnEquipItem(session, MsgDef.EquipOpsReq(xiongJiaItem.uid)) session.player.itemCtrl.delItem(xiongJiaItem.uid) itemCfgId = 30111113 canUseCfgId = [] needlv = 10 #session.player.level randomLv = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50] lv = randomLv[random.randint(0, len(randomLv) - 1)] sql = "SELECT cfgid FROM equipprop WHERE itemtype = 103 AND job = " + str( session.player.job) + " and name like '%" + str(lv) + "级-品质1-1套'" db = ffext.allocDbConnection('cfg', ffext.getConfig('-cfg')) ret = db.queryResult(sql) if ret: result = ret.result ffext.dump('result:', result) randRow = result[random.randint(0, len(result) - 1)] itemCfgId = int(randRow[0]) item = session.player.itemCtrl.addItemByCfgId(itemCfgId) ItemHandler.processEquipItem(session, MsgDef.EquipOpsReq(item.uid))
def init(self): #读取配置 db = ffext.allocDbConnection('cfg', ffext.getConfig('-cfg')) ret = db.queryResult( 'select quality,level,expMax,needlevel,hp,mp,physic_attack_min,physic_attack_max,magic_attack_min,magic_attack_max,physic_defend_min,physic_defend_max,\ magic_defend_min,magic_defend_max,crit,hit,avoid,attackspeed,attacksing,attackinterval,attackdistance,movespeed,hurtabsorb,hpabsorb, cfgid from pet' ) self.allCfg = {} def toNum(s, d=0): if s != '': return int(s) return d def toFloat(s, d=0.0): if s != '': m = s.replace('%', '') return float(m) return d for row in ret.result: cfg = PetCfg() cfg.quality = row[0] cfg.level = int(row[1]) cfg.expMax = toNum(row[2]) cfg.needlevel = toNum(row[3]) cfg.hp = toNum(row[4]) cfg.mp = toNum(row[5]) cfg.physicAttackMin = toNum(row[6]) cfg.physicAttackMax = toNum(row[7]) cfg.magicAttackMin = toNum(row[8]) cfg.magicAttackMax = toNum(row[9]) cfg.physicDefendMin = toNum(row[10]) cfg.physicDefendMax = toNum(row[11]) cfg.magicDefendMin = toNum(row[12]) cfg.magicDefendMax = toNum(row[13]) cfg.crit = int(toFloat(row[14]) * Base.CRIT_RATE_BASE / 100) cfg.hit = int(toFloat(row[15]) * Base.HIT_RATE_BASE / 100) cfg.avoid = int(toFloat(row[16]) * Base.AVOID_RATE_BASE / 100) cfg.attackspeed = toNum(row[17]) cfg.attacksing = toNum(row[18]) cfg.attackinterval = toNum(row[19]) cfg.attackdistance = toNum(row[20]) cfg.movespeed = toNum(row[21]) cfg.hurtabsorb = toNum(row[22]) cfg.hpabsorb = toNum(row[23]) cfg.petType = self.str2Type[cfg.quality] destDict = self.allCfg.get(cfg.petType) cfg.cfgid = toNum(row[24]) if None == destDict: destDict = {} self.allCfg[cfg.petType] = destDict destDict[cfg.level] = cfg self.id2cfg[cfg.cfgid] = cfg ffext.dump('load pet num=%d' % (len(ret.result))) return True
def readBagIdCfg(self): db = ffext.allocDbConnection('cfg', ffext.getConfig('-cfg')) ret = db.queryResult( 'select id,intro,rate,itemlist,num from monsterdrop_bag2item') self.bagid2cfg = {} for row in ret.result: obj = MonDropBagCfg(int(row[0]), row[1], int(ffext.perToNum(row[2])), row[3], int(row[4])) self.bagid2cfg[obj.bagid] = obj #ffext.dump('bag obj', obj) return True
def initMonster(self):#读取任务配置 db = ffext.allocDbConnection('cfg',ffext.getConfig('-cfg')) ret = db.queryResult('select skillid,name,intro,mp,cd,attackspeed,attacksing,attackinterval,attackdistance,attackrange,costanger from monsterskill') self.allMonsterSkillCfg = {} for row in ret.result: skillCfg = self.data2cfg(row) cfgDict = self.allMonsterSkillCfg.get(skillCfg.skillType) #ffext.dump('load monsterskill cfg', skillCfg) if skillCfg.skillId == 4151: skillCfg.hurtCalcultor = SkillCalculatorZhanShi.PuGong() self.allMonsterSkillCfg[skillCfg.skillType] = skillCfg ffext.dump('load monsterskill num=%d'%(len(self.allMonsterSkillCfg))) return True
def init(self): #if len(self.level2exp) == 0: db = ffext.allocDbConnection('cfg', ffext.getConfig('-cfg')) ret = db.queryResult( 'select level,expmax,standard_monster_exp,onhook_hour_exp,onhook_8hour_exp from level2exp' ) self.level2exp = {} self.levelMax = 0 for i in range(0, len(ret.result)): row = ret.result[i] expProp = ExpProp() expProp.level = int(row[0]) expProp.expMax = ffext.strToNum(row[1]) expProp.standardMonsterExp = ffext.strToNum(row[2]) expProp.onhookHourExp = ffext.strToNum(row[3]) expProp.onhook8HourExp = ffext.strToNum(row[4]) self.level2exp[expProp.level] = expProp if expProp.level > self.levelMax: self.levelMax = expProp.level self.level2prop = {} for job in Base.ALL_JOB: self.level2prop[job] = {} ret = db.queryResult( 'select level,hp,mp,physic_attack_min,physic_attack_max,magic_attack_min,magic_attack_max,physic_defend_min, \ physic_defend_max,magic_defend_min,magic_defend_max from levelprop%d' % (job)) for i in range(0, len(ret.result)): row = ret.result[i] prop = PlayerLevelProp() prop.level = int(row[0]) prop.hp = ffext.strToNum(row[1]) prop.mp = ffext.strToNum(row[2]) prop.physicAttackMin = ffext.strToNum(row[3]) prop.physicAttackMax = ffext.strToNum(row[4]) prop.magicAttackMin = ffext.strToNum(row[5]) prop.magicAttackMax = ffext.strToNum(row[6]) prop.physicDefendMin = ffext.strToNum(row[7]) prop.physicDefendMax = ffext.strToNum(row[8]) prop.magicDefendMin = ffext.strToNum(row[9]) prop.magicDefendMax = ffext.strToNum(row[10]) self.level2prop[job][prop.level] = prop ffext.dump('load level2prop job=%d num=%d' % (job, len(self.level2prop[job]))) self.readRandNames() return True
def init(self): #读取任务配置 name2DuiBai = self.readdNpcDuibaiCfg() db = ffext.allocDbConnection('cfg', ffext.getConfig('-cfg')) ret = db.queryResult( 'select name,appr,mapid,x,y,script,direction,cfgid from npc') self.allCfg = {} for row in ret.result: npcCfg = NpcCfg() npcCfg.name = row[0] npcCfg.appr = int(row[1]) npcCfg.mapname = row[2] npcCfg.x = int(row[3]) npcCfg.y = int(row[4]) npcCfg.script = row[5] npcCfg.direction = int(row[6]) npcCfg.cfgid = int(row[7]) npcCfg.defaultDuiBai = name2DuiBai.get(npcCfg.name, '勇士你好!我是%s' % (npcCfg.name)) self.allCfg[npcCfg.cfgid] = npcCfg mapObj = MapMgr.getMapMgr().allocMapByFile(npcCfg.mapname) if not mapObj: ffext.warn( 'gen npc failed name=%s, script=%s, map=%s not in this gs' % (npcCfg.name, npcCfg.script, npcCfg.mapname)) #ffext.dump('load npc ', npcCfg) npc = Npc() npc.name = npcCfg.name npc.appr = npcCfg.appr npc.mapname = npcCfg.mapname npc.script = npcCfg.script npc.direction = npcCfg.direction npc.cfg = npcCfg try: npc.scriptMod = __import__('npc.' + npc.script, fromlist=[npc.script]) except: ffext.error( 'gen npc failed name=%s, script=%s map=%s,%d,%d' % (npc.name, npc.script, npcCfg.mapname, npcCfg.x, npcCfg.y)) try: mapObj.npcEnterMap(npc, npcCfg.x, npcCfg.y) except: ffext.error( 'gen npc failed2 name=%s, script=%s map=%s,%d,%d' % (npc.name, npc.script, npcCfg.mapname, npcCfg.x, npcCfg.y)) ffext.dump('load npc num=%d' % (len(self.allCfg))) return True
def init(self, TopDir): subdir = TopDir + '/cfg/map' allMapFile = os.listdir(subdir) file2data = {} for k in allMapFile: fileName = k[0:-4] fileNameStr = '%s/%s' % (subdir, k) width, height, mapPos = ffext.readTMCMap(fileNameStr) #ffext.dump('MapMgr init k =', k, width, height, len(mapPos), width * height) file2data[fileName] = (width, height, mapPos, fileNameStr) ffext.ff.create_map(fileName, fileNameStr) sql = 'select name, id,revivemap,offlinemap from map' db = ffext.allocDbConnection('cfg', ffext.getConfig('-cfg')) ret = db.queryResult(sql) for row in ret.result: showName = row[0] fileName = row[1] ffext.info('mapmgr %s %s' % (showName, fileName)) data = file2data.get(fileName) if None == data: continue mapCfg = MapCfg() reviveMap = row[2] args = reviveMap.split(';') if len(args) >= 3: mapCfg.reviveMap = MapPosData() mapCfg.reviveMap.mapname = args[0] mapCfg.reviveMap.x = int(args[1]) mapCfg.reviveMap.y = int(args[2]) offlineMap = row[3] args = offlineMap.split(';') if len(args) >= 3: mapCfg.offlineMap = MapPosData() mapCfg.offlineMap.mapname = args[0] mapCfg.offlineMap.x = int(args[1]) mapCfg.offlineMap.y = int(args[2]) #ffext.dump('mapCfg', mapCfg) mapCfg.allPos = data[2] mapObj = MapObj(mapCfg, fileName, data[0], data[1], mapCfg.allPos) mapObj.showName = showName mapObj.tmxFilePath = data[3] self.allMap[showName] = mapObj self.allMap[fileName] = mapObj self.id2map[int(fileName)] = mapObj self.readCfgTransferPoint() return True
def readCfgTransferPoint(self): sql = 'select cfgid, mapid,x,y,tomapid,tox,toy from transferpoint' db = ffext.allocDbConnection('cfg', ffext.getConfig('-cfg')) ret = db.queryResult(sql) self.allTransfeerPoint = {} for row in ret.result: tp = TransferPoint() tp.cfgid = int(row[0]) tp.mapid = int(row[1]) tp.x = int(row[2]) tp.y = int(row[3]) tp.tomapid = int(row[4]) tp.tox = int(row[5]) tp.toy = int(row[6]) self.allTransfeerPoint[tp.cfgid] = tp #ffext.dump( self.allTransfeerPoint) return True
def readRandNames(self): sql = 'select name1, name2, name3, name4, name5 from randnames' db = ffext.allocDbConnection('cfg', ffext.getConfig('-cfg')) ret = db.queryResult(sql) self.randName1 = [] self.randName2 = [] self.randName3 = [] self.randName4 = [] self.randName5 = [] for row in ret.result: if row[0] != '': self.randName1.append(row[0]) if row[1] != '': self.randName2.append(row[1]) if row[2] != '': self.randName3.append(row[2]) if row[3] != '': self.randName4.append(row[3]) if row[4] != '': self.randName5.append(row[4])
def readmonsterdrop_lv2bag(self): db = ffext.allocDbConnection('cfg', ffext.getConfig('-cfg')) ret = db.queryResult( 'select monsterdrop_lv2bag.level,goldmin,goldmax,dropbagid1,dropbagid2,dropbagid3,dropbagid4,rate1,rate2,rate3,num1,num2,num3 \ from monsterdrop_lv2bag,monsterdrop_lv2rate,monsterdrop_lv2num \ where monsterdrop_lv2bag.level = monsterdrop_lv2rate.level and monsterdrop_lv2bag.level=monsterdrop_lv2num.level' ) self.cfgLevel2Drop = {} for row in ret.result: obj = MonDropCfg(int(row[0]), int(row[1]), int(row[2]), int(row[3]), int(row[4]), int(row[5]), int(row[6])) obj.rateList[0] = int(float(row[7]) * 100) obj.rateList[1] = int(float(row[8]) * 100) obj.rateList[2] = int(float(row[9]) * 100) obj.numList[0] = int(row[10]) obj.numList[1] = int(row[11]) obj.numList[2] = int(row[12]) self.cfgLevel2Drop[obj.level] = obj #ffext.dump('MonDropCfg obj', obj) return True
def init(self): db = ffext.allocDbConnection('cfg', ffext.getConfig('-cfg')) #sample data => 1, '登录第1天', '1020102;1020101', 1, '', 0 ret = db.queryResult( 'select id,desc,itemlist,num,extra_itemlist,extra_num from seven_login_reward' ) self.allSevenRewardCfg = {} for row in ret.result: sevenCfg = self.sevenData2Cfg(row) if sevenCfg: self.allSevenRewardCfg[sevenCfg.id] = sevenCfg pass pass #sample data => 1, '在线累计30分钟', '1020102;1020101', 1 ret = db.queryResult('select id,desc,itemlist,num from online_reward') self.allLoginRewardCfg = {} for row in ret.result: loginCfg = self.loginData2Cfg(row) if loginCfg: self.allLoginRewardCfg[loginCfg.id] = loginCfg pass pass #sample data => 1, '邀请奖励金币', 500, '', 0 ret = db.queryResult( 'select id,desc,gold,itemlist,num from invite_friend_reward limit 1' ) for row in ret.result: inviteCfg = self.inviteData2Cfg(row) if inviteCfg: self.inviteRewardCfg = inviteCfg break pass return True
def init(): #pdb.set_trace() print('scene init......') #if ffext.is_enable_option('-d'): #ffext.ENABLE_DUMP = False if not idtool.init(ffext.getConfig('-db')): ffext.error('idtool init failed:' + ffext.getConfig('-db')) return -1 if not DbServiceBase.init(): ffext.error('scene init failed when DbService.init......') return -1 if not GlobalRecordModel.getGlobalRecordMgr().init(): ffext.error( 'scene init failed when GlobalRecordModel.getGlobalRecordMgr().init......' ) return -1 if not MapMgr.getMapMgr().init(TOPDIR): ffext.error('scene init failed when MapMgr.getMapMgr().init......') return -1 if not PlayerModel.getPlayerMgr().init(): ffext.error( 'scene init failed when PlayerModel.getPlayerMgr().init......') return -1 if not SkillModel.getSkillMgr().init(): ffext.error( 'scene init failed when SkillModel.getSkillMgr().init()......') return -1 if not SkillModel.getSkillMgr().initMonster(): ffext.error( 'scene init failed when SkillModel.getSkillMgr().initMonster()......' ) return -1 if not ItemModel.getItemMgr().init(): ffext.error( 'scene init failed when ItemModel.getItemMgr().init().....') return -1 #ffext.dump("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") #pdb.set_trace() if not MonsterModel.getMonsterMgr().loadCfg(): ffext.error('scene init failed when MonsterModel.loadCfg()......') return -1 #pdb.set_trace() #ffext.dump("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb") #pdb.set_trace() if not TaskModel.getTaskMgr().init(): ffext.error( 'scene init failed when TaskModel.geTaskMgr().init()......') return -1 #print "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx" #pdb.set_trace() #读取NPC 配置 if not NpcModel.getNpcMgr().init(): ffext.error('scene init failed when NpcModel.getMgr().init()......') return -1 if not PetModel.getPetMgr().init(): ffext.error('scene init failed when PetModel.getMgr().init()......') return -1 #读取行会配置 if not GuildModel.getGuildMgr().init(): ffext.error('scene init failed when GuildModel.getMgr().init()......') return -1 if not TeamModel.getBrotherMgr().init(): ffext.error( 'scene init failed when BrotherModel.getBrotherMgr().init()......') return -1 if not MarryModel.getMarryMgr().init(): ffext.error( 'scene init failed when MarryModel.getMarryMgr().init......') return -1 if not RankModel.getRankMgr().init(): ffext.error('scene init failed when RankModel.getRankMgr().init......') return -1 # 读取每日登录配置 if not LoginRewardModel.getLoginRewardMgr().init(): ffext.error( 'scene init failed when LoginRewardModel.getLoginRewardMgr().init......' ) return -1 if not ArenaModel.getArenaMgr().init(): ffext.error('scene init failed when ArenaModel.init......') return -1 #print "xxxxxxxx" #pdb.set_trace() ffext.timer(1000, MonsterModel.onTimer) MapMgr.getMapMgr().initTimer() #db.set_trace() ffext.timer(5000, PlayerModel.autoRecoverHpMp) GuildModel.getGuildMgr().initTimer() #print "autcitonTimer" #pdb.set_trace() ffext.timer(30000, ItemModel.auctionOnTimer) #pdb.set_trace() return 0
def loadCfg(self): #读取所有怪物的配置 self.allMonPropCfgById.clear() self.allMonPropCfgByName.clear() db = ffext.allocDbConnection('cfg', ffext.getConfig('-cfg')) ret = db.queryResult( 'select cfgid,job,monstertype,level,powerfight,expgoldtimes,expval,hp,mp,\ physic_attack_min,physic_attack_max,magic_attack_min,magic_attack_max,\ physic_defend_min, physic_defend_max, magic_defend_min, magic_defend_max,\ crit, hit, avoid, attackspeed, attacksing, attackinterval, \ attackdistance, movespeed, hurtaborb, hpabsorb, name,burst_all,burst_one,burst_some,bosstype from monsterprop' ) for row in ret.result: propCfg = MonsterProp() propCfg.cfgId = int(row[0]) propCfg.job = int(row[1]) propCfg.monstertype = int(row[2]) propCfg.level = int(row[3]) propCfg.powerfight = int(row[4]) propCfg.expgoldtimes = int(row[5]) if propCfg.expgoldtimes < 1: propCfg.expgoldtimes = 1 propCfg.expval = int(row[6]) propCfg.hp = int(row[7]) propCfg.mp = int(row[8]) #物理攻击 propCfg.physicAttackMin = int(row[9]) #最小物理攻击 propCfg.physicAttackMax = int(row[10]) #最大物理攻击 #法术攻击 propCfg.magicAttackMin = int(row[11]) #最小法术攻击 propCfg.magicAttackMax = int(row[12]) #最大法术攻击 #物理防御 propCfg.physicDefendMin = int(row[13]) #最小物理防御 propCfg.physicDefendMax = int(row[14]) #最大物理防御 #法术防御 propCfg.magicDefendMin = int(row[15]) #最小法术防御 propCfg.magicDefendMax = int(row[16]) #最大法术防御 #暴击 propCfg.crit = int( ffext.perToNum(row[17]) * Base.CRIT_RATE_BASE / 100) #暴击 影响暴击的概率 浮点数 propCfg.hit = int( ffext.perToNum(row[18]) * Base.HIT_RATE_BASE / 100) #命中 影响攻击时的命中率 浮点数 propCfg.avoid = int( ffext.perToNum(row[19]) * Base.AVOID_RATE_BASE / 100) #躲避 被攻击时,影响降低被命中的概率 浮点数 propCfg.attackSpeed = int(row[20]) #攻击速度 propCfg.attackSing = int( row[21] ) #攻击吟唱时间 影响释放攻击动作前的吟唱时间 吟唱时间内被攻击,有50%概率被打断,打断后需要重新吟唱,单位:秒 精确到毫秒 propCfg.attackInterval = int(row[22]) #两次攻击之间间隔时间,单位:秒 精确到毫秒 propCfg.attackDistance = int( row[23]) #攻击距离 以单位为中心的圆内可以攻击,近战标准值:100,远程值:600 if propCfg.attackDistance >= 100: propCfg.attackDistance = int(propCfg.attackDistance / 100) #propCfg.attackDistance += 1 propCfg.moveSpeed = int(row[24]) #移动速度 影响地图上移动速度,标准值:100 精确到毫秒 propCfg.hurtAbsorb = int(row[25]) #伤害吸收 受到伤害时,一定比例转换为生命值 百分比 propCfg.hpAbsorb = int(row[26]) #吸血 当对敌人造成伤害时,吸取血量恢复自身生命值 百分比 propCfg.name = row[27].strip() burstGroupCfg = strToBurstGroupCfg(row[28], BurstType.BURST_ALL) if len(burstGroupCfg.allBurstCfg) > 0: propCfg.allBurstCfg.append(burstGroupCfg) #ffext.dump('monster burst cfg', burstGroupCfg) burstGroupCfg = strToBurstGroupCfg(row[29], BurstType.BURST_ONE) if len(burstGroupCfg.allBurstCfg) > 0: propCfg.allBurstCfg.append(burstGroupCfg) #ffext.dump('monster burst cfg', burstGroupCfg) burstGroupCfg = strToBurstGroupCfg(row[30], BurstType.BURST_SOME) if len(burstGroupCfg.allBurstCfg) > 0: propCfg.allBurstCfg.append(burstGroupCfg) #ffext.dump('monster burst cfg', burstGroupCfg) if row[31] != '': propCfg.bosstype = int(row[31]) self.allMonPropCfgById[propCfg.cfgId] = propCfg self.allMonPropCfgByName[propCfg.name] = propCfg sql = 'select name, mapid, x,y, num,rebornSec,autoattack from monstergen' db = ffext.allocDbConnection('cfg', ffext.getConfig('-cfg')) ret = db.queryResult(sql) self.mnstergen = [] for row in ret.result: monName = row[0].strip() mapName = row[1].strip() x = int(row[2]) y = int(row[3]) num = int(row[4]) rangeMax = 0 if num > 1: rangeMax = num rebornSec = int(row[5]) autoattack = int(row[6]) self.mnstergen.append( [mapName, monName, x, y, num, rangeMax, rebornSec]) genMonster(mapName, monName, x, y, num, rangeMax, rebornSec, autoattack) #爆落相关的配置 self.readBagIdCfg() self.readmonsterdrop_lv2bag() return True
def init(self): #读取任务配置 db = ffext.allocDbConnection('cfg', ffext.getConfig('-cfg')) ret = db.queryResult( 'select id,name,lastid,task_type,action,jie_npc,jiao_npc,mubiao,show_jie,show_jiao, jie_duibai,jiao_duibai,jie_juqing,complete_juqing,jiao_juqing,jl_exp,jl_coin,mubiao_name,mubiao_num,level,branch_id, jie_gei_daoju from task' ) self.allTaskCfg = {} #taskid -> TaskCfg self.type2Task = {} #tasktype -> list<TaskCfg> for i in range(0, len(ret.result)): row = ret.result[i] taskCfg = TaskCfg() taskCfg.taskId = Base.str2Int(row[0]) taskCfg.name = row[1] taskCfg.desc = row[7] preTaskId = Base.str2Int(row[2]) taskCfg.needLevel = Base.str2Int(row[19]) taskCfg.taskType = Base.str2Int(row[20]) #TaskType.MAIN_TASK action = Base.str2Action(row[4]) taskCfg.action = action taskCfg.object = 0 taskCfg.value = 1 if action == Base.Action.KILL_MONSTER: taskCfg.object = 101 #TODO elif action == Base.Action.COPY_MAP: taskCfg.object = 10005 #TODO if action == Base.Action.NONE_ACTION: ffext.error( 'Task.Init failed taskid = %d not support action = %s' % (taskCfg.taskId, row[4])) continue elif action == Base.Action.KILL_MONSTER: objectStr = row[7] monsterName = row[ 17] #objectStr.decode('utf-8')[2:].encode('utf-8') taskCfg.value = int(row[18]) #monsterName = row[7][:4] monCfg = MonsterModel.getMonsterMgr().getCfgByName(monsterName) if None == monCfg: ffext.error( 'Task.Init failed taskid = %d not support monsterName = %s [%s]' % (taskCfg.taskId, row[7], monsterName)) taskCfg.object = 0 #return False else: taskCfg.object = monCfg.cfgId #ret2 = db.queryResult("update maintask set targetName = '%s', targetNum = 1 where taskid = %d"%(monsterName, taskCfg.taskId)) #ffext.dump('*************', monsterName, taskCfg.object) elif action == Base.Action.COLLECT: objectStr = row[7] itemName = row[ 17] #objectStr.decode('utf-8')[2:].encode('utf-8') from model import ItemModel itemCfg = ItemModel.getItemMgr().getCfgByName(itemName) if itemCfg: taskCfg.object = itemCfg.cfgId taskCfg.value = int(row[18]) #ret2 = db.queryResult("update maintask set targetName = '%s', targetNum = 1 where taskid = %d"%(itemName, taskCfg.taskId)) #ffext.dump('*************', itemName, taskCfg.object) taskCfg.nextTaskId = 0 taskCfg.acceptshow = row[8] #接任务NPC面板显示 taskCfg.finishshow = row[9] #交任务NPC面板显示 #'select id,name,lastid,task_type,action,jie_npc,jiao_npc,mubiao,show_jie,show_jiao,' #'jie_duibai,jiao_duibai,jie_juqing,complete_juqing,jiao_juqing,jl_exp,jl_coin,mubiao_name,mubiao_num from task') if row[10] != '': taskCfg.acceptdialog = int(row[10]) #接任务剧情对白id jie_duibai if row[11] != '': taskCfg.finishdialog = int(row[11]) #jiao_duibai if row[12] != '': taskCfg.acceptplay = int(row[12]) #接任务插入剧情id jie_juqing #if row[11] != '': # taskCfg.completedialog = int(row[11]) #目标完成剧情对白id if row[13] != '': taskCfg.completeplay = int(row[13]) #条件达成剧情id complete_juqing if row[14] != '': taskCfg.finishplay = int(row[14]) #交任务插入剧情id complete_juqing taskCfg.exp = int(row[15]) #经验奖励 taskCfg.gold = int(row[16]) #金币奖励 if preTaskId == taskCfg.taskId: preTaskId = 0 if i != 0 and preTaskId != 0: if self.allTaskCfg.get(preTaskId) == None: ffext.error('tid %d 前置任务 %d 不存在' % (taskCfg.taskId, preTaskId)) continue self.allTaskCfg[preTaskId].nextTaskId = taskCfg.taskId if row[5].isdigit(): taskCfg.acceptNpc = int(row[5]) if row[6].isdigit(): taskCfg.finishNpc = int(row[6]) taskCfg.itemGiveAccept = row[21] self.allTaskCfg[taskCfg.taskId] = taskCfg cfg = self.type2Task.get(taskCfg.taskType) if not cfg: self.type2Task[taskCfg.taskType] = [taskCfg] else: cfg.append(taskCfg) ffext.dump('load task num=%d' % (len(ret.result))) return True
def init(self): db = ffext.allocDbConnection('cfg', ffext.getConfig('-cfg')) ret = db.queryResult( 'select guildLevel,guildExp,guildNum, guildDayExp, playerDayExp from guild' ) self.guildLevelCfg = {} for row in ret.result: levelCfg = guildLevelCfg() levelCfg.setGuildLevelCfg(long(row[0]), long(row[1]), long(row[2]), long(row[3]), long(row[4])) self.guildLevelCfg[levelCfg.guildLevel] = levelCfg def guildInfo(ret): if ret.flag == False or len(ret.result) == 0: self.allGuild = {} return for i in range(0, len(ret.result)): guildID = long(ret.result[i][0]) if None == self.getGuildById(guildID): guildInfo = GuildInfo() guildLevel = long(ret.result[i][8]) guildExp = long(ret.result[i][9]) #行会剩余资源 levelRanking = 1 #遍历现有字典,获取该行会现有排名,并插入 for uid, val in self.allGuild.iteritems(): if val.guildLevel < guildLevel or ( val.guildLevel == guildLevel and val.guildExp < guildExp): val.levelRanking = val.levelRanking + 1 else: levelRanking = levelRanking + 1 guildInfo.allGuildMemberTemp = {} #申请加入行会成员列表 guildInfo.guildID = long(ret.result[i][0]) #行会ID guildInfo.guildName = str(ret.result[i][5]) #行会名称 guildInfo.guildImage = str(ret.result[i][6]) #行会名称 guildInfo.guildNotice = str(ret.result[i][7]) #行会名称 guildInfo.guildLevel = guildLevel #行会等级 guildInfo.levelRanking = levelRanking #行会经验 guildInfo.guildExp = guildExp guildInfo.guildLeaderName = str(ret.result[i][10]) #行会名称 guildInfo.lastDateContribution = long( ret.result[i][11]) #行会经验 guildInfo.lastDate = str(ret.result[i][12]) #行会名称 self.allGuild[guildInfo.guildID] = guildInfo else: guildInfo = self.getGuildById(guildID) playerGuildInfo = PlayerGuildInfo() ranking = 1 contribute = ret.result[i][4] #遍历现有字典,获取该行会现有排名,并插入 for uid, val in guildInfo.allGuildMember.iteritems(): if val.contribute > contribute: ranking = ranking + 1 else: val.ranking = val.ranking + 1 #ffext.dump('ret is!!!!!!!!!!!!!!!!!!!!!!!!! ', ret) playerGuildInfo.setPlayerGuildInfo(long(ret.result[i][1]), str(ret.result[i][2]), long(ret.result[i][3]), contribute, ranking) guildInfo.allGuildMember[playerGuildInfo.uid] = playerGuildInfo return #DbService.getGuildService().syncGetGuildMemberInfoList(guildInfo) def loadAllGuild(ret): if ret.flag == False or len(ret.result) == 0: self.allGuild = {} return for i in range(0, len(ret.result)): guildInfo = GuildInfo() levelRanking = i + 1 #sql = "select guildid, guildname, guildimage, guildnotice, guildlevel, guildExp, guildchiefname, lastdatecontribution, lastdate from guildinfo order by guildlevel desc, guildExp desc" guildInfo.guildID = long(ret.result[i][0]) # 行会ID guildInfo.guildName = str(ret.result[i][1]) # 行会名称 guildInfo.guildImage = str(ret.result[i][2]) # 行会名称 guildInfo.guildNotice = str(ret.result[i][3]) # 行会名称 guildInfo.guildLevel = long(ret.result[i][4]) # 行会等级 guildInfo.levelRanking = levelRanking guildInfo.guildExp = long(ret.result[i][5]) # 行会经验 guildInfo.guildLeaderName = str(ret.result[i][6]) # 行会名称 guildInfo.lastDateContribution = long(ret.result[i][7]) # 行会经验 guildInfo.lastDate = ffext.str2timestamp( ret.result[i][8]) # 行会名称 #ffext.dump('loadAllGuild', guildInfo) self.allGuild[guildInfo.guildID] = guildInfo return def loadAllGuildMember(ret): for i in range(0, len(ret.result)): playerGuildInfo = PlayerGuildInfo() row = ret.result[i] guildID = long(row[0]) guildInfo = self.getGuildById(guildID) if not guildInfo: return #sql = "select guildid, guildmemberinfo.uid as uid1, name2,memberpost3, contribute4 daycontribute5, lastdate6, level7 from guildmemberinfo, player where player.uid = guildmemberinfo.uid and player.delflag = 0" playerGuildInfo.setPlayerGuildInfo(long(row[1]), str(row[2]), long(row[3]), long(row[4]), 1, int(row[7]), int(row[8])) playerGuildInfo.daycontribute = long(row[5]) playerGuildInfo.lastdate = ffext.str2timestamp(row[6]) guildInfo.allGuildMember[playerGuildInfo.uid] = playerGuildInfo #ffext.dump('loadAllGuildMember!!!!!!!!!!!!!!!!!!!!!!!!', row, playerGuildInfo) return DbService.getGuildService().syncGetAllGuildInfo(loadAllGuild) DbService.getGuildService().syncGetAllGuildMember(loadAllGuildMember) for k, v in self.allGuild.iteritems(): v.calMemberRank() return True
def init(self):#读取任务配置 db = ffext.allocDbConnection('cfg',ffext.getConfig('-cfg')) #id name des mofa lengque speed yinchang jiange juli zuoyong nuqi icon ret = db.queryResult('select id,name,des,mofa,lengque,speed,yinchang,jiange,juli,zuoyong,nuqi,needlevel,skilltype,skilllevel from skill') self.allSkillCfg = {} from handler import MarryHandler for row in ret.result: skillCfg = self.data2cfg(row) cfgDict = self.allSkillCfg.get(skillCfg.skillType) #ffext.dump('load skill cfg', skillCfg.skillType, skillCfg.skillLevel) #读取战士相关的技能配置 if skillCfg.skillId == 110: param = int(Base.parseStrBetween(skillCfg.intro, '攻击', '%')) #ffext.dump('skill param', skillCfg.skillId, param) skillCfg.hurtCalcultor = SkillCalculatorZhanShi.PuGong(param) elif skillCfg.skillId>= 120 and skillCfg.skillId <= 129: param = int(Base.parseStrBetween(skillCfg.intro, '攻击', '%')) #ffext.dump('skill param', skillCfg.skillId, param) skillCfg.hurtCalcultor = SkillCalculatorZhanShi.ChuanQiangCiShu(param) elif skillCfg.skillId >= 130 and skillCfg.skillId <= 139: param = int(Base.parseStrBetween(skillCfg.intro, '目标造成', '%')) param2 = int(Base.parseStrBetween(skillCfg.intro, '溅射造成', '%')) #ffext.dump('skill param', skillCfg.skillId, param, param2) skillCfg.hurtCalcultor = SkillCalculatorZhanShi.HengSaoQianJun(param, param2) elif skillCfg.skillId >= 140 and skillCfg.skillId <= 149: param = int(Base.parseStrBetween(skillCfg.intro, '造成', '%')) param2 = float(Base.parseStrBetween(skillCfg.intro, '眩晕', '秒')) #ffext.dump('skill param', skillCfg.skillId, param, param2) skillCfg.hurtCalcultor = SkillCalculatorZhanShi.ChongFengXianZhen(param, 2, param2) elif skillCfg.skillId >= 150 and skillCfg.skillId <= 159:#151 暴怒一击-2 对目标造成200%物理伤害 param = int(Base.parseStrBetween(skillCfg.intro, '造成', '%')) #ffext.dump('skill param', skillCfg.skillId, param) skillCfg.hurtCalcultor = SkillCalculatorZhanShi.PuGong(param) elif skillCfg.skillId >= 160 and skillCfg.skillId <= 169:#TODO strArg = Base.parseStrBetween(skillCfg.intro, '造成', '%的物理伤害') args = strArg.split('%,') ##ffext.dump('skill param', skillCfg.skillId, strArg, args) intArgs = [] for k in args: intArgs.append(int(k)) #ffext.dump('skill param', skillCfg.skillId, intArgs) skillCfg.hurtCalcultor = SkillCalculatorZhanShi.YinLongHuXiao(intArgs[0], intArgs[1], intArgs[2]) elif skillCfg.skillId == Base.WUSHUANG_SKILL_ID:# 1001 战士无双 - 无人能挡 对自身周围敌人造成物理攻击250 % 的物理伤害,同时敌人眩晕1秒 param = int(Base.parseStrBetween(skillCfg.intro, '物理攻击', '%')) param2 = float(Base.parseStrBetween(skillCfg.intro, '眩晕', '秒')) #ffext.dump('skill param', skillCfg.skillId, param, param2) skillCfg.hurtCalcultor = SkillCalculatorZhanShi.WuShuangWuRenNengDang(param, param2) elif skillCfg.skillId == 210:#210 普通攻击 对目标造成魔法攻击105%的魔法伤害 param = int(Base.parseStrBetween(skillCfg.intro, '魔法攻击', '%')) #ffext.dump('skill param', skillCfg.skillId, param) skillCfg.hurtCalcultor = SkillCalculatorFaShi.PuGong(param) elif skillCfg.skillId >= 220 and skillCfg.skillId <= 229:#220 引动天雷-1 对目标敌人造成125%的魔法伤害,有30%几率对目标周围造成15%魔法伤害 param = int(Base.parseStrBetween(skillCfg.intro, '敌人造成', '%')) param2 = int(Base.parseStrBetween(skillCfg.intro, ',有', '%')) param3 = int(Base.parseStrBetween(skillCfg.intro, '周围造成', '%')) #ffext.dump('skill param', skillCfg.skillId, param, param2, param3) skillCfg.hurtCalcultor = SkillCalculatorFaShi.YinDongTianLei(param, param2, param3) elif skillCfg.skillId >= 230 and skillCfg.skillId <= 239: # 230 冰封之术-1 对目标造成魔法攻击100%的魔法伤害,同时5秒内减速目标15%移动速度 param = int(Base.parseStrBetween(skillCfg.intro, '魔法攻击', '%')) param2 = int(Base.parseStrBetween(skillCfg.intro, '减速目标', '%')) #ffext.dump('skill param', skillCfg.skillId, param, param2) skillCfg.hurtCalcultor = SkillCalculatorFaShi.BingFengZhiShu(param, param2) elif skillCfg.skillId >= 240 and skillCfg.skillId <= 249: # 240 神明护体-1 魔法的能量环绕身体,120秒内降低对法师的造成伤害25% param = int(Base.parseStrBetween(skillCfg.intro, '身体,', '秒')) param2 = int(Base.parseStrBetween(skillCfg.intro, '伤害', '%')) #ffext.dump('skill param', skillCfg.skillId, param, param2) skillCfg.hurtCalcultor = SkillCalculatorFaShi.ShenMingFuTi(param, param2) #250 陨石暴落-1 一颗陨石从天而降,对单个目标造成250%的魔法伤害,5秒内造成2次附带灼烧25%魔法伤害 elif skillCfg.skillId >= 250 and skillCfg.skillId <= 259: param = int(Base.parseStrBetween(skillCfg.intro, '目标造成', '%')) param2 = int(Base.parseStrBetween(skillCfg.intro, '伤害,', '秒')) param3 = int(Base.parseStrBetween(skillCfg.intro, '内造成', '次附带')) param4 = int(Base.parseStrBetween(skillCfg.intro, '灼烧', '%魔法伤害')) #ffext.dump('skill param', skillCfg.skillId, param, param2) skillCfg.hurtCalcultor = SkillCalculatorFaShi.YunShiBaoLuo(param, param2, param3, param4) elif skillCfg.skillId >= 260 and skillCfg.skillId <= 269: # 260 天火燎原-1 对目标造成120%的魔法伤害,同时对目标周围范围的目标造成35%溅射伤害。 param = int(Base.parseStrBetween(skillCfg.intro, '对目标造成', '%')) param2 = int(Base.parseStrBetween(skillCfg.intro, '的目标造成', '%')) #ffext.dump('skill param', skillCfg.skillId, param, param2) skillCfg.hurtCalcultor = SkillCalculatorFaShi.TianHuoLiaoYuan(param, param2) elif skillCfg.skillId == Base.FA_WUSHUANG_SKILL_ID: # 1002 法师 无双 param = int(Base.parseStrBetween(skillCfg.intro, '魔法攻击', '%')) # ffext.dump('skill param', skillCfg.skillId, param, param2) skillCfg.hurtCalcultor = SkillCalculatorFaShi.FaShiWuShuang_LongXiaoJiuTian(param) # 术士-技能读取 -------- elif skillCfg.skillId == 310: param = int(Base.parseStrBetween(skillCfg.intro, '攻击', '%')) #ffext.dump('skill param', skillCfg.skillId, param) skillCfg.hurtCalcultor = SkillCalculatorShuShi.PuGong(param) elif skillCfg.skillId >= 320 and skillCfg.skillId <= 329: param = int(Base.parseStrBetween(skillCfg.intro, '目标', '秒内')) param2 = int(Base.parseStrBetween(skillCfg.intro, '内每', '秒回')) param3 = int(Base.parseStrBetween(skillCfg.intro, '回复', '点')) #ffext.dump('skill param', skillCfg.skillId, param, param2, param3) skillCfg.hurtCalcultor = SkillCalculatorShuShi.ZhiYuShu(param3) elif skillCfg.skillId >= 330 and skillCfg.skillId <= 339: param = int(Base.parseStrBetween(skillCfg.intro, '召唤', '个')) param2 = int(Base.parseStrBetween(skillCfg.intro, '自身属性', '%')) #ffext.dump('skill param', skillCfg.skillId, param, param2) skillCfg.hurtCalcultor = SkillCalculatorShuShi.ZhaoHuanYinXiang(param, param2) elif skillCfg.skillId >= 340 and skillCfg.skillId <= 349: param = int(Base.parseStrBetween(skillCfg.intro, '中毒,', '秒内')) param2 = int(Base.parseStrBetween(skillCfg.intro, '每', '秒受')) param3 = int(Base.parseStrBetween(skillCfg.intro, '受到', '%')) #ffext.dump('skill param', skillCfg.skillId, param, param2) skillCfg.hurtCalcultor = SkillCalculatorShuShi.ShiDuShu(param, param2, param3) elif skillCfg.skillId >= 350 and skillCfg.skillId <= 359: param = int(Base.parseStrBetween(skillCfg.intro, '目标', '%')) #ffext.dump('skill param', skillCfg.skillId, param) skillCfg.hurtCalcultor = SkillCalculatorShuShi.GuWuShiQi(60, param) elif skillCfg.skillId >= 360 and skillCfg.skillId <= 369: param = int(Base.parseStrBetween(skillCfg.intro, '最大生命值', '%')) #ffext.dump('skill param', skillCfg.skillId, param) skillCfg.hurtCalcultor = SkillCalculatorShuShi.FuHuoZhiShu(param) # 术士-技能读取 -------- #游侠/弓箭手-技能读取 -------- elif skillCfg.skillId == 410: param = int(Base.parseStrBetween(skillCfg.intro, '攻击', '%')) #ffext.dump('skill param', skillCfg.skillId, param) skillCfg.hurtCalcultor = SkillCalculatorYouXia.PuGong(param) elif skillCfg.skillId >= 420 and skillCfg.skillId <= 429: param = int(Base.parseStrBetween(skillCfg.intro, '造成', '%的物理')) param2 = int(Base.parseStrBetween(skillCfg.intro, '四个目标造成', '%溅射')) #ffext.dump('skill param', skillCfg.skillId, param, param2) skillCfg.hurtCalcultor = SkillCalculatorYouXia.WuJianLianShe(param, 4, param2) elif skillCfg.skillId >= 430 and skillCfg.skillId <= 439: param = int(Base.parseStrBetween(skillCfg.intro, '攻击', '%')) param2 = float(Base.parseStrBetween(skillCfg.intro, '同时', '秒内')) param3 = int(Base.parseStrBetween(skillCfg.intro, '减速目标', '%')) #ffext.dump('skill param XuRuoZhiJian', skillCfg.skillId, param, param2, param3) skillCfg.hurtCalcultor = SkillCalculatorYouXia.XuRuoZhiJian(param, param2, param3) elif skillCfg.skillId >= 440 and skillCfg.skillId <= 449: param = int(Base.parseStrBetween(skillCfg.intro, '攻击', '%')) #ffext.dump('skill param', skillCfg.skillId, param) skillCfg.hurtCalcultor = SkillCalculatorYouXia.PoJiaZhiJian(param) elif skillCfg.skillId >= 450 and skillCfg.skillId <= 459: param = int(Base.parseStrBetween(skillCfg.intro, '2次', '%')) #ffext.dump('skill param', skillCfg.skillId, param) skillCfg.hurtCalcultor = SkillCalculatorYouXia.SanLianJiShe(3, param) elif skillCfg.skillId >= 460 and skillCfg.skillId <= 469: #ffext.dump('skill param', skillCfg.skillId) skillCfg.hurtCalcultor = SkillCalculatorYouXia.JiSuHouChe() # 游侠/弓箭手-技能读取 -------- # elif int(skillCfg.skillId / 100) == 2: # param = 125 # skillCfg.hurtCalcultor = SkillCalculatorFaShi.PuGong(param) # elif int(skillCfg.skillId / 100) == 3: # param = 110 # skillCfg.hurtCalcultor = SkillCalculatorShuShi.PuGong(param) # elif int(skillCfg.skillId / 100) == 4: # param = 110 # skillCfg.hurtCalcultor = SkillCalculatorShuShi.PuGong(param) elif skillCfg.skillId == Base.BRO_SKILL_ID:#结义技能 #2001 结义技能 当结义队友在场时,释放技能后,60秒内结义队友全部增加10%物理和魔法攻击力 param1 = 60 param2 = 0.1 skillCfg.hurtCalcultor = SkillCalculatorZhanShi.JieYi(param1, param2) elif skillCfg.skillId == MarryHandler.WEDDING_SKILL_ID: param1 = 60 param2 = 10 skillCfg.hurtCalcultor = SkillCalculatorZhanShi.Wedding(param1, param2) else: param = 110 skillCfg.hurtCalcultor = SkillCalculatorZhanShi.PuGong(param) if not cfgDict: self.allSkillCfg[skillCfg.skillType] = {skillCfg.skillLevel: skillCfg} else: self.allSkillCfg[skillCfg.skillType][skillCfg.skillLevel] = skillCfg #ffext.dump('load skill type=%d,level=%d, %s'%(skillCfg.skillType, skillCfg.skillLevel, type(skillCfg.skillLevel))) #sql = 'update skill set skilltype=%d,skilllevel=%d where skillid=%d'%(skillCfg.skillType, skillCfg.skillLevel, int(row[0])) #ffext.dump('sql', sql) #ret = db.queryResult(sql) ffext.dump('load skill num=%d'%(len(self.allSkillCfg))) #print(self.allSkillCfg[120][2]) return True