private void WorldModelOnOnNewlyInfectedNode(Coordinates coordinates)
 {
     // If a random number is less than DISPATCH_FREQUENCY, and there are yet-unassigned ORTs,
     // send one there by air. Don't want all governments instantly sending their ORTs to the first
     // ten or fifteen infected nodes, do we? Wouldn't look right.
     if (s_dispatchDecider.NextDouble() < DISPATCH_FREQUENCY)
     {
         OutbreakResponseTeam nextUp = ResponseTeams.FirstOrDefault(n => n.StandingBy);
         //if ( nextUp != null ) console.WriteLine($"{SimCountryData.Name} is sending {nextUp} to {coordinates}.");
         nextUp?.SetDestinationAndSpeed(coordinates, OutbreakResponseTeam.AIRCRAFT_MOVE_SPEED);
     }
     //else
     //{
     //    console.WriteLine($"{SimCountryData.Name} will not respond to infection at {coordinates}.");
     //}
 }
Exemple #2
0
        private void CreateAndAssignGovernments()
        {
            m_allORTs = new List<OutbreakResponseTeam>();
            ILineWriter console = Locator.Resolve<ILineWriter>("console");
            Dictionary<string, List<Coordinates>> nodeToCountryMapping = new Dictionary<string, List<Coordinates>>();

            for (int x = 0; x < m_mapData.Width; x++)
            {
                for (int y = 0; y < m_mapData.Height; y++)
                {
                    DiseaseNode dn = m_nodes[x, y];
                    string cc = dn.MapCell.CountryCode;
                    if (cc != null && !"--".Equals(cc))
                    {
                        List<Coordinates> diseaseNodeCoordinates;
                        if (!nodeToCountryMapping.TryGetValue(cc, out diseaseNodeCoordinates))
                        {
                            diseaseNodeCoordinates = new List<Coordinates>();
                            nodeToCountryMapping.Add(cc, diseaseNodeCoordinates);
                        }
                        diseaseNodeCoordinates.Add(new Coordinates {X = x, Y = y});
                    }
                }
            }

            Dictionary<string, NationalGovernment> govts = new Dictionary<string, NationalGovernment>();
            for (int x = 0; x < m_mapData.Width; x++)
            {
                for (int y = 0; y < m_mapData.Height; y++)
                {
                    DiseaseNode dn = m_nodes[x, y];
                    string countryCode = dn.MapCell.CountryCode;
                    if ("--".Equals(countryCode)) continue;
                    if (countryCode == null) continue;
                    if (!m_countryDataByCountryCodes.ContainsKey(countryCode))
                    {
                        //console.WriteLine($"No country data for country code \"{countryCode}\".");
                        continue;
                    }
                    SimCountryData simCountryData = m_countryDataByCountryCodes[countryCode];
                    if (nodeToCountryMapping.ContainsKey(dn.MapCell.CountryCode))
                    {
                        if (!govts.ContainsKey(countryCode))
                        {
                            NationalGovernment ng = new NationalGovernment(this)
                            {
                                WorldModel = this,
                                SimCountryData = m_countryDataByCountryCodes[countryCode],
                                DiseaseNodeCoordinates = nodeToCountryMapping[countryCode]
                            };

                            if (m_ortCounts.ContainsKey(simCountryData.CountryCode))
                            {
                                var ortCount = m_ortCounts[simCountryData.CountryCode];
                                int numberOfResponseTeams = ortCount.Item1;
                                for (int i = 0; i < numberOfResponseTeams; i++)
                                {
                                    int randomDiseaseNode = m_random.Next(0, ng.DiseaseNodeCoordinates.Count - 1);
                                    Coordinates initialCoordinates = ng.DiseaseNodeCoordinates[randomDiseaseNode];
                                    OutbreakResponseTeam ort = 
                                        new OutbreakResponseTeam(simCountryData.CountryCode, i, ortCount.Item2, this, initialCoordinates);
                                    ng.ResponseTeams.Add(ort);
                                    simCountryData.ResponseTeams.Add(ort);
                                    m_allORTs.Add(ort);
                                }
                            }

                            simCountryData.Government = ng;
                            govts.Add(countryCode, ng);
                            ng.UpdateDiseaseNodes(true);
                        }
                    }
                    else
                    {
                        console.WriteLine($"Could not find a list of nodes for country code {simCountryData.CountryCode}");
                    }

                }
            }
            m_governments.AddRange(govts.Values);
        }