-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Introduced concept of Tester Features, optionally, somewhat-secret …
…things that can be enabled by helpers and testers - Created the Mod validation Tester Feature, and the Multiplayer Tester Feature
- Loading branch information
1 parent
234adf7
commit 5b4b65f
Showing
10 changed files
with
129 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace StardewArchipelago.GameModifications.Testing | ||
{ | ||
public static class VerifyMods | ||
{ | ||
public const int MODS_AND_VERSIONS = 0; | ||
public const int MODS_ONLY = 1; | ||
public const int NOTHING = 2; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
StardewArchipelago/GameModifications/Testing/TesterFeature.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace StardewArchipelago.GameModifications.Testing | ||
{ | ||
public class TesterFeature | ||
{ | ||
public string Name { get; set; } | ||
public int Value { get; set; } | ||
|
||
public TesterFeature(string name, int defaultValue) | ||
{ | ||
Name = name; | ||
Value = defaultValue; | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
StardewArchipelago/GameModifications/Testing/TesterFeatureNames.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace StardewArchipelago.GameModifications.Testing | ||
{ | ||
public class TesterFeatureNames | ||
{ | ||
public const string UNSTABLE_MODS = "VerifyMods"; | ||
public const string MULTIPLAYER = "Multiplayer"; | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
StardewArchipelago/GameModifications/Testing/TesterFeatures.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using KaitoKid.ArchipelagoUtilities.Net.Interfaces; | ||
using StardewModdingAPI; | ||
|
||
namespace StardewArchipelago.GameModifications.Testing | ||
{ | ||
public class TesterFeatures | ||
{ | ||
private const string TESTER_FEATURES_FILE = "tester.json"; | ||
public readonly TesterFeature Multiplayer = new(TesterFeatureNames.MULTIPLAYER, 0); | ||
public readonly TesterFeature UnstableMods = new(TesterFeatureNames.UNSTABLE_MODS, VerifyMods.MODS_AND_VERSIONS); | ||
private readonly Dictionary<string, TesterFeature> _featuresByName = new(); | ||
|
||
public TesterFeatures(ILogger logger, IModHelper modHelper) | ||
{ | ||
_featuresByName.Add(Multiplayer.Name, Multiplayer); | ||
_featuresByName.Add(UnstableMods.Name, UnstableMods); | ||
|
||
#if DEBUG | ||
UnstableMods.Value = VerifyMods.NOTHING; | ||
#endif | ||
|
||
try | ||
{ | ||
var entries = modHelper.Data.ReadJsonFile<Dictionary<string, int>>(TESTER_FEATURES_FILE); | ||
if (entries == null || !entries.Any()) | ||
{ | ||
return; | ||
} | ||
|
||
foreach (var (name, value) in entries) | ||
{ | ||
if (!_featuresByName.ContainsKey(name)) | ||
{ | ||
continue; | ||
} | ||
|
||
_featuresByName[name].Value = value; | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
logger.LogError($"Failed at reading the TesterFeatures file. The file is probably corrupted and should be deleted to start fresh, or fixed manually"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters