public static void NewGameInstance() { using (var db = new FiefContext()) { if (db.GameState.FirstOrDefault() == null) { db.GameState.Add(new GameState { Day = 1, Season = 1, Year = 1 }); } if (db.Market.ToList().Count == 0) { db.Market.Add(new Market { Type = "Wood", Price = 100 }); db.Market.Add(new Market { Type = "Stone", Price = 100 }); db.Market.Add(new Market { Type = "Food", Price = 100 }); } db.SaveChanges(); } FiefdomActions.Ballots.Add(FiefdomActions.CreateVote()); FiefdomActions.Ballots.Add(FiefdomActions.CreateVote()); FiefdomActions.Ballots.Add(FiefdomActions.CreateVote()); }
public void ProcessVotes() { FiefdomActions.Edicts.Clear(); FiefdomActions.MarketTax = 0; List <bool> votes = FiefdomActions.CountVotes(); for (int i = 0; i < FiefdomActions.Ballots.Count; i++) { string edict = FiefdomActions.Ballots[i]; String[] splitted = edict.Split(); if (splitted[0] == "Market" || splitted[0] == "Levy") { FiefdomActions.Edicts.Add(new Edict { Type = splitted[0], Target = splitted[1], Amount = int.Parse(splitted[2]), Passed = votes[i] }); } if (splitted[0] == "Tax") { if (votes[i]) { FiefdomActions.MarketTax += int.Parse(splitted[1]); } FiefdomActions.Edicts.Add(new Edict { Type = "Tax", Amount = int.Parse(splitted[1]), Passed = votes[i] }); } } FiefdomActions.Ballots.Clear(); FiefdomActions.ClearVote(); FiefdomActions.Ballots.Add(FiefdomActions.CreateVote()); FiefdomActions.Ballots.Add(FiefdomActions.CreateVote()); FiefdomActions.Ballots.Add(FiefdomActions.CreateVote()); }