Beispiel #1
0
	def getConfig(confname):
		conf = cache.loc_getValue('config:' + confname)
		if not conf:
			conf = json.loads(config.getConfigStr(confname))
			cache.loc_setValue('config:' + confname, conf)
			conf = cache.loc_getValue('config:' + confname)
		#conf = json.loads(config.getConfigStr(confname))
		return conf
Beispiel #2
0
	def setConfig(confname, confstr):
		"""
		设置配置
		"""
		confjson = json.loads(confstr)
		conn = DBConnection.getConnection();
		conn.excute("UPDATE config SET conf = %s WHERE confname = %s", [confstr, confname])
		cache.loc_delete('config:' + confname)
Beispiel #3
0
	def award_score(roleid, awardScore):
		"""
		分数奖励
		"""
		if SIGLE_SERVER:
			from arenarank.routine.arena import arena as arenaR
			return arenaR.award_score(str(roleid), awardScore)
		else:
			return json.loads(curl.url(ARENE_SERVER +  '/arena/award_score/', None, {'roleid':roleid, 'award_score': awardScore}))
Beispiel #4
0
	def GetBattle(usr):
		"""
		得到战斗
		"""
		if SIGLE_SERVER:
			from arenarank.routine.infection import infection as infectionR
			return infectionR.get_battle(str(usr.roleid))
		else: 
			return json.loads(curl.url(ARENE_SERVER +  '/arena/infection_get_battle/', None, {'roleid':usr.roleid}))
Beispiel #5
0
	def show_ladder(usr):
		"""
		显示楼梯
		"""
		if SIGLE_SERVER:
			from arenarank.routine.tower import tower as towerR
			return {'tower_ladder':towerR.show_ladder()}
		else:
			return {'tower_ladder':json.loads(curl.url(ARENE_SERVER +  '/arena/tower_show/', None, {'roleid': usr.roleid, 'level': usr.level}))}
Beispiel #6
0
	def BattleAward(usr, battleRoleid, create_time):
		"""
		站斗奖励
		"""
		if SIGLE_SERVER:
			from arenarank.routine.infection import infection as infectionR
			return infectionR.award(str(usr.roleid), battleRoleid, create_time)
		else:
			return json.loads(curl.url(ARENE_SERVER +  '/arena/infection_battle_award/', None, {'roleid':str(usr.roleid), 'battle_roleid': battleRoleid, 'create_time':create_time}))
Beispiel #7
0
	def Info(usr):
		"""
		感染信息
		"""
		if SIGLE_SERVER:
			from arenarank.routine.infection import infection as infectionR
			return infectionR.user_info(str(usr.roleid))
		else: 
			return json.loads(curl.url(ARENE_SERVER + '/arena/infection_info/', None, {'roleid':usr.roleid}))
Beispiel #8
0
	def Ladder(usr, tp):
		"""
		天梯
		"""
		if SIGLE_SERVER:
			from arenarank.routine.infection import infection as infectionR
			return infectionR.ladder(tp, str(usr.roleid))
		else:			
			return json.loads(curl.url(ARENE_SERVER +  '/arena/infection_ladder/', None, {'type':tp, 'rolelevel': usr.level}))
Beispiel #9
0
	def stand(usr):
		"""
		加入排行榜
		"""
		if SIGLE_SERVER:
			from arenarank.routine.tower import tower as towerR
			return towerR.stand(str(usr.roleid), usr.name, usr.level, usr.tower['current']['point'], tower.current_floor(usr))
		else: 
			return json.loads(curl.url(ARENE_SERVER +  '/arena/tower_stand/', None, {'roleid': usr.roleid, 'level': usr.level, 'point':  usr.tower['current']['point'], 'name':usr.name, 'floor':tower.current_floor(usr)}))
Beispiel #10
0
	def show(usr):	
		"""
		显示
		"""	
		if SIGLE_SERVER:
			from arenarank.routine.arena import arena as arenaR
			return arenaR.show(str(usr.roleid))
		else: 
			return json.loads(curl.url(ARENE_SERVER + '/arena/show/', None, {'roleid': usr.roleid}))
Beispiel #11
0
	def score(roleid):
		"""
		分数
		"""
		if SIGLE_SERVER:
			from arenarank.routine.arena import arena as arenaR
			return arenaR.score(str(roleid))
		else:
			return json.loads(curl.url(ARENE_SERVER +  '/arena/score/', None, {'roleid':roleid}))
Beispiel #12
0
	def show_all():
		"""
		显示所有
		"""
		if SIGLE_SERVER:
			from arenarank.routine.arena import arena as arenaR
			return arenaR.show_all()
		else:
			return json.loads(curl.url(ARENE_SERVER +  '/arena/show_all/', None, {}))
Beispiel #13
0
	def set_avatar_id(roleid, avatar_id):
		"""
		设置avatar id
		"""
		if SIGLE_SERVER:
			from arenarank.routine.arena import arena as arenaR
			return arenaR.set_avatar_id(str(roleid), avatar_id)
		else:
			return json.loads(curl.url(ARENE_SERVER +  '/arena/set_avatar_id/', None, {'roleid':roleid, 'avatar_id':avatar_id}))
Beispiel #14
0
	def stand_ladder(usr):
		"""
		站上天梯
		"""
		if SIGLE_SERVER:
			from arenarank.routine.arena import arena as arenaR
			return arenaR.stand(str(usr.roleid))
		else:
			return json.loads(curl.url(ARENE_SERVER +  '/arena/stand_ladder/', None, {'roleid':str(usr.roleid)}))
Beispiel #15
0
	def Encount(usr):
		"""
		遇敌
		"""
		if SIGLE_SERVER:
			from arenarank.routine.infection import infection as infectionR
			return infectionR.encounter(str(usr.roleid), usr.name)
		else:
			return json.loads(curl.url(ARENE_SERVER +  '/arena/infection_encounter/', None, {'roleid':str(usr.roleid), 'rolename': usr.name}))
Beispiel #16
0
	def gift_ladder(usr, tp, begin, end):
		"""
		礼物天梯
		"""
		if tp != 'charm' and tp != 'tuhao':
			return {'msg':'parameter_bad'}
		return json.loads(curl.url(ARENE_SERVER +  '/arena/network_range/', None, {'roleid':usr.roleid, 'type':tp, 'begin': begin, 'end': end}))
	
		
Beispiel #17
0
	def PrestigeAward(usr):
		"""
		声望奖励
		"""
		if SIGLE_SERVER:
			from arenarank.routine.infection import infection as infectionR
			return infectionR.prestige_award(str(usr.roleid), usr.level)
		else:
			return json.loads(curl.url(ARENE_SERVER + '/arena/infiection_prestige_award/', None, {'roleid':usr.roleid, 'rolelevel': usr.level}))
Beispiel #18
0
	def ResetPrestigeScore(usr):
		"""
		重置声望分数
		"""
		if SIGLE_SERVER:
			from arenarank.routine.infection import infection as infectionR
			return infectionR.reset_prestige_score(str(usr.roleid))
		else: 
			return json.loads(curl.url(ARENE_SERVER + '/arena/infection_reset_prestige_score/', None, {'roleid':usr.roleid}))
Beispiel #19
0
    def setConfig(confname, confstr):
        """
		设置配置
		"""
        confjson = json.loads(confstr)
        conn = DBConnection.getConnection()
        conn.excute("UPDATE config SET conf = %s WHERE confname = %s",
                    [confstr, confname])
        cache.loc_delete('config:' + confname)
Beispiel #20
0
    def show_all():
        """
		显示所有
		"""
        if SIGLE_SERVER:
            from arenarank.routine.arena import arena as arenaR
            return arenaR.show_all()
        else:
            return json.loads(
                curl.url(ARENE_SERVER + '/arena/show_all/', None, {}))
Beispiel #21
0
    def defeate(usr):
        """
		击败
		"""
        res = None
        if usr.arena.has_key('challenge_roleid'):

            if SIGLE_SERVER:
                from arenarank.routine.arena import arena as arenaR
                return arenaR.defeat(str(usr.roleid),
                                     str(usr.arena['challenge_roleid']))
            else:
                res = json.loads(
                    curl.url(
                        ARENE_SERVER + '/arena/defeat/', None, {
                            'offence_roleid': usr.roleid,
                            'defence_roleid': usr.arena['challenge_roleid']
                        }))

            arenaLootConf = config.getConfig('arena_loot')
            gameConf = config.getConfig('game')

            if res.has_key('msg'):
                return res

            alreadyReach = False
            for item in gameConf['arena_rank_award']:
                if item['rank'] >= res['position'] and (
                        not usr.arena['rank_award'].has_key(item['rank'])):
                    usr.arena['rank_award'][item['rank']] = True

            arenaLootInfo = arenaLootConf[usr.level - 1]
            challengeRole = usr.__class__.get(usr.arena['challenge_roleid'])
            challengeRole.gold = challengeRole.gold - arenaLootInfo['gold']
            if challengeRole.gold < 0:
                challengeRole.gold = 0
            challengeRole.notify_gold()
            challengeRole.save()
            del usr.arena['challenge_roleid']
            card = None
            gold = 0
            skl = None
            data = {}
            if usr.arena.has_key('loot'):
                data = drop.do_award(usr, usr.arena['loot'], data)
                data = drop.makeData(data, res, 'award')

            usr.gainExp(arenaLootInfo['exp'])
            usr.gold = usr.gold + arenaLootInfo['gold']
            data['exp'] = usr.exp
            data['level'] = usr.level
            data['gold'] = usr.gold
            usr.save()
            return data
        return {'msg': 'arena_ladder_have_not_chellenge'}
Beispiel #22
0
    def stand_ladder(usr):
        """
		站上天梯
		"""
        if SIGLE_SERVER:
            from arenarank.routine.arena import arena as arenaR
            return arenaR.stand(str(usr.roleid))
        else:
            return json.loads(
                curl.url(ARENE_SERVER + '/arena/stand_ladder/', None,
                         {'roleid': str(usr.roleid)}))
Beispiel #23
0
    def Info(usr):
        """
		感染信息
		"""
        if SIGLE_SERVER:
            from arenarank.routine.infection import infection as infectionR
            return infectionR.user_info(str(usr.roleid))
        else:
            return json.loads(
                curl.url(ARENE_SERVER + '/arena/infection_info/', None,
                         {'roleid': usr.roleid}))
Beispiel #24
0
    def getConfig(confname):
        """
		得到置配
		"""
        conf = cache.loc_getValue('config:' + confname)
        if not conf:
            conf = json.loads(config.getConfigStr(confname))
            cache.loc_setValue('config:' + confname, conf)
            conf = cache.loc_getValue('config:' + confname)
        #conf = json.loads(config.getConfigStr(confname))
        return conf
Beispiel #25
0
    def score(roleid):
        """
		分数
		"""
        if SIGLE_SERVER:
            from arenarank.routine.arena import arena as arenaR
            return arenaR.score(str(roleid))
        else:
            return json.loads(
                curl.url(ARENE_SERVER + '/arena/score/', None,
                         {'roleid': roleid}))
Beispiel #26
0
    def show(usr):
        """
		显示
		"""
        if SIGLE_SERVER:
            from arenarank.routine.arena import arena as arenaR
            return arenaR.show(str(usr.roleid))
        else:
            return json.loads(
                curl.url(ARENE_SERVER + '/arena/show/', None,
                         {'roleid': usr.roleid}))
Beispiel #27
0
    def tryGrab(defenceRoleid):
        """
		尝试抢夺
		"""
        if SIGLE_SERVER:
            from arenarank.routine.medal import medal as medalR
            return medalR.try_grab(defenceRoleid)
        else:
            return json.loads(
                curl.url(ARENE_SERVER + '/arena/try_grab/', None,
                         {'defence_roleid': defenceRoleid}))
Beispiel #28
0
    def GetBattle(usr):
        """
		得到战斗
		"""
        if SIGLE_SERVER:
            from arenarank.routine.infection import infection as infectionR
            return infectionR.get_battle(str(usr.roleid))
        else:
            return json.loads(
                curl.url(ARENE_SERVER + '/arena/infection_get_battle/', None,
                         {'roleid': usr.roleid}))
Beispiel #29
0
    def ResetPrestigeScore(usr):
        """
		重置声望分数
		"""
        if SIGLE_SERVER:
            from arenarank.routine.infection import infection as infectionR
            return infectionR.reset_prestige_score(str(usr.roleid))
        else:
            return json.loads(
                curl.url(
                    ARENE_SERVER + '/arena/infection_reset_prestige_score/',
                    None, {'roleid': usr.roleid}))
Beispiel #30
0
    def set_avatar_id(roleid, avatar_id):
        """
		设置avatar id
		"""
        if SIGLE_SERVER:
            from arenarank.routine.arena import arena as arenaR
            return arenaR.set_avatar_id(str(roleid), avatar_id)
        else:
            return json.loads(
                curl.url(ARENE_SERVER + '/arena/set_avatar_id/', None, {
                    'roleid': roleid,
                    'avatar_id': avatar_id
                }))
Beispiel #31
0
    def award_score(roleid, awardScore):
        """
		分数奖励
		"""
        if SIGLE_SERVER:
            from arenarank.routine.arena import arena as arenaR
            return arenaR.award_score(str(roleid), awardScore)
        else:
            return json.loads(
                curl.url(ARENE_SERVER + '/arena/award_score/', None, {
                    'roleid': roleid,
                    'award_score': awardScore
                }))
Beispiel #32
0
	def get(cls, cacheid):
		"""
		get object from cache if not exist return object without laod call.
		"""
		key = cls.makeMKey(cacheid)
		datastr = cache.mc_getValue(key);
		obj = cls()
		obj.cacheid = cacheid		
		obj.cache_key = key
		if datastr:
			data = json.loads(datastr)
			obj.load(cacheid, data)
		return obj
Beispiel #33
0
    def addProtectTime(usr, second):
        """
		添加保护时间
		"""
        if SIGLE_SERVER:
            from arenarank.routine.medal import medal as medalR
            return medalR.add_protect_time(usr.roleid, second)
        else:
            return json.loads(
                curl.url(ARENE_SERVER + '/arena/add_protect_time/', None, {
                    'roleid': usr.roleid,
                    'add_second': second
                }))
Beispiel #34
0
    def Ladder(usr, tp):
        """
		天梯
		"""
        if SIGLE_SERVER:
            from arenarank.routine.infection import infection as infectionR
            return infectionR.ladder(tp, str(usr.roleid))
        else:
            return json.loads(
                curl.url(ARENE_SERVER + '/arena/infection_ladder/', None, {
                    'type': tp,
                    'rolelevel': usr.level
                }))
Beispiel #35
0
    def Encount(usr):
        """
		遇敌
		"""
        if SIGLE_SERVER:
            from arenarank.routine.infection import infection as infectionR
            return infectionR.encounter(str(usr.roleid), usr.name)
        else:
            return json.loads(
                curl.url(ARENE_SERVER + '/arena/infection_encounter/', None, {
                    'roleid': str(usr.roleid),
                    'rolename': usr.name
                }))
Beispiel #36
0
	def get(cls, cacheid):
		"""
		get object from cache if not exist return object without laod call.
		"""
		key = cls.makeMKey(cacheid)
		datastr = cache.mc_getValue(key);
		obj = cls()
		obj.cacheid = cacheid		
		obj.cache_key = key
		if datastr:
			data = json.loads(datastr)
			obj.load(cacheid, data)
		return obj
Beispiel #37
0
	def Call(usr, friend):
		"""
		呼叫援军
		"""
		if SIGLE_SERVER:
			from arenarank.routine.infection import infection as infectionR
			return infectionR.call_relief(str(usr.roleid), friend)
		else:
			data = {}
			for (i, f) in enumerate(friend):
				data['friendid' + str(i)] = f[0]
				data['friendname' + str(i)] = f[1]['name']
			data['roleid'] = usr.roleid
			return json.loads(curl.url(ARENE_SERVER +  '/arena/infection_call_relief/', None, data))
Beispiel #38
0
	def getObject(tp, roleid):
		conn = DBConnection.getConnection()		
		res = conn.query('SELECT * FROM ' + tp.__name__ + ' WHERE roleid = %s', [roleid])
		if len(res) == 1:
			obj = tp()
			obj.id = res[0][0]
			obj.roleid = res[0][1]			
			obj.load(roleid, json.loads(res[0][2]))
			i = 0
			for column in obj.extend_columns:
				setattr(obj, column['name'], res[0][3 + i])
				i = i + 1
			return obj
		return None
Beispiel #39
0
    def levelupMedal(roleid, medalid):
        """
		升级勋章
		"""
        if SIGLE_SERVER:
            from arenarank.routine.medal import medal as medalR
            return medalR.medal_levelup(roleid, medalidm)
        else:
            return json.loads(
                curl.url(ARENE_SERVER + '/arena/medal_levelup/', None, {
                    'medalid': medalid,
                    'roleid': roleid,
                    'medalid': medalid
                }))
Beispiel #40
0
    def PrestigeAward(usr):
        """
		声望奖励
		"""
        if SIGLE_SERVER:
            from arenarank.routine.infection import infection as infectionR
            return infectionR.prestige_award(str(usr.roleid), usr.level)
        else:
            return json.loads(
                curl.url(ARENE_SERVER + '/arena/infiection_prestige_award/',
                         None, {
                             'roleid': usr.roleid,
                             'rolelevel': usr.level
                         }))
Beispiel #41
0
    def convert(usr, mediumCount):
        """
		况换
		"""
        gameConf = config.getConfig('game')
        pointConsume = mediumCount * gameConf['arena_medium_price']

        if SIGLE_SERVER:
            from arenarank.routine.arena import arena as arenaR
            res = arenaR.convert(str(usr.roleid), pointConsume)
        else:
            res = json.loads(
                curl.url(ARENE_SERVER + '/arena/convert/', None, {
                    'roleid': usr.roleid,
                    'score': pointConsume
                }))

        if res.has_key('msg'):
            return res

        mediumId = gameConf['arena_medium_id']
        inv = usr.getInventory()
        updateIt, newIt = inv.addItemCount(mediumId, mediumCount)
        inv.save()

        data = res

        data['drop'] = []
        if updateIt:
            for it in updateIt:
                data['drop'].append({
                    'id': it['itemid'],
                    'insId': it['id'],
                    'type': 4,
                    'count': it['count']
                })
        if newIt:
            for it in newIt:
                data['drop'].append({
                    'id': it['itemid'],
                    'insId': it['id'],
                    'type': 4,
                    'count': it['count']
                })

        #if updateIt:
        #	data['update_item_array'] = updateIt
        #if newIt:
        #	data['add_item_array'] = newIt
        return data
Beispiel #42
0
	def getFacility(tp, name):
		conn = DBConnection.getConnection()		
		res = conn.query('SELECT * FROM ' + tp.__name__ + ' WHERE name = %s', [name])
		if len(res) == 1:
			obj = tp()
			obj.id = res[0][0]
			obj.name = res[0][1]			
			obj.load(name, json.loads(res[0][2]))
			i = 0
			for column in obj.extend_columns:
				setattr(obj, column['name'], res[0][3 + i])
				i = i + 1
			return obj
		return None
Beispiel #43
0
	def defeate(usr):
		"""
		击败
		"""
		res = None
		if usr.arena.has_key('challenge_roleid'):
			
			if SIGLE_SERVER:
				from arenarank.routine.arena import arena as arenaR
				return arenaR.defeat(str(usr.roleid), str(usr.arena['challenge_roleid']))
			else:
				res = json.loads(curl.url(ARENE_SERVER +  '/arena/defeat/', None, {'offence_roleid':usr.roleid, 'defence_roleid':usr.arena['challenge_roleid']}))
			
			arenaLootConf = config.getConfig('arena_loot')
			gameConf = config.getConfig('game')
						
			if res.has_key('msg'):
				return res
				
			alreadyReach = False
			for item in gameConf['arena_rank_award']:
				if item['rank'] >= res['position'] and (not usr.arena['rank_award'].has_key(item['rank'])):
					usr.arena['rank_award'][item['rank']] = True
					
				
			arenaLootInfo = arenaLootConf[usr.level - 1]
			challengeRole = usr.__class__.get(usr.arena['challenge_roleid'])
			challengeRole.gold = challengeRole.gold - arenaLootInfo['gold']
			if challengeRole.gold < 0:
				challengeRole.gold = 0
			challengeRole.notify_gold()
			challengeRole.save()
			del usr.arena['challenge_roleid']
			card = None
			gold = 0
			skl = None			
			data = {}
			if usr.arena.has_key('loot'):
				data = drop.do_award(usr, usr.arena['loot'], data)
				data = drop.makeData(data, res, 'award')
				
			usr.gainExp(arenaLootInfo['exp'])
			usr.gold = usr.gold + arenaLootInfo['gold']
			data['exp'] = usr.exp
			data['level'] = usr.level
			data['gold'] = usr.gold
			usr.save()
			return data			
		return {'msg':'arena_ladder_have_not_chellenge'}
Beispiel #44
0
    def BattleAward(usr, battleRoleid, create_time):
        """
		站斗奖励
		"""
        if SIGLE_SERVER:
            from arenarank.routine.infection import infection as infectionR
            return infectionR.award(str(usr.roleid), battleRoleid, create_time)
        else:
            return json.loads(
                curl.url(
                    ARENE_SERVER + '/arena/infection_battle_award/', None, {
                        'roleid': str(usr.roleid),
                        'battle_roleid': battleRoleid,
                        'create_time': create_time
                    }))
Beispiel #45
0
    def seekHolder(usr, medalid, chipnum):
        """
		寻找持有者
		"""
        if SIGLE_SERVER:
            from arenarank.routine.medal import medal as medalR
            return medalR.seek_holder(usr.roleid, usr.level, medalid, chipnum)
        else:
            return json.loads(
                curl.url(
                    ARENE_SERVER + '/arena/seek_holder/', None, {
                        'roleid': usr.roleid,
                        'level': usr.level,
                        'medalid': medalid,
                        'chipnum': chipnum
                    }))
Beispiel #46
0
    def Call(usr, friend):
        """
		呼叫援军
		"""
        if SIGLE_SERVER:
            from arenarank.routine.infection import infection as infectionR
            return infectionR.call_relief(str(usr.roleid), friend)
        else:
            data = {}
            for (i, f) in enumerate(friend):
                data['friendid' + str(i)] = f[0]
                data['friendname' + str(i)] = f[1]['name']
            data['roleid'] = usr.roleid
            return json.loads(
                curl.url(ARENE_SERVER + '/arena/infection_call_relief/', None,
                         data))
Beispiel #47
0
	def Beat(usr, battle_roleid, damage):		
		"""
		击败
		"""
		data = {}
		data['roleid'] = usr.roleid
		data['rolename'] = usr.name
		data['rolelevel'] = usr.level	
		data['battle_roleid'] = battle_roleid
		data['damage1'] = damage[0]
		data['damage2'] = damage[1]
		data['damage3'] = damage[2]
		data['damage4'] = damage[3]
		data['damage5'] = damage[4]
		data['damage6'] = damage[5]		
		
		return json.loads(curl.url(ARENE_SERVER +  '/arena/infection_beat/', None, data))
Beispiel #48
0
    def getFacility(tp, name):
        """
		得到设施
		"""
        conn = DBConnection.getConnection()
        res = conn.query('SELECT * FROM facility WHERE name = %s', [name])
        if len(res) == 1:
            obj = tp()
            obj.id = res[0][0]
            obj.name = res[0][1]
            obj.load(name, json.loads(res[0][2]))
            i = 0
            for column in obj.extend_columns:
                setattr(obj, column['name'], res[0][3 + i])
                i = i + 1
            return obj
        return None
Beispiel #49
0
    def newMedal(usr, medalid, chipnum, cnt):
        """
		新勋章
		"""
        if SIGLE_SERVER:
            from arenarank.routine.medal import medal as medalR
            return medalR.new_medal(usr.roleid, usr.level, medalid, chipnum,
                                    cnt)
        else:
            return json.loads(
                curl.url(
                    ARENE_SERVER + '/arena/new_medal/', None, {
                        'roleid': usr.roleid,
                        'level': usr.level,
                        'medalid': medalid,
                        'chipnum': chipnum,
                        'count': cnt
                    }))
Beispiel #50
0
    def grabMedal(offenceRoleid, defenceRoleid, level, medalid, chipnum):
        """
		抢夺勋章
		"""
        if SIGLE_SERVER:
            from arenarank.routine.medal import medal as medalR
            return medalR.grab_medal(offenceRoleid, defenceRoleid, level,
                                     medalid, chipnum)
        else:
            return json.loads(
                curl.url(
                    ARENE_SERVER + '/arena/grab_medal/', None, {
                        'level': level,
                        'medalid': medalid,
                        'chipnum': chipnum,
                        'offenceRoleid': offenceRoleid,
                        'deffenceRoleid': defenceRoleid
                    }))
Beispiel #51
0
    def Beat(usr, battle_roleid, damage):
        """
		击败
		"""
        data = {}
        data['roleid'] = usr.roleid
        data['rolename'] = usr.name
        data['rolelevel'] = usr.level
        data['battle_roleid'] = battle_roleid
        data['damage1'] = damage[0]
        data['damage2'] = damage[1]
        data['damage3'] = damage[2]
        data['damage4'] = damage[3]
        data['damage5'] = damage[4]
        data['damage6'] = damage[5]

        return json.loads(
            curl.url(ARENE_SERVER + '/arena/infection_beat/', None, data))
Beispiel #52
0
	def convert(usr, mediumCount):
		"""
		况换
		"""
		gameConf = config.getConfig('game')
		pointConsume = mediumCount * gameConf['arena_medium_price']
		
		if SIGLE_SERVER:
			from arenarank.routine.arena import arena as arenaR
			res = arenaR.convert(str(usr.roleid), pointConsume)
		else:
			res = json.loads(curl.url(ARENE_SERVER +  '/arena/convert/', None, {'roleid':usr.roleid, 'score':pointConsume}))
				
		if res.has_key('msg'):
			return res

		mediumId = gameConf['arena_medium_id']
		inv = usr.getInventory()
		updateIt, newIt = inv.addItemCount(mediumId, mediumCount)
		inv.save()

		data = res
		
		data['drop'] = []
		if updateIt:
			for it in updateIt:
				data['drop'].append({'id' :it['itemid'], 'insId' : it['id'], 'type': 4, 'count':it['count']})
		if newIt:
			for it in newIt:
				data['drop'].append({'id' :it['itemid'], 'insId' : it['id'], 'type': 4, 'count':it['count']})
	
		#if updateIt:
		#	data['update_item_array'] = updateIt
		#if newIt:
		#	data['add_item_array'] = newIt
		return data
Beispiel #53
0
def tool_create_player(request):
	if request.method == 'POST':
		player_name = request.POST['player_name']
		levelf = int(request.POST['levelf'])
		levelt = int(request.POST['levelt'])
		protagonist_card = request.POST['protagonist_card']
		other_card = request.POST['other_card']
		card_count = int(request.POST['card_count'])
		card_levelf = int(request.POST['card_levelf'])
		card_levelt = int(request.POST['card_levelt'])
		attack_equipment = request.POST['attack_equipment']
		hp_equipment = request.POST['hp_equipment']
		defence_equipment = request.POST['defence_equipment']		
		pd_equipment = request.POST['pd_equipment']
		md_equipment = request.POST['md_equipment']
		equipment_strength_levelf = int(request.POST['equipment_strength_levelf'])
		equipment_strength_levelt = int(request.POST['equipment_strength_levelt'])
		fire_skill = request.POST['fire_skill']
		water_skill = request.POST['water_skill']
		poison_skill = request.POST['poison_skill']
		super_skill = request.POST['super_skill']
		straw_skill = request.POST['straw_skill']		
		general_skill = request.POST['general_skill']
		skill_levelf = int(request.POST['skill_levelf'])
		skill_levelt = int(request.POST['skill_levelt'])
		stone_seed = request.POST['stone']
		stone_levelf = int(request.POST['stone_levelf'])
		stone_levelt = int(request.POST['stone_levelt'])
		practicef = int(request.POST['practicef'])
		practicet = int(request.POST['practicet'])
		strengthenf = int(request.POST['strengthenf'])
		strengthent = int(request.POST['strengthent'])
		
		intelligencef = int(request.POST['intelligencef'])
		intelligencet = int(request.POST['intelligencet'])
		artificef = int(request.POST['artificef'])
		artificet = int(request.POST['artificet'])
		medal_levelf = int(request.POST['medal_levelf'])
		medal_levelt = int(request.POST['medal_levelt'])
			
		gameConf = config.getConfig('game')
		
		for i in range(card_count):
			usr = user()					
			usr.init(None)
			usr.last_login = currentTime()
			usr.name = player_name
			usr.gender = 'male'
			usr.avatar = '1'
			usr.install(0)
			
			usr.saveRoleId()
			usr.onInit()
			usr.level = random.randint(levelf, levelt)
			inv = usr.getInventory()
			awd = drop.open(usr, protagonist_card, {})
			for (i, l) in enumerate(gameConf['team_member_open_level']):
				if l <= usr.level:
					if awd['add_card_array']:
						awd['add_card_array'][0]['level'] = random.randint(card_levelf, card_levelt)
						inv.team[i] = awd['add_card_array'][0]['id']
					break
					
			for (i, l) in enumerate(gameConf['team_member_open_level']):
				if l <= usr.level and not inv.team[i]:
					awd = drop.open(usr, other_card, {})
					if awd['add_card_array']:
						awd['add_card_array'][0]['level'] = random.randint(card_levelf, card_levelt)
						inv.team[i] = awd['add_card_array'][0]['id']
					break			
			petConf = config.getConfig('pet')
			for (i, cid) in enumerate(inv.team):
				if cid:
					card = inv.getCard(cid)
					if card:
						awd = drop.open(usr, attack_equipment, {})
						if awd.has_key('add_equipment_array'):
							awd['add_equipment_array'][0]['strengthLevel'] = random.randint(equipment_strength_levelf, equipment_strength_levelt)
							equipment.equip(usr, i, -1, awd['add_equipment_array'][0]['id'])
						awd = drop.open(usr, hp_equipment, {})
						if awd.has_key('add_equipment_array'):
							awd['add_equipment_array'][0]['strengthLevel'] = random.randint(equipment_strength_levelf, equipment_strength_levelt)
							equipment.equip(usr, i, -1, awd['add_equipment_array'][0]['id'])
						awd = drop.open(usr, defence_equipment, {})
						if awd.has_key('add_equipment_array'):
							awd['add_equipment_array'][0]['strengthLevel'] = random.randint(equipment_strength_levelf, equipment_strength_levelt)
							equipment.equip(usr, i, -1, awd['add_equipment_array'][0]['id'])						
						awd = drop.open(usr, pd_equipment, {})
						if awd.has_key('add_equipment_array'):
							awd['add_equipment_array'][0]['strengthLevel'] = random.randint(equipment_strength_levelf, equipment_strength_levelt)
							equipment.equip(usr, i, -1, awd['add_equipment_array'][0]['id'])
						awd = drop.open(usr, md_equipment, {})
						if awd.has_key('add_equipment_array'):
							awd['add_equipment_array'][0]['strengthLevel'] = random.randint(equipment_strength_levelf, equipment_strength_levelt)
							equipment.equip(usr, i, -1, awd['add_equipment_array'][0]['id'])
						
						petInfo = petConf[card['cardid']]						
						skill_seed = None
						
						if petInfo['nature'] == '2':
							skill_seed = poison_skill
						elif petInfo['nature'] == '3':
							skill_seed = straw_skill
						elif petInfo['nature'] == '4':
							skill_seed = water_skill
						elif petInfo['nature'] == '5':
							skill_seed = fire_skill
						elif petInfo['nature'] == '6':
							skill_seed = super_skill
						elif petInfo['nature'] == '7':
							skill_seed = general_skill
							
						if skill_seed:
							for k in range(3):
								awd = drop.open(usr, skill_seed, {})
								if awd.has_key('add_skill_array'):
									awd['add_skill_array'][0]['level'] = random.randint(skill_levelf, skill_levelt)
									skill.install(usr, i, -1, k, awd['add_skill_array'][0]['id'])
									
						for (k, l) in enumerate(gameConf['stone_slot_level']):
							if l <= usr.level:
								awd = drop.open(usr, stone_seed, {})
								if awd.has_key('add_stone_array'):
									awd['add_stone_array'][0]['level'] = random.randint(stone_levelf, stone_levelt)
									stone.install(usr, i, -1, k, awd['add_stone_array'][0]['id'])
						card['strength'] = random.randint(strengthenf, strengthent)
						card['intelligence'] = random.randint(intelligencef, intelligencet)
						card['artifice'] = random.randint(artificef, artificet)
						
						medalConf = config.getConfig('medal')
						
						for medalid in medalConf:
							inv.medal[medalid] =  {'level':0, 'chip': [0] * medalConf[medalid]['chip'], 'id':medalid, 'gravel':0}
							inv.medal[medalid]['level'] = random.randint(medal_levelf, medal_levelt)
									
			usr.practice['critical_level'] = random.randint(practicef, practicet)
			usr.practice['tenacity_level'] = random.randint(practicef, practicet)
			usr.practice['block_level'] = random.randint(practicef, practicet)
			usr.practice['wreck_level'] = random.randint(practicef, practicet)			
			
																	
			usr.save()
			res = arena.stand_ladder(usr)	
			if isinstance(res, str):
				res = json.loads(res)
				if res.has_key('msg'):
					return HttpResponse('error:' + str(i) + ':' + str(usr.roleid) + res['msg'])		
	ld = arena.show_all()	
	return render(request, 'arena_tool.html', {'ladder':ld})