public GetItemsWithAMaxValue ( string category, int maximum ) : List |
||
category | string | |
maximum | int | |
Результат | List |
/// <summary> /// Updates the Vendor's stock to brand new stock /// </summary> /// <param name="actor"></param> public void UpdateVendorStock(Actor actor) { //First see how much money they have to buy stuff with. //Money to buy stuff = SUM (Base Values of old stock Inventory Items) + Money on Hand - 1000 int totalMoney = actor.VendorDetails.Stock.GetAllObjects().Sum(s => s.BaseValue) + actor.VendorDetails.Money - 1000; //Generate the stuff InventoryItemManager iim = new InventoryItemManager(); actor.VendorDetails.Stock = new GroupedList<InventoryItem>(); actor.VendorDetails.GenerationTime = new DivineRightDateTime(GameState.UniverseTime); switch (actor.VendorDetails.VendorType) { case VendorType.GENERAL: foreach (InventoryItem inv in iim.GetItemsWithAMaxValue(InventoryCategory.ARMOUR.ToString(), totalMoney / 4)) { inv.InInventory = true; actor.VendorDetails.Stock.Add(inv.Category, inv); } foreach (InventoryItem inv in iim.GetItemsWithAMaxValue(InventoryCategory.LOOT.ToString(), totalMoney / 4)) { inv.InInventory = true; actor.VendorDetails.Stock.Add(inv.Category, inv); } foreach (InventoryItem inv in iim.GetItemsWithAMaxValue(InventoryCategory.WEAPON.ToString(), totalMoney / 4)) { inv.InInventory = true; actor.VendorDetails.Stock.Add(inv.Category, inv); } foreach (InventoryItem inv in iim.GetItemsWithAMaxValue(InventoryCategory.SUPPLY.ToString(), totalMoney / 4)) { inv.InInventory = true; actor.VendorDetails.Stock.Add(inv.Category, inv); } break; case VendorType.SMITH: foreach (InventoryItem inv in iim.GetItemsWithAMaxValue(InventoryCategory.ARMOUR.ToString(), totalMoney / 2)) { inv.InInventory = true; actor.VendorDetails.Stock.Add(inv.Category, inv); } foreach (InventoryItem inv in iim.GetItemsWithAMaxValue(InventoryCategory.WEAPON.ToString(), totalMoney / 2)) { inv.InInventory = true; actor.VendorDetails.Stock.Add(inv.Category, inv); } break; case VendorType.TRADER: foreach (InventoryItem inv in iim.GetItemsWithAMaxValue(InventoryCategory.LOOT.ToString(), totalMoney)) { inv.InInventory = true; actor.VendorDetails.Stock.Add(inv.Category, inv); } break; case VendorType.TAVERN: foreach (InventoryItem inv in iim.GetItemsWithAMaxValue(InventoryCategory.SUPPLY.ToString(), totalMoney)) { inv.InInventory = true; actor.VendorDetails.Stock.Add(inv.Category, inv); } break; } actor.VendorDetails.Money = 1000; }
/// <summary> /// Generates loot for treasure rooms. We will have LOOT_MULTIPLIER of loot multiplied by tierNumber /// </summary> public void GenerateLoot(MapBlock[,] blocks, int tierNumber) { //Determine the maximum total value we want to generate int totalValue = tierNumber * LOOT_MULTIPLIER; InventoryItemManager mgr = new InventoryItemManager(); var items = mgr.GetItemsWithAMaxValue(null, totalValue); //Put the items on the map foreach (var item in items) { //Find a random point. Try 50 times for (int attempts = 0; attempts < 50; attempts++) { var chosenBlock = blocks[GameState.Random.Next(blocks.GetLength(0)), GameState.Random.Next(blocks.GetLength(1))]; if (chosenBlock.MayContainItems) { //Put it in chosenBlock.ForcePutItemOnBlock(item); break; } } } }
/// <summary> /// Generates a vendor, adds the vendor details to the actor being created /// </summary> /// <param name="newActor"></param> /// <param name="actor"></param> public void GenerateVendor(Actor newActor, MapletActor actor) { newActor.VendorDetails = new VendorDetails(); newActor.VendorDetails.VendorType = actor.VendorType.Value; newActor.VendorDetails.VendorLevel = actor.VendorLevel ?? 1; newActor.VendorDetails.GenerationTime = new DivineRightDateTime(GameState.UniverseTime); //Generate the stuff InventoryItemManager iim = new InventoryItemManager(); int maxCategorySize = 1000 * newActor.VendorDetails.VendorLevel; newActor.VendorDetails.Stock = new GroupedList<InventoryItem>(); switch (newActor.VendorDetails.VendorType) { case VendorType.GENERAL: foreach (InventoryItem inv in iim.GetItemsWithAMaxValue(InventoryCategory.SUPPLY.ToString(), (int)(maxCategorySize * 0.75))) { inv.InInventory = true; newActor.VendorDetails.Stock.Add(inv.Category, inv); } foreach (InventoryItem inv in iim.GetItemsWithAMaxValue(InventoryCategory.LOOT.ToString(), (int)(maxCategorySize * 0.75))) { inv.InInventory = true; newActor.VendorDetails.Stock.Add(inv.Category, inv); } foreach (InventoryItem inv in iim.GetItemsWithAMaxValue(InventoryCategory.ARMOUR.ToString(), (int)(maxCategorySize * 0.75))) { inv.InInventory = true; newActor.VendorDetails.Stock.Add(inv.Category, inv); } foreach (InventoryItem inv in iim.GetItemsWithAMaxValue(InventoryCategory.WEAPON.ToString(), (int)(maxCategorySize * 0.75))) { inv.InInventory = true; newActor.VendorDetails.Stock.Add(inv.Category, inv); } break; case VendorType.SMITH: foreach (InventoryItem inv in iim.GetItemsWithAMaxValue(InventoryCategory.ARMOUR.ToString(), (int)(maxCategorySize * 1.5))) { inv.InInventory = true; newActor.VendorDetails.Stock.Add(inv.Category, inv); } foreach (InventoryItem inv in iim.GetItemsWithAMaxValue(InventoryCategory.WEAPON.ToString(), (int)(maxCategorySize * 1.5))) { inv.InInventory = true; newActor.VendorDetails.Stock.Add(inv.Category, inv); } break; case VendorType.TRADER: foreach (InventoryItem inv in iim.GetItemsWithAMaxValue(InventoryCategory.LOOT.ToString(), maxCategorySize * 3)) { inv.InInventory = true; newActor.VendorDetails.Stock.Add(inv.Category, inv); } break; case VendorType.TAVERN: foreach (InventoryItem inv in iim.GetItemsWithAMaxValue(InventoryCategory.SUPPLY.ToString(), maxCategorySize)) { inv.InInventory = true; newActor.VendorDetails.Stock.Add(inv.Category, inv); } break; } newActor.VendorDetails.Money = 1000; }
/// <summary> /// Generates the particular Game Multi Event for character creation /// </summary> /// <returns></returns> public static GameMultiEvent GenerateCharacterCreation() { var book = SpriteManager.GetSprite(InterfaceSpriteName.BOOK); GameMultiEvent gme = new GameMultiEvent(); gme.EventName = "GENERATE_CHARACTER"; gme.Image = book; gme.Title = "The Avatar is born"; gme.Text = "And thus, world was done\nHumans forget their maker.\nAvatar will come"; List<MultiEventChoice> choices = new List<MultiEventChoice>(); choices.Add(new MultiEventChoice() { ChoiceName = "GEN", Text = "Little is known about their early life", }); choices.Add(new MultiEventChoice() { ChoiceName = "RANDOM", Text = "Nothing is known about their early life" }); gme.Choices = choices.ToArray(); GameMultiEvent next = new GameMultiEvent(); gme.Choices[0].NextChoice = next; next.Image = book; next.Title = "The form of the Avatar"; next.Text = "Avatar takes form\nAs a human has been born\nA perfect human"; choices = new List<MultiEventChoice>(); choices.Add(new MultiEventChoice() { ChoiceName = "MALE", Text = "The Male form was Chosen" }); choices.Add(new MultiEventChoice() { ChoiceName = "FEMALE", Text = "The Female form was Chosen" } ); next.Choices = choices.ToArray(); next = new GameMultiEvent(); foreach (var choice in choices) { choice.NextChoice = next; } next.Image = book; next.Title = "The Family of the Avatar"; next.Text = "Common Family\nFew riches,little greatness\nCommon Beginnings"; choices = new List<MultiEventChoice>(); choices.Add(new MultiEventChoice() { ChoiceName = "MERCHANTS", Text = "A family of Merchants" }); choices.Add(new MultiEventChoice() { ChoiceName = "CLERICS", Text = "A family of Clerics" }); choices.Add(new MultiEventChoice() { ChoiceName = "EXPLORERS", Text = "A family of Explorers" }); next.Choices = choices.ToArray(); next = new GameMultiEvent(); foreach (var choice in choices) { choice.NextChoice = next; } next.Image = book; next.Title = "The Avatar's Nature"; next.Text = "And Avatar grew.\nA special little human\nAnd brilliance was theirs"; choices = new List<MultiEventChoice>(); choices.Add(new MultiEventChoice() { ChoiceName = "INTEL", Text = "As the Wisdom of Dragon's was theirs" }); choices.Add(new MultiEventChoice() { ChoiceName = "AGIL", Text = "As Grace and Speed was theirs" }); choices.Add(new MultiEventChoice() { ChoiceName = "CHAR", Text = "As a tongue of gold was theirs" }); choices.Add(new MultiEventChoice() { ChoiceName = "BRAWN", Text = "As the strenght of many men was theirs" }); next.Choices = choices.ToArray(); next = new GameMultiEvent(); foreach (var choice in choices) { choice.NextChoice = next; } next.Image = book; next.Title = "The Avatar fights"; next.Text = "And Avatar Grew\nIn militia was drafted\nExcelled amongst other men"; choices = new List<MultiEventChoice>(); choices.Add(new MultiEventChoice() { ChoiceName = "LEADER", Text = "as the Leader of men" }); choices.Add(new MultiEventChoice() { ChoiceName = "HEALING", Text = "as their healer" }); choices.Add(new MultiEventChoice() { ChoiceName = "PERSUATION", Text = "as their persuader" }); next.Choices = choices.ToArray(); next = new GameMultiEvent(); foreach (var choice in choices) { choice.NextChoice = next; } next.Image = book; next.Title = "And it begins"; next.EventName = "GENERATE_CHARACTER"; next.Text = "True god spoke to them\nAnd they left their parents' house\nWith blessing and gift"; choices = new List<MultiEventChoice>(); choices.Add(new MultiEventChoice() { ChoiceName = "SWORD", Text = "A sword to smite the nonbelievers" }); choices.Add(new MultiEventChoice() { ChoiceName = "ARMOUR", Text = "Armour to protect against the heretic" }); choices.Add(new MultiEventChoice() { ChoiceName = "MONEY", Text = "Money to sway the hearts of lesser men" }); next.Choices = choices.ToArray(); //Give them the items everyone starts with InventoryItemManager iim = new InventoryItemManager(); var food = iim.GetItemsWithAMaxValue("SUPPLY", 150); foreach (var foodItem in food) { GameState.PlayerCharacter.Inventory.Inventory.Add(InventoryCategory.SUPPLY, foodItem as InventoryItem); (foodItem as InventoryItem).InInventory = true; } return gme; }