@@ -263,6 +263,7 @@ class APItem {
263263 if (this .condition .checkFn (this )) {
264264 // trace("Condition passed, executing onTrigger for item: " + this.name);
265265 onTrigger ();
266+ allItems .remove (this );
266267 } else {
267268 // trace("Condition failed, onTrigger not executed for item: " + this.name);
268269 }
@@ -283,13 +284,13 @@ class APItem {
283284 if (this .condition .checkFn (this )) {
284285 // trace("Condition passed, executing onTrigger for item: " + this.name);
285286 onTrigger ();
287+ allItems .remove (this );
286288 } else {
287289 // trace("Condition failed, onTrigger not executed for item: " + this.name);
288290 }
289291 }
290292
291293 // trace("Removing item from allItems: " + this.name);
292- allItems .remove (this );
293294 }
294295
295296 public static function createItems (): Void {
@@ -364,4 +365,124 @@ class APChartModifier extends APItem {
364365 public static function restoreFromSave (modifier : String ): Void {
365366 new APChartModifier (modifier );
366367 }
367- }
368+ }
369+ class APAprilFools extends APItem {
370+ private static var options : Map <Int , Void -> Void > = new Map ();
371+
372+ static function initializeOptions (): Void {
373+ options .set (0 , function () {
374+ APItem .createCustomItem (" April Fools - Nothing" , ConditionHelper . Everywhere (), function () {
375+ archipelago. APItem .popup (" April Fools! Nothing happened this time." , " April Fools!" );
376+ });
377+ });
378+
379+ options .set (1 , function () {
380+ APItem .createCustomItem (" April Fools - Random Item" , ConditionHelper . Everywhere (), function () {
381+ var randomItem = [" Blue Balls Curse" , " Fake Transition" , " Ticket" , " SvC Effect" , " Ghost Chat" , " Shield" , " Max HP Up" , " Tutorial Trap" ];
382+ var chosenItem = randomItem [Std .random (randomItem .length )];
383+ archipelago. APItem .createItemByName (chosenItem );
384+ });
385+ });
386+
387+ options .set (2 , function () {
388+ APItem .createCustomItem (" April Fools - No Heal" , ConditionHelper . PlayState (), function () {
389+ if (Std .is (FlxG .state , states. PlayState )) {
390+ var playState : states. PlayState = cast FlxG .state ;
391+ playState .noHeal = true ;
392+ archipelago. APItem .popup (" Healing disabled! Good luck!" , " April Fools!" );
393+ }
394+ });
395+ });
396+
397+ options .set (3 , function () {
398+ APItem .createCustomItem (" April Fools - Fake Transition" , ConditionHelper . Everywhere (), function () {
399+ var transitionType = Std .random (2 ) == 0 ? " fallSequential" : " fallRandom" ;
400+ TransitionState .fakeTransition ({ transitionType : transitionType });
401+ archipelago. APItem .popup (" I hope you don't mind playing again!" , " April Fools!" );
402+ });
403+ });
404+
405+ options .set (4 , function () {
406+ APItem .createCustomItem (" April Fools - Random Song" , ConditionHelper . Freeplay (), function () {
407+ if (Std .is (FlxG .state , states. FreeplayState )) {
408+ var freeplayState : states. FreeplayState = cast FlxG .state ;
409+ var songList = freeplayState .songList ;
410+ if (songList .length == 0 ) {
411+ archipelago. APItem .popup (" No songs available to switch!" , " April Fools!" );
412+ return ;
413+ }
414+ }
415+ });
416+ });
417+
418+ options .set (5 , function () {
419+ APItem .createCustomItem (" April Fools - Health/MaxHP" , ConditionHelper . PlayState (), function () {
420+ if (Std .is (FlxG .state , states. PlayState )) {
421+ var playState : states. PlayState = cast FlxG .state ;
422+ if (Std .random (2 ) == 0 ) {
423+ var tween = flixel.tweens. FlxTween .num (playState .health , 0 , 1 , function (value : Float ) {
424+ playState .health = value ;
425+ });
426+ archipelago. APItem .popup (" Your health is now 0!" , " April Fools!" );
427+ } else {
428+ var tween = flixel.tweens. FlxTween .num (playState. MaxHP , 0 , 1 , function (value : Float ) {
429+ playState. MaxHP = value ;
430+ });
431+ archipelago. APItem .popup (" Your MaxHP is now 0!" , " April Fools!" );
432+ }
433+ }
434+ });
435+ });
436+
437+
438+ options .set (6 , function () {
439+ APItem .createCustomItem (" April Fools - Screen Flip" , ConditionHelper . PlayState (), function () {
440+ if (Std .is (FlxG .state , states. PlayState )) {
441+ var playState : states. PlayState = cast FlxG .state ;
442+ var randomChance = Std .random (100 );
443+ var targetAngle = 180 ;
444+
445+ if (randomChance < 10 ) { // 10% chance to overflip or underflip
446+ targetAngle = 180 + (Std .random (3 ) - 1 ) * 360 ;
447+ } else if (randomChance < 20 ) { // 10% chance to invert the screen
448+ targetAngle = 0 ;
449+ }
450+
451+ flixel. FlxG .camera .angle = 0 ;
452+ flixel.tweens. FlxTween .num (0 , targetAngle , 1 , function (value : Float ) {
453+ flixel. FlxG .camera .angle = value ;
454+ });
455+ archipelago. APItem .popup (" The screen is flipped!" , " April Fools!" );
456+ }
457+ });
458+ });
459+
460+ // Windows Only, as notifications can't be sent this way on other platforms
461+ #if windows
462+ options .set (7 , function () {
463+ APItem .createCustomItem (" April Fools - Windows Notification" , ConditionHelper . Everywhere (), function () {
464+ var notification = new haxe.win32. Notification (" April Fools!" , " This is a Windows notification!" );
465+ notification .show ();
466+ });
467+ });
468+
469+
470+
471+ }
472+
473+ public function new () {
474+ super (" April Fools" , ConditionHelper . Special (), function () {
475+ if (options .lengthTo () == 0 ) {
476+ initializeOptions ();
477+ }
478+
479+
480+ var randomChoice = Std .random (options .lengthTo ());
481+ var action = options .get (randomChoice );
482+ if (action != null ) {
483+ action ();
484+ APItem .popup (" Something happened..." , " April Fools!" );
485+ }
486+ }, false , false );
487+ }
488+ }
0 commit comments