/** Registers that a given item has been identified to given level */ public void RegisterItemIdentified(MDRItem item, IdentificationLevel idLevel) { if (!Enabled) { return; } if (item == null) { return; } if (idLevel == IdentificationLevel.Auto || idLevel == null) { return; } if (!ItemStats.ContainsKey(item)) { ItemStats[item] = new ItemStatRecord(item); } ItemStatRecord record = ItemStats[item]; if (idLevel.ID > record.IDLevel.ID) { record.IDLevel = idLevel; } }
/** Reads game stats to XML */ public override void ReadNode(XElement node) { base.ReadNode(node); Records = ReadDataObject <GameRecordLibrary>(node, "Records") ?? new GameRecordLibrary(); InitDefaultGameRecords(); // Monsters var monsterStatsNode = node.Element("MonsterStats"); if (monsterStatsNode != null) { foreach (var subNode in monsterStatsNode.Elements("Monster")) { int id = int.Parse(subNode.Attribute("ID").Value); var monster = CoM.Monsters.ByID(id); if (monster == null) { Trace.LogWarning("Stat record for monster [{0}] but no matching monster.", subNode.Attribute("ID").Value); continue; } var record = new MonsterStatRecord(monster); record.ReadNode(subNode); MonsterStats[monster] = record; } } // Items var itemStatsNode = node.Element("ItemStats"); if (itemStatsNode != null) { foreach (var subNode in itemStatsNode.Elements("Item")) { int id = int.Parse(subNode.Attribute("ID").Value); var item = CoM.Items.ByID(id); if (item == null) { Trace.LogWarning("Data Error [Stat record]: Stats for item [{0}] but no matching item.", subNode.Attribute("ID").Value); continue; } var record = new ItemStatRecord(item); record.ReadNode(subNode); ItemStats[item] = record; } } }
/** * Registers an item droped from a given monster. */ public void RegisterItemFound(MDRCharacter character, MDRItemInstance itemInstance, MDRMonster monsterFoundOn) { if (!Enabled) { return; } if (itemInstance == null || itemInstance.Item == null) { return; } var item = itemInstance.Item; if (!ItemStats.ContainsKey(item)) { ItemStats[item] = new ItemStatRecord(item); } ItemStatRecord record = ItemStats[item]; if (record.NumberFound == 0) { record.FirstFoundBy = (character == null ? "unknown" : character.Name); if (character != null) { PostNotification("Discovered " + itemInstance.Name, item.Icon); } } record.NumberFound++; if (monsterFoundOn != null) { record.LastFoundOnMonster = monsterFoundOn.Name; } record.LastSeenDate = DateTime.Now; RegisterItemIdentified(item, itemInstance.IDLevel); }