diff --git a/src/js/game/systems/goal_acceptor.js b/src/js/game/systems/goal_acceptor.js index 4972afb2..3abf5651 100644 --- a/src/js/game/systems/goal_acceptor.js +++ b/src/js/game/systems/goal_acceptor.js @@ -11,11 +11,15 @@ export class GoalAcceptorSystem extends GameSystemWithFilter { /** @param {GameRoot} root */ constructor(root) { super(root, [GoalAcceptorComponent]); + + this.puzzleCompleted = false; } update() { const now = this.root.time.now(); + let allAccepted = true; + for (let i = 0; i < this.allEntities.length; ++i) { const entity = this.allEntities[i]; const goalComp = entity.components.GoalAcceptor; @@ -25,6 +29,20 @@ export class GoalAcceptorSystem extends GameSystemWithFilter { d => now - d.time < globalConfig.goalAcceptorMinimumDurationSeconds && d.item === goalComp.item ); + + if (goalComp.deliveryHistory.length < goalComp.getRequiredDeliveryHistorySize()) { + allAccepted = false; + } + } + + if ( + !this.puzzleCompleted && + this.root.gameInitialized && + allAccepted && + !this.root.gameMode.getIsEditor() + ) { + this.root.hud.parts.dialogs.showInfo("Puzzle completed", "Congrats!"); + this.puzzleCompleted = true; } }