public void GeneratePlayers() { if (PlayerManager.TotalPlayers() == 0) { string[] playerNames = players.Split(','); foreach (string pName in playerNames) { Player player = new Player(); player.Name = pName; player.LastLogin = new DateTime(DateTime.Now.Year, DateTime.Now.Month, random.Next(1, DateTime.Now.Day)); PlayerManager.SavePlayer(player); } } }
public static Player LoadPlayer(string name) { Siaqodb database = DatabaseFactory.GetInstance(); Player p = (from Player player in database where player.Name == name select player).FirstOrDefault<Player>(); if (p == null)//not exists so create and save { p = new Player(); p.Name = name; p.LastLogin = DateTime.Now; database.StoreObject(p); } return p; }
public static void SavePlayer(Player p) { Siaqodb database = DatabaseFactory.GetInstance(); database.StoreObject(p); }
//Server public void RemovePlayer( Player player ) { player.SetDeleted(); }