generated from AriasCreations/vsmodtemplate
Refactor Costs to ComandCosts
This commit is contained in:
parent
bdbf67c86e
commit
ced16d9fb9
2 changed files with 24 additions and 19 deletions
|
@ -37,7 +37,7 @@ namespace AriasServerUtils
|
|||
public int PlayerSleepingPercentage { get; set; } = 50;
|
||||
public int MaxRTPBlockDistance { get; set; } = 50000;
|
||||
public Dictionary<CooldownType, string> Cooldowns { get; set; } = new Dictionary<CooldownType, string>();
|
||||
public Costs costs { get; set; } = new Costs();
|
||||
public CommandCosts cmdCosts { get; set; } = new CommandCosts();
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
@ -75,27 +75,18 @@ namespace AriasServerUtils
|
|||
ServerUtilities.MarkDirty(); // This is here to ensure that the config gets saved when there is a update. Whenever a new field is added to config, the CURRENT_VERSION should get bumped so that this SanityCheck can properly work
|
||||
}
|
||||
|
||||
// Sanity check costs config
|
||||
// Sanity check CommandCosts config
|
||||
bool checkCostDefaults = false;
|
||||
if (costs == null)
|
||||
if (cmdCosts == null)
|
||||
{
|
||||
costs = new Costs(); // Initialize a brand new costs object
|
||||
cmdCosts = new CommandCosts(); // Initialize a brand new CommandCosts object
|
||||
checkCostDefaults = true;
|
||||
}
|
||||
else if (costs.costs.Count != Costs.defaults.Count) checkCostDefaults = true;
|
||||
else if (cmdCosts.costs.Count != CommandCosts.defaults.Count) checkCostDefaults = true;
|
||||
|
||||
if (checkCostDefaults)
|
||||
{
|
||||
|
||||
foreach (var def in Costs.defaults)
|
||||
{
|
||||
if (!costs.costs.ContainsKey(def.Key))
|
||||
{
|
||||
costs.costs.Add(def.Key, def.Value);
|
||||
}
|
||||
}
|
||||
|
||||
ServerUtilities.MarkDirty();
|
||||
cmdCosts.SanityCheck();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -141,11 +132,11 @@ namespace AriasServerUtils
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// This contains per command costs, as well as helper functions that can refund a player, or check if the player has the required balance, or payment
|
||||
/// This contains per command CommandCosts, as well as helper functions that can refund a player, or check if the player has the required balance, or payment
|
||||
///
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class Costs
|
||||
public class CommandCosts
|
||||
{
|
||||
public enum CostType
|
||||
{
|
||||
|
@ -195,6 +186,20 @@ namespace AriasServerUtils
|
|||
if (gears >= required) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void SanityCheck()
|
||||
{
|
||||
|
||||
foreach (var def in defaults)
|
||||
{
|
||||
if (!costs.ContainsKey(def.Key))
|
||||
{
|
||||
costs.Add(def.Key, def.Value);
|
||||
}
|
||||
}
|
||||
|
||||
ServerUtilities.MarkDirty();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
"modid": "ariasserverutils",
|
||||
"name": "Aria's Server Utilities",
|
||||
"authors": ["zontreck"],
|
||||
"description": "A collection of server utilities\n\nBuild Date: 06-07-2025 @ 1:18 AM MST",
|
||||
"version": "1.1.0-dev.4",
|
||||
"description": "A collection of server utilities\n\nBuild Date: 06-07-2025 @ 12:16 PM MST",
|
||||
"version": "1.1.0-dev.5",
|
||||
"dependencies": {
|
||||
"game": ""
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue