public static string ItemIncome(this ItemCollectionRecord record, string itemName, int count = 1) { var isNew = false; var HonorHelper = AutofacSvc.Resolve <HonorSvc>(); var honorName = HonorHelper.FindHonorName(itemName); var honor = HonorHelper.FindHonor(honorName); if (!record.HonorCollections.ContainsKey(honorName)) { record.HonorCollections.Add(honorName, new HonorItemCollection() { Name = honorName, Type = honor is LimitHonorModel ? HonorType.Limit : HonorType.Normal }); isNew = true; } var collection = record.HonorCollections[honorName]; if (!collection.Items.ContainsKey(itemName)) { collection.Items.Add(itemName, 0); isNew = true; } collection.Items[itemName] += count; record.Update(); if (!isNew || collection.Items.Count < honor.Items.Count) { return($"成就 【{honor.FullName}】 完成度:{collection.Items.Count}/{honor.Items.Count}"); } return($"恭喜你解锁了成就 【{honor.FullName}】! (集齐物品:{string.Join(",", honor.Items.Select(p => p.Name))})"); }
public static void SellItemToShop(string itemName, OSPerson osPerson, int count = 1) { var price = HonorSvc.GetItemPrice(HonorSvc.FindItem(itemName), osPerson.QQNum); osPerson.Golds += price * count; var record = ItemCollectionRecord.Get(osPerson.QQNum); record.ItemConsume(itemName, count); record.Update(); }
public static void SellHonorToShop(ItemCollectionRecord record, string honorName, OSPerson osPerson) { var price = HonorSvc.GetHonorPrice(honorName, osPerson.QQNum); osPerson.Golds += price; var honorCollection = record.HonorCollections[honorName]; for (var i = 0; i < honorCollection.Items.Count; i++) { var(key, value) = honorCollection.Items.ElementAt(i); honorCollection.Items[key] = value - 1; } }
public static ItemCollectionRecord Get(long QQNum) { var record = MongoService <ItemCollectionRecord> .GetOnly(p => p.QQNum == QQNum); if (record != null) { return(record); } record = new ItemCollectionRecord() { QQNum = QQNum }; MongoService <ItemCollectionRecord> .Insert(record); return(record); }