Beispiel #1
0
 public static void StartGame(CommandArgs args)
 {
     if (FreezeTools.GetFTPlayerByID(args.Player.Index).CurrentGame != null)
     {
         args.Player.SendMessage("You may not start a new FreezeTag game nor join an existing FreezeTag game while a part of a FreezeTag game.", Color.Red);
         return;
     }
     switch (args.Parameters.Count)
     {
         default:
             {
                 args.Player.SendMessage("Invalid syntax. Proper usage: /joinft <game name> [password]", Color.Red);
                 break;
             }
         case 1:
             {
                 foreach (FTGame gms in Games)
                 {
                     if (gms.Name == args.Parameters[0])
                     {
                         gms.AddMember(args.Player.Index);
                         return;
                     }
                 }
                 args.Player.SendMessage(String.Format("Game not found. Creating a new one called \"{0}\".", args.Parameters[0]), Color.Aqua);
                 FTGame newgame = new FTGame(args.Parameters[0]);
                 newgame.AddMember(args.Player.Index);
                 Games.Add(newgame);
                 break;
             }
         case 2:
             {
                 foreach (FTGame gms in Games)
                 {
                     if (gms.Name == args.Parameters[0])
                     {
                         if (gms.Password == args.Parameters[1])
                         {
                             gms.AddMember(args.Player.Index);
                             return;
                         }
                         else
                         {
                             args.Player.SendMessage(String.Format("Wrong password for game: \"{0}\"", gms.Name), Color.Red);
                             return;
                         }
                     }
                 }
                 args.Player.SendMessage(String.Format("Game not found. Creating a new one called \"{0}\" with the password \"{1}\".", args.Parameters[0], args.Parameters[1]), Color.Aqua);
                 FTGame newgame = new FTGame(args.Parameters[0], args.Parameters[1]);
                 newgame.AddMember(args.Player.Index);
                 Games.Add(newgame);
                 break;
             }
     }
 }
Beispiel #2
0
 public static void RemoveGame(FTGame game)
 {
     lock (FreezeMain.Games)
         FreezeMain.Games.Remove(game);
 }