Exemple #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();
        }
        static void Main()
        {
            var players = GetPlayers();
            var sittingDuck = new SittingDuck();
            sittingDuck.SetPlayers(players);
            var externalTracks = new []
            {
                new ExternalTrack(TrackConfiguration.Track1, sittingDuck.BlueZone),
                new ExternalTrack(TrackConfiguration.Track2, sittingDuck.RedZone),
                new ExternalTrack(TrackConfiguration.Track3, sittingDuck.WhiteZone)
            };
            var internalTrack = new InternalTrack(TrackConfiguration.Track4);

            var externalThreats = new ExternalThreat[]
            {
                new Destroyer(3, ZoneLocation.Blue, sittingDuck),
                new Fighter(4, ZoneLocation.Red, sittingDuck),
                new Fighter(5, ZoneLocation.White, sittingDuck)
            };
            var internalThreats = new InternalThreat[]
            {
                new SkirmishersA(3, sittingDuck),
                new Fissure(2, sittingDuck)
                //new Alien(1, sittingDuck)
            };
            var game = new Game(sittingDuck, externalThreats, externalTracks, internalThreats, internalTrack, players);
            var currentTurn = 0;
            try
            {
                for (currentTurn = 0; currentTurn < Game.NumberOfTurns; currentTurn++)
                    game.PerformTurn();
            }
            catch (LoseException loseException)
            {
                Console.WriteLine("Killed on turn {0} by: {1}", currentTurn, loseException.Threat);
            }
            Console.WriteLine("Damage Taken:\r\nBlue: {0}\r\nRed: {1}\r\nWhite: {2}",
                sittingDuck.BlueZone.TotalDamage,
                sittingDuck.RedZone.TotalDamage,
                sittingDuck.WhiteZone.TotalDamage);
            Console.WriteLine("Threats killed: {0}. Threats survived: {1}",
                game.defeatedThreats.Count,
                game.survivedThreats.Count);
            Console.WriteLine("Total points: {0}", game.TotalPoints);
            foreach (var zone in sittingDuck.Zones)
            {
                foreach (var token in zone.AllDamageTokensTaken)
                    Console.WriteLine("{0} damage token taken in zone {1}. Still damaged: {2}", token, zone.ZoneLocation, zone.CurrentDamageTokens.Contains(token));
            }
        }
Exemple #3
0
 public Game(
     SittingDuck sittingDuck,
     IList <ExternalThreat> externalThreats,
     IEnumerable <ExternalTrack> externalTracks,
     IList <InternalThreat> internalThreats,
     InternalTrack internalTrack,
     IList <Player> players)
 {
     this.sittingDuck    = sittingDuck;
     allExternalThreats  = externalThreats;
     allInternalThreats  = internalThreats;
     this.externalTracks = externalTracks.ToDictionary(track => track.Zone.ZoneLocation);
     this.internalTrack  = internalTrack;
     this.players        = players;
     PadPlayerActions();
     nextTurn = 0;
 }