コード例 #1
0
ファイル: ServerUpdate.cs プロジェクト: j-farkas/Fiefdom
        public void UpdateServer(object state)
        {
            if (!GameValues.clientUpdate)
            {
                GameValues.clientUpdate = true;
                using (var db = new FiefContext())
                {
                    var fiefdom = db.Fiefdom.Include("FiefdomPlot").Include("FiefdomResources").ToList();
                    foreach (Fief fief in fiefdom)
                    {
                        FiefdomUpdate.UpdateResources(fief);
                    }
                    var gameState = db.GameState.FirstOrDefault();

                    gameState.Day++;
                    UpdateMarketPrices();
                    if (gameState.Day >= 10)
                    {
                        ProcessVotes();
                        gameState.Day     = 1;
                        gameState.Season += 1;
                    }
                    if (gameState.Season > 4)
                    {
                        gameState.Season = 1;
                        gameState.Year++;
                    }
                    db.SaveChanges();
                    UpdateClients();
                    GameValues.clientUpdate = false;
                }
            }
        }
コード例 #2
0
 public void UpdateServer(Object source, ElapsedEventArgs e)
 {
     using (var db = new FiefContext())
     {
         var fiefdom = db.Fiefdom.Include("FiefdomPlot").Include("FiefdomResources").ToList();
         foreach (Fief fief in fiefdom)
         {
             FiefdomUpdate.UpdateResources(fief);
         }
         db.SaveChanges();
     }
 }