Skip to content

Commit 9bc0c4a

Browse files
committed
fix compile errors. Autoquest temporarily broken
1 parent d3daedf commit 9bc0c4a

10 files changed

Lines changed: 84 additions & 152 deletions

Mythril.Blazor/Services/PersistenceService.cs

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ public async Task SaveAsync()
2424
{
2525
Inventory = state.Inventory.ToDictionary(k => k.Key, v => v.Value),
2626
MagicCapacity = state.MagicCapacity,
27-
PinnedItems = state.PinnedItems.ToList(),
28-
UnlockedCadences = state.UnlockedCadenceNames.ToList(),
29-
UnlockedAbilities = state.UnlockedAbilities.ToList(),
30-
CompletedQuests = state.CompletedQuests.ToList(),
31-
ActiveQuests = state.ActiveQuests.Select(q => new QuestProgressDTO {
27+
PinnedItems = [.. state.PinnedItems],
28+
UnlockedCadences = [.. state.UnlockedCadenceNames],
29+
UnlockedAbilities = [.. state.UnlockedAbilities],
30+
CompletedQuests = [.. state.CompletedQuests],
31+
ActiveQuests = [.. state.ActiveQuests.Select(q => new QuestProgressDTO {
3232
ItemName = q.Name,
3333
AbilityName = q.Item is CadenceUnlock cu ? cu.CadenceName : "",
3434
ItemType = q.Item is QuestData ? "Quest" : (q.Item is CadenceUnlock ? "CadenceUnlock" : "Refinement"),
@@ -38,20 +38,20 @@ public async Task SaveAsync()
3838
SlotIndex = q.SlotIndex,
3939
Description = q.Description,
4040
DurationSeconds = q.DurationSeconds
41-
}).ToList(),
42-
Junctions = state.Junctions.Select(j => new JunctionDTO {
41+
})],
42+
Junctions = [.. state.Junctions.Select(j => new JunctionDTO {
4343
CharacterName = j.Character.Name,
4444
StatName = j.Stat.Name,
4545
MagicName = j.Magic.Name
46-
}).ToList(),
47-
AssignedCadences = state.AssignedCadences.Where(kvp => kvp.Value != null).Select(kvp => new AssignedCadenceDTO {
46+
})],
47+
AssignedCadences = [.. state.AssignedCadences.Where(kvp => kvp.Value != null).Select(kvp => new AssignedCadenceDTO {
4848
CadenceName = kvp.Key,
4949
CharacterName = kvp.Value!
50-
}).ToList(),
50+
})],
5151
AutoQuestEnabled = state.AutoQuestEnabled.ToDictionary(k => k.Key, v => v.Value),
52-
UnlockedLocations = state.UnlockedLocationNames.ToList(),
53-
StarredRecipes = state.StarredRecipes.ToList(),
54-
SeenContent = state.SeenContent.ToList(),
52+
UnlockedLocations = [.. state.UnlockedLocationNames],
53+
StarredRecipes = [.. state.StarredRecipes],
54+
SeenContent = [.. state.SeenContent],
5555
HasUnseenCadence = state.HasUnseenCadence,
5656
HasUnseenWorkshop = state.HasUnseenWorkshop,
5757
CurrentTime = state.CurrentTime,
@@ -119,33 +119,29 @@ public async Task LoadAsync()
119119
double bonusSeconds = (DateTime.Now - saveData.LastSaveTime).TotalSeconds;
120120
var activeQuestsWithBonus = activeQuests.Select(q => q with { SecondsElapsed = q.SecondsElapsed + Math.Max(0, bonusSeconds) }).ToImmutableList();
121121

122-
var journal = saveData.Journal.Select(j => new JournalEntry(j.TaskName, j.CharacterName, j.Details, j.CompletedAt, j.IsFirstTime, j.WasCancelled)).ToImmutableList();
123-
124122
var state = new GameState(
125123
Inventory: inventory,
126124
MagicCapacity: saveData.MagicCapacity,
127125
PinnedItems: pinnedItems,
128126
AssignedCadences: saveData.AssignedCadences.ToImmutableDictionary(x => x.CadenceName, x => (string?)x.CharacterName),
129127
Junctions: junctions,
130128
CharacterPermanentStatBoosts: saveData.CharacterStatBoosts.ToImmutableDictionary(k => k.Key, v => v.Value.ToImmutableDictionary()),
131-
CompletedQuests: saveData.CompletedQuests.ToImmutableHashSet(),
132-
UnlockedAbilities: saveData.UnlockedAbilities.ToImmutableHashSet(),
129+
CompletedQuests: [.. saveData.CompletedQuests],
130+
UnlockedAbilities: [.. saveData.UnlockedAbilities],
133131
ActiveQuests: activeQuestsWithBonus,
134132
AutoQuestEnabled: saveData.AutoQuestEnabled.ToImmutableDictionary(),
135-
StarredRecipes: saveData.StarredRecipes.ToImmutableHashSet(),
136-
UnlockedLocationNames: saveData.UnlockedLocations.ToImmutableHashSet(),
137-
UnlockedCadenceNames: saveData.UnlockedCadences.ToImmutableHashSet(),
138-
HighlightedPath: ImmutableHashSet<string>.Empty,
139-
Journal: journal,
140-
CharacterMiniLogs: saveData.CharacterMiniLogs.ToImmutableDictionary(kvp => kvp.Key, kvp => kvp.Value.ToImmutableList<string>()),
141-
EverPerformedActivities: saveData.EverPerformedActivities.ToImmutableHashSet(),
142-
SeenContent: saveData.SeenContent.ToImmutableHashSet(),
133+
StarredRecipes: [.. saveData.StarredRecipes],
134+
UnlockedLocationNames: [.. saveData.UnlockedLocations],
135+
UnlockedCadenceNames: [.. saveData.UnlockedCadences],
136+
LastFinishedActivity: saveData.LastFinishedActivities.ToImmutableDictionary(),
137+
HighlightedPath: [],
138+
EverPerformedActivities: [.. saveData.EverPerformedActivities],
139+
SeenContent: [.. saveData.SeenContent],
143140
CurrentTime: saveData.CurrentTime,
144141
IsTestMode: saveData.IsTestMode,
145142
HasUnseenCadence: saveData.HasUnseenCadence,
146143
HasUnseenWorkshop: saveData.HasUnseenWorkshop,
147-
ActiveTab: saveData.ActiveTab,
148-
ShowMiniLogs: saveData.ShowMiniLogs
144+
ActiveTab: saveData.ActiveTab
149145
);
150146

151147
gameStore.Dispatch(new SetStateAction(state));

Mythril.Data/GameState.cs

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,34 +24,32 @@ public record GameState(
2424
bool IsTestMode,
2525
bool HasUnseenCadence,
2626
bool HasUnseenWorkshop,
27-
string ActiveTab,
28-
bool ShowMiniLogs
27+
string ActiveTab
2928
)
3029
{
3130
public static GameState Initial => new(
32-
Inventory: ImmutableDictionary<string, int>.Empty,
31+
Inventory: [],
3332
MagicCapacity: 30,
34-
PinnedItems: ImmutableHashSet<string>.Empty,
35-
AssignedCadences: ImmutableDictionary<string, string?>.Empty,
36-
Junctions: ImmutableList<Junction>.Empty,
37-
CharacterPermanentStatBoosts: ImmutableDictionary<string, ImmutableDictionary<string, int>>.Empty,
38-
CompletedQuests: ImmutableHashSet<string>.Empty,
39-
UnlockedAbilities: ImmutableHashSet<string>.Empty,
40-
ActiveQuests: ImmutableList<QuestProgress>.Empty,
41-
AutoQuestEnabled: ImmutableDictionary<string, bool>.Empty,
42-
LastFinishedActivity: ImmutableDictionary<string, string?>.Empty,
43-
StarredRecipes: ImmutableHashSet<string>.Empty,
44-
UnlockedLocationNames: ImmutableHashSet<string>.Empty,
45-
UnlockedCadenceNames: ImmutableHashSet<string>.Empty,
46-
HighlightedPath: ImmutableHashSet<string>.Empty,
47-
EverPerformedActivities: ImmutableHashSet<string>.Empty,
48-
SeenContent: ImmutableHashSet<string>.Empty,
33+
PinnedItems: [],
34+
AssignedCadences: [],
35+
Junctions: [],
36+
CharacterPermanentStatBoosts: [],
37+
CompletedQuests: [],
38+
UnlockedAbilities: [],
39+
ActiveQuests: [],
40+
AutoQuestEnabled: [],
41+
LastFinishedActivity: [],
42+
StarredRecipes: [],
43+
UnlockedLocationNames: [],
44+
UnlockedCadenceNames: [],
45+
HighlightedPath: [],
46+
EverPerformedActivities: [],
47+
SeenContent: [],
4948
CurrentTime: 0,
5049
IsTestMode: false,
5150
HasUnseenCadence: false,
5251
HasUnseenWorkshop: false,
53-
ActiveTab: "hand",
54-
ShowMiniLogs: false
52+
ActiveTab: "hand"
5553
);
5654
}
5755

Mythril.Data/GameStateStore.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ public partial class GameStore
1818
public GameState State { get; private set; } = GameState.Initial;
1919
public event Action<GameState>? OnStateChanged;
2020
public event Action<string, int>? OnItemOverflow;
21-
public event Action? OnJournalUpdated;
2221

2322
public string ExportState() => JsonSerializer.Serialize(State, _options);
2423
public void ImportState(string json)
@@ -42,9 +41,5 @@ public void Dispatch(IGameAction action)
4241
{
4342
OnItemOverflow?.Invoke(overflowItem, overflowQty);
4443
}
45-
if (action is AddToJournalAction || action is ClearJournalAction || action is SetStateAction || action is FinishQuestAction)
46-
{
47-
OnJournalUpdated?.Invoke();
48-
}
4944
}
5045
}

Mythril.Data/Models.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ public class SaveData
201201
public string ActiveTab { get; set; } = "hand";
202202
public DateTime LastSaveTime { get; set; }
203203
public Dictionary<string, Dictionary<string, int>> CharacterStatBoosts { get; set; } = [];
204+
public Dictionary<string, string?> LastFinishedActivities {get; set;} = [];
205+
public List<string> EverPerformedActivities = [];
204206
}
205207

206208
public class AssignedCadenceDTO

Mythril.Data/ResourceManager_Logistics.cs

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -113,43 +113,45 @@ private void CheckAutoQuestTick()
113113
int autoLimit = GetAutoQuestLimit(character);
114114
int current = ActiveQuests.Count(p => p.Character.Name == character.Name);
115115

116+
117+
//TODO => Fix autoquest now that journal is gone. Need a new standalone mapping of last tasks
116118
if (current < limit)
117119
{
118-
// Find the last entry for this character in this session
119-
var lastEntry = Journal.FirstOrDefault(j => j.CharacterName == character.Name);
120-
if (lastEntry?.TaskName != null && !lastEntry.WasCancelled)
121-
{
122-
// Check if we are allowed to restart in the next free slot
123-
// If current = 0, we are filling slot 0. If current = 1, we are filling slot 1.
124-
if (current >= autoLimit) continue;
120+
// // Find the last entry for this character in this session
121+
// var lastEntry = Journal.FirstOrDefault(j => j.CharacterName == character.Name);
122+
// if (lastEntry?.TaskName != null && !lastEntry.WasCancelled)
123+
// {
124+
// // Check if we are allowed to restart in the next free slot
125+
// // If current = 0, we are filling slot 0. If current = 1, we are filling slot 1.
126+
// if (current >= autoLimit) continue;
125127

126-
// Check if it's a recurring quest or refinement
127-
var quest = _quests.All.FirstOrDefault(q => q.Name == lastEntry.TaskName);
128-
if (quest.Name != null)
129-
{
130-
var detail = _questDetails[quest];
131-
if (detail.Type == QuestType.Recurring)
132-
{
133-
var questData = new QuestData(quest, detail);
134-
if (CanAfford(questData, character))
135-
{
136-
// Use -1.5 as initialSecondsElapsed to provide a "preparing" visual delay in the UI
137-
StartQuest(questData, character, -1.5);
138-
}
139-
}
140-
}
141-
else
142-
{
143-
// Check refinements
144-
var refData = _refinements.ByKey.SelectMany(r => r.Value.Recipes.Select(rec => new RefinementData(r.Key, rec.Key, rec.Value, r.Value.PrimaryStat)))
145-
.FirstOrDefault(rd => rd.Name == lastEntry.TaskName);
128+
// // Check if it's a recurring quest or refinement
129+
// var quest = _quests.All.FirstOrDefault(q => q.Name == lastEntry.TaskName);
130+
// if (quest.Name != null)
131+
// {
132+
// var detail = _questDetails[quest];
133+
// if (detail.Type == QuestType.Recurring)
134+
// {
135+
// var questData = new QuestData(quest, detail);
136+
// if (CanAfford(questData, character))
137+
// {
138+
// // Use -1.5 as initialSecondsElapsed to provide a "preparing" visual delay in the UI
139+
// StartQuest(questData, character, -1.5);
140+
// }
141+
// }
142+
// }
143+
// else
144+
// {
145+
// // Check refinements
146+
// var refData = _refinements.ByKey.SelectMany(r => r.Value.Recipes.Select(rec => new RefinementData(r.Key, rec.Key, rec.Value, r.Value.PrimaryStat)))
147+
// .FirstOrDefault(rd => rd.Name == lastEntry.TaskName);
146148

147-
if (refData.Name != null && CanAfford(refData, character))
148-
{
149-
StartQuest(refData, character, -1.5);
150-
}
151-
}
152-
}
149+
// if (refData.Name != null && CanAfford(refData, character))
150+
// {
151+
// StartQuest(refData, character, -1.5);
152+
// }
153+
// }
154+
// }
153155
}
154156
}
155157
}

Mythril.Data/ResourceManager_Quests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ public void CancelQuest(QuestProgress progress)
4949
{
5050
_gameStore.Dispatch(new CancelQuestAction(progress));
5151
RefundCosts(progress.Item);
52-
53-
// Add to journal as cancelled so AutoQuest knows not to repeat it
54-
AddToJournal(progress.Name, progress.Character.Name, $"Cancelled {progress.Name}", wasCancelled: true);
5552
}
53+
54+
//TODO: Send a singal to whatever is managing autoquest for the character
55+
5656
}
5757

5858
public bool CanAfford(object item, Character? character = null)

Mythril.Tests/AdditionalUIComponentTests.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -237,13 +237,6 @@ public void CharacterDisplay_AutoQuestToggle_RendersWhenUnlocked()
237237
Assert.IsTrue(ResourceManager.IsAutoQuestEnabled(character));
238238
}
239239

240-
[TestMethod]
241-
public void JournalPanel_RendersCorrectly()
242-
{
243-
var cut = RenderComponent<JournalPanel>();
244-
Assert.IsTrue(cut.Markup.Contains("journal-panel"));
245-
}
246-
247240
[TestMethod]
248241
public void App_RendersCorrectly()
249242
{

Mythril.Tests/JournalTests.cs

Lines changed: 0 additions & 35 deletions
This file was deleted.

Mythril.Tests/ResourceManagerCoreTests.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -209,19 +209,6 @@ public void ResourceManager_Initialize_ClearsJunctions()
209209
Assert.AreEqual(0, _resourceManager.JunctionManager.Junctions.Count, "Junctions should be cleared on initialization.");
210210
}
211211

212-
[TestMethod]
213-
public void ResourceManager_Journal_TracksFirstTime()
214-
{
215-
// Act
216-
_resourceManager!.ReceiveRewards(new QuestProgress(new QuestData(_quests!.All[0], _questDetails![_quests.All[0]]), "Test", 0, _resourceManager.Characters[0], 0)).Wait();
217-
_resourceManager!.ReceiveRewards(new QuestProgress(new QuestData(_quests!.All[0], _questDetails![_quests.All[0]]), "Test", 0, _resourceManager.Characters[0], 0)).Wait();
218-
219-
// Assert
220-
Assert.AreEqual(2, _resourceManager.Journal.Count);
221-
// Note: Journal order is newest first in implementation
222-
Assert.IsTrue(_resourceManager.Journal[1].IsFirstTime, "First completion (older) should be marked as first time.");
223-
Assert.IsFalse(_resourceManager.Journal[0].IsFirstTime, "Second completion (newer) should NOT be marked as first time.");
224-
}
225212

226213
[TestMethod]
227214
public void Character_Name_ReturnsCorrectValue()

Mythril.Tests/RewardTests.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Mythril.Tests;
88
public class RewardTests : BunitTestBase
99
{
1010
[TestMethod]
11-
public async Task ReceiveRewards_Quest_AddsItemsToInventoryAndJournal()
11+
public async Task ReceiveRewards_Quest_AddsItemsToInventory()
1212
{
1313
// Arrange
1414
var item = new Item("Stone", "Desc", ItemType.Material);
@@ -26,13 +26,10 @@ public async Task ReceiveRewards_Quest_AddsItemsToInventoryAndJournal()
2626

2727
// Assert
2828
Assert.AreEqual(5, InventoryManager.GetQuantity(item));
29-
Assert.AreEqual(1, ResourceManager.Journal.Count);
30-
Assert.AreEqual("Test Quest", ResourceManager.Journal[0].TaskName);
31-
Assert.AreEqual("Hero", ResourceManager.Journal[0].CharacterName);
3229
}
3330

3431
[TestMethod]
35-
public async Task ReceiveRewards_CadenceUnlock_AddsAbilityAndJournal()
32+
public async Task ReceiveRewards_CadenceUnlock_AddsAbility()
3633
{
3734
// Arrange
3835
var ability = new CadenceAbility("Fire Ball", "Desc");
@@ -47,12 +44,10 @@ public async Task ReceiveRewards_CadenceUnlock_AddsAbilityAndJournal()
4744

4845
// Assert
4946
Assert.IsTrue(ResourceManager.UnlockedAbilities.Contains("Mage:Fire Ball"));
50-
Assert.AreEqual(1, ResourceManager.Journal.Count);
51-
Assert.AreEqual("Fire Ball", ResourceManager.Journal[0].TaskName);
5247
}
5348

5449
[TestMethod]
55-
public async Task ReceiveRewards_Refinement_AddsOutputAndJournal()
50+
public async Task ReceiveRewards_Refinement_AddsOutput()
5651
{
5752
// Arrange
5853
var ability = new CadenceAbility("Refine", "Desc");
@@ -81,7 +76,6 @@ public async Task ReceiveRewards_Refinement_AddsOutputAndJournal()
8176

8277
// Assert
8378
Assert.AreEqual(2, InventoryManager.GetQuantity(output));
84-
Assert.AreEqual(1, ResourceManager.Journal.Count);
8579
}
8680

8781
[TestMethod]

0 commit comments

Comments
 (0)