public bool Leave(long playerId, evolib.BattleEntry.Type type) { if (!PlayerIdMap.ContainsKey(playerId)) { return(false); } var entry = PlayerIdMap[playerId]; PlayerIdMap.Remove(playerId); var leavePlayer = entry._Players.Find(p => p.PlayerId == playerId); if (leavePlayer != null) { Logger.Logging( new LogObj().AddChild(new LogModels.LeavePlayer { PlayerId = playerId, EntryDate = entry.EntryTime, Date = DateTime.UtcNow, Type = type, Rating = leavePlayer.Rating, MatchId = "", }) ); } var idx = entry._Players.FindIndex(p => p.PlayerId == playerId); entry._Players.RemoveAt(idx); if (entry.Players.Count == 0) { Entries.Remove(entry.EntryId); } else { entry.RecalcRating(); } return(true); }
public IReadOnlyList <IBattleEntryPlayer> Cancel(ulong entryId, string matchId, evolib.BattleEntry.Type type) { if (!Entries.ContainsKey(entryId)) { return(new List <IBattleEntryPlayer>()); } var entry = Entries[entryId]; entry._Players.ForEach(p => { PlayerIdMap.Remove(p.PlayerId); Logger.Logging( new LogObj().AddChild(new LogModels.LeavePlayer { PlayerId = p.PlayerId, EntryDate = entry.EntryTime, Date = DateTime.UtcNow, Type = type, Rating = p.Rating, MatchId = matchId, }) ); }); Entries.Remove(entry.EntryId); return(entry.Players); }