public Cleric(string name) : base(name) { IsWorthy = item => item.Name.ToLowerInvariant().Contains("key"); Success = " gratefully accepts the {0}, and offers you the {1} in exchange."; Failure = " is not interested in the {0} - you should have offered her a key. She casts you into a contravariant subclass, and you spend the rest of your life trying to prove that all squares are rectangles."; Treasure = new TreasureItem() { Name = "Alt Key", Description = "The Alt Key gives you the power of shape-shifting." }; }
public Earl(string name) : base(name) { IsWorthy = item => item.Name.ToLowerInvariant().Contains("diamond"); Success = " takes the {0}! Whilst he's examining it, you grab the {1} and hide it under your cloak."; Failure = " is furious with you for wasting his time! He tosses the {0} aside, and banishes you to his deepest dungeons... forever. Next time, bring him the Diamond of Multiple Inheritance"; Treasure = new TreasureItem() { Name = "Delete Key", Description = "The Delete Key gives you the power to turn back time." }; }
public Weaver(string name) : base(name) { IsWorthy = item => true; Success = " is so happy to see you, he gives you the {1} - for nothing!"; Failure = String.Empty; Treasure = new TreasureItem() { Name = "Cloak of Demeter", Description = "The cloak of Demeter hides information, as well as brave adventurers" }; }
public Wizard(string name) : base(name) { IsWorthy = item => item.Name.ToLowerInvariant().Contains("potion"); Success = " takes the {0}! Whilst he's examining it, you hide the {1} under your jerkin."; Failure = " is not interested in {0}. You should have brought him a potion instead."; Treasure = new TreasureItem() { Name = "Control Key", Description = "The Control Key gives you the power to control animals." }; }
public Knight(string name) : base(name) { // The knight is only interested in swords. IsWorthy = item => item.Name.ToLowerInvariant().Contains("cloak of demeter"); Success = " does not see you, thanks to {0}, and you quietly sneak away with {1}."; Failure = " strikes you down with his sword. Next time, obtain the Cloak of Demeter from /weaver first so he doesn't see you."; Treasure = new TreasureItem() { Name = "Potion of Immutability", Description = "This potion provides powerful defence against side-effects." }; }
public Encounter Interact(TreasureItem item) { Thread.Sleep(500 + random.Next(1000)); if (IsWorthy(item)) { return(new Encounter() { Text = Name + String.Format(Success, item.Name, Treasure.Name), Item = Treasure }); } var phrase = String.Format(Name + Failure, item.Name); throw (new Exception(phrase)); }
public Keysmith(string name) : base(name) { IsWorthy = item => { try { return(item.Name.ToLowerInvariant().Contains("gold")); } catch (Exception) { return(false); } }; Success = " happily sells you a {1} in exchange for your {0}."; Failure = " is not running a charity here! If you want {0}, you'll need to give him a a bag of gold!"; Treasure = new TreasureItem() { Name = "Key of Shifting", Description = "The Key of Shifting is very mysterious." }; }
public void RoomClearedOfMonstersTest() { //Configure some fixed, known pieces of room content and add it to a new room IRoomContent skeleton = new Skeleton(), kobold = new Kobold(), treasureItem = new TreasureItem(); Room room = new Room(skeleton, kobold, treasureItem); //Test that the room contains monsters at this point Assert.IsFalse(room.RoomClearedOfMonsters, "RoomClearedOfMonstersTest (RoomTests) failed. No monsters detected in the room."); //Remove just the fixed, known monsters - Leaving the treasure item intact room.RemoveContentFromRoom(skeleton, kobold); //Final round of tests. Ensure all monsters have been removed and that only one piece of content remains (the treasure item) Assert.IsTrue(room.RoomClearedOfMonsters, "RoomClearedOfMonstersTest (RoomTests) failed. Monsters detected in the room."); Assert.AreEqual <int>(room.RoomFeatures.Count, 1, "RoomClearedOfMonstersTest (RoomTests) failed. An unexpected room feature count was detected (room.RoomFeatures.Count)."); Assert.IsInstanceOfType(room.RoomFeatures.First(), typeof(TreasureItem), "RoomClearedOfMonstersTest (RoomTests) failed. Remaining room feature is not of the expected type. Type detected: {0}", room.RoomFeatures.First().GetType().Name); }
public void RefreshTreasureOwner(TreasureItem ti) { //Delete every thing var deleteVal = from tr in m_dbContext.TreasureChara where tr.IDTR == ti.Treasure.ID select tr; m_dbContext.TreasureChara.RemoveRange(deleteVal); //Commit everything foreach (StringWrapped name in ti.TreasureOwner) { if (name.Value != "") { AddTreasureOwner(new TreasureChara { CharaName = name.Value, IDTR = ti.Treasure.ID }); } } Commit(); }
void GenerateButtonClicked(object sender, EventArgs e) { Treasure t; if (_ShowingItems) { TreasureGenerator gen = new TreasureGenerator(); t = new Treasure(); int count = (int)_CountButton.Tag; ItemLevel level = (ItemLevel)(int)_ChartLevelButton.Tag; TreasureGenerator.RandomItemType types = (TreasureGenerator.RandomItemType) 0; foreach (var b in _ItemCheckButtons) { if ((bool)b.Data) { var v = (TreasureGenerator.RandomItemType)(int) b.Tag; switch (v) { case TreasureGenerator.RandomItemType.MinorWondrous: switch (level) { case ItemLevel.Medium: v = TreasureGenerator.RandomItemType.MediumWondrous; break; case ItemLevel.Major: v = TreasureGenerator.RandomItemType.MinorWondrous; break; } break; case TreasureGenerator.RandomItemType.Rod: case TreasureGenerator.RandomItemType.Staff: if (level == ItemLevel.Minor) { v = (TreasureGenerator.RandomItemType) 0; } break; } types |= v; } } if (types != 0) { for (int i = 0; i < count; i++) { TreasureItem item = gen.GenerateRandomItem(level, types); t.Items.Add(item); } } } else { TreasureGenerator gen = new TreasureGenerator(); gen.Coin = (int)_CoinButton.Tag; gen.Level = (int)_LevelButton.Tag; gen.Items = (int)_ItemsButton.Tag; gen.Goods = (int)_GoodsButton.Tag; t = gen.Generate(); } _GeneratedHtml = TreasureHtmlCreator.CreateHtml(t); _WebView.LoadHtmlString(_GeneratedHtml, new NSUrl("http://localhost")); }
public static string CreateHtml(Treasure treasure, bool showTitle) { StringBuilder blocks = new StringBuilder(); blocks.CreateHtmlHeader(); if (treasure.Coin != null && treasure.Coin.GPValue != 0) { blocks.CreateSectionHeader("Coin"); blocks.AppendOpenTag("p"); blocks.AppendHtml(treasure.Coin.ToString()); blocks.AppendCloseTag("p"); } if (treasure.Goods.Count > 0) { SortedDictionary <string, List <Good> > groupedItems = new SortedDictionary <string, List <Good> >(); foreach (Good t in treasure.Goods) { if (!groupedItems.ContainsKey(t.Name)) { groupedItems[t.Name] = new List <Good>(); } groupedItems[t.Name].Add(t); } StringBuilder subBlocks = new StringBuilder(); subBlocks.AppendOpenTag("p"); bool first = true; decimal goodsVal = 0; foreach (List <Good> list in groupedItems.Values) { if (!first) { subBlocks.AppendLineBreak(); } if (list.Count > 1) { subBlocks.AppendHtml(list.Count + " x "); } Good good = list[0]; subBlocks.AppendHtml(good.Name); bool firstTreasure = true; subBlocks.AppendHtml(" ("); decimal tv = 0; bool allSame = true; foreach (Good ti in list) { goodsVal += ti.Value; if (firstTreasure) { tv = ti.Value; firstTreasure = false; } else { if (tv != ti.Value) { allSame = false; } } } if (allSame && list.Count > 1) { subBlocks.AppendHtml(good.Value + " gp each)"); } else { firstTreasure = true; foreach (Good ti in list) { if (!firstTreasure) { subBlocks.AppendHtml(", "); } firstTreasure = false; subBlocks.AppendHtml(ti.Value + " gp"); } subBlocks.AppendHtml(")"); } first = false; } subBlocks.AppendCloseTag("p"); blocks.CreateSectionHeader("Goods (" + goodsVal + " gp)"); blocks.Append(subBlocks.ToString()); } if (treasure.Items.Count > 0) { SortedDictionary <string, List <TreasureItem> > groupedItems = new SortedDictionary <string, List <TreasureItem> >(); foreach (TreasureItem t in treasure.Items) { if (!groupedItems.ContainsKey(t.Name)) { groupedItems[t.Name] = new List <TreasureItem>(); } groupedItems[t.Name].Add(t); } StringBuilder subBlocks = new StringBuilder(); subBlocks.AppendOpenTag("p"); bool first = true; string type = ""; decimal itemsVal = 0; foreach (List <TreasureItem> list in groupedItems.Values) { TreasureItem item = list[0]; if (item.Type != type) { if (type != "") { subBlocks.AppendLineBreak(); } type = item.Type; subBlocks.AppendSpan(type, "itemspace"); first = true; } if (first) { subBlocks.AppendLineBreak(); } if (list.Count > 1) { subBlocks.AppendHtml(list.Count + " x "); } if (item.MagicItem != null) { subBlocks.AppendHtml(item.MagicItem.Name); } else if ((item.Type == "Scroll" || item.Type == "Wand" || item.Type == "Potion") && item.Spell != null) { if (item.Type == "Scroll") { subBlocks.AppendHtml("Scroll of "); } else if (item.Type == "Potion") { subBlocks.AppendHtml("Potion of "); } else { subBlocks.AppendHtml("Wand of "); } subBlocks.AppendHtml(item.Spell.Name); } else { subBlocks.AppendHtml(item.Name); } bool firstTreasure = true; subBlocks.AppendHtml(" ("); decimal tv = 0; bool allSame = true; foreach (TreasureItem ti in list) { itemsVal += ti.Value; if (firstTreasure) { tv = ti.Value; firstTreasure = false; } else { if (tv != ti.Value) { allSame = false; } } } if (allSame && list.Count > 1) { subBlocks.AppendHtml(item.Value + " gp each)"); } else { firstTreasure = true; foreach (TreasureItem ti in list) { if (!firstTreasure) { subBlocks.AppendHtml(", "); } firstTreasure = false; subBlocks.AppendHtml(ti.Value + " gp"); } subBlocks.AppendHtml(")"); } subBlocks.AppendLineBreak(); first = false; } subBlocks.AppendCloseTag("p"); blocks.CreateSectionHeader("Items (" + itemsVal + " gp)"); blocks.Append(subBlocks.ToString()); } blocks.CreateSectionHeader("Total Value " + treasure.TotalValue.ToString("0.##") + " gp"); return(blocks.ToString()); }
public override void Setup() { RareItem.Add(new DropData(40440, 20f)); // Life Exploration Fishing Rod, 20 RareItem.Add(new DropData(18605, 10f)); // Ladeca Helm, 10 RareItem.Add(new DropData(40385, 5f)); // Ladeca Ice Wand, 5 RareItem.Add(new DropData(41130, 5f)); // Ladeca's Light Short Sword, 5 RareItem.Add(new DropData(41131, 5f)); // Ladeca's Light Short Sword, 5 RareItem.Add(new DropData(13015, 1f)); // Brigandine, 1 // RareItem.Add(new DropData(51041, 30f)); // Good Luck Potion, 30 (out until scripted) RareItem.Add(new DropData(51042, 40f)); // Poison Bottle, 40 RareItem.Add(new DropData(62058, 10f)); // Ancient Magic Powder, 10 RareItem.Add(new DropData(63025, 30f)); // Massive Holy Water of Lymilark, 30 Random rng1 = new Random(); Item pickedItem = Item.GetRandomDrop(rng1, RareItem); // Adds 0~2 Rare Items var rnd = RandomProvider.Get(); var addCount = rnd.Next(0, 3); for (int i = 0; i < addCount; i++) { rng1 = new Random(); pickedItem = Item.GetRandomDrop(rng1, RareItem); int pickID1 = pickedItem.Data.Id; switch (pickID1) // here's where items get their pricing, enchanting, tweaking. { case 13015: { var item = Item.CreateEnchanted(13015, 21202, 0); // Marble -> Brigandine var price = Convert.ToInt32(item.OptionInfo.Price * 3.5); // Cost Multiplier: 3.5x (some freakish ~850k figure) var stock = rnd.Next(1, 4); Add("Rare Items", item, price, stock); // What does this do? Pulled from edern.cs break; } /* case 00000: * { * // do whatever * // CreateEnchantedItem * // CreateEnchant * // etc ... * // Add(...); * } */ default: // else, just sell item at normal NPC price. { Add("Rare Items", pickID1); break; } } } TreasureItem.Add(new DropData(70155, 100f)); // Ordinary Key, 100 TreasureItem.Add(new DropData(91038, 500f)); // Ordinary Chest, 500 TreasureItem.Add(new DropData(70156, 10f)); // Premium Key, 10 TreasureItem.Add(new DropData(91039, 100f)); // Premium Chest, 100 TreasureItem.Add(new DropData(91208, 1f)); // Ancient Key, 1 TreasureItem.Add(new DropData(91206, 10f)); // Ancient Chest, 10 TreasureItem.Add(new DropData(91209, 20f)); // Ancient Chest Fragment, 20 Random rng2 = new Random(); Item pickedTreasure = Item.GetRandomDrop(rng2, TreasureItem); int pickID2 = pickedTreasure.Data.Id; Add("Treasures", pickID2); // RNG Treasure for this ErinnTime day Add("Dungeon Pass", 52004); Add("Dungeon Pass", 52005); Add("Dungeon Pass", 52006); Add("Dungeon Pass", 52007); Add("Event", 50532); // Broken Ice Piece Add("Event", 63063); // Glowing Frost Crystal }