public JournalMissionAccepted(JObject evt) : base(evt, JournalTypeEnum.MissionAccepted)
        {
            Faction = evt["Faction"].Str();
            Name    = JournalFieldNaming.GetBetterMissionName(evt["Name"].Str());

            TargetType          = evt["TargetType"].Str();
            TargetTypeFriendly  = JournalFieldNaming.GetBetterTargetTypeName(TargetType);   // remove $, underscore it
            TargetTypeLocalised = evt["TargetType_Localised"].Str();
            TargetFaction       = evt["TargetFaction"].Str();
            Target          = evt["Target"].Str();
            TargetFriendly  = JournalFieldNaming.GetBetterTargetTypeName(Target);                                       // remove $, underscore it
            TargetLocalised = evt["Target_localised"].Str();                                                            // not all

            DestinationSystem  = evt["DestinationSystem"].Str().Replace("$MISSIONUTIL_MULTIPLE_INNER_SEPARATOR;", ","); // multi missions get this strange list;
            DestinationStation = evt["DestinationStation"].Str();

            Influence  = evt["Influence"].Str();
            Reputation = evt["Reputation"].Str();

            MissionId = evt["MissionID"].Int();

            Commodity          = JournalFieldNaming.FixCommodityName(evt["Commodity"].Str()); // instances of $_name, fix to fdname
            CommodityLocalised = evt["Commodity_Localised"].Str();
            FriendlyCommodity  = JournalFieldNaming.RMat(Commodity);

            Count = evt["Count"].IntNull();

            if (!evt["Expiry"].Empty())
            {
                string s = evt.Value <string>("Expiry");
                //System.Diagnostics.Debug.WriteLine("Time " + s);
                Expiry = DateTime.Parse(s, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal);
            }

            PassengerCount  = evt["PassengerCount"].IntNull();
            PassengerVIPs   = evt["PassengerVIPs"].BoolNull();
            PassengerWanted = evt["PassengerWanted"].BoolNull();
            PassengerType   = evt["PassengerType"].StrNull();
        }
        public JournalMissionAccepted(JObject evt) : base(evt, JournalTypeEnum.MissionAccepted)
        {
            Faction = evt["Faction"].Str();
            Name    = JournalFieldNaming.GetBetterMissionName(evt["Name"].Str());

            TargetType          = evt["TargetType"].Str();
            TargetTypeFriendly  = JournalFieldNaming.GetBetterTargetTypeName(TargetType);   // remove $, underscore it
            TargetTypeLocalised = evt["TargetType_Localised"].Str();
            TargetFaction       = evt["TargetFaction"].Str();
            Target          = evt["Target"].Str();
            TargetFriendly  = JournalFieldNaming.GetBetterTargetTypeName(Target);                                       // remove $, underscore it
            TargetLocalised = evt["Target_localised"].Str();                                                            // not all

            DestinationSystem  = evt["DestinationSystem"].Str().Replace("$MISSIONUTIL_MULTIPLE_INNER_SEPARATOR;", ","); // multi missions get this strange list;
            DestinationStation = evt["DestinationStation"].Str();

            Influence  = evt["Influence"].Str();
            Reputation = evt["Reputation"].Str();

            MissionId = evt["MissionID"].Int();

            Commodity          = JournalFieldNaming.FixCommodityName(evt["Commodity"].Str()); // instances of $_name, fix to fdname
            CommodityLocalised = evt["Commodity_Localised"].Str();
            FriendlyCommodity  = JournalFieldNaming.RMat(Commodity);

            Count  = evt["Count"].IntNull();
            Expiry = evt["Expiry"].DateTimeUTC();

            PassengerCount  = evt["PassengerCount"].IntNull();
            PassengerVIPs   = evt["PassengerVIPs"].BoolNull();
            PassengerWanted = evt["PassengerWanted"].BoolNull();
            PassengerType   = evt["PassengerType"].StrNull();

            Reward = evt["Reward"].IntNull();   // not in DOC V13, but present in latest journal entries

            Wing = evt["Wing"].BoolNull();      // new 3.02
        }
        public JournalMissionCompleted(JObject evt) : base(evt, JournalTypeEnum.MissionCompleted)
        {
            FDName  = evt["Name"].Str();
            Name    = JournalFieldNaming.GetBetterMissionName(FDName);
            Faction = evt["Faction"].Str();

            Commodity          = JournalFieldNaming.FixCommodityName(evt["Commodity"].Str()); // evidence of $_name problem, fix to fdname
            Commodity          = JournalFieldNaming.FDNameTranslation(Commodity);             // pre-mangle to latest names, in case we are reading old journal records
            FriendlyCommodity  = MaterialCommodityData.GetNameByFDName(Commodity);
            CommodityLocalised = JournalFieldNaming.CheckLocalisationTranslation(evt["Commodity_Localised"].Str(), FriendlyCommodity);

            Count = evt["Count"].IntNull();

            TargetType          = evt["TargetType"].Str();
            TargetTypeFriendly  = JournalFieldNaming.GetBetterTargetTypeName(TargetType);                                     // remove $, underscores etc
            TargetTypeLocalised = JournalFieldNaming.CheckLocalisation(evt["TargetTypeLocalised"].Str(), TargetTypeFriendly); // may be empty..

            TargetFaction = evt["TargetFaction"].Str();

            Target          = evt["Target"].Str();
            TargetFriendly  = JournalFieldNaming.GetBetterTargetTypeName(Target);                                  // remove $, underscores etc
            TargetLocalised = JournalFieldNaming.CheckLocalisation(evt["Target_Localised"].Str(), TargetFriendly); // copied from Accepted.. no evidence

            Reward = evt["Reward"].LongNull();
            JToken dtk = evt["Donation"];

            if (dtk != null)
            {
                if (dtk.IsString)      // some records have donations as strings incorrectly
                {
                    Donation = dtk.Str().InvariantParseLongNull();
                }
                else
                {
                    Donation = dtk.LongNull();
                }
            }

            MissionId = evt["MissionID"].Int();

            DestinationSystem = evt["DestinationSystem"].Str().Replace("$MISSIONUTIL_MULTIPLE_INNER_SEPARATOR;", ",")
                                .Replace("$MISSIONUTIL_MULTIPLE_FINAL_SEPARATOR;", ",");                                     // multi missions get this strange list;
            DestinationStation = evt["DestinationStation"].Str();

            PermitsAwarded = evt["PermitsAwarded"]?.ToObjectQ <string[]>();

            // 7/3/2018 journal 16 3.02

            CommodityReward = evt["CommodityReward"]?.ToObjectQ <CommodityRewards[]>();

            if (CommodityReward != null)
            {
                foreach (CommodityRewards c in CommodityReward)
                {
                    c.Normalise();
                }
            }

            MaterialsReward = evt["MaterialsReward"]?.ToObjectQ <MaterialRewards[]>();

            if (MaterialsReward != null)
            {
                foreach (MaterialRewards m in MaterialsReward)
                {
                    m.Normalise();
                }
            }

            FactionEffects = evt["FactionEffects"]?.ToObjectQ <FactionEffectsEntry[]>();      // NEEDS TEST
        }
Esempio n. 4
0
        public JournalMissionCompleted(JObject evt) : base(evt, JournalTypeEnum.MissionCompleted)
        {
            Name    = JournalFieldNaming.GetBetterMissionName(evt["Name"].Str());
            Faction = evt["Faction"].Str();

            Commodity          = JournalFieldNaming.FixCommodityName(evt["Commodity"].Str()); // evidence of $_name problem, fix to fdname
            Commodity          = JournalFieldNaming.FDNameTranslation(Commodity);             // pre-mangle to latest names, in case we are reading old journal records
            CommodityLocalised = evt["Commodity_Localised"].Str();
            FriendlyCommodity  = JournalFieldNaming.RMat(Commodity);

            Count = evt["Count"].IntNull();

            TargetType          = evt["TargetType"].Str();
            TargetTypeFriendly  = JournalFieldNaming.GetBetterTargetTypeName(TargetType); // remove $, underscores etc
            TargetTypeLocalised = evt["TargetTypeLocalised"].Str();                       // may be empty..
            TargetFaction       = evt["TargetFaction"].Str();
            Target          = evt["Target"].Str();
            TargetFriendly  = JournalFieldNaming.GetBetterTargetTypeName(Target); // remove $, underscores etc
            TargetLocalised = evt["Target_Localised"].Str();                      // copied from Accepted.. no evidence

            Reward    = evt["Reward"].LongNull();
            Donation  = evt["Donation"].LongNull();
            MissionId = evt["MissionID"].Int();

            DestinationSystem  = evt["DestinationSystem"].Str().Replace("$MISSIONUTIL_MULTIPLE_INNER_SEPARATOR;", ",");      // multi missions get this strange list
            DestinationStation = evt["DestinationStation"].Str();

            PermitsAwarded = evt["PermitsAwarded"]?.ToObjectProtected <string[]>();

            if (!evt["CommodityReward"].Empty())
            {
                JArray rewards = (JArray)evt["CommodityReward"];        // does not have the $_name problem, straight FDNAME

                if (rewards.Count > 0)
                {
                    System.Tuple <string, int>[] cr = new System.Tuple <string, int> [rewards.Count];
                    int i = 0;
                    foreach (JToken jc in rewards.Children())
                    {
                        if (!jc["Name"].Empty() && !jc["Count"].Empty())        // evidence of empty values
                        {
                            cr[i++] = new System.Tuple <string, int>(JournalFieldNaming.FDNameTranslation(jc["Name"].Value <string>()), jc["Count"].Value <int>());
                        }

                        //System.Diagnostics.Trace.WriteLine(string.Format(" >> Child {0} {1}", jc.Path, jc.Type.ToString()));
                    }
                    CommodityReward = new System.Tuple <string, int> [i];
                    System.Array.Copy(cr, CommodityReward, i);
                }
            }

            // 16/2/2018 NO EVIDENCE in manual of format, turn on when have answer

            if (!evt["MaterialsReward"].Empty())
            {
                JArray rewards = (JArray)evt["MaterialsReward"];        // does not have the $_name problem, straight FDNAME

                if (rewards.Count > 0)
                {
                    System.Tuple <string, int>[] cr = new System.Tuple <string, int> [rewards.Count];
                    int i = 0;
                    foreach (JToken jc in rewards.Children())
                    {
                        if (!jc["Name"].Empty() && !jc["Count"].Empty())        // evidence of empty values
                        {
                            cr[i++] = new System.Tuple <string, int>(JournalFieldNaming.FDNameTranslation(jc["Name"].Str()), jc["Count"].Int());
                        }

                        //System.Diagnostics.Trace.WriteLine(string.Format(" >> Child {0} {1}", jc.Path, jc.Type.ToString()));
                    }
                    MaterialsReward = new System.Tuple <string, int> [i];
                    System.Array.Copy(cr, MaterialsReward, i);
                }
            }

            FactionEffects = evt["FactionEffects"]?.ToObjectProtected <FactionEffectsEntry[]>();      // NEEDS TEST
        }