/// <summary> /// Blacksmith constructor /// </summary> /// <param name="shoppeKeeperDialogueReference"></param> /// <param name="inventory"></param> /// <param name="theShoppeKeeperReferences"></param> /// <param name="dataOvlReference"></param> public BlackSmith(ShoppeKeeperDialogueReference shoppeKeeperDialogueReference, Inventory inventory, ShoppeKeeperReference theShoppeKeeperReferences, DataOvlReference dataOvlReference) : base(shoppeKeeperDialogueReference, theShoppeKeeperReferences, dataOvlReference) { _inventory = inventory; // go through each of the pieces of equipment in order to build a map of equipment index // -> merchant string list int nEquipmentCounter = 0; foreach (DataOvlReference.Equipment equipment in Enum.GetValues((typeof(DataOvlReference.Equipment)))) { // we only look at equipment up to SpikedCollars if ((int)equipment > (int)DataOvlReference.Equipment.SpikedCollar) { continue; } const int nEquipmentOffset = 8; CombatItem item = inventory.GetItemFromEquipment(equipment); if (item.BasePrice <= 0) { continue; } // add an equipment offset because equipment strings don't start at zero in the merchant strings _equipmentMapToMerchantStrings.Add((int)equipment, nEquipmentCounter + nEquipmentOffset); nEquipmentCounter++; } }
public ShoppeKeeperReferences(DataOvlReference dataOvlReference, NonPlayerCharacterReferences npcReferences) { _dataOvlReference = dataOvlReference; // we load a list of all shoppe keeper locations which we unfortunately had to map // ourselves because it appears most shoppe keeper data is in the code (OVL) files _shoppeKeepersByIndex = ShoppeKeeperReferences.LoadShoppeKeepersByIndex(_dataOvlReference); List <string> shoppeNames = dataOvlReference.GetDataChunk(DataOvlReference.DataChunkName.STORE_NAMES) .GetChunkAsStringList().Strs; List <string> shoppeKeeperNames = dataOvlReference .GetDataChunk(DataOvlReference.DataChunkName.SHOPPE_KEEPER_NAMES).GetChunkAsStringList().Strs; // Dammit Simplon, how the hell did you sneak into the Shoppe Keeper array!?! shoppeKeeperNames.Remove(@"Simplon"); Debug.Assert(shoppeNames.Count == shoppeKeeperNames.Count, "Must be same number of shoppe keepers to shoppes"); for (int i = 0; i < shoppeNames.Count; i++) { // create a new shoppe keeper object then add it to the list ShoppeKeeperReference shoppeKeeper = _shoppeKeepersByIndex[i];//new TheShoppeKeeperReference(); string shoppeKeeperName = shoppeKeeperNames[i]; shoppeKeeper.ShoppeName = shoppeNames[i]; shoppeKeeper.ShoppeKeeperName = shoppeKeeperName; List <NonPlayerCharacterReference> npcRefs = npcReferences.GetNonPlayerCharacterByLocationAndNPCType(shoppeKeeper.ShoppeKeeperLocation, shoppeKeeper.TheShoppeKeeperType); Debug.Assert(npcRefs.Count == 1); shoppeKeeper.NpcRef = npcRefs[0]; _shoppeKeepers.Add(shoppeKeeperName, shoppeKeeper); // we keep track of the location + type for easier world access to shoppe keeper reference if (!_shoppeKeepersByLocationAndType.ContainsKey(shoppeKeeper.ShoppeKeeperLocation)) { _shoppeKeepersByLocationAndType.Add(shoppeKeeper.ShoppeKeeperLocation, new Dictionary <NonPlayerCharacterReference.NPCDialogTypeEnum, ShoppeKeeperReference>()); } _shoppeKeepersByLocationAndType[shoppeKeeper.ShoppeKeeperLocation] .Add(shoppeKeeper.TheShoppeKeeperType, shoppeKeeper); // if it's a blacksmith then we load their items for sale if (shoppeKeeper.NpcRef.NPCType == NonPlayerCharacterReference.NPCDialogTypeEnum.Blacksmith) { shoppeKeeper.EquipmentForSaleList = GetEquipmentList(i); } } }
/// <summary> /// Construct a shoppe keeper /// </summary> /// <param name="shoppeKeeperDialogueReference"></param> /// <param name="theShoppeKeeperReference"></param> /// <param name="dataOvlReference"></param> protected ShoppeKeeper(ShoppeKeeperDialogueReference shoppeKeeperDialogueReference, ShoppeKeeperReference theShoppeKeeperReference, DataOvlReference dataOvlReference) { ShoppeKeeperDialogueReference = shoppeKeeperDialogueReference; DataOvlReference = dataOvlReference; TheShoppeKeeperReference = theShoppeKeeperReference; }