Beispiel #1
0
        public Game(IDataAccess dataAccess, IList<string> playerNames, Difficulty difficulty)
        {
            OutbreakCounter = new OutbreakCounter();

            Diseases = dataAccess.GetDiseases();
            Nodes = dataAccess.GetNodes();
            Players = PlayerFactory.GetPlayers(playerNames);

            NodeCounters = GetNodeDiseaseCounter(Nodes, Diseases, OutbreakCounter);
            DiseaseCounters = GetDiseaseCounters(Diseases, NodeCounters, OutbreakCounter);

            SubscribeNodesToMovers();
            SubscribeToPlayerCounters();

            InfectionRateCounter = new InfectionRateCounter();
            ResearchStationCounter = new ResearchStationCounter();

            cityCards = GetCityCards(Nodes);
            infectionCards = GetInfectionCards(NodeCounters);

            infectionDeck = new InfectionDeck(infectionCards.ToList());

            ActionCardManager = new ActionCardManager(Nodes, Players, ResearchStationCounter, infectionDeck);

            playerDeck = new PlayerDeck(new List<Card>(cityCards), new List<Card>() { ActionCardManager.GovernmentGrant, ActionCardManager.Airlift });

            epidemicCards = GetEpidemicCards(InfectionRateCounter, infectionDeck);

            StartGame((int)difficulty);

            playerQueue = new PlayerQueue(Players.ToList());
            Players = Players.OrderBy(i => i.TurnOrder);

            ActionManager = new ActionManager();
            DrawManager = new DrawManager(playerDeck);
            DrawManager.DrawPhaseCompleted += DrawPhaseComplete;
            InfectionManager = new InfectionManager(InfectionRateCounter, infectionDeck);
            InfectionManager.InfectionPhaseCompleted += InfectionPhaseCompleted;

            //game over
            OutbreakCounter.GameOver += GameOverNotified;
            playerDeck.GameOver += GameOverNotified;

            foreach (DiseaseCounter dc in DiseaseCounters)
            {
                dc.GameOver += GameOverNotified;
            }

            //game won
            CureTracker = new CureTracker(Diseases);
            CureTracker.GameWon += GameWonNotified;

            NextPlayer();
        }
        public GameStatusViewModel(OutbreakCounter outbreakCounter, InfectionRateCounter infectionRateCounter, ResearchStationCounter researchStationCounter, IEnumerable<IDiseaseCounterViewModel> diseaseCounterViewModels, Notifier notifier)
        {
            if (diseaseCounterViewModels == null)
                throw new ArgumentNullException("DiseaseCounterViewModels");

            this.outbreakCounter = outbreakCounter;
            this.infectionRateCounter = infectionRateCounter;
            this.researchStationCounter = researchStationCounter;
            this.diseaseCounterViewModels = diseaseCounterViewModels;
            notifier.SubscribeToViewModel(this);
        }
        internal void SetPlayer(Player player, IEnumerable<Player> players, IEnumerable<Node> nodes, IEnumerable<NodeDiseaseCounter> nodeDiseaseCounters, ResearchStationCounter researchStationCounter, IEnumerable<Disease> diseases)
        {
            driveManager = new DriveManager(player);
            CanDrive = driveManager.CanDrive;
            Drive = driveManager.Drive;

            directFlightManager = new DirectFlightManager(player);
            CanDirectFlight = directFlightManager.CanDirectFlight;
            DirectFlight = directFlightManager.DirectFlight;

            charterFlightManager = new CharterFlightManager(player, nodes);
            CanCharterFlight = charterFlightManager.CanCharterFlight;
            CharterFlight = charterFlightManager.CharterFlight;

            shuttleFlightManager = new ShuttleFlightManager(player, nodes);
            CanShuttleFlight = shuttleFlightManager.CanShuttleFlight;
            ShuttleFlight = shuttleFlightManager.ShuttleFlight;

            researchStationConstructionManager = new ResearchStationConstructionManager(player, researchStationCounter, nodes);
            CanBuildResearchStation = researchStationConstructionManager.CanConstructResearchStation;
            BuildResearchStation = researchStationConstructionManager.ConstructResearchStation;

            treatDiseaseManager = new TreatDiseaseManager(player, nodeDiseaseCounters);
            CanTreatDisease = treatDiseaseManager.CanTreat;
            TreatDisease = treatDiseaseManager.Treat;

            shareKnowledgeManager = new ShareKnowledgeManager(player, players);
            CanShareKnowledge = shareKnowledgeManager.CanShareKnowledge;
            ShareKnowledge = shareKnowledgeManager.ShareKnowledge;

            discoverCureManager = new DiscoverCureManager(player, diseases);
            CanDiscoverCure = discoverCureManager.CanDiscoverCure;
            DiscoverCure = discoverCureManager.DiscoverCure;

            dispatchManager = new DispatchManager(player, players);
            CanDispatch = dispatchManager.CanDispatch;
            Dispatch = dispatchManager.Dispatch;

            operationsRelocationManager = new OperationsRelocationManager(player, nodes);
            CanRelocate = operationsRelocationManager.CanRelocate;
            Relocate = operationsRelocationManager.Relocate;
        }