Skip to content

Commit bf8a016

Browse files
committed
Fix Workshop Magic filter by mapping it to Spell ItemType. Added unit test for Workshop filtering.
1 parent b60bfad commit bf8a016

4 files changed

Lines changed: 105 additions & 46 deletions

File tree

Mythril.Blazor/Components/Workshop.razor

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,25 @@
3737
.Where(rd => {
3838
if (_activeFilter == "All") return true;
3939

40-
// Check if output matches filter
41-
var outType = rd.Recipe.OutputItem.ItemType.ToString() + "s";
42-
if (outType.Contains(_activeFilter, StringComparison.OrdinalIgnoreCase)) return true;
40+
// Map filter to ItemType string
41+
var filterType = _activeFilter switch {
42+
"Magic" => "Spell",
43+
"Materials" => "Material",
44+
_ => _activeFilter
45+
};
46+
47+
var outType = rd.Recipe.OutputItem.ItemType.ToString();
48+
if (outType.Equals(filterType, StringComparison.OrdinalIgnoreCase)) return true;
4349

4450
// If output is NOT a standard Material/Spell category (e.g. Currency like Gold)
4551
// then check if the INPUT matches the filter.
46-
bool outputIsStandard = outType.Contains("Material", StringComparison.OrdinalIgnoreCase) ||
47-
outType.Contains("Spell", StringComparison.OrdinalIgnoreCase);
52+
bool outputIsStandard = outType.Equals("Material", StringComparison.OrdinalIgnoreCase) ||
53+
outType.Equals("Spell", StringComparison.OrdinalIgnoreCase);
4854

4955
if (!outputIsStandard)
5056
{
51-
var inType = rd.InputItem.ItemType.ToString() + "s";
52-
return inType.Contains(_activeFilter, StringComparison.OrdinalIgnoreCase);
57+
var inType = rd.InputItem.ItemType.ToString();
58+
return inType.Equals(filterType, StringComparison.OrdinalIgnoreCase);
5359
}
5460

5561
return false;

Mythril.Tests/WorkshopComponentTests.cs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,55 @@ public void RefinementCard_RendersCorrectly()
6565
var iconHtml = cut.Find(".character-access").InnerHtml;
6666
Assert.Contains("person", iconHtml); // Protagonist icon
6767
}
68+
69+
[TestMethod]
70+
public void Workshop_Filtering_Works()
71+
{
72+
// Arrange
73+
var resourceManager = Services.GetRequiredService<ResourceManager>();
74+
var items = ContentHost.GetContent<Items>().All;
75+
var scrap = items.First(i => i.Name == SandboxContent.Scrap);
76+
var gold = items.First(i => i.Name == SandboxContent.Gold);
77+
var basicGem = items.First(i => i.Name == SandboxContent.BasicGem);
78+
var fireI = items.First(i => i.Name == SandboxContent.FireI);
79+
80+
// Gold is Currency, Scrap is Material, BasicGem is Material, FireI is Spell
81+
Assert.AreEqual(ItemType.Currency, gold.ItemType);
82+
Assert.AreEqual(ItemType.Material, scrap.ItemType);
83+
Assert.AreEqual(ItemType.Material, basicGem.ItemType);
84+
Assert.AreEqual(ItemType.Spell, fireI.ItemType);
85+
86+
// Setup abilities
87+
resourceManager.UnlockAbility(SandboxContent.Recruit, SandboxContent.RefineScrap);
88+
resourceManager.UnlockAbility(SandboxContent.Student, SandboxContent.RefineFire);
89+
90+
var unlockedAbilities = new HashSet<string> {
91+
$"{SandboxContent.Recruit}:{SandboxContent.RefineScrap}",
92+
$"{SandboxContent.Student}:{SandboxContent.RefineFire}"
93+
};
94+
95+
// Act & Assert
96+
var cut = RenderComponent<Workshop>(parameters => parameters
97+
.Add(p => p.UnlockedAbilities, unlockedAbilities)
98+
);
99+
100+
// 1. Default (All)
101+
var cards = cut.FindComponents<RefinementCard>();
102+
Assert.AreEqual(2, cards.Count);
103+
104+
// 2. Filter by Magic
105+
var magicFilter = cut.Find("[data-testid='workshop-filter-magic']");
106+
magicFilter.Click();
107+
cards = cut.FindComponents<RefinementCard>();
108+
Assert.AreEqual(1, cards.Count);
109+
Assert.AreEqual(SandboxContent.RefineFire, cards[0].Instance.Refinement.Ability.Name);
110+
111+
// 3. Filter by Materials
112+
var materialsFilter = cut.Find("[data-testid='workshop-filter-materials']");
113+
materialsFilter.Click();
114+
cards = cut.FindComponents<RefinementCard>();
115+
Assert.AreEqual(1, cards.Count);
116+
// RefineScrap outputs Gold (Currency) but inputs Scrap (Material), so it should show up under Materials
117+
Assert.AreEqual(SandboxContent.RefineScrap, cards[0].Instance.Refinement.Ability.Name);
118+
}
68119
}

docs/Playtest_Feedback.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454

5555
- Archive Sifting gives too many Lost Parchment. Lost Parchment does nothing.
5656

57+
- Gather moonberries isn't unlocking a futher quest line
58+
5759
- Consider an appendix tab that lists and explains all unlocked items, locations, cadences and abilities. Make it searchable.
5860

5961
- UI quick reference in the Workshop to remind who has access to craft what. Character icons but will need to function differently than cadence equip UI because multiple characters can have access to the same refinement recipes.

simulation_report.md

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Game Content Health Report
2-
Generated: 2026-04-28 13:36:53
2+
Generated: 2026-04-28 13:46:31
33

44
## 💀 Reachability Analysis
55
Total Quests Completed: 31
@@ -11,68 +11,68 @@ Routed Completion Time: 87.8m
1111

1212
## ⚖️ Economic Sustainability
1313
### Sustainable Recurring Activities
14-
- Refine Ice:Moonberry->Ice I
15-
- Refine Earth:Crystal Shards->Earth I
16-
- Shatter the Crystals
17-
- Alchemy I:Basic Gem->Gold
18-
- Chop Wood
19-
- Refine Water:Blue Coral->Water I
20-
- Archive Sifting
21-
- Refine Life:Ancient Bark->Cure I
2214
- Refine Ice:Mana Leaf->Ice I
23-
- Refine Haste:Lost Parchment->Haste I
24-
- Refine Lightning:Ice Shard->Lightning I
25-
- High Altitude Survey
15+
- Refine Fire:Iron Ore->Fire I
2616
- Study Ancient Texts
27-
- Tutorial Section
28-
- Refine Mixology:Herb->Potion
29-
- Deep Sea Scavenge
30-
- Harvest Sea-Life
17+
- Alchemy I:Basic Gem->Gold
3118
- Refine Lightning:Fire Shard->Lightning I
32-
- Hunt Sand-Sharks
3319
- Hunt Spiders
20+
- Tutorial Section
21+
- Hunt Bats
22+
- Refine Scrap:Web->Gold
3423
- Refine Wood:Log->Herb
35-
- Refine Fire:Iron Ore->Fire I
24+
- Harvest Sea-Life
25+
- Refine Mixology:Herb->Potion
26+
- Hunt Slimes
27+
- Refine Water:Blue Coral->Water I
28+
- Shatter the Crystals
29+
- Scavenge Scrap
3630
- Power the Forge
37-
- Gather Moonberries
31+
- Refine Earth:Crystal Shards->Earth I
3832
- Mine Iron Ore
39-
- Hunt Slimes
40-
- Refine Scrap:Web->Gold
33+
- Chop Wood
34+
- Refine Lightning:Ice Shard->Lightning I
35+
- Archive Sifting
36+
- Refine Ice:Moonberry->Ice I
4137
- Refine Fire:Basic Gem->Fire I
42-
- Hunt Bats
43-
- Scavenge Scrap
4438
- Hunt Goblins
39+
- Deep Sea Scavenge
40+
- High Altitude Survey
41+
- Hunt Sand-Sharks
42+
- Refine Haste:Lost Parchment->Haste I
43+
- Gather Moonberries
44+
- Refine Life:Ancient Bark->Cure I
4545

4646
### ⚠️ Unsustainable Activities (Reachable but starving)
47-
- Refine Life:Solar Essence->Cure I
4847
- Alchemy II:Potion->Gold
49-
- Refine Scrap:Slime->Gold
48+
- Refine Life:Solar Essence->Cure I
5049
- Alchemy II:Sun-baked Scale->Gold
50+
- Refine Scrap:Slime->Gold
5151

5252
### Net Resource Rates (per second)
53+
- **Potion**: 4.9887/s
5354
- **Fire I**: 54.0445/s
54-
- **Herb**: 19.9549/s
55-
- **Sun-baked Scale**: 0.8315/s
55+
- **Cure I**: 24.9436/s
5656
- **Lightning I**: 49.8873/s
57+
- **Water I**: 105.1123/s
58+
- **Herb**: 19.9549/s
5759
- **Ice Shard**: 30.0487/s
58-
- **Lost Parchment**: 3.3258/s
59-
- **Potion**: 4.9887/s
60-
- **Crystal Shards**: 7.4831/s
60+
- **Fire Shard**: 31.2959/s
61+
- **Ice I**: 49.8873/s
6162
- **Moonberry**: 21.2893/s
62-
- **Water I**: 105.1123/s
63+
- **Basic Gem**: 5.5225/s
64+
- **Lost Parchment**: 3.3258/s
65+
- **Slime**: 4.1573/s
6366
- **Earth I**: 24.9436/s
67+
- **Sun-baked Scale**: 0.8315/s
68+
- **Leather**: 26.2781/s
69+
- **Gold**: 6896.7448/s
6470
- **Mythril Spark**: 0.4157/s
6571
- **Log**: 4.9887/s
66-
- **Slime**: 4.1573/s
67-
- **Mana Leaf**: 5.3223/s
6872
- **Iron Ore**: 11.1049/s
69-
- **Basic Gem**: 5.5225/s
70-
- **Leather**: 26.2781/s
73+
- **Mana Leaf**: 5.3223/s
7174
- **Haste I**: 24.9436/s
72-
- **Fire Shard**: 31.2959/s
73-
- **Gold**: 6896.7448/s
74-
- **Cure I**: 24.9436/s
75-
- **Ice I**: 49.8873/s
75+
- **Crystal Shards**: 7.4831/s
7676

7777
## 🔄 Feedback Loops
7878
✅ No unbounded growth loops detected (approximation).

0 commit comments

Comments
 (0)