Darkhax-Minecraft / Game-Stages

An API for universal player based progression.
https://minecraft.curseforge.com/projects/game-stages
GNU Lesser General Public License v2.1
63 stars 17 forks source link

1.16.5 above or below request] adding a new statement to the StageHelper #69

Closed Shibva closed 2 years ago

Shibva commented 2 years ago

Description

So I was trying to make a new thing, a series of requirements for a stage to be granted to the player, but I found myself having a hard time creating a statement that would account for different statements

my suggestion: a new helper statment to make thigs a bit easier; the grantStageIF parameter blank format example StageHelper.grantStageIf( Statements , "StageName);

this may seem redundant, but in terms of making things more compact and simple, it can help. The main purpose of this statement is to serve as a means of combining the other grantStage conditions provided by the stage helper and allowing for more than one type to be used with ease rather than having to try and wrap your head around a complicated workaround

how would this work: ill provide an example:

Imagine your trying to make a function for you to grant the player a stage using a combination of advancements, items, and experience. there are ways that this can be done, but to someone that is still learning and just wants it to be simple, this would help for you would do the following StageHelper.grantStageIf( onAdvancment[ A, B] && OnLevel[ parameters] && myIInventory.hasAny[ items], "Stage_one"');

as you can see, this uses examples that were not only proved by the hander but also by craftweaker's detection methods if one desires to sue them (obviously their methods would have to be imported for that to work) adding this can be useful in more ways than one, considering that at the time being there is no creaftweaker method to detect specific advancements (only that any advancement is being earned)

Additional Context

it could also be useful to add in a statement for detecting items that have data with them as well, as well as a way to possibly detect multiple of the same item if they were for some reason not able to stack

Screenshots / Media

You may include relevant media here if you have some. This includes screenshots, gifs, videos, diagrams, etc.

Darkhax commented 2 years ago

I've read over this request a few times now and it doesn't really make sense to me. The other conditions available in StageHelper are not conditions, but rather event listeners. Event listeners can not be defined in the way you suggest or easily chained together.

For example granting a stage on join using the stage helper like this

StageHelper.grantStageOnJoin("join_example_one");

is effectively converted to something like this behind the scenes.

CTEventManager.register<MCPlayerLoggedInEvent>((event) => {
    if (!event.player.world.remote && !event.player.hasGameStage("join_example_one")) {
        event.player.addGameStage("join_example_one");
    }
});

The design philosophy here is that those who are new to GameStages or CraftTweaker benefit from having a simple starting point for understanding how the systems work without requiring them to understand functional programming and other complex topics. The system you are describing is way out of scope for this.