Exemplo n.º 1
0
        internal override string ToTimelineString()
        {
            string timelinestring = base.ToTimelineString();

            string location = "in ";

            if (Subregion != null)
            {
                location += Subregion.ToString();
            }
            else
            {
                location += Site.AltName;
            }

            if (Devourer != null)
            {
                return(string.Format("{0} {1} devoured someone {2}.",
                                     timelinestring, Devourer.ToString(), location));
            }
            else
            {
                return(string.Format("{0} Creature devoured {1}.",
                                     timelinestring, location));
            }
        }
Exemplo n.º 2
0
    private static List <Subregion> CreateSubregionAt(int X, int Y)
    {
        int subregionStartX = ((int)(X / _subregionSize)) * _subregionSize;
        int subregionStartY = ((int)(Y / _subregionSize)) * _subregionSize;

        //Deleting any subregions that existed on 10x10 chunk
        for (int x = subregionStartX; x < subregionStartX + _subregionSize; x++)
        {
            for (int y = subregionStartY; y < subregionStartY + _subregionSize; y++)
            {
                PathGrid.NodeAt(x, y)?.subregion?.Reset();
            }
        }

        //Creating new subregions on named chunk
        List <Subregion> createdSubregions = new List <Subregion>();

        for (int x = subregionStartX; x < subregionStartX + _subregionSize; x++)
        {
            for (int y = subregionStartY; y < subregionStartY + _subregionSize; y++)
            {
                Subregion newSubregion = FillSubregionFrom(PathGrid.NodeAt(x, y));
                if (newSubregion != null)
                {
                    newSubregion.CalculateAverageCoordinates();
                    createdSubregions.Add(newSubregion);
                }
            }
        }
        return(createdSubregions);
    }
Exemplo n.º 3
0
        protected override string LegendsDescription()
        {
            var timestring = base.LegendsDescription();

            var location = "in ";

            if (Subregion != null)
            {
                location += Subregion.ToString();
            }
            else
            {
                location += Site.AltName;
            }

            if (Devourer != null)
            {
                return(string.Format("{0} the {1} {2} devoured the {3} {4} {5}.",
                                     timestring, Devourer.Race, Devourer, "UNKNOWN", "UNKNOWN",
                                     location));
            }
            return(string.Format("{0} the {1} {2} devoured the {3} {4} {5}.",
                                 timestring, "UNKNOWN", "UNKNOWN", "UNKNOWN", "UNKNOWN",
                                 location));
        }
Exemplo n.º 4
0
    private static bool NextWaveIteration(ref List <Node> openSet, ref Subregion subregion)
    {
        for (int i = openSet.Count - 1; i >= 0; i--)
        {
            if (openSet[i].subregion != null)
            {
                openSet.RemoveAt(i);
            }
        }

        if (openSet.Count == 0)
        {
            return(false);
        }

        foreach (Node neighbour in openSet[0].GetNeighbours())
        {
            if (!neighbour.IsTraversable || neighbour.subregion != null ||
                !IsInsideArea(neighbour.X, neighbour.Y, ((int)(openSet[0].X / _subregionSize)) * _subregionSize, ((int)(openSet[0].Y / _subregionSize)) * _subregionSize))
            {
                continue;
            }
            openSet.Add(neighbour);
        }

        subregion.AddNode(openSet[0]);
        openSet.RemoveAt(0);

        return(true);
    }
Exemplo n.º 5
0
        protected override string LegendsDescription()
        {
            var timestring = base.LegendsDescription();

            return(string.Format("{0} {1} tamed the {2} of {3}.",
                                 timestring, GroupHF, "UNKNOWN",
                                 Subregion == null ? "UNKNOWN" : Subregion.ToString()));
        }
Exemplo n.º 6
0
        internal override string ToTimelineString()
        {
            string timelinestring = base.ToTimelineString();

            return(string.Format("{0} {1} attacked {2} in {3}.",
                                 timelinestring, AttackerCiv.ToString(), DefenderCiv.ToString(),
                                 Subregion.ToString()));
        }
Exemplo n.º 7
0
 public void AddNeighbour(Subregion neighbour)
 {
     if (neighbouringSubregions.Contains(neighbour))
     {
         return;
     }
     neighbouringSubregions.Add(neighbour);
     neighbour.AddNeighbour(this);
 }
Exemplo n.º 8
0
        public override string LegendsDescription()
        {
            string timestring = base.LegendsDescription();

            return(string.Format("{0} {1} attacked {2} in {3}. \nThe {4} {5} led the attack, \nand the defenders were led by the {6} {7}.",
                                 timestring, AttackerCiv.ToString(), DefenderCiv.ToString(),
                                 Subregion.ToString(), AttackerGeneralHF.Race.ToString(), AttackerGeneralHF.ToString(),
                                 DefenderGeneralHF.Race.ToString(), DefenderGeneralHF.ToString()));
        }
        public void EntitySubregionToDictionary()
        {
            int       mapId              = 1;
            string    name               = "Very Mists";
            int       minLevel           = 40;
            int       maxLevel           = 55;
            int       defaultFloor       = 5;
            Rectangle mapRectangle       = new Rectangle(new Point2D(100, 200), new Point2D(200, 300));
            Rectangle continentRectangle = new Rectangle(new Point2D(10, 20), new Point2D(20, 30));

            var expected = new Dictionary <string, object>()
            {
                { "map_id", mapId },
                { "name", name },
                { "min_level", minLevel },
                { "max_level", maxLevel },
                { "default_floor", defaultFloor },
                { "map_rect", new Dictionary <string, double>()
                  {
                      { "x", mapRectangle.X },
                      { "y", mapRectangle.Y },
                      { "width", mapRectangle.Width },
                      { "height", mapRectangle.Height }
                  } },
                { "continent_rect", new Dictionary <string, double>()
                  {
                      { "x", continentRectangle.X },
                      { "y", continentRectangle.Y },
                      { "width", continentRectangle.Width },
                      { "height", continentRectangle.Height }
                  } },
                { "points_of_interest", new List <object>() },
                { "tasks", new List <object>() },
                { "skill_challenges", new List <object>() },
                { "sectors", new List <object>() }
            };

            Subregion subregion = new Subregion()
            {
                MapId              = mapId,
                Name               = name,
                MinimumLevel       = minLevel,
                MaximumLevel       = maxLevel,
                DefaultFloor       = defaultFloor,
                MapRectangle       = mapRectangle,
                ContinentRectangle = continentRectangle
            };

            var actual = subregion.ToDictionary();

            Assert.AreEqual(expected, actual, "Subregion");
            CollectionAssert.AreEquivalent((IDictionary <string, double>)expected["map_rect"],
                                           (IDictionary <string, double>)actual["map_rect"], "Map rectangle");
            CollectionAssert.AreEquivalent((IDictionary <string, double>)expected["continent_rect"],
                                           (IDictionary <string, double>)actual["continent_rect"], "Continent Rectangle");
        }
Exemplo n.º 10
0
    private static Region CreateRegionAt(Subregion subregion)
    {
        Region           region  = new Region();
        List <Subregion> openSet = new List <Subregion>();

        openSet.Add(subregion);
        do
        {
        } while(NextWaveIteration(ref openSet, ref region));

        return(region);
    }
Exemplo n.º 11
0
        protected override string LegendsDescription() //TODO: Test Display
        {
            //TODO: Incorporate new data (multiple GroupHFs)
            var timestring = base.LegendsDescription();

            if (Pets != null && Pets.Count == 1)
            {
                return
                    ($"{timestring} {Hfs[0]} tamed the {Pets[0]} of {Subregion?.ToString() ?? "UNKNOWN"}.");
            }
            return
                ($"{timestring} {Hfs[0]} tamed the {"UNKNOWN"} of {Subregion?.ToString() ?? "UNKNOWN"}.");
        }
Exemplo n.º 12
0
        protected override string LegendsDescription()
        {
            var timestring = base.LegendsDescription();

            if (Escape)
            {
                return($"{timestring} {Hf} escaped from the Underworld.");
            }
            if (Return)
            {
                return($"{timestring} {Hf} returned to {(Site == null ? "UNKNONW" : Site.AltName)}.");
            }
            return($"{timestring} {Hf} made a journey to {Subregion?.ToString() ?? "UNKNONW"}.");
        }
Exemplo n.º 13
0
        public ActionResult ShowSubregion(string subregion)
        {
            var countries = GetCountries().Where(x => x.Subregion == subregion);

            var Subregion = new Subregion()
            {
                Name       = subregion,
                Population = countries.Sum(x => x.Population),
                Region     = countries.Select(x => x.Region).First(x => x.HasValue()),
                Countries  = countries.Select(x => x.Name)
            };

            return(PartialView("SubRegionView", Subregion));
        }
    private static int GetDistance(Subregion subA, Subregion subB)
    {
        Node A = PathGrid.NodeAt(subA.avergX, subA.avergY);
        Node B = PathGrid.NodeAt(subB.avergX, subB.avergY);

        int distX = Mathf.Abs(A.X - B.X);
        int distY = Mathf.Abs(A.Y - B.Y);

        if (distX > distY)
        {
            return(14 * distY + 10 * (distX - distY));
        }

        return(14 * distX + 10 * (distY - distX));
    }
Exemplo n.º 15
0
        internal override string ToTimelineString()
        {
            var timelinestring = base.ToTimelineString();

            if (Escape)
            {
                return($"{timelinestring} {Hf} escaped from the Underworld.");
            }
            if (Return)
            {
                return($"{timelinestring} {Hf} returned to {(Site == null ? "UNKNONW" : Site.AltName)}.");
            }
            return
                ($"{timelinestring} {Hf} made a journey to {Subregion?.ToString() ?? "UNKNONW"}.");
        }
    private static List <Subregion> RetracePath(Subregion startSubregion, Subregion endSubregion)
    {
        List <Subregion> path             = new List <Subregion>();
        Subregion        currentSubregion = endSubregion;

        while (currentSubregion != startSubregion)
        {
            path.Add(currentSubregion);
            currentSubregion.ParentSubregion.child = currentSubregion;
            currentSubregion = currentSubregion.ParentSubregion;
        }
        path.Add(startSubregion);

        //path.Reverse();
        return(path);
    }
Exemplo n.º 17
0
    private static Subregion FillSubregionFrom(Node node)
    {
        if (node == null || node.subregion != null || node.IsTraversable == false)
        {
            return(null);
        }

        Subregion   subregion = new Subregion();
        List <Node> openNodes = new List <Node>();

        openNodes.Add(node);
        do
        {
        } while(NextWaveIteration(ref openNodes, ref subregion));
        subregions.Add(subregion);
        return(subregion);
    }
Exemplo n.º 18
0
    public static List <Subregion> DijkstraFor(int steps, Subregion startSubregion)
    {
        List <Subregion> closedSet = new List <Subregion>();
        List <Subregion> openSet   = new List <Subregion>();

        openSet.Add(startSubregion);

        while (closedSet.Count != steps)
        {
            if (NextDijkstraIteration(ref openSet, ref closedSet) == false)
            {
                break;
            }
        }

        return(closedSet);
    }
Exemplo n.º 19
0
        internal override void Export(string table)
        {
            base.Export(table);

            table = GetType().Name;

            var vals = new List <object>
            {
                Id,
                HfId_Target.DBExport(),
                HfId_Doer.DBExport(),
                Interaction.DBExport(HistoricalFigure.Interactions),
                SiteId.DBExport(),
                Subregion.DBExport()
            };

            Database.ExportWorldItem(table, vals);
        }
Exemplo n.º 20
0
        public async Task <Subregion> GetSubregionDetails(string subregionName)
        {
            if (subregionName.IsNullOrWhiteSpace())
            {
                throw new ArgumentNullException(nameof(subregionName));
            }

            var listOfCountries = await _subregionsHttpClient.GetSubregionDetailsAsync(subregionName);

            var subregion = new Subregion
            {
                Name       = subregionName,
                Population = listOfCountries.Select(p => p.Population).Sum(),
                Region     = listOfCountries.Select(r => r.Region).FirstOrDefault(),
                Countries  = listOfCountries
            };

            return(subregion);
        }
Exemplo n.º 21
0
        internal override string ToTimelineString()
        {
            var timelinestring = base.ToTimelineString();

            if (Escape)
            {
                return(string.Format("{0} {1} escaped from the Underworld.",
                                     timelinestring, GroupHF));
            }
            if (Return)
            {
                return(string.Format("{0} {1} returned to {2}.",
                                     timelinestring, GroupHF,
                                     Site == null ? "UNKNONW" : Site.AltName));
            }
            return(string.Format("{0} {1} made a journey to {2}.",
                                 timelinestring, GroupHF,
                                 Subregion == null ? "UNKNONW" : Subregion.ToString()));
        }
Exemplo n.º 22
0
        protected override string LegendsDescription()
        {
            var timestring = base.LegendsDescription();

            if (Escape)
            {
                return(string.Format("{0} {1} escaped from the Underworld.",
                                     timestring, GroupHF));
            }
            if (Return)
            {
                return(string.Format("{0} {1} returned to {2}.",
                                     timestring, GroupHF,
                                     Site == null ? "UNKNONW" : Site.AltName));
            }
            return(string.Format("{0} {1} made a journey to {2}.",
                                 timestring, GroupHF,
                                 Subregion == null ? "UNKNONW" : Subregion.ToString()));
        }
        public void EntitySubregionWithSectorToDictionary()
        {
            Sector sector = new Sector()
            {
                SectorId = 60
            };
            Subregion subregion = new Subregion()
            {
                Sectors = new List <Sector>()
                {
                    sector
                }
            };

            var expected = sector.ToDictionary();
            var actualPointOfInterest = (ICollection <object>)subregion.ToDictionary()["sectors"];
            var actual = (IDictionary <string, object>)actualPointOfInterest.First();

            Assert.AreEqual(expected, actual);
        }
        public void EntitySubregionWithSkillChallengeToDictionary()
        {
            SkillChallenge skillChallenge = new SkillChallenge()
            {
                Coordinates = new Point2D(10, 20)
            };
            Subregion subregion = new Subregion()
            {
                SkillChallenges = new List <SkillChallenge>()
                {
                    skillChallenge
                }
            };

            var expected = skillChallenge.ToDictionary();
            var actualPointOfInterest = (ICollection <object>)subregion.ToDictionary()["skill_challenges"];
            var actual = (IDictionary <string, object>)actualPointOfInterest.First();

            Assert.AreEqual(expected, actual);
        }
        public void EntitySubregionWithRenownTaskToDictionary()
        {
            RenownTask task = new RenownTask()
            {
                TaskId = 12
            };
            Subregion subregion = new Subregion()
            {
                Tasks = new List <RenownTask>()
                {
                    task
                }
            };

            var expected = task.ToDictionary();
            var actualPointOfInterest = (ICollection <object>)subregion.ToDictionary()["tasks"];
            var actual = (IDictionary <string, object>)actualPointOfInterest.First();

            Assert.AreEqual(expected, actual);
        }
        public void EntitySubregionWithPointOfInterestToDictionary()
        {
            PointOfInterest pointOfInterest = new PointOfInterest()
            {
                PointOfInterestId = 54
            };
            Subregion subregion = new Subregion()
            {
                PointsOfInterest = new List <PointOfInterest>()
                {
                    pointOfInterest
                }
            };

            var expected = pointOfInterest.ToDictionary();
            var actualPointOfInterest = (ICollection <object>)subregion.ToDictionary()["points_of_interest"];
            var actual = (IDictionary <string, object>)actualPointOfInterest.First();

            Assert.AreEqual(expected, actual);
        }
        public void EntityRegionWithSubregionToDictionary()
        {
            Subregion subregion = new Subregion()
            {
                MapId = 111
            };
            Region region = new Region()
            {
                Maps = new Dictionary <int, Subregion>()
                {
                    { subregion.MapId, subregion }
                }
            };

            var expected         = subregion.ToDictionary();
            var actualSubregions = (IDictionary <int, object>)region.ToDictionary()["maps"];
            var actual           = (IDictionary <string, object>)actualSubregions[subregion.MapId];

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 28
0
        internal override string ToTimelineString()
        {
            //TODO: Incorporate new data
            var timelinestring = base.ToTimelineString();

            var location = "in ";

            if (Subregion != null)
            {
                location += Subregion.ToString();
            }
            else
            {
                location += Site.AltName;
            }

            if (Hf_Devourer != null)
            {
                return($"{timelinestring} {Hf_Devourer} devoured someone {location}.");
            }
            return($"{timelinestring} Creature devoured {location}.");
        }
Exemplo n.º 29
0
    public static Tile FindClosestBySubregionTileWhere(Vector2Int sourcePosition, Func <Tile, bool> requirementsFunction,
                                                       bool checkEqualityOfRegions = true)
    {
        List <Subregion> closedSet = new List <Subregion>();
        List <Subregion> openSet   = new List <Subregion>();

        openSet.Add(Utils.NodeAt(sourcePosition.x, sourcePosition.y).Subregion);

        while (Dijkstra.NextDijkstraIteration(ref openSet, ref closedSet))
        {
            Subregion subregion = closedSet[0];
            foreach (Node node in subregion.Nodes)
            {
                Tile checkTile = Utils.TileAt(node.X, node.Y);
                if (requirementsFunction(checkTile))
                {
                    return(checkTile);
                }
            }
        }

        return(null);
    }
Exemplo n.º 30
0
        protected override string LegendsDescription()
        {
            var timestring = base.LegendsDescription();

            var location = "in ";

            if (Subregion != null)
            {
                location += Subregion.ToString();
            }
            else
            {
                location += Site.AltName;
            }

            var devourertext = "an unknown creature";

            if (Hf_Devourer != null)
            {
                devourertext = $"the {Hf_Devourer.Race.ToString().ToLower()} {Hf_Devourer}";
            }

            if (Hf_Victim == null)
            {
                return
                    ($"{timestring} {devourertext} devoured a {VictimRace?.ToString()?.ToLower() ?? "UNKNOWN"} of {Entity?.ToString() ?? ""} in {location}.");
            }
            if (Entity == null)
            {
                return
                    ($"{timestring} {devourertext} devoured the {VictimRace.ToString().ToLower()} {Hf_Victim} {location}.");
            }


            return($"{timestring} the {"UNKNOWN"} {"UNKNOWN"} devoured the {"UNKNOWN"} {"UNKNOWN"} {location}.");
        }