package example.sundering;

import forgottentowns.mod.api.GameMod;
import forgottentowns.mod.api.ModContext;
import forgottentowns.mod.api.ParticleShape;
import forgottentowns.mod.api.ParticleShape.Point;
import java.util.List;

/** Working example of startup hooks; gameplay values remain in the pack's JSON. */
public final class SunderingMod implements GameMod {
    /** Creates the public no-argument entrypoint required by the mod loader. */
    public SunderingMod() {}

    /**
     * Registers the extraction roll and sharp shard silhouette.
     * @param context registrations scoped to the sundering manifest
     * @throws IllegalArgumentException if configuration or registrations are invalid
     */
    @Override public void register(ModContext context) {
        var settings = new forgottentowns.mod.api.ModSettings(context.settings());
        int bonus = settings.integer("successBonusPercent",0,-100,100);
        settings.requireAllRead();
        context.registerEquipmentTransform("sundering:extract",
                (input, percentile) -> percentile.getAsInt() < Math.clamp(input.successPercent()+bonus,0,100));
        context.registerParticleShape("sundering:sliver", new ParticleShape(List.of(
                new Point(1, 0), new Point(-0.25, 0.45), new Point(-0.7, 0), new Point(-0.25, -0.45))));
    }
}
