Beispiel #1
0
        public Game(
            IList <Player> players,
            IList <InternalThreat> internalThreats,
            IList <ExternalThreat> externalThreats,
            IList <Threat> bonusThreats,
            IDictionary <ZoneLocation, TrackConfiguration> externalTrackConfigurationsByZone,
            TrackConfiguration internalTrackConfiguration,
            ILookup <ZoneLocation, DamageToken> initialDamage)
        {
            EventMaster   = new EventMaster();
            GameStatus    = GameStatus.InProgress;
            NumberOfTurns = 12;
            var externalTracksByZone = externalTrackConfigurationsByZone.ToDictionary(
                trackConfigurationWithZone => trackConfigurationWithZone.Key,
                trackConfigurationWithZone => new Track(trackConfigurationWithZone.Value));
            var internalTrack = new Track(internalTrackConfiguration);

            ThreatController = new ThreatController(externalTracksByZone, internalTrack, externalThreats, internalThreats, EventMaster);
            ThreatController.PhaseStarting += (sender, args) => PhaseStarting(this, args);
            SittingDuck = new SittingDuck(ThreatController, this, initialDamage);
            var allThreats = bonusThreats.Concat(internalThreats).Concat(externalThreats);

            foreach (var threat in allThreats)
            {
                threat.Initialize(SittingDuck, ThreatController, EventMaster);
            }
            SittingDuck.SetPlayers(players);
            Players = players;
            foreach (var player in players)
            {
                player.Initialize(SittingDuck);
            }
            PadPlayerActions();
        }
Beispiel #2
0
        private void PerformPlayerActions()
        {
            PhaseStarting(this, new PhaseEventArgs
            {
                PhaseHeader = ResolutionPhase.PerformPlayerActions.GetDescription()
            });
            foreach (var player in Players)
            {
                player.PerformStartOfPlayerActions(CurrentTurn);
            }

            var playerOrder = Players
                              .Where(player => !player.IsKnockedOut)
                              .OrderByDescending(player => player.IsPerformingMedic(CurrentTurn))
                              .ThenBy(player => player.Index);

            foreach (var player in playerOrder)
            {
                EventMaster.LogEvent(player.PlayerColor.ToString());
                while (!player.GetActionForTurn(CurrentTurn).AllActionsPerformed())
                {
                    player.CurrentStation.PerformNextPlayerAction(player, CurrentTurn);
                }
            }
            ThreatController.OnPlayerActionsEnded();
        }
Beispiel #3
0
        public void AddNewThreatsToTracks(int currentTurn)
        {
            PhaseStarting(this, new PhaseEventArgs {
                PhaseHeader = ResolutionPhase.AddNewThreats.GetDescription()
            });

            var newExternalThreats = ExternalThreats.Where(threat => threat.TimeAppears == currentTurn).ToList();

            foreach (var newThreat in newExternalThreats)
            {
                newThreat.AttackedSittingDuck += (sender, args) => { ThreatAttackedShip(sender, args); };
                newThreat.PlaceOnTrack(ExternalTracks[newThreat.CurrentZone]);
                EventMaster.LogEvent(string.Format(CultureInfo.CurrentCulture, "{0} Appeared", newThreat.DisplayName));
            }

            var newInternalThreats = InternalThreats.Where(threat => threat.TimeAppears == currentTurn).ToList();

            foreach (var newThreat in newInternalThreats)
            {
                newThreat.AttackedSittingDuck += (sender, args) => { ThreatAttackedShip(sender, args); };
                newThreat.PlaceOnTrack(InternalTrack);
                EventMaster.LogEvent(string.Format(CultureInfo.CurrentCulture, "{0} Appeared", newThreat.DisplayName));
            }

            if (!newExternalThreats.Any() && !newInternalThreats.Any())
            {
                EventMaster.LogEvent("No New Threats Appear.");
            }
        }
Beispiel #4
0
 internal ThreatController(
     IDictionary <ZoneLocation, Track> externalTracks,
     Track internalTrack,
     IList <ExternalThreat> externalThreats,
     IList <InternalThreat> internalThreats,
     EventMaster eventMaster)
 {
     InternalTrack   = internalTrack;
     ExternalTracks  = externalTracks;
     ExternalThreats = externalThreats.ToList();
     InternalThreats = internalThreats.ToList();
     EventMaster     = eventMaster;
 }