def _post_upgrade(data, user, old_level, new_level, now): """用户升级后的处理 1 可能解锁 PVP 2 可能解锁 pvp arena 3 升级世界地图上己方主城的等级 4 增加政令值 5 想邀请者转发升级通知 """ if not check_pvp_authority(data): return False if not check_arena_authority(data, now): return False if not check_worldboss_authority(data): return False own_basic_id = NodeInfo.get_own_node_basic_id() own_id = NodeInfo.generate_id(data.id, own_basic_id) own = data.node_list.get(own_id) own.update_own_city_level(user.level) energy = data.energy.get() level_diff = new_level - old_level diff = 1 while diff <= level_diff: energy.update_energy_and_capacity(old_level + diff) diff += 1 if user.is_invited(): _forward_invitee_upgrade(data, user) return True
def init_map(data, pattern, now): """初始化地图 创建新用户时,调用 Args: data[UserData]: 用户数据 pattern[int]: 初始化模式 now[int]: 时间戳 Returns: True False """ user = data.user.get() #创建地图信息 map = MapInfo.create(data.id) data.map.add(map) #创建问答, 副本信息 question = QuestionInfo.create(data.id) data.question.add(question) dungeon = DungeonInfo.create(data.id) data.dungeon.add(dungeon) #创建所有节点信息 for basic_id in MapGraph(): node = NodeInfo.create(data.id, basic_id) data.node_list.add(node) #第一次刷新,占领自己主城 own_basic_id = NodeInfo.get_own_node_basic_id() own_id = NodeInfo.generate_id(data.id, own_basic_id) own = data.node_list.get(own_id) own.update_own_city_level(user.level) ##开启主城邻接关键点 #for basic_id in MapGraph().get_neighbors(own.basic_id): # neighbor_id = NodeInfo.generate_id(data.id, basic_id) # neighbor = data.node_list.get(neighbor_id) # if not neighbor.is_visible(): # respawn_enemy_key_node(data, neighbor, now) ##为新刷出的敌方节点匹配敌人:只有 PVE #node_enemy_scores = [100, 101, 102] #硬编码,初始三个node上固定敌人 #i = 0 #matcher = RivalMatcher(user.level, [data.id]) #for node in data.node_list.get_all(): # if node.is_lack_enemy_detail(): # node.rival_score_min = node_enemy_scores[i] # node.rival_score_max = node_enemy_scores[i] # i = i + 1 # matcher.add_condition(data, node) #matcher.match(only_pve = True) ##为初次刷新的敌人添加 debuff 效果,为了让玩家初次攻击可以轻易取胜 #for node in data.node_list.get_all(): # if node.is_enemy_complete(): # rival_id = node.rival_id # rival = data.rival_list.get(rival_id) # buff_id = data_loader.InitUserBasicInfo_dict[pattern].enemyBuffId # rival.set_buff(buff_id) map.update_next_war_time(now) # map.update_next_luck_time(now) return True