public void EndMatch() { if (EndedAlready) { return; } EndedAlready = true; bool IsBotMatch = (Player1.IsAIBot || Player2.IsAIBot); Player1.Equipments.ClearMask(); if (Player2 != null) { Player2.Equipments.ClearMask(); } Player1.ArenaMatch = null; if (Player2 != null) { Player2.ArenaMatch = null; } Player1.Battle = null; if (Player2 != null) { Player2.Battle = null; } SendEnd(); if (Player2 != null) { uint WinAmount = (uint)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next(32, 113); uint LoseAmount = (uint)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next((int)(WinAmount / 3), (int)(WinAmount / 2)); LoseAmount /= 2; if (IsBotMatch) { WinAmount = 0; LoseAmount = 0; } if (Player1Damage == Player2Damage) { Player1.WasInArena = true; Player2.WasInArena = true; Player1.LostArena = true; Player2.LostArena = true; // draw if (!IsBotMatch) { Player1.Arena.ArenaHonorPoints += LoseAmount; Player2.Arena.ArenaHonorPoints += LoseAmount; using (var msg = Packets.Message.MessageCore.CreateSystem2("ALL", string.Format(Core.MessageConst.ARENA_DRAW, Player1.Name, Player2.Name))) { Packets.Message.MessageCore.SendGlobalMessage(msg); } } } else if (Player1Damage > Player2Damage) { Player1.WasInArena = true; Player2.WasInArena = true; Player2.LostArena = true; Player1.LostArena = false; if (!IsBotMatch) { // player1 win Player1.Arena.ArenaHonorPoints += WinAmount; Player2.Arena.ArenaHonorPoints -= LoseAmount; Player1.Arena.ArenaWinsToday++; Player1.Arena.ArenaTotalWins++; //Player1.Send(arenaAction); Player2.Arena.ArenaLossToday++; Player2.Arena.ArenaTotalLoss++; using (var msg = Packets.Message.MessageCore.CreateSystem2("ALL", string.Format(Core.MessageConst.ARENA_WIN, Player1.Name, Player2.Name))) { Packets.Message.MessageCore.SendGlobalMessage(msg); } } } else { Player1.WasInArena = true; Player2.WasInArena = true; Player1.LostArena = true; Player2.LostArena = false; // player 2 win if (!IsBotMatch) { Player2.Arena.ArenaHonorPoints += WinAmount; Player1.Arena.ArenaHonorPoints -= LoseAmount; Player2.Arena.ArenaWinsToday++; Player2.Arena.ArenaTotalWins++; Player1.Arena.ArenaLossToday++; Player1.Arena.ArenaTotalLoss++; using (var msg = Packets.Message.MessageCore.CreateSystem2("ALL", string.Format(Core.MessageConst.ARENA_WIN, Player2.Name, Player1.Name))) { Packets.Message.MessageCore.SendGlobalMessage(msg); } } } } if (!Player1.LeaveDynamicMap()) { Player1.NetworkClient.Disconnect("Could not leave arena..."); } Player1.ForceRevive(); if (Player2 != null) { if (!Player2.LeaveDynamicMap()) { Player2.NetworkClient.Disconnect("Could not leave arena..."); } Player2.ForceRevive(); } KickWatchers(); if (Player2 != null) { if (!IsBotMatch) { Player1.Arena.Save(); Player2.Arena.Save(); } } ArenaQualifier.GetTop10(); Player1.Arena.Status = Enums.ArenaStatus.NotSignedUp; using (var wait = Player1.Arena.Build()) Player1.Send(wait); if (Player2 != null) { Player2.Arena.Status = Enums.ArenaStatus.NotSignedUp; using (var wait = Player2.Arena.Build()) Player2.Send(wait); } Player1 = null; Player2 = null; ArenaQualifier.MatchQueue.Remove(this); }
public void GiveUp(Entities.GameClient Player) { if (EndedAlready) { return; } EndedAlready = true; Player1.Equipments.ClearMask(); Player2.Equipments.ClearMask(); if (Player1 == Player) { SendGiveUp(Player2); SendWin(Player2); Player1.Arena.Status = Enums.ArenaStatus.WaitingInactive; using (var wait = Player1.Arena.Build()) Player1.Send(wait); Player2.Arena.Status = Enums.ArenaStatus.WaitingForOpponent; using (var wait = Player2.Arena.Build()) Player2.Send(wait); } else { SendGiveUp(Player1); SendWin(Player1); Player1.Arena.Status = Enums.ArenaStatus.WaitingForOpponent; using (var wait = Player1.Arena.Build()) Player1.Send(wait); Player2.Arena.Status = Enums.ArenaStatus.WaitingInactive; using (var wait = Player2.Arena.Build()) Player2.Send(wait); } Player1.ArenaMatch = null; Player2.ArenaMatch = null; Player1.Battle = null; Player2.Battle = null; uint WinAmount = (uint)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next(32, 113); uint LoseAmount = (uint)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next((int)(WinAmount / 3), (int)(WinAmount / 2)); LoseAmount /= 2; if (Player != Player1) { Player1.Arena.ArenaHonorPoints += WinAmount; Player2.Arena.ArenaHonorPoints -= LoseAmount; } else { Player2.Arena.ArenaHonorPoints += WinAmount; Player1.Arena.ArenaHonorPoints -= LoseAmount; } Player1.Arena.Save(); Player2.Arena.Save(); ArenaQualifier.GetTop10(); Player1 = null; Player2 = null; ArenaQualifier.MatchQueue.Remove(this); }