public ActionResponse StartGame(StartGameAction action) { var result = TryToResolve(action.User); if (result) { //todo move this out foreach (var p in Players) { GameRule.PaymentTransaction(p, 50); } GameRule.ChangeTurnOrder(_container.GameContext); return(new StartGameResponse()); } return(new StartGameResponse(Constants.Instance.ErrorMessage.Not_Everybody_Checked_ReadyMark)); }
//todo need to move it outside public bool Build(City city) { var context = GameContext.GetContextByPlayer(Player); var builts = context.GameBoard.BuildPlayersCities.Values.SelectMany(m => m.Cities) .Where(m => m.City.Id == city.Id); var level = builts.Any() ? builts.Max(m => m.Level) : -1; level++; if (level <= city.Levels.Max(m => m.Key)) { var cost = city.Levels[level]; if (GameRule.CanPay(Player, cost)) { Cities.Add(new BuiltCity(city, level)); GameRule.PaymentTransaction(Player, -cost); return(true); } } return(false); }