public static void HandleGameFightJoinRequestMessage(WorldClient client, GameFightJoinRequestMessage message) { if (!client.Character.IsFighting()) { Fight fight = Singleton <FightManager> .Instance.GetFight(message.fightId); if (fight == null) { ContextHandler.SendChallengeFightJoinRefusedMessage(client, client.Character, FighterRefusedReasonEnum.TOO_LATE); } else { if (fight.Map != client.Character.Map) { ContextHandler.SendChallengeFightJoinRefusedMessage(client, client.Character, FighterRefusedReasonEnum.WRONG_MAP); } else { if (fight.IsStarted) { if (message.fighterId == 0 && fight.CanSpectatorJoin(client.Character)) { fight.AddSpectator(client.Character.CreateSpectator(fight)); } } else { FightTeam fightTeam; if (fight.RedTeam.Leader.Id == message.fighterId) { fightTeam = fight.RedTeam; } else { if (fight.BlueTeam.Leader.Id != message.fighterId) { ContextHandler.SendChallengeFightJoinRefusedMessage(client, client.Character, FighterRefusedReasonEnum.WRONG_MAP); return; } fightTeam = fight.BlueTeam; } FighterRefusedReasonEnum reason; if ((reason = fightTeam.CanJoin(client.Character)) != FighterRefusedReasonEnum.FIGHTER_ACCEPTED) { ContextHandler.SendChallengeFightJoinRefusedMessage(client, client.Character, reason); } else { fightTeam.AddFighter(client.Character.CreateFighter(fightTeam)); } } } } } }
public static void HandleGameRolePlayPlayerFightRequestMessage(WorldClient client, GameRolePlayPlayerFightRequestMessage message) { Character actor = client.Character.Map.GetActor <Character>((int)message.targetId); if (actor != null) { if (message.friendly) { FighterRefusedReasonEnum fighterRefusedReasonEnum = client.Character.CanRequestFight(actor); if (fighterRefusedReasonEnum != FighterRefusedReasonEnum.FIGHTER_ACCEPTED) { ContextHandler.SendChallengeFightJoinRefusedMessage(client, client.Character, fighterRefusedReasonEnum); } else { FightRequest fightRequest = new FightRequest(client.Character, actor); client.Character.OpenRequestBox(fightRequest); actor.OpenRequestBox(fightRequest); fightRequest.Open(); } } else { FighterRefusedReasonEnum fighterRefusedReasonEnum = client.Character.CanAgress(actor); if (fighterRefusedReasonEnum != FighterRefusedReasonEnum.FIGHTER_ACCEPTED) { ContextHandler.SendChallengeFightJoinRefusedMessage(client, client.Character, fighterRefusedReasonEnum); } else { Fight fight = Singleton <FightManager> .Instance.CreateAgressionFight(actor.Map, client.Character.AlignmentSide, actor.AlignmentSide); fight.RedTeam.AddFighter(client.Character.CreateFighter(fight.RedTeam)); fight.BlueTeam.AddFighter(actor.CreateFighter(fight.BlueTeam)); fight.StartPlacement(); } } } }