/// <summary> /// Puts an occupation into player for the given player. After all custom event triggers are fired, /// a PlayOccupationTrigger will be fired. /// </summary> /// <param name="player">The player who owns the occupation</param> /// <param name="eventTriggers">Any triggers that should be fired when this occupation is played</param> /// <param name="resultingNotices">A list of notices that should be sent to players</param> /// <param name="data">The data for the occupation being played</param> public static void PlayOccupation(AgricolaPlayer player, ImmutableList <GameEventTrigger> eventTriggers, List <GameActionNotice> resultingNotices, OccupationActionData data) { var card = ((AgricolaGame)player.Game).GetCard(data.Id.Value); var cost = Curator.GetOccupationCost(player, data.ActionId, data.Id.Value); foreach (var resource in cost) { player.AddResource(resource.Type, -resource.Count); } player.PlayCard(data.Id.Value); foreach (var evnt in card.OnPlayEvents) { evnt.Execute(player, null, card, resultingNotices); } resultingNotices.Add(new GameActionNotice(player.Name, NoticeVerb.PlayOccupation.ToString(), new IdPredicate(data.Id.Value))); CheckTriggers(player, eventTriggers, resultingNotices); var trigger = new PlayOccupationTrigger(card); ProcessEventTrigger(player, trigger, resultingNotices); }
public static bool CanPlayOccupation(AgricolaPlayer player, int actionId, int cardId) { var card = ((AgricolaGame)player.Game).GetCard(cardId); if (!player.HandOccupations.Contains(card)) { return(false); } ResourceCache[] costs = Curator.GetOccupationCost(player, actionId, cardId); if (!player.CanAfford(costs) || !card.PrerequisitesMet(player)) { return(false); } return(true); }