Ejemplo n.º 1
0
 public CommanderRatingsEvent(DateTime timestamp, CombatRating combat, TradeRating trade, ExplorationRating exploration, CQCRating cqc, EmpireRating empire, FederationRating federation, MercenaryRating mercenary, ExobiologistRating exobiologist) : base(timestamp, NAME)
 {
     this.combat       = combat;
     this.trade        = trade;
     this.exploration  = exploration;
     this.cqc          = cqc;
     this.empire       = empire;
     this.federation   = federation;
     this.mercenary    = mercenary;
     this.exobiologist = exobiologist;
 }
Ejemplo n.º 2
0
        /// <summary>Create a profile given the results from a /profile call</summary>
        public static Profile ProfileFromJson(JObject json, DateTime timestamp)
        {
            Profile Profile = new Profile
            {
                json      = json,
                timestamp = timestamp
            };

            if (json["commander"] != null)
            {
                FrontierApiCommander Commander = new FrontierApiCommander
                {
                    // Caution: The "id" property here may not match the FID returned from the player journal
                    name               = (string)json["commander"]["name"],
                    combatrating       = CombatRating.FromRank((int?)json["commander"]["rank"]["combat"] ?? 0),
                    traderating        = TradeRating.FromRank((int?)json["commander"]["rank"]["trade"] ?? 0),
                    explorationrating  = ExplorationRating.FromRank((int?)json["commander"]["rank"]["explore"] ?? 0),
                    cqcrating          = CQCRating.FromRank((int?)json["commander"]["rank"]["cqc"] ?? 0),
                    empirerating       = EmpireRating.FromRank((int?)json["commander"]["rank"]["empire"] ?? 0),
                    federationrating   = FederationRating.FromRank((int?)json["commander"]["rank"]["federation"] ?? 0),
                    mercenaryrating    = MercenaryRating.FromRank((int?)json["commander"]["rank"]["soldier"] ?? 0),
                    exobiologistrating = ExobiologistRating.FromRank((int?)json["commander"]["rank"]["exobiologist"] ?? 0),
                    crimerating        = (int?)json["commander"]["rank"]["crime"] ?? 0,
                    servicerating      = (int?)json["commander"]["rank"]["service"] ?? 0,
                    powerrating        = (int?)json["commander"]["rank"]["power"] ?? 0,

                    credits = (long?)json["commander"]["credits"] ?? 0,
                    debt    = (long?)json["commander"]["debt"] ?? 0
                };
                Profile.Cmdr   = Commander;
                Profile.docked = (bool)json["commander"]["docked"];
                Profile.onFoot = (bool)json["commander"]["onfoot"];
                Profile.alive  = (bool)json["commander"]["alive"];

                if (json["commander"]["capabilities"] != null)
                {
                    var contexts = new ProfileContexts
                    {
                        allowCobraMkIV = (bool?)json["commander"]["capabilities"]["AllowCobraMkIV"] ?? false,
                        inHorizons     = (bool?)json["commander"]["capabilities"]["Horizons"] ?? false,
                        inOdyssey      = (bool?)json["commander"]["capabilities"]["Odyssey"] ?? false
                    };
                    Profile.contexts = contexts;
                }

                string systemName = json["lastSystem"] == null ? null : (string)json["lastSystem"]["name"];
                if (systemName != null)
                {
                    Profile.CurrentStarSystem = new ProfileStarSystem
                    {
                        // Caution: The "id" property here may not match the systemAddress
                        systemName = systemName,
                        // Caution: The "faction" property here may return the edName for the faction rather than the invariant name
                    };
                }

                if (json["lastStarport"] != null)
                {
                    Profile.LastStation = new ProfileStation
                    {
                        name     = ((string)json["lastStarport"]["name"])?.ReplaceEnd('+'),
                        marketId = (long?)json["lastStarport"]["id"]
                    };
                    if ((bool)json["commander"]["docked"])
                    {
                        Profile.LastStation.systemname = Profile.CurrentStarSystem.systemName;
                    }
                }
            }

            return(Profile);
        }