fix player_setlevel command not also changing XP (#359)

This commit is contained in:
Jesse Plamondon-Willard 2017-10-27 02:44:53 -04:00
parent 7f16ebdb19
commit b945fcf555
2 changed files with 31 additions and 1 deletions

View File

@ -3,6 +3,7 @@
* For players:
* Fixed compatibility check crashing for players with Stardew Valley 1.08.
* Fixed the game's test messages being shown in the console and log.
* Fixed TrainerMod's `player_setlevel` command not also setting XP.
* For modders:
* Added support for public code in reflection API, to simplify mod integrations.

View File

@ -1,11 +1,34 @@
using StardewModdingAPI;
using System.Collections.Generic;
using StardewModdingAPI;
using StardewValley;
using SFarmer = StardewValley.Farmer;
namespace TrainerMod.Framework.Commands.Player
{
/// <summary>A command which edits the player's current level for a skill.</summary>
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
*********/
@ -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;
}