summaryrefslogtreecommitdiff
path: root/src/TrainerMod/Framework
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-10-27 02:44:53 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-10-27 02:44:53 -0400
commitb945fcf5553f2df63db1fad8a73c65cd7fa7daa3 (patch)
tree02663c2b1110a0a3ce1b46b8055e082020d357fa /src/TrainerMod/Framework
parent7f16ebdb19982c182b60312883452c44fdd08fda (diff)
downloadSMAPI-b945fcf5553f2df63db1fad8a73c65cd7fa7daa3.tar.gz
SMAPI-b945fcf5553f2df63db1fad8a73c65cd7fa7daa3.tar.bz2
SMAPI-b945fcf5553f2df63db1fad8a73c65cd7fa7daa3.zip
fix player_setlevel command not also changing XP (#359)
Diffstat (limited to 'src/TrainerMod/Framework')
-rw-r--r--src/TrainerMod/Framework/Commands/Player/SetLevelCommand.cs31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/TrainerMod/Framework/Commands/Player/SetLevelCommand.cs b/src/TrainerMod/Framework/Commands/Player/SetLevelCommand.cs
index b223aa9f..54d5e47b 100644
--- a/src/TrainerMod/Framework/Commands/Player/SetLevelCommand.cs
+++ b/src/TrainerMod/Framework/Commands/Player/SetLevelCommand.cs
@@ -1,5 +1,7 @@
-using StardewModdingAPI;
+using System.Collections.Generic;
+using StardewModdingAPI;
using StardewValley;
+using SFarmer = StardewValley.Farmer;
namespace TrainerMod.Framework.Commands.Player
{
@@ -7,6 +9,27 @@ namespace TrainerMod.Framework.Commands.Player
internal class SetLevelCommand : TrainerCommand
{
/*********
+ ** Properties
+ *********/
+ /// <summary>The experience points needed to reach each level.</summary>
+ /// <remarks>Derived from <see cref="SFarmer.checkForLevelGain"/>.</remarks>
+ private readonly IDictionary<int, int> LevelExp = new Dictionary<int, int>
+ {
+ [0] = 0,
+ [1] = 100,
+ [2] = 380,
+ [3] = 770,
+ [4] = 1300,
+ [5] = 2150,
+ [6] = 3300,
+ [7] = 4800,
+ [8] = 6900,
+ [9] = 10000,
+ [10] = 15000
+ };
+
+
+ /*********
** Public methods
*********/
/// <summary>Construct an instance.</summary>
@@ -30,31 +53,37 @@ namespace TrainerMod.Framework.Commands.Player
{
case "luck":
Game1.player.LuckLevel = level;
+ Game1.player.experiencePoints[SFarmer.luckSkill] = this.LevelExp[level];
monitor.Log($"OK, your luck skill is now {Game1.player.LuckLevel}.", LogLevel.Info);
break;
case "mining":
Game1.player.MiningLevel = level;
+ Game1.player.experiencePoints[SFarmer.miningSkill] = this.LevelExp[level];
monitor.Log($"OK, your mining skill is now {Game1.player.MiningLevel}.", LogLevel.Info);
break;
case "combat":
Game1.player.CombatLevel = level;
+ Game1.player.experiencePoints[SFarmer.combatSkill] = this.LevelExp[level];
monitor.Log($"OK, your combat skill is now {Game1.player.CombatLevel}.", LogLevel.Info);
break;
case "farming":
Game1.player.FarmingLevel = level;
+ Game1.player.experiencePoints[SFarmer.farmingSkill] = this.LevelExp[level];
monitor.Log($"OK, your farming skill is now {Game1.player.FarmingLevel}.", LogLevel.Info);
break;
case "fishing":
Game1.player.FishingLevel = level;
+ Game1.player.experiencePoints[SFarmer.fishingSkill] = this.LevelExp[level];
monitor.Log($"OK, your fishing skill is now {Game1.player.FishingLevel}.", LogLevel.Info);
break;
case "foraging":
Game1.player.ForagingLevel = level;
+ Game1.player.experiencePoints[SFarmer.foragingSkill] = this.LevelExp[level];
monitor.Log($"OK, your foraging skill is now {Game1.player.ForagingLevel}.", LogLevel.Info);
break;
}