-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add handling to repair fragile charm when upgraded to unbreakable.
- Loading branch information
1 parent
855acac
commit 995fef3
Showing
1 changed file
with
20 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,38 @@ | ||
namespace ItemChanger.Items | ||
using Newtonsoft.Json; | ||
|
||
namespace ItemChanger.Items | ||
{ | ||
/// <summary> | ||
/// CharmItem which gives the unbreakable version of the charm. | ||
/// </summary> | ||
public class UnbreakableCharmItem : CharmItem | ||
{ | ||
public string unbreakableBool | ||
public string GetUnbreakableBool() => charmNum switch | ||
{ | ||
get | ||
{ | ||
switch (charmNum) | ||
{ | ||
case 23: | ||
return nameof(PlayerData.fragileHealth_unbreakable); | ||
case 24: | ||
return nameof(PlayerData.fragileGreed_unbreakable); | ||
case 25: | ||
return nameof(PlayerData.fragileStrength_unbreakable); | ||
default: | ||
throw new ArgumentException("CharmNum out of range."); | ||
} | ||
} | ||
} | ||
23 => nameof(PlayerData.fragileHealth_unbreakable), | ||
24 => nameof(PlayerData.fragileGreed_unbreakable), | ||
25 => nameof(PlayerData.fragileStrength_unbreakable), | ||
_ => throw new ArgumentException("CharmNum out of range."), | ||
}; | ||
|
||
public string GetBrokenBool() => charmNum switch | ||
{ | ||
23 => nameof(PlayerData.brokenCharm_23), | ||
24 => nameof(PlayerData.brokenCharm_24), | ||
25 => nameof(PlayerData.brokenCharm_25), | ||
_ => throw new ArgumentException("CharmNum out of range."), | ||
}; | ||
|
||
public override void GiveImmediate(GiveInfo info) | ||
{ | ||
base.GiveImmediate(info); | ||
PlayerData.instance.SetBool(unbreakableBool, true); | ||
if (PlayerData.instance.GetBool(GetBrokenBool())) PlayerData.instance.SetBool(GetBrokenBool(), false); | ||
PlayerData.instance.SetBool(GetUnbreakableBool(), true); | ||
} | ||
|
||
public override bool Redundant() | ||
{ | ||
return base.Redundant() && PlayerData.instance.GetBool(unbreakableBool); | ||
return base.Redundant() && PlayerData.instance.GetBool(GetUnbreakableBool()); | ||
} | ||
} | ||
} |