public ScenarioRunner ReceivesAnswerDirectTradeOfferEvent(string buyingPlayerName, ResourceClutch wantedResources) { var gameEvent = new AnswerDirectTradeOfferEvent(this.GetPlayerId(buyingPlayerName), wantedResources); var eventInstruction = new EventInstruction(gameEvent); this.currentPlayerAgent.AddInstruction(eventInstruction); return(this); }
public void Post(GameEvent gameEvent) { if (gameEvent is GameJoinedEvent gameJoinedEvent) { this.playerId = gameJoinedEvent.PlayerId; } else if (gameEvent is MakeDirectTradeOfferEvent makeDirectTradeOfferEvent) { this.lastMakeDirectTradeOfferEvent = makeDirectTradeOfferEvent; } else if (gameEvent is AnswerDirectTradeOfferEvent answerDirectTradeOfferEvent) { this.lasetAnswerDirectTradeOffEvent = answerDirectTradeOfferEvent; } else if (gameEvent is ResourcesCollectedEvent resourcesCollectedEvent && resourcesCollectedEvent.ResourcesCollectedByPlayerId.ContainsKey(this.playerId)) { foreach (var resourceCollection in resourcesCollectedEvent.ResourcesCollectedByPlayerId[this.playerId]) { this.Resources += resourceCollection.Resources; } } this.GameEvent.Invoke(gameEvent); }