Ejemplo n.º 1
0
        public static void Handle(Entities.GameClient client, DataPacket packet)
        {
            using (var team = new TeamActionPacket(packet))
            {
                switch (team.Action)
                {
                case Enums.TeamAction.Create:
                    if (client.Battle != null)
                    {
                        return;
                    }
                    Data.Team.Create(client, team);
                    break;

                case Enums.TeamAction.Dismiss:
                {
                    if (client.Battle != null)
                    {
                        return;
                    }
                    if (client.Team == null)
                    {
                        return;
                    }
                    client.Team.Delete(client, team);
                    break;
                }

                case Enums.TeamAction.RequestJoin:
                {
                    if (client.Battle != null)
                    {
                        return;
                    }
                    if (client.Team != null)
                    {
                        return;
                    }
                    Entities.GameClient Leader;
                    if (Core.Kernel.Clients.TrySelect(team.EntityUID, out Leader))
                    {
                        if (Leader.Team == null)
                        {
                            return;
                        }
                        if (!Leader.IsInMap(client))
                        {
                            return;
                        }

                        Leader.Team.Join(client, team);
                    }
                    break;
                }

                case Enums.TeamAction.AcceptJoin:
                {
                    if (client.Battle != null)
                    {
                        return;
                    }
                    if (client.Team == null)
                    {
                        return;
                    }
                    client.Team.Join(client, team);
                    break;
                }

                case Enums.TeamAction.RequestInvite:
                {
                    if (client.Battle != null)
                    {
                        return;
                    }
                    if (client.Team == null)
                    {
                        return;
                    }
                    client.Team.Invite(client, team);
                    break;
                }

                case Enums.TeamAction.AcceptInvite:
                {
                    if (client.Battle != null)
                    {
                        return;
                    }
                    if (client.Team != null)
                    {
                        return;
                    }
                    Entities.GameClient Leader;
                    if (Core.Kernel.Clients.TrySelect(team.EntityUID, out Leader))
                    {
                        if (Leader.Team == null)
                        {
                            return;
                        }
                        if (!Leader.IsInMap(client))
                        {
                            return;
                        }

                        Leader.Team.Invite(client, team);
                    }
                    break;
                }

                case Enums.TeamAction.Kick:
                {
                    if (client.Battle != null)
                    {
                        return;
                    }
                    if (client.Team == null)
                    {
                        return;
                    }
                    client.Team.Kick(client, team);
                    break;
                }

                case Enums.TeamAction.LeaveTeam:
                {
                    if (client.Battle != null)
                    {
                        return;
                    }
                    if (client.Team == null)
                    {
                        return;
                    }
                    client.Team.Leave(client, team);
                    break;
                }
                }
            }
        }
Ejemplo n.º 2
0
        public static void Handle(Entities.GameClient client, DataPacket packet)
        {
            using (var team = new TeamActionPacket(packet))
            {
                switch (team.Action)
                {
                    case Enums.TeamAction.Create:
                        if (client.Battle != null)
                            return;
                        Data.Team.Create(client, team);
                        break;
                    case Enums.TeamAction.Dismiss:
                        {
                            if (client.Battle != null)
                                return;
                            if (client.Team == null)
                                return;
                            client.Team.Delete(client, team);
                            break;
                        }
                    case Enums.TeamAction.RequestJoin:
                        {
                            if (client.Battle != null)
                                return;
                            if (client.Team != null)
                                return;
                            Entities.GameClient Leader;
                            if (Core.Kernel.Clients.TrySelect(team.EntityUID, out Leader))
                            {
                                if (Leader.Team == null)
                                    return;
                                if (!Leader.IsInMap(client))
                                    return;

                                Leader.Team.Join(client, team);
                            }
                            break;
                        }
                    case Enums.TeamAction.AcceptJoin:
                        {
                            if (client.Battle != null)
                                return;
                            if (client.Team == null)
                                return;
                            client.Team.Join(client, team);
                            break;
                        }
                    case Enums.TeamAction.RequestInvite:
                        {
                            if (client.Battle != null)
                                return;
                            if (client.Team == null)
                                return;
                            client.Team.Invite(client, team);
                            break;
                        }
                    case Enums.TeamAction.AcceptInvite:
                        {
                            if (client.Battle != null)
                                return;
                            if (client.Team != null)
                                return;
                            Entities.GameClient Leader;
                            if (Core.Kernel.Clients.TrySelect(team.EntityUID, out Leader))
                            {
                                if (Leader.Team == null)
                                    return;
                                if (!Leader.IsInMap(client))
                                    return;

                                Leader.Team.Invite(client, team);
                            }
                            break;
                        }
                    case Enums.TeamAction.Kick:
                        {
                            if (client.Battle != null)
                                return;
                            if (client.Team == null)
                                return;
                            client.Team.Kick(client, team);
                            break;
                        }
                    case Enums.TeamAction.LeaveTeam:
                        {
                            if (client.Battle != null)
                                return;
                            if (client.Team == null)
                                return;
                            client.Team.Leave(client, team);
                            break;
                        }
                }
            }
        }