示例#1
0
        void HandleLeave(Player p, string[] args)
        {
            string prefix  = "%dParties> %S";
            string noParty = prefix + "You are not in a party.";

            Team team = Team.GetData(p).Team;

            if (team == null)
            {
                p.Message(noParty); return;
            }

            // Handle '/party leave me alone', for example
            if (args.Length > 1)
            {
                team.Message(p, args.Join(" ")); return;
            }

            team.Action(p, "has left the party.");
            team.Remove(p.name);
            Team.GetData(p).Team = null;

            team.OwnerLeft(p);
            Team.SaveList();
        }
示例#2
0
        void HandleJoin(Player p, string[] args)
        {
            string prefix  = "%dParties> %S";
            string noParty = prefix + "You are not in a party.";

            Team   team   = Team.GetData(p).Team;
            string invite = Team.GetData(p).Invite;

            if (invite == null)
            {
                p.Message(prefix + "You have not been invited to any parties."); return;
            }
            if (team != null)
            {
                p.Message(prefix + "You need to leave your current party before you can join another one."); return;
            }

            team = Team.Find(invite);
            if (team == null)
            {
                p.Message(prefix + "The party you were invited to no longer exists."); return;
            }

            Team.GetData(p).Team   = team;
            Team.GetData(p).Invite = null;

            team.Members.Add(p.name);
            team.Action(p, "joined the party.");
            Team.SaveList();
        }
示例#3
0
        void HandleOwner(Player p, string[] args)
        {
            string prefix  = "%dParties> %S";
            string noParty = prefix + "You are not in a party.";

            Team team = Team.GetData(p).Team;

            if (team == null)
            {
                p.Message(noParty); return;
            }

            if (args.Length == 1)
            {
                p.Message(prefix + "The current owner of the party is: " + team.Owner); return;
            }

            Player who = PlayerInfo.FindMatches(p, args[1]);

            if (who == null)
            {
                return;
            }

            if (!p.name.CaselessEq(team.Owner))
            {
                p.Message(prefix + "Only the party owner can set the new party owner."); return;
            }

            team.Owner = who.name;
            team.Action(p, "set the party owner to " + who.ColoredName + "%S.");
            Team.SaveList();
        }
示例#4
0
        void LeaveServer(Player p, string reason)
        {
            Team team = Team.GetData(p).Team;

            if (team == null)
            {
                return;
            }

            if (p.name.CaselessEq(team.Owner))
            {
                team.OwnerLeft(p);
                return;
            }

            team.Action(p, "has left the party (disconnected).");
            team.Remove(p.name);
            Team.GetData(p).Team = null;
            Team.SaveList();
        }
示例#5
0
        void HandleKick(Player p, string[] args)
        {
            string prefix  = "%dParties> %S";
            string noParty = prefix + "You are not in a party.";

            Team team = Team.GetData(p).Team;

            if (team == null)
            {
                p.Message(noParty); return;
            }

            if (args.Length == 1)
            {
                p.Message(prefix + "You need to provide the name of the player to kick."); return;
            }

            if (!p.name.CaselessEq(team.Owner))
            {
                p.Message(prefix + "Only the party owner can kick players from the party."); return;
            }

            if (team.Remove(args[1]))
            {
                team.Action(p, "kicked " + args[1] + " %Sfrom the party.");
                Player who = PlayerInfo.FindExact(args[1]);
                if (who != null)
                {
                    Team.GetData(who).Team = null;
                }

                team.OwnerLeft(p);
                Team.SaveList();
            }

            else
            {
                p.Message(prefix + "Player not found. You need to use their full account name.");
            }
        }
示例#6
0
        public void OwnerLeft(Player p)
        {
            Team team = Team.GetData(p).Team;

            if (Members.Count > 0)
            {
                // Choose a new owner at random
                team.Action(p, "has left the party (disconnected).");
                team.Remove(p.name);
                Team.SaveList();
                Team.GetData(p).Team = null;

                var random = new Random();
                int index  = random.Next(team.Members.Count);

                team.Message(p, "%dThe new party owner is %b" + team.Members[index]);

                team.Owner = team.Members[index];
                Team.SaveList();
                return;
            }

            Teams.Remove(this); // Remove empty
        }
示例#7
0
        void HandleCreate(Player p, string[] args, CommandData data)
        {
            string prefix  = "%dParties> %S";
            string noParty = prefix + "You are not in a party.";
            string nothing = "";

            if (!HasExtraPerm(p, data.Rank, 1))
            {
                return;
            }
            Team team = Team.GetData(p).Team;

            if (team != null)
            {
                p.Message(prefix + "You need to leave your current party before you can create one."); return;
            }

            team = new Team(nothing, p.name);
            Team.GetData(p).Team = team;
            Team.Add(team);
            Team.SaveList();

            p.Message(prefix + "%SYou created a party. You can invite people to it via %b/party invite [name]%d.");
        }