public static async Task <ResultWithError <RoomPrepareInfo> > M2R_PrepareRoom(int serverId, int roomId, List <MatchUser> users, bool isManual = false) { return(await RpcProxy.RunAsync(typeof(RoomService), serverId, RpcProxy.BuildArgs(serverId, roomId, users, isManual), async() => await INSTANCE.PostAsync(() => INSTANCE.PrepareRoom(roomId, users, isManual)) )); }
public static async Task ReportBattleException(int serverId, int attackerId, int version, string battleEnterDataOfLua) { await RpcProxy.RunAsync(typeof(BattleService), 10000, RpcProxy.BuildArgs(serverId, attackerId, version, battleEnterDataOfLua), () => { }); }
public static async Task <int> RemoteDeleteCOOPRankItem(int serverId, string key) { if (RunServerId.Value < 0) { return(-1); } if (serverId < 0) { return(-1); } if (string.IsNullOrEmpty(key)) { return(-1); } return(await RpcProxy.RunAsync(typeof(RankCenterService), RunServerId.Value, RpcProxy.BuildArgs(serverId, key), () => { if (COOPRankPool == null) { Logger.LogError("COOPRankPool == null"); return -1; } var rank = COOPRankPool.Remove(key); Logger.LogDebug($"[Success]ServerId[{serverId}] delete COOPRankItem Key[{key}]Rank[{rank}]"); return rank; } )); }
public static async Task <int> RemoteAddCOOPRankItem(int serverId, TRankCOOPItem item, int robotScore1, int robotScore2) { if (RunServerId.Value < 0) { return(-1); } if (item == null) { return(-1); } if ((item.UserId1) == 0 && (item.UserId2 == 0)) { return(-1); } return(await RpcProxy.RunAsync(typeof(RankCenterService), RunServerId.Value, RpcProxy.BuildArgs(serverId, item, robotScore1, robotScore2), () => { if (COOPRankPool == null) { Logger.LogError("COOPRankPool == null"); return -1; } //低于允许上榜的最低回合数 if (item.Round < ConfigConstants.COOP_RANKING_MIN) { var key = item.PrimaryKey; //从榜单池中移除 var rank = COOPRankPool.Remove(key); //删除数据 TRankCOOPItem.Cache.TryDelete(key); Logger.LogDebug($"[Fail]ServerId[{serverId}] add COOPRankItem Key[{key}]Round[{item.Round}]Rank[{rank}] < COOP_RANKING_MIN"); } //允许上榜 else { var rank = COOPRankPool.Add(item); //加入成功, 保存数据 if (rank > 0) { TRankCOOPItem.Cache.AddOrUpdate(item); } Logger.LogDebug($"[Success]ServerId[{serverId}] add COOPRankItem Key[{item.PrimaryKey}]Round[{item.Round}]Rank[{rank}]"); //机器人自动上榜PVP if ((item.UserId1 < 0) && (robotScore1 >= ConfigConstants.PK_RANKING_MIN) && (!PKRankPool.ContainsKey(item.UserId1))) { var pkItem = new TRankPKItem(-1, item.UserId1, item.Name1, robotScore1, item.Team1.HeroBaseId, item.Team1.TowerPool, item.Team1.FieldId, DateTime.UtcNow.ToSecondsSinceEpoch()); PKRankPool.Add(pkItem); } if ((item.UserId2 < 0) && (robotScore2 >= ConfigConstants.PK_RANKING_MIN) && (!PKRankPool.ContainsKey(item.UserId2))) { var pkItem = new TRankPKItem(-1, item.UserId2, item.Name2, robotScore2, item.Team2.HeroBaseId, item.Team2.TowerPool, item.Team2.FieldId, DateTime.UtcNow.ToSecondsSinceEpoch()); PKRankPool.Add(pkItem); } } return GetCOOPMinRound(); } )); }
public static async Task <int> RemoteGetCOOPMinRound(int serverId) { if (RunServerId.Value < 0) { return(ConfigConstants.COOP_RANKING_MIN); } if (serverId < 0) { return(ConfigConstants.COOP_RANKING_MIN); } return(await RpcProxy.RunAsync(typeof(RankCenterService), RunServerId.Value, RpcProxy.BuildArgs(serverId), () => { var round = GetCOOPMinRound(); Logger.LogDebug($"[Success]ServerId[{serverId}] get COOPMinRound[{round}]"); return round; } )); }
public static async Task <int> RemoteAddPKRankItem(int serverId, TRankPKItem item) { if (RunServerId.Value < 0) { return(-1); } if (item == null) { return(-1); } if (item.UserId == 0) { return(-1); } return(await RpcProxy.RunAsync(typeof(RankCenterService), RunServerId.Value, RpcProxy.BuildArgs(serverId, item), () => { if (PKRankPool == null) { Logger.LogError("PKRankPool == null"); return -1; } //低于允许上榜的最低分 if (item.Score < ConfigConstants.PK_RANKING_MIN) { //从榜单池中移除 var rank = PKRankPool.Remove(item.UserId); //删除数据 TRankPKItem.Cache.TryDelete(item.UserId.ToString()); Logger.LogDebug($"[Fail]ServerId[{serverId}] add PKRankItem UserId[{item.UserId}]Score[{item.Score}]Rank[{rank}] < PK_RANKING_MIN"); } //允许上榜 else { //加入成功, 保存数据 var rank = PKRankPool.Add(item); if (rank > 0) { TRankPKItem.Cache.AddOrUpdate(item); } Logger.LogDebug($"[Success]ServerId[{serverId}] add PKRankItem UserId[{item.UserId}]Score[{item.Score}]Rank[{rank}]"); } return GetPKMinScore(); } )); }
public static async Task <int> RemoteDeletePKRankItem(int serverId, int userId) { if (RunServerId.Value < 0) { return(-1); } if (userId == 0) { return(-1); } return(await RpcProxy.RunAsync(typeof(RankCenterService), RunServerId.Value, RpcProxy.BuildArgs(serverId, userId), () => { if (PKRankPool == null) { Logger.LogError("PKRankPool == null"); return -1; } var rank = PKRankPool.Remove(userId); Logger.LogDebug($"[Success]ServerId[{serverId}] delete PKRankItem UserId[{userId}]Rank[{rank}]"); return rank; } )); }
public static async Task <int> RemoteGetPKMinScore(int serverId) { if (RunServerId.Value < 0) { return(ConfigConstants.PK_RANKING_MIN); } if (serverId < 0) { return(ConfigConstants.PK_RANKING_MIN); } return(await RpcProxy.RunAsync(typeof(RankCenterService), RunServerId.Value, RpcProxy.BuildArgs(serverId), () => { var score = GetPKMinScore(); Logger.LogDebug($"[Success]ServerId[{serverId}] get PKMinScore[{score}]"); return score; } )); }
public static async Task <TRankPack> RemoteLoadPack(int serverId) { if (serverId < 0) { return(null); } if (RunServerId.Value < 0) { return(null); } return(await RpcProxy.RunAsync(typeof(RankCenterService), RunServerId.Value, RpcProxy.BuildArgs(serverId), () => { if (PKRankPool == null) { Logger.LogError("PKRankPool == null"); return null; } if (COOPRankPool == null) { Logger.LogError("COOPRankPool == null"); return null; } var pack = new TRankPack() { PKList = PKRankPool.GetRange(0, 99), COOPList = COOPRankPool.GetRange(0, 99), }; var pkCount = pack.PKList == null ? 0 : pack.PKList.Count; var coopCount = pack.COOPList == null ? 0 : pack.COOPList.Count; Logger.LogDebug($"[Success]ServerId[{serverId}] load RankPack pkCount[{pkCount}]coopCount[{coopCount}]"); return pack; } )); }