@@ -254,14 +254,14 @@ class APItem {
254254 // trace("Condition type: " + this.condition.type);
255255 // trace("Condition check result: " + this.condition.checkFn(this));
256256
257- if (! this .isException && this .condition .type != ConditionType . Everywhere && this .condition .checkFn (this ) && APItem .allowedToTrigger ) {
257+ if (! this .isException && ( this .condition .type != ConditionType . Everywhere ) && this .condition .checkFn (this ) && APItem .allowedToTrigger ) {
258258 // trace("Setting active item to: " + this.name);
259259 APItem .activeItem = this ;
260260 } else {
261261 // trace("Active item not set due to condition, exception rules, or being an Everywhere item.");
262262 }
263263
264- if (this .condition .checkFn (this )) {
264+ if (this .condition .checkFn (this ) && APItem . allowedToTrigger ) {
265265 // trace("Condition passed, executing onTrigger for item: " + this.name);
266266 onTrigger ();
267267 allItems .remove (this );
@@ -282,7 +282,7 @@ class APItem {
282282 // trace("Active item not set due to condition, exception rules, or being an Everywhere item.");
283283 }
284284
285- if (this .condition .checkFn (this )) {
285+ if (this .condition .checkFn (this ) && APItem . allowedToTrigger ) {
286286 // trace("Condition passed, executing onTrigger for item: " + this.name);
287287 onTrigger ();
288288 allItems .remove (this );
@@ -372,6 +372,8 @@ class APChartModifier extends APItem {
372372}
373373class APrilFools extends APItem {
374374 private static var options : Map <Int , Void -> Void > = new Map ();
375+ private static var initialized : Bool = false ;
376+ private var triggered : Bool = false ;
375377
376378 static function initializeOptions (): Void {
377379 options .set (0 , function () {
@@ -614,20 +616,40 @@ class APrilFools extends APItem {
614616
615617 }
616618
617- public function new () {
618- super (" April Fools" , ConditionHelper . Special (), function () {
619- if (options .lengthTo () == 0 ) {
620- initializeOptions ();
621- APItem .popup (" Something odd is brewing." , " Archipelago" , true );
622- }
619+ public override function trigger (): Void {
620+ if (triggered ) {
621+ return ; // Prevent multiple triggers
622+ }
623+ triggered = true ; // Set triggered to true to prevent multiple triggers
624+ super .trigger ();
625+ // trace("April Fools item triggered.");
626+ }
623627
628+ public function new () {
629+ super (" April Fools" , ConditionHelper . Special (), function () {
630+ // trace("April Fools item triggered.");
631+ if (! initialized ) {
632+ initialized = true ;
633+ trace (" Initializing options for April Fools." );
634+ initializeOptions ();
635+ APItem .popup (" Something odd is brewing." , " Archipelago" , true );
636+ }
624637
625- var randomChoice = Std .random (options .lengthTo ());
626- var action = options .get (randomChoice );
627- if (action != null ) {
628- action ();
629- APItem .popup (" Something happened..." , " Archipelago" , true );
630- }
631- }, false , false );
638+ var optionss : Int = 0 ;
639+ for (o in options .keys ()) {
640+ optionss ++ ;
641+ }
642+
643+ var randomChoice = Std .random (optionss );
644+ // trace("Random choice selected: " + randomChoice);
645+ var action = options .get (randomChoice );
646+ if (action != null ) {
647+ // trace("Executing action for choice: " + randomChoice);
648+ action ();
649+ APItem .popup (" Something happened..." , " Archipelago" , true );
650+ } else {
651+ // trace("No action found for choice: " + randomChoice);
652+ }
653+ }, false , false );
654+ }
632655 }
633- }
0 commit comments