FindGame() public static method

Return game of selected level, or null, if game isn't enabled.
public static FindGame ( Level level ) : Game
level Level
return Game
Esempio n. 1
0
 private void InitializeGame(Player p, string[] param)
 {
     if (p.level == null)
     {
         p.SendMessage("Error, can't use /gamemaster via console.");
         return;
     }
     else
     {
         // param[0] - name of game
         if (GameControl.availableGames.Contains(param[0]))
         {
             if (GameControl.IsEnabled(p.level))
             {
                 p.SendMessage("Error, game " + GameControl.FindGame(p.level).name + " already initialized.");
                 return;
             }
             else
             {
                 GameControl.Add(GameControl.GetGame(param[0], p.level));
                 p.level.ChatLevel("Game " + param[0] + " initialized.");
             }
         }
         else
         {
             p.SendMessage("Error, game name " + param[0] + " is invalid.");
             return;
         }
     }
 }
Esempio n. 2
0
 private void SendInfo(Player p, string[] param)
 {
     if (GameControl.IsEnabled(p.level))
     {
         string[] sa = GameControl.FindGame(p.level).GetCurrentInfo(GetSetParameters(param));
         foreach (string s in sa)
         {
             p.level.ChatLevel(s);
         }
     }
     else
     {
         p.SendMessage("Error, game isn't enabled on level.");
     }
 }
Esempio n. 3
0
 private void Leave(Player p, string[] param)
 {
     if (GameControl.FindGame(p.level).GameOPs.Contains(p))
     {
         GameControl.FindGame(p.level).GameOPs.Remove(p);
         SendToGameOPs(GameControl.FindGame(p.level), new string[] { (p.name + " is no more gameOP.") });
         if (GameControl.FindGame(p.level).GameOPs.Count == 0)
         {
             GameControl.Delete(p.level);
             p.level.ChatLevel("Game disposed.");
         }
     }
     else
     {
         p.SendMessage("Error, you are not in gameOP list.");
     }
 }
Esempio n. 4
0
 private void CheckIsOp(Player p, string[] param)
 {
     if (GameControl.IsEnabled(p.level))
     {
         try
         {
             if (!GameControl.FindGame(p.level).GameOPs.Contains(p) && param[0] != "leave")
             {
                 GameControl.FindGame(p.level).GameOPs.Add(p);
                 SendToGameOPs(GameControl.FindGame(p.level), new string[] { (p.name + " added to gameOP list.") });
             }
         }
         // no parameter
         catch
         {  }
     }
 }
Esempio n. 5
0
 private void EndGame(Player p, string[] param)
 {
     if (GameControl.IsEnabled(p.level))
     {
         if (GameControl.FindGame(p.level).IsInProgress())
         {
             GameControl.FindGame(p.level).ForceEnd(GetSetParameters(param));
             // Message, if game was ended manually
             SendToLevel(p.level, GameControl.FindGame(p.level).GetForceEndMessage());
         }
         else
         {
             p.SendMessage("Error, game isn't started.");
         }
     }
     else
     {
         p.SendMessage("Error, game isn't enabled on level.");
     }
 }
Esempio n. 6
0
 private void SetParam(Player p, string[] param)
 {
     if (GameControl.IsEnabled(p.level))
     {
         bool     isCompleted = false;
         string[] message     = new string[0];
         GameControl.FindGame(p.level).SetParameters(GetSetParameters(param), ref isCompleted, ref message);
         if (isCompleted)
         {
             SendToGameOPs(GameControl.FindGame(p.level), message);
         }
         else
         {
             SendToPlayer(p, message);
         }
     }
     else
     {
         p.SendMessage("Error, game isn't enabled on level.");
     }
 }
Esempio n. 7
0
 private void StartGame(Player p, string[] param)
 {
     if (GameControl.IsEnabled(p.level))
     {
         if (GameControl.FindGame(p.level).IsInProgress())
         {
             p.SendMessage("Error, game already started.");
         }
         else
         {
             bool     isCompleted = false;
             string[] message     = new string[0];
             SendToLevel(p.level, GameControl.FindGame(p.level).GetStartMessage());
             GameControl.FindGame(p.level).Start(GetSetParameters(param), ref isCompleted, ref message);
         }
     }
     else
     {
         p.SendMessage("Error, no initialized game found.");
     }
 }