Ejemplo n.º 1
0
        public void AddFlag(Player p, string col, ushort x, ushort y, ushort z)
        {
            char teamCol = (char)col[1];

            BaseGame gameInfo = Server.allGames.Find(g => g.lvl == p.level);

            if (gameInfo == null)
            {
                Player.SendMessage(p, "Il y a aucune partie en cours sur la map"); return;
            }
            if (gameInfo.typeGame.ToLower() != "ctf")
            {
                Player.SendMessage(p, "Le ctf n'est pas actif sur cette map"); return;
            }

            if (p != gameInfo.owner || p.group.Permission < LevelPermission.Operator)
            {
                Player.SendMessage(p, "Vous n'etes pas le maitre de la partie"); return;
            }

            CTFGame2 ctfInfo = (CTFGame2)gameInfo;

            Team workTeam = ctfInfo.teams.Find(team => team.color == teamCol);

            workTeam.flagBase[0] = x;
            workTeam.flagBase[1] = y;
            workTeam.flagBase[2] = z;

            workTeam.flagLocation[0] = x;
            workTeam.flagLocation[1] = y;
            workTeam.flagLocation[2] = z;
            workTeam.Drawflag();
        }
Ejemplo n.º 2
0
        public override void Use(Player p, string message)
        {
            if (p == null)
            {
                Player.SendMessage(p, "Impossible depuis la console ou l'irc"); return;
            }

            CTFGame2 game = (CTFGame2)Server.allGames.Find(g => g.lvl == p.level);

            if (game == null)
            {
                Player.SendMessage(p, "Le ctf n'est pas en cours sur cette map"); return;
            }

            if (message != "")
            {
                Help(p); return;
            }
            if (p.hasflag != null)
            {
                game.DropFlag(p, p.hasflag);
                return;
            }
            else
            {
                Player.SendMessage(p, "Vous n'avez pas le drapeau.");
            }
        }
Ejemplo n.º 3
0
        public void RemoveTeam(Player p, string color, CTFGame2 game)
        {
            char teamCol = (char)color[1];

            if (game.teams.Find(team => team.color == teamCol) == null)
            {
                Player.SendMessage(p, "Cet equipe n'existe pas."); return;
            }
            game.RemoveTeam("&" + color);
        }
Ejemplo n.º 4
0
        public void AddTeam(Player p, string color, CTFGame2 game)
        {
            char teamCol = (char)color[1];

            if (game.teams.Find(team => team.color == teamCol) != null)
            {
                Player.SendMessage(p, "Cet equipe existe deja."); return;
            }
            game.AddTeam(color);
        }
Ejemplo n.º 5
0
        public void AddSpawn(Player p, string color, CTFGame2 game)
        {
            char   teamCol = (char)color[1];
            ushort x, y, z, rotx;

            x    = (ushort)(p.pos[0] / 32);
            y    = (ushort)(p.pos[1] / 32);
            z    = (ushort)(p.pos[2] / 32);
            rotx = (ushort)(p.rot[0]);
            game.teams.Find(team => team.color == teamCol).AddSpawn(x, y, z, rotx, 0);
            Player.SendMessage(p, "Spawn ajoute pour " + game.teams.Find(team => team.color == teamCol).teamstring);
        }
Ejemplo n.º 6
0
        public override void Use(Player p, string message)
        {
            if (message == "")
            {
                Help(p); return;
            }

            if (message == "list" || message == "liste")
            {
                if (listGame.Count == 0)
                {
                    Player.SendMessage(p, "Aucun jeu ne propose de statistiques");
                }

                string li = "";
                foreach (string g in listGame)
                {
                    li += g + ", ";
                }
                Player.SendMessage(p, "Jeux avec statistiques : " + li.Remove(li.Length - 2));
                return;
            }

            if (message.Split(' ').Length < 2)
            {
                Help(p); return;
            }

            switch (message.Split(' ')[0])
            {
            case "top":
                switch (message.Split(' ')[1])
                {
                case "bomberman":
                    BombermanGame.top(p);
                    break;

                case "ctf":
                    CTFGame2.top(p);
                    break;

                case "infection":
                    InfectionGame.top(p);
                    break;

                default:
                    Player.SendMessage(p, "Le jeu '" + message.Split(' ')[1] + "' n'a pas de statistiques");
                    break;
                }
                break;

            case "reset":
                if (p.group.Permission < LevelPermission.Admin)
                {
                    Player.SendMessage(p, "Tu n'a pas les permissions de faire ca");
                }
                if (!listGame.Exists(m => m == message.Split(' ')[1]))
                {
                    Player.SendMessage(p, "Le jeu '" + message.Split(' ')[1] + "' n'a pas de statistiques");
                }
                if (message.Split(' ').Length == 2)     //resetjeu
                {
                    BaseGame.resetGame(message.Split(' ')[1]);
                    Player.SendMessage(p, "Statistiques du jeu '" + message.Split(' ')[1] + "' reinitialise");
                }
                else
                {
                    BaseGame.resetPlayer(message.Split(' ')[2], message.Split(' ')[1]);
                    Player.SendMessage(p, "Statistique de '" + message.Split(' ')[2] + "' reset sur '" + message.Split(' ')[1] + "'");
                }
                break;

            case "bomberman":
                BombermanGame.stats(p, message.Split(' ')[1]);
                break;

            case "ctf":
                CTFGame2.stats(p, message.Split(' ')[1]);
                break;

            case "infection":
                InfectionGame.stats(p, message.Split(' ')[1]);
                break;

            default:
                Player.SendMessage(p, "Le jeu '" + message.Split(' ')[0] + "' n'a pas de statistiques");
                break;
            }
        }
Ejemplo n.º 7
0
        public override void Use(Player p, string message)
        {
            if (p == null)
            {
                Player.SendMessage(p, "Impossible depuis la console ou l'irc"); return;
            }

            BaseGame game = Server.allGames.Find(g => g.lvl == p.level);


            if (game == null)
            {
                Player.SendMessage(p, "Il n'y a pas de jeu en cours sur cette map"); return;
            }

            if (game.typeGame != "ctf")
            {
                Player.SendMessage(p, "Le CTF n'est pas active sur cette map.");
                return;
            }
            CTFGame2 ctfGame = (CTFGame2)game;

            if (message.Split(' ')[0].ToLower() == "set")
            {
                if (game.gameOn)
                {
                    Player.SendMessage(p, "Vous le pouvez pas rejoindre modifier les equipes en cours de partie");
                }

                if (p.group.Permission >= LevelPermission.Operator)
                {
                    string name = message.Split(' ')[1].ToLower();
                    string team = message.Split(' ')[2].ToLower();
                    if (team == "none")
                    {
                        Player pl = Player.Find(name);
                        if (pl == null || pl.level != p.level)
                        {
                            Player.SendMessage(p, "Ce joueur n'est pas sur la meme map que vous.");
                        }
                        if (pl.team == null)
                        {
                            Player.SendMessage(p, "Ce joueur n'est pas dans une equipe.");
                        }
                        pl.team.RemoveMember(pl);
                        return;
                    }
                    string color = c.Parse(team);
                    if (color == "")
                    {
                        Player.SendMessage(p, "Couleur de d'equipe invalide."); return;
                    }
                    Player who = Player.Find(name);
                    if (who == null || who.level != p.level)
                    {
                        Player.SendMessage(p, "Ce joueur n'est pas sur la meme map que vous.");
                    }
                    char teamCol = (char)color[1];
                    if (ctfGame.teams.Find(team1 => team1.color == teamCol) == null)
                    {
                        Player.SendMessage(p, "Ce joueur n'est pas dans une equipe."); return;
                    }
                    Team workTeam = ctfGame.teams.Find(team1 => team1.color == teamCol);
                    if (who.team != null)
                    {
                        who.team.RemoveMember(who);
                    }
                    workTeam.AddMember(who);
                }
            }
            if (message.Split(' ')[0].ToLower() == "join")
            {
                if (game.gameOn)
                {
                    Player.SendMessage(p, "Vous ne pouvez pas rejoindre le ctf en cours de partie");
                }
                string color = c.Parse(message.Split(' ')[1]);
                if (color == "")
                {
                    Player.SendMessage(p, "Couleur d'equipe invalide."); return;
                }
                char teamCol = (char)color[1];
                if (ctfGame.teams.Find(team => team.color == teamCol) == null)
                {
                    Player.SendMessage(p, "Couleur d'equipe invalide."); return;
                }
                Team workTeam = ctfGame.teams.Find(team => team.color == teamCol);
                if (p.team != null)
                {
                    p.team.RemoveMember(p);
                }
                workTeam.AddMember(p);
            }
            else if (message.Split(' ')[0].ToLower() == "leave")
            {
                if (p.team != null)
                {
                    p.team.RemoveMember(p);
                }
                else
                {
                    Player.SendMessage(p, "Vous n'etent pas dans une equipe.");
                    return;
                }
            }
            else if (message.Split(' ')[0].ToLower() == "chat")
            {
                if (p.team == null)
                {
                    Player.SendMessage(p, "Vous devez etre dans une equipe pour pouvoir utiliser le tchat d'equipe."); return;
                }
                p.teamchat = !p.teamchat;
                if (p.teamchat)
                {
                    Player.SendMessage(p, "Le tchat d'equipe est active.");
                    return;
                }
                else
                {
                    Player.SendMessage(p, "Le tchat d'equipe est desactive.");
                    return;
                }
            }
            else if (message.Split(' ')[0].ToLower() == "scores")
            {
                foreach (Team t in ctfGame.teams)
                {
                    Player.SendMessage(p, t.teamstring + " a " + t.points + " point(s).");
                }
            }
        }
Ejemplo n.º 8
0
        public override void Use(Player p, string message)
        {
            if (p == null)
            {
                Player.SendMessage(p, "Impossible depuis la console ou l'irc"); return;
            }


            BaseGame gameInfo = Server.allGames.Find(g => g.lvl == p.level);
            CTFGame2 ctfInfo  = null;

            if (gameInfo != null)
            {
                if (gameInfo.typeGame == "ctf")
                {
                    ctfInfo = (CTFGame2)gameInfo;
                }
            }

            string key = "";

            if (message == "")
            {
                ;
            }
            else if (message.IndexOf(' ') == -1)
            {
                key = message; message = "";
            }
            else
            {
                key = message.Split(' ')[0]; message = message.Substring(message.IndexOf(' ') + 1);
            }

            switch (key.ToLower())
            {
            case "start":
                if (!verif(gameInfo, p))
                {
                    return;
                }
                if (ctfInfo.gameOn)
                {
                    Player.SendMessage(p, "Le jeu est deja lance"); return;
                }
                ctfInfo.startGame(p);
                break;

            case "stop":
                if (!verif(gameInfo, p))
                {
                    return;
                }
                if (!ctfInfo.gameOn)
                {
                    Player.SendMessage(p, "Le jeu n'est pas lance"); return;
                }
                ctfInfo.gameOn = false;
                ctfInfo.stopGame(p);
                break;

            case "info":
                if (gameInfo == null)
                {
                    Player.SendMessage(p, "Il y a aucune partie en cours sur la map"); return;
                }
                if (gameInfo.typeGame.ToLower() != "ctf")
                {
                    Player.SendMessage(p, "Le ctf n'est pas actif sur cette map"); return;
                }
                ctfInfo.GameInfo(p);
                break;

            case "list":
                BaseGame.listSave(p, "ctf");
                break;

            case "save":
                if (!verif(gameInfo, p))
                {
                    return;
                }
                if (ctfInfo.gameOn)
                {
                    Player.SendMessage(p, "Impossible de sauvegarder les configurations quand le CTF est lance"); return;
                }
                ctfInfo.saveGame(p, message);
                break;

            case "load":
                if (!verif(gameInfo, p))
                {
                    return;
                }
                if (ctfInfo.gameOn)
                {
                    Player.SendMessage(p, "Impossible de charger une configuration quand le CTF est lance"); return;
                }
                ctfInfo.loadGame(p, message);
                break;

            case "clear":
                if (!verif(gameInfo, p))
                {
                    return;
                }
                ctfInfo.stopGame(p);
                List <Team> storedT = new List <Team>();
                for (int i = 0; i < ctfInfo.teams.Count; i++)
                {
                    storedT.Add(ctfInfo.teams[i]);
                }
                foreach (Team t in storedT)
                {
                    ctfInfo.RemoveTeam("&" + t.color);
                }
                ctfInfo.onTeamCheck.Stop();
                ctfInfo.onTeamCheck.Dispose();
                ctfInfo.gameOn = false;
                ctfInfo.loadCmds();
                Player.SendMessage(p, "Les parametres du CTF ont ete remis a 0.");
                break;

            case "ff":
                if (!verif(gameInfo, p))
                {
                    return;
                }
                if (ctfInfo.friendlyfire)
                {
                    p.level.ChatLevel("Les tirs alliers ont ete activer.");
                    ctfInfo.friendlyfire = false;
                }
                else
                {
                    p.level.ChatLevel("Les tirs alliers ont ete activer.");
                    ctfInfo.friendlyfire = true;
                }
                break;

            case "flag":
                if (!verif(gameInfo, p))
                {
                    return;
                }
                string colorf = c.Parse(message);
                if (colorf == "")
                {
                    Player.SendMessage(p, "Couleur d'equipe invalide."); return;
                }
                char teamColf = (char)colorf[1];
                if (ctfInfo.teams.Find(team => team.color == teamColf) == null)
                {
                    Player.SendMessage(p, "Couleur d'equipe invalide."); return;
                }
                CatchPos cpos;
                cpos.x = 0; cpos.y = 0; cpos.z = 0; cpos.color = colorf; p.blockchangeObject = cpos;
                Player.SendMessage(p, "Place un bloc pour determiner la position du drapeau.");
                p.ClearBlockchange();
                p.Blockchange += new Player.BlockchangeEventHandler(FlagBlockChange);
                break;

            case "spawn":
                if (!verif(gameInfo, p))
                {
                    return;
                }
                string colors = c.Parse(message);
                if (colors == "")
                {
                    Player.SendMessage(p, "Couleur d'equipe invalide."); return;
                }
                char teamCols = (char)colors[1];
                if (ctfInfo.teams.Find(team => team.color == teamCols) == null)
                {
                    Player.SendMessage(p, "Couleur d'equipe invalide."); return;
                }
                AddSpawn(p, colors, ctfInfo);
                break;

            case "points":
                if (!verif(gameInfo, p))
                {
                    return;
                }
                int points = 0;
                Int32.TryParse(message, out points);
                if (points <= 0)
                {
                    Player.SendMessage(p, "Vous devez choisir un nombre de points superieur a 0 !"); return;
                }
                ctfInfo.maxPoints = points;
                Player.SendMessage(p, "Le nombre de points a ete mis a " + points);
                break;

            case "team":
                if (!verif(gameInfo, p))
                {
                    return;
                }
                if (message.Split(' ').Length != 2)
                {
                    Help(p); return;
                }

                if (message.Split(' ')[0] == "add")
                {
                    string colort = c.Parse(message.Split(' ')[1]);
                    if (colort == "")
                    {
                        Player.SendMessage(p, "Couleur d'equipe invalide."); return;
                    }
                    char teamColt = (char)colort[1];
                    switch (teamColt)
                    {
                    case '2':
                    case '5':
                    case '8':
                    case '9':
                    case 'c':
                    case 'e':
                    case 'f':
                        AddTeam(p, colort, ctfInfo);
                        break;

                    default:
                        Player.SendMessage(p, "Couleur d'equipe invalide.");
                        return;
                    }
                }
                else if (message.Split(' ')[0] == "remove")
                {
                    string colort = c.Parse(message.Split(' ')[1]);
                    if (colort == "")
                    {
                        Player.SendMessage(p, "Couleur d'equipe invalide."); return;
                    }
                    char teamColt = (char)colort[1];
                    switch (teamColt)
                    {
                    case '2':
                    case '5':
                    case '8':
                    case '9':
                    case 'c':
                    case 'e':
                    case 'f':
                        RemoveTeam(p, colort, ctfInfo);
                        break;

                    default:
                        Player.SendMessage(p, "Couleur d'equipe invalide.");
                        return;
                    }
                }
                break;

            default:
                if (gameInfo == null)
                {
                    if (p.level.world != p.name.ToLower() && p.group.Permission < LevelPermission.Operator)
                    {
                        Player.SendMessage(p, "Vous ne pouvez pas lancer de jeu dans ce monde"); return;
                    }

                    if (Server.allGames.Count > Server.maxGames)
                    {
                        Player.SendMessage(p, "Le maximum de jeux en simultanees est attein");
                        Player.SendMessage(p, "Attendez qu'une partie se finisse avant d'en lancer une autre");
                        return;
                    }
                    CTFGame2 ctf = new CTFGame2(p.level);
                    ctf.owner = p;

                    if (key == "")
                    {
                        Player.SendMessage(p, "Vous devez donner un nom a la partie"); return;
                    }
                    if (message != "")
                    {
                        Player.SendMessage(p, "Le nom de la partie doit etre fait d'un seul mot"); return;
                    }
                    ctf.name = key;

                    if (!BaseGame.addGame(ctf))
                    {
                        Player.SendMessage(p, "Impossible de creer le jeu, reessayez !"); return;
                    }

                    Player.SendMessage(p, "Creation du ctf termine");
                    Player.GlobalMessage("Une partie de CTF vas bientot demarrer sur &b" + ctf.lvl.name + Server.DefaultColor + " du monde &b" + ctf.lvl.world);
                    return;
                }

                if (gameInfo.typeGame.ToLower() != "ctf")
                {
                    Player.SendMessage(p, "Un jeu est deja actif sur cette map"); return;
                }

                if (gameInfo != null)
                {
                    if (p != gameInfo.owner || p.group.Permission < LevelPermission.Operator)
                    {
                        Player.SendMessage(p, "Vous n'etes pas le maitre de la partie"); return;
                    }
                    if (gameInfo.gameOn)
                    {
                        Player.SendMessage(p, "Arettez la partie avant de desactiver le ctf"); return;
                    }

                    gameInfo.deleteGame(p);

                    Player.GlobalMessageLevel(p.level, "Mode CTF desactive");
                    return;
                }
                break;
            }
        }