Example #1
0
    private void CheckValidationResult(List <WorldObject> worldObjs, List <string> resultSentences, List <GUI_TextInputElement> list)
    {
        WorldResult <EValidationResult> result = _world.Check(new WorldParameter(worldObjs, resultSentences));

        for (int i = 0; i < result.Result.Value.Count; i++)
        {
            Result <EValidationResult> item = result.Result.Value[i];
            list[i].Validate(item);
        }

        SetPresentationLayout(_world);
    }
Example #2
0
    public void SetPresentationLayout(bool hardResetGame = false)
    {
        WorldResult <EValidationResult> result = _world.Check(new WorldParameter(CalculateWorldObjects(), new List <string>()));

        if (hardResetGame)
        {
            SetPresentationLayout(_world, false);
        }
        else
        {
            SetPresentationLayout(_world, GameManager.Instance.GUIGame != null);
        }
    }
Example #3
0
            private World ResolveLocation(HttpContext context, string field, ResourceManager manager, SectorMap.Milieu map)
            {
                string query = context.Request.QueryString[field];

                if (string.IsNullOrWhiteSpace(query))
                {
                    throw new HttpError(400, "Bad Request", $"Missing {field} location");
                }

                query = query.Trim();

                Match match = Regex.Match(query, @"^(?<sector>.+?)\s+(?<hex>\d\d\d\d)$");

                if (!match.Success)
                {
                    int         x   = GetIntOption("x", 0);
                    int         y   = GetIntOption("y", 0);
                    WorldResult loc = SearchEngine.FindNearestWorldMatch(query, GetStringOption("milieu"), x, y) ??
                                      throw new HttpError(404, "Not Found", $"Location not found: {query}");

                    loc.Resolve(map, manager, out Sector loc_sector, out World loc_world);
                    return(loc_world);
                }

                string name   = match.Groups["sector"].Value;
                Sector sector = map.FromName(name) ??
                                throw new HttpError(404, "Not Found", $"Sector not found: {name}");

                string hexString = match.Groups["hex"].Value;
                Hex    hex       = new Hex(hexString);

                if (!hex.IsValid)
                {
                    throw new HttpError(400, "Not Found", $"Invalid hex: {hexString}");
                }

                World world = sector.GetWorlds(manager)[hex.ToInt()] ??
                              throw new HttpError(404, "Not Found", $"No such world: {sector.Names[0].Text} {hexString}");

                return(world);
            }
Example #4
0
            public static SearchResultItem LocationToSearchResult(SectorMap map, ResourceManager resourceManager, ItemLocation location)
            {
                if (location is WorldLocation)
                {
                    Sector sector;
                    World world;
                    ((WorldLocation)location).Resolve(map, resourceManager, out sector, out world);

                    if (sector == null || world == null)
                        return null;

                    WorldResult r = new WorldResult();
                    r.SectorX = sector.X;
                    r.SectorY = sector.Y;
                    r.SectorTags = sector.TagString;
                    r.HexX = world.X;
                    r.HexY = world.Y;
                    r.Name = world.Name;
                    r.Sector = sector.Names[0].Text;
                    r.Uwp = world.UWP;
                    r.Importance = world.ImportanceValue;

                    return r;
                }
                else if (location is SubsectorLocation)
                {
                    Sector sector;
                    Subsector subsector;
                    ((SubsectorLocation)location).Resolve(map, out sector, out subsector);

                    if (sector == null || subsector == null)
                        return null;

                    SubsectorResult r = new SubsectorResult();
                    r.SectorX = sector.X;
                    r.SectorY = sector.Y;
                    r.SectorTags = sector.TagString;
                    r.Name = subsector.Name;
                    r.Index = subsector.Index;
                    r.Sector = sector.Names[0].Text;

                    return r;
                }
                else if (location is SectorLocation)
                {
                    Sector sector = ((SectorLocation)location).Resolve(map);

                    if (sector == null)
                        return null;

                    SectorResult r = new SectorResult();
                    r.SectorX = sector.X;
                    r.SectorY = sector.Y;
                    r.SectorTags = sector.TagString;
                    r.Name = sector.Names[0].Text;

                    return r;
                }

                return null;
            }
Example #5
0
        internal static Item LocationToSearchResult(SectorMap.Milieu map, ResourceManager resourceManager, ItemLocation location)
        {
            if (location is WorldLocation)
            {
                Sector sector;
                World  world;
                ((WorldLocation)location).Resolve(map, resourceManager, out sector, out world);

                if (sector == null || world == null)
                {
                    return(null);
                }

                WorldResult r = new WorldResult();
                r.SectorX    = sector.X;
                r.SectorY    = sector.Y;
                r.SectorTags = sector.TagString;
                r.HexX       = world.X;
                r.HexY       = world.Y;
                r.Name       = world.Name;
                r.Sector     = sector.Names[0].Text;
                r.Uwp        = world.UWP;
                r.Importance = world.ImportanceValue;

                return(r);
            }

            if (location is SubsectorLocation)
            {
                Sector    sector;
                Subsector subsector;
                ((SubsectorLocation)location).Resolve(map, out sector, out subsector);

                if (sector == null || subsector == null)
                {
                    return(null);
                }

                SubsectorResult r = new SubsectorResult();
                r.SectorX    = sector.X;
                r.SectorY    = sector.Y;
                r.SectorTags = sector.TagString;
                r.Name       = subsector.Name;
                r.Index      = subsector.Index;
                r.Sector     = sector.Names[0].Text;

                return(r);
            }

            if (location is SectorLocation)
            {
                Sector sector = ((SectorLocation)location).Resolve(map);

                if (sector == null)
                {
                    return(null);
                }

                SectorResult r = new SectorResult();
                r.SectorX    = sector.X;
                r.SectorY    = sector.Y;
                r.SectorTags = sector.TagString;
                r.Name       = sector.Names[0].Text;

                return(r);
            }

            if (location is LabelLocation)
            {
                LabelLocation label  = location as LabelLocation;
                Location      l      = Astrometrics.CoordinatesToLocation(label.Coords);
                Sector        sector = label.Resolve(map);

                LabelResult r = new LabelResult();
                r.Name    = label.Label;
                r.SectorX = l.Sector.X;
                r.SectorY = l.Sector.Y;
                r.HexX    = l.Hex.X;;
                r.HexY    = l.Hex.Y;
                r.Scale   =
                    label.Radius > 80 ? 4 :
                    label.Radius > 40 ? 8 :
                    label.Radius > 20 ? 32 : 64;
                r.SectorTags = sector.TagString;

                return(r);
            }

            throw new ArgumentException(string.Format("Unexpected result type: {0}", location.GetType().Name), "location");
        }
Example #6
0
        internal static Item LocationToSearchResult(SectorMap.Milieu map, ResourceManager resourceManager, ItemLocation location)
        {
            if (location is WorldLocation)
            {
                Sector sector;
                World world;
                ((WorldLocation)location).Resolve(map, resourceManager, out sector, out world);

                if (sector == null || world == null)
                    return null;

                WorldResult r = new WorldResult();
                r.SectorX = sector.X;
                r.SectorY = sector.Y;
                r.SectorTags = sector.TagString;
                r.HexX = world.X;
                r.HexY = world.Y;
                r.Name = world.Name;
                r.Sector = sector.Names[0].Text;
                r.Uwp = world.UWP;
                r.Importance = world.ImportanceValue;

                return r;
            }

            if (location is SubsectorLocation)
            {
                Sector sector;
                Subsector subsector;
                ((SubsectorLocation)location).Resolve(map, out sector, out subsector);

                if (sector == null || subsector == null)
                    return null;

                SubsectorResult r = new SubsectorResult();
                r.SectorX = sector.X;
                r.SectorY = sector.Y;
                r.SectorTags = sector.TagString;
                r.Name = subsector.Name;
                r.Index = subsector.Index;
                r.Sector = sector.Names[0].Text;

                return r;
            }

            if (location is SectorLocation)
            {
                Sector sector = ((SectorLocation)location).Resolve(map);

                if (sector == null)
                    return null;

                SectorResult r = new SectorResult();
                r.SectorX = sector.X;
                r.SectorY = sector.Y;
                r.SectorTags = sector.TagString;
                r.Name = sector.Names[0].Text;

                return r;
            }

            if (location is LabelLocation)
            {
                LabelLocation label = location as LabelLocation;
                Location l = Astrometrics.CoordinatesToLocation(label.Coords);
                Sector sector = label.Resolve(map);

                LabelResult r = new LabelResult();
                r.Name = label.Label;
                r.SectorX = l.Sector.X;
                r.SectorY = l.Sector.Y;
                r.HexX = l.Hex.X;;
                r.HexY = l.Hex.Y;
                r.Scale =
                    label.Radius > 80 ? 4 :
                    label.Radius > 40 ? 8 :
                    label.Radius > 20 ? 32 : 64;
                r.SectorTags = sector.TagString;

                return r;
            }

            throw new ArgumentException(string.Format("Unexpected result type: {0}", location.GetType().Name), "location");
        }
            public static SearchResultItem LocationToSearchResult(SectorMap map, ResourceManager resourceManager, ItemLocation location)
            {
                if (location is WorldLocation)
                {
                    Sector sector;
                    World  world;
                    ((WorldLocation)location).Resolve(map, resourceManager, out sector, out world);

                    if (sector == null || world == null)
                    {
                        return(null);
                    }

                    WorldResult r = new WorldResult();
                    r.SectorX = sector.X;
                    r.SectorY = sector.Y;
                    r.HexX    = (world.Hex / 100);
                    r.HexY    = (world.Hex % 100);
                    r.Name    = world.Name;
                    r.Sector  = sector.Names[0].Text;
                    r.Uwp     = world.UWP;

                    return(r);
                }
                else if (location is SubsectorLocation)
                {
                    Sector    sector;
                    Subsector subsector;
                    ((SubsectorLocation)location).Resolve(map, out sector, out subsector);

                    if (sector == null || subsector == null)
                    {
                        return(null);
                    }

                    SubsectorResult r = new SubsectorResult();
                    r.SectorX = sector.X;
                    r.SectorY = sector.Y;
                    r.Name    = subsector.Name;
                    r.Index   = subsector.Index;
                    r.Sector  = sector.Names[0].Text;

                    return(r);
                }
                else if (location is SectorLocation)
                {
                    Sector sector = ((SectorLocation)location).Resolve(map);

                    if (sector == null)
                    {
                        return(null);
                    }

                    SectorResult r = new SectorResult();
                    r.SectorX = sector.X;
                    r.SectorY = sector.Y;
                    r.Name    = sector.Names[0].Text;

                    return(r);
                }

                return(null);
            }