using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Holo.Virtual.Rooms.Games;
using System.Collections;
namespace Holo.Source.Managers.gameManager
{
class gameManager
{
///
/// The hashtable that contains all the games.
///
public static Hashtable Games = new Hashtable();
///
/// Returns the list with 'BattleBall'/'SnowStorm' games, depending on the mode of this lobby. This list is for usage in the game browser's index.
///
public static string gameList()
{
try
{ //"FZ + Number of games + ID of game + Name of map (not showed) + Char(2) +
StringBuilder gameList = new StringBuilder(Encoding.encodeVL64(Games.Count));
foreach (Game Game in Games.Values)
{
gameList.Append(Encoding.encodeVL64(Game.ID)
+ "Bouncing Ball level 5" // Unknown purpose, game map name
+ Convert.ToChar(2)
+ "I" // Snowstorm or Battleball (I = bb, H = ss)
+ Encoding.encodeVL64(Game.mapID) // ID of map
+ Encoding.encodeVL64(Game.Teams.Length) // Count of teams
+ Encoding.encodeVL64(12) // Max users in game
+ Game.Owner.User._Username // Owner's username
+ Convert.ToChar(2));
}
return gameList.ToString();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
return "";
}
}
public static void createGame(gamePlayer Owner, int mapID, int teamAmount, int[] enabledPowerups, bool isPrivate)
{
int gameID = 1;
while (Games.ContainsKey(gameID))
gameID++;
Owner.Game.movePlayer(Owner, -1, 0);
Games.Add(gameID, Owner.Game);
}
public static void removeGame(Game Game)
{
Games.Remove(Game.ID);
Game.sendData("F`" + "H");
Holo.Managers.userManager.sendData("F`" + "H");
}
public static Game getGame(int id)
{
foreach (Game Game in Games.Values)
if (Game.ID == id)
return Game;
return null;
}
}
}