Exemple #1
0
        public static List <MicroResourceAmount> ReadMicroResources(string key, IDictionary <string, object> data, string categoryEdName = null)
        {
            var result = new List <MicroResourceAmount>();

            if (data.TryGetValue(key, out object val))
            {
                if (val is List <object> listVal)
                {
                    foreach (IDictionary <string, object> microResourceVal in listVal)
                    {
                        var edname       = JsonParsing.getString(microResourceVal, "Name");
                        var fallbackName = JsonParsing.getString(microResourceVal, "Name_Localised");
                        categoryEdName = JsonParsing.getString(microResourceVal, "Type") ?? categoryEdName ?? MicroResourceCategory.Unknown.edname;
                        var resource = MicroResource.FromEDName(edname, fallbackName, categoryEdName);

                        var ownerId   = JsonParsing.getOptionalInt(microResourceVal, "OwnerID");
                        var missionId = JsonParsing.getOptionalDecimal(microResourceVal, "MissionID");
                        var amount    = JsonParsing.getInt(microResourceVal, "Count");

                        result.Add(new MicroResourceAmount(resource, ownerId, missionId, amount));
                    }
                }
            }
            return(result);
        }
Exemple #2
0
 public MicroResourceAmount(MicroResource microResource, int?ownerId, decimal?missionId, int amount, int?price = null)
 {
     this.microResource = microResource;
     this.ownerId       = ownerId;
     this.missionId     = missionId;
     this.amount        = amount;
     this.price         = price;
 }