import Entity from '../Entity.js';
import printMessage from '../printMessage.js';
import action from '../action.js';
import time from '../time.js';

export class AlarmClock extends Entity {
  constructor() {
    super();
    this.ringing = true;
  }

  name() {
    return "alarm clock";
  }

  actions() {
    const checkTime = action("Look at the time.", () => {
      printMessage(`It is now ${time()}.`);
    })

    if(this.ringing) {
      return [
        action("Snooze", () => {
          printMessage(`You sleep for another 5 minutes before the alarm clock rings again. It's now ${time()}.`);
        }),
        action("Turn if off.", () => {
          this.ringing = false;
          printMessage('You turn the alarm clock off.');
        }),
        checkTime
      ];
    } else {
      return [checkTime];
    }
  }
}

export default new AlarmClock();

import Entity from '../Entity.js';
import printMessage from '../printMessage.js';
import action from '../action.js';
import time from '../time.js';

export class AlarmClock extends Entity {
  constructor() {
    super();
    this.ringing = true;
  }

  name() {
    return "alarm clock";
  }

  actions() {
    if(this.ringing) {
      return [
        action("Snooze", () => {
          printMessage(`You sleep for another 5 minutes before the alarm clock rings again. It's now ${time()}.`);
        }),
        action("Turn if off.", () => {
          this.ringing = false;
          printMessage('You turn the alarm clock off.');
        })
      ];
    } else {
      return [];
    }
  }
}

export default new AlarmClock();

--- 
+++ 
@@ -14,10 +14,6 @@
   }
 
   actions() {
-    const checkTime = action("Look at the time.", () => {
-      printMessage(`It is now ${time()}.`);
-    })
-
     if(this.ringing) {
       return [
         action("Snooze", () => {
@@ -26,11 +22,10 @@
         action("Turn if off.", () => {
           this.ringing = false;
           printMessage('You turn the alarm clock off.');
-        }),
-        checkTime
+        })
       ];
     } else {
-      return [checkTime];
+      return [];
     }
   }
 }
Check time after alarm disabled
