示例#1
0
        //Air Force CODEs are more complicated, but will require similar substitutions.
        private static string[] GetMOS(MilitaryRank.Branch.Rank rank)
        {
            var raw = File.ReadAllText("config/military_mos.json");
            var o   = JsonConvert.DeserializeObject <MOSModels.MOSManager>(raw);

            var    i     = 0;
            string mosid = null;
            string mos   = null;

            while (mos == null)
            {
                var m = o.Branches.FirstOrDefault(x => x.Name == rank.Branch.ToString());
                if (m != null)
                {
                    if (m.MOS == null || !m.MOS.Any())
                    {
                        return(null);
                    }
                    var possibleMOS = m.MOS.RandomElement();
                    if (possibleMOS == null)
                    {
                        continue;
                    }
                    var m1 = possibleMOS.Items.Where(x => PayToInt(x.Low, "low") <= PayToInt(rank.Pay) &&
                                                     PayToInt(x.High, "high") >= PayToInt(rank.Pay));
                    var e = m1 as MOSModels.Item[] ?? m1.ToArray();
                    if (e.Any())
                    {
                        var t = e.RandomElement();
                        mos   = t.Name;
                        mosid = t.Code;

                        if (!string.IsNullOrEmpty(mos))
                        {
                            break;
                        }
                    }
                }

                i++;
                if (i > 50)
                {
                    break;
                }
            }

            if (rank.Branch == MilitaryBranch.USN && mosid != null)
            {
                if (rank.Pay[0] == 'W' && mosid[3] == 'X')
                {
                    mosid = mosid.Substring(0, 3) + '1';
                }
                if (rank.Pay[0] == 'O' && mosid[3] == 'X')
                {
                    mosid = mosid.Substring(0, 3) + '0';
                }
            }
            string[] ret = new string[] { mos, mosid };
            return(ret);
        }
示例#2
0
        private static string GetBillet(MilitaryRank.Branch.Rank rank)
        {
            var raw = File.ReadAllText("config/military_billet.json");
            var o   = JsonConvert.DeserializeObject <BilletManager>(raw);

            var branch = o.Branches.FirstOrDefault(x => x.Name == rank.Branch.ToString());

            if (branch == null)
            {
                return(null);
            }
            var possibleBillets = branch.Billets.Where(x => x.Pay == rank.Pay);
            var billets         = possibleBillets as Billet[] ?? possibleBillets.ToArray();

            if (!billets.Any())
            {
                return(null);
            }
            var thisBillet = billets.RandomElement();

            return(thisBillet?.Roles.RandomElement());
        }