Exemple #1
0
        public bool Matches(World world)
        {
            int v;

            switch (field)
            {
            case Field.Starport: v = "XEDCBA".IndexOf(world.Starport); break;

            case Field.Size: v = world.Size; break;

            case Field.Atmosphere: v = world.Atmosphere; break;

            case Field.Hydrosphere: v = world.Hydrographics; break;

            case Field.Population: v = world.PopulationExponent; break;

            case Field.Government: v = world.Government; break;

            case Field.Law: v = world.Law; break;

            case Field.Tech: v = world.TechLevel; break;

            case Field.Importance: v = SecondSurvey.Importance(world); break;

            default: throw new ApplicationException("Invalid pattern");
            }
            return(InRange(v));
        }
Exemple #2
0
                IEnumerable <World> PathFinder.Map <World> .Adjacent(World world)
                {
                    if (world == null)
                    {
                        throw new ArgumentNullException(nameof(world));
                    }
                    foreach (World w in new HexSelector(map, manager, Astrometrics.CoordinatesToLocation(world.Coordinates), Jump).Worlds)
                    {
                        // Exclude destination from filters.
                        if (w != end)
                        {
                            if (RequireWildernessRefuelling && (w.GasGiants == 0 && !w.WaterPresent))
                            {
                                continue;
                            }
                            if (AvoidRedZones && w.IsRed)
                            {
                                continue;
                            }
                            if (ImperialWorldsOnly && !SecondSurvey.IsDefaultAllegiance(w.Allegiance))
                            {
                                continue;
                            }
                        }

                        yield return(w);
                    }
                }
Exemple #3
0
 public override void Process(ResourceManager resourceManager)
 {
     SendResult(SecondSurvey.AllegianceCodes
                .OrderBy(code => code)
                .Select(code => {
         var alleg = SecondSurvey.GetStockAllegianceFromCode(code);
         return(new Results.AllegianceCode(code, alleg.LegacyCode, alleg.Name, alleg.Location));
     }).ToList());
 }
Exemple #4
0
 public override void Process(ResourceManager resourceManager)
 {
     SendResult(SecondSurvey.SophontCodes
                .OrderBy(code => code)
                .Select(code => {
         var sophont = SecondSurvey.SophontForCode(code);
         return(new Results.SophontCode(code, sophont.Name, sophont.Location));
     }).ToList());
 }
Exemple #5
0
        public ActionResult TakeSecondarySurvey(SecondSurvey model)
        {
            if (ModelState.IsValid)
            {
                List <string> analysts = new List <string>();
                foreach (var item in db.Users.Select(s => new { s.Email, s.Id }).ToList())
                {
                    var roles = UserManager.GetRoles(item.Id);
                    if (roles.Contains("Analyst"))
                    {
                        analysts.Add(item.Email);
                    }
                }

                var selectedAnalyst = analysts[new Random().Next(analysts.Count)];

                MailHelper.SendMail(User.Identity.Name, "Welcome from Survey App", string.Format(@"Welcome to survey application...

Please start interacting with the Analyst, follow the link to start, http://primum.mobi/surveyapp/Analyst/AnalysisSurvey"));



                SurveyClient sc = db.TSurveyClient.Where(d => d.UserId == db.Users.Where(u => u.Email == User.Identity.Name).FirstOrDefault().Id).FirstOrDefault();
                if (sc != null)
                {
                    sc.Address   = model.Address;
                    sc.FirstName = model.FirstName;
                    sc.LastName  = model.LastName;
                    sc.Pincode   = model.Pincode;
                    sc.AnalystId = selectedAnalyst;
                }
                db.Entry(sc).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("AnalysisSurvey", "Analyst"));
            }
            return(View(model));
        }
Exemple #6
0
        protected static void ParseWorld(WorldCollection worlds, Dictionary <string, string> dict, string line, int lineNumber, ErrorLogger?errors)
        {
            try
            {
                FieldChecker checker = new FieldChecker(dict, errors, lineNumber, line);
                World        world   = new World()
                {
                    Hex        = checker.Check("Hex", HEX_REGEX) ?? "",
                    Name       = checker.Check("Name") ?? "",
                    UWP        = checker.Check("UWP", UWP_REGEX) ?? "",
                    Remarks    = checker.Check(new string[] { "Remarks", "Trade Codes", "Comments" }, options: CheckOptions.EmptyIfDash) ?? "",
                    Importance = checker.Check(new string[] { "{Ix}", "{ Ix }", "Ix" }, options: CheckOptions.Optional),
                    Economic   = checker.Check(new string[] { "(Ex)", "( Ex )", "Ex" }, options: CheckOptions.Optional),
                    Cultural   = checker.Check(new string[] { "[Cx]", "[ Cx ]", "Cx" }, options: CheckOptions.Optional),
                    Nobility   = checker.Check(new string[] { "N", "Nobility" }, NOBILITY_REGEX, CheckOptions.EmptyIfDash | CheckOptions.Optional),
                    Bases      = checker.Check(new string[] { "B", "Bases" }, BASES_REGEX, CheckOptions.EmptyIfDash) ?? "",
                    Zone       = checker.Check(new string[] { "Z", "Zone" }, ZONE_REGEX, CheckOptions.EmptyIfDash) ?? "",
                    PBG        = checker.Check("PBG", PBG_REGEX) ?? "",
                    Allegiance = checker.Check(new string[] { "A", "Al", "Allegiance" },
                                               a => a.Length != 4 || SecondSurvey.IsKnownT5Allegiance(a),
                                               worlds.IsUserData ? CheckOptions.Warning : CheckOptions.Default,
                                               " - 4-character codes are allowed in custom data but not submitted data") ?? "",
                    Stellar = checker.Check(new string[] { "Stellar", "Stars", "Stellar Data" }, STARS_REGEX, CheckOptions.Warning) ?? ""
                };
                if (byte.TryParse(checker.Check(new string[] { "W", "Worlds" }, options: CheckOptions.Optional), NumberStyles.Integer, CultureInfo.InvariantCulture, out byte w))
                {
                    world.Worlds = w;
                }

                if (int.TryParse(checker.Check("RU", options: CheckOptions.Optional), NumberStyles.Integer | NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out int ru))
                {
                    world.ResourceUnits = ru;
                }

                // Cleanup known placeholders
                if (world.Name == world.Name.ToUpperInvariant() && world.IsHi)
                {
                    world.Name = world.Name.FixCapitalization();
                }

                if (worlds[world.X, world.Y] != null)
                {
                    errors?.Warning("Duplicate World", lineNumber, line);
                }

                if (!checker.HadError)
                {
                    worlds[world.X, world.Y] = world;
                }

                if (errors != null)
                {
                    world.Validate(errors, lineNumber, line);

                    if (!T5StellarData.IsValid(world.Stellar))
                    {
                        errors.Warning("Invalid stellar data: " + world.Stellar, lineNumber, line);
                    }
                }
            }
            catch (Exception e) when(errors != null)
            {
                errors.Error("Parse Error: " + e.Message, lineNumber, line);
                //throw new Exception($"UWP Parse Error in line {lineNumber}:\n{e.Message}\n{line}");
            }
        }
 public override void Process(ResourceManager resourceManager)
 {
     SendResult(SecondSurvey.AllegianceCodes.Select(
                    code => new Results.AllegianceCode(code, SecondSurvey.GetStockAllegianceFromCode(code).Name)).ToList());
 }
 public override void Process(ResourceManager resourceManager)
 {
     SendResult(SecondSurvey.SophontCodes.Select(code => new Results.SophontCode(code, SecondSurvey.SophontCodeToName(code))).ToList());
 }
Exemple #9
0
        protected static void ParseWorld(WorldCollection worlds, Dictionary <string, string> dict, string line, int lineNumber, ErrorLogger errors)
        {
            try
            {
                FieldChecker checker = new FieldChecker(dict, errors, lineNumber, line);
                World        world   = new World();
                world.Hex        = checker.Check("Hex", HEX_REGEX);
                world.Name       = checker.Check("Name");
                world.UWP        = checker.Check("UWP", UWP_REGEX);
                world.Remarks    = checker.Check(new string[] { "Remarks", "Trade Codes", "Comments" });
                world.Importance = checker.Check(new string[] { "{Ix}", "{ Ix }", "Ix" }, options: CheckOptions.Optional);
                world.Economic   = checker.Check(new string[] { "(Ex)", "( Ex )", "Ex" }, options: CheckOptions.Optional);
                world.Cultural   = checker.Check(new string[] { "[Cx]", "[ Cx ]", "Cx" }, options: CheckOptions.Optional);
                world.Nobility   = checker.Check(new string[] { "N", "Nobility" }, NOBILITY_REGEX, CheckOptions.EmptyIfDash | CheckOptions.Optional);
                world.Bases      = checker.Check(new string[] { "B", "Bases" }, BASES_REGEX, CheckOptions.EmptyIfDash);
                world.Zone       = checker.Check(new string[] { "Z", "Zone" }, ZONE_REGEX, CheckOptions.EmptyIfDash);
                world.PBG        = checker.Check("PBG", PBG_REGEX);
                world.Allegiance = checker.Check(new string[] { "A", "Al", "Allegiance" },
                                                 // TODO: Allow unofficial sectors to have locally declared allegiances.
                                                 a => a.Length != 4 || SecondSurvey.IsKnownT5Allegiance(a));
                world.Stellar = checker.Check(new string[] { "Stellar", "Stars", "Stellar Data" }, STARS_REGEX, CheckOptions.Warning);

                byte w;
                if (byte.TryParse(checker.Check(new string[] { "W", "Worlds" }, options: CheckOptions.Optional), NumberStyles.Integer, CultureInfo.InvariantCulture, out w))
                {
                    world.Worlds = w;
                }

                int ru;
                if (int.TryParse(checker.Check("RU", options: CheckOptions.Optional), NumberStyles.Integer | NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out ru))
                {
                    world.ResourceUnits = ru;
                }

                // Cleanup known placeholders
                if (world.Name == world.Name.ToUpperInvariant() && world.IsHi)
                {
                    world.Name = Util.FixCapitalization(world.Name);
                }

                if (worlds[world.X, world.Y] != null && errors != null)
                {
                    errors.Warning("Duplicate World", lineNumber, line);
                }

                if (!checker.HadError)
                {
                    worlds[world.X, world.Y] = world;
                }
            }
            catch (Exception e)
            {
                if (errors != null)
                {
                    errors.Error("Parse Error: " + e.Message, lineNumber, line);
                }
                else
                {
                    throw;
                }
                //throw new Exception(string.Format("UWP Parse Error in line {0}:\n{1}\n{2}", lineNumber, e.Message, line));
            }
        }
Exemple #10
0
 public override void Process()
 {
     SendResult(Context, SecondSurvey.AllegianceCodes.Select(
                    code => new Results.AllegianceCode(code, SecondSurvey.GetStockAllegianceFromCode(code).Name)).ToList());
 }
Exemple #11
0
 public override void Process()
 {
     SendResult(Context,
                SecondSurvey.SophontCodes.Select(code => new Results.SophontCode(code, SecondSurvey.SophontCodeToName(code))).ToList());
 }