public static string JoinList(this IEnumerable <Development> developments) { var quantity = developments.Count(); string bonus = (developments.Select(x => x.Bonus).Distinct().Count() == 1) ? $" ({developments.First().Bonus.ToString()})" : ""; return($"{quantity} {(quantity == 1 ? Development.Singular() : Development.Plural())}{bonus}"); }
private void TakeCard(Development development) { var taken = deck.Remove(development); if (!taken) { throw new NotFoundException(nameof(Development)); } updateDeck?.Invoke(); }
public void BuyCard(Development development) { if (!deck.Contains(development)) { throw new NotFoundException($"Can not take {development.ToString()} because it is not in the deck"); } if (!IsVisible(development)) { throw new DomainException($"Can not take {development.ToString()} because it is not visible"); } TakeCard(development); }
public GameAction MakeMove() { var development = globalElectionService.Search(); if (!(development is null)) { new PurchaseService(development, currentPlayer).Purchase(deck, market); var noble = ChooseRandomNobleIfPossible(); return(log.BuyDevelopment(currentTurn, currentPlayer, noble, development)); } if (currentPlayer.TotalGems() <= 5) { var gems = ThreeRandomGems()?.ToArray() ?? new Gem[0]; if (market.CanBeTaken(gems)) { new TakeGemsService(currentPlayer, market, gems).Take(); var noble = ChooseRandomNobleIfPossible(); return(log.TakeGems(currentTurn, currentPlayer, noble, gems)); } } if (currentPlayer.TotalGems() <= 8) { var gems = TwoSameRandomGems()?.ToArray() ?? new Gem[0]; if (market.CanBeTaken(gems)) { new TakeGemsService(currentPlayer, market, gems).Take(); var noble = ChooseRandomNobleIfPossible(); return(log.TakeGems(currentTurn, currentPlayer, noble, gems)); } } Development developmentToReserve = RandomDevelopment(); var reserveService = new ReserveService(developmentToReserve, currentPlayer, market); if (reserveService.CanReserve()) { bool takeGold = reserveService.WouldTakeGoldToken(); reserveService.Reserve(deck); var noble = ChooseRandomNobleIfPossible(); return(log.ReserveDevelopment(currentTurn, currentPlayer, noble, developmentToReserve, takeGold)); } return(null); }
public void ReserveCard(Development development) { ReservedDevelopments.Add(development); updatePlayer?.Invoke(); }
public void BuyCard(Development development) { Developments.Add(development); updatePlayer?.Invoke(); }
public GameAction ReserveDevelopment(int currentTurn, Player player, Noble noble, Development development, bool takeGold) { var move = new ReserveDevelopment(development, takeGold, noble); Entries.Add(new LogEntry(currentTurn, move, player)); return(move); }
public GameAction BuyDevelopment(int currentTurn, Player player, Noble noble, Development development) { var move = new BuyDevelopment(development, noble); Entries.Add(new LogEntry(currentTurn, move, player)); return(move); }
public ReserveService(Development development, Player player, Market market) { this.development = development; this.player = player; this.market = market; }
public PurchaseService(Development development, Player player) { this.development = development; this.player = player; gold = player.TotalGems(Gems.Gold); }
public bool IsVisible(Development development) => VisibleDevelopments().Contains(development);
public void ReserveCard(Development development) => TakeCard(development);