-
Notifications
You must be signed in to change notification settings - Fork 83
Handling for music_play_instrument_mastery condition type
#563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,14 +27,15 @@ public PlayerCommand(GameSession session, AchievementMetadataStorage achievement | |
|
|
||
| private class MasteryCommand : Command { | ||
| public MasteryCommand(GameSession session) : base("mastery", "Set player mastery.") { | ||
| AddCommand(new MasteryExpCommand(session)); | ||
| AddCommand(new MasteryAddExpCommand(session)); | ||
| AddCommand(new MasterySetExpCommand(session)); | ||
| AddCommand(new MasteryLevelCommand(session)); | ||
| } | ||
|
|
||
| private class MasteryExpCommand : Command { | ||
| private class MasteryAddExpCommand : Command { | ||
| private readonly GameSession session; | ||
|
|
||
| public MasteryExpCommand(GameSession session) : base("exp", "Set player mastery experience.") { | ||
| public MasteryAddExpCommand(GameSession session) : base("addexp", "Add player mastery experience.") { | ||
| this.session = session; | ||
|
|
||
| var masteryCode = new Argument<MasteryType>("mastery", "MasteryType of the player."); | ||
|
|
@@ -45,6 +46,31 @@ public MasteryExpCommand(GameSession session) : base("exp", "Set player mastery | |
| this.SetHandler<InvocationContext, MasteryType, int>(Handle, masteryCode, exp); | ||
| } | ||
|
|
||
| private void Handle(InvocationContext ctx, MasteryType masteryType, int exp) { | ||
| try { | ||
| session.Mastery[masteryType] = session.Mastery[masteryType] + exp; | ||
| ctx.ExitCode = 0; | ||
| } catch (SystemException ex) { | ||
| ctx.Console.Error.WriteLine(ex.Message); | ||
| ctx.ExitCode = 1; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private class MasterySetExpCommand : Command { | ||
| private readonly GameSession session; | ||
|
|
||
| public MasterySetExpCommand(GameSession session) : base("setexp", "Set player mastery experience.") { | ||
| this.session = session; | ||
|
|
||
| var masteryCode = new Argument<MasteryType>("mastery", "MasteryType of the player."); | ||
| var exp = new Argument<int>("exp", "Experience points to set to."); | ||
|
|
||
| AddArgument(masteryCode); | ||
| AddArgument(exp); | ||
| this.SetHandler<InvocationContext, MasteryType, int>(Handle, masteryCode, exp); | ||
| } | ||
|
|
||
| private void Handle(InvocationContext ctx, MasteryType masteryType, int exp) { | ||
| try { | ||
| session.Mastery[masteryType] = exp; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if its a set command we shouldn't add.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will change the description of the subcommand. Did forget to do that as the Furthermore adding would be more inline with the other commands e.g. If you'd like I can also introduce a
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think would be better to introduce a subcommand like setexp/addexp |
||
|
|
||
|
Tandashi marked this conversation as resolved.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
setexp cannot decrease mastery due to clamping in MasteryManager indexer.
Both addexp and setexp route through session.Mastery[...] which clamps to [current..max]; setexp cannot lower EXP/level, contrary to “Set” semantics. Provide an absolute setter or an override path for admin commands.
If you prefer to keep the indexer strict, inject a bool allowDecrease into the indexer (default false) and use it only from admin commands.
Also applies to: 74-82
🤖 Prompt for AI Agents