controllers/game/l_t_b_l_controller.js

  1. import { Controller } from "@hotwired/stimulus"
  2. /**
  3. * @class Game.LTBLController
  4. * @classdesc Stimulus controller for /game/let-there-be-light.
  5. * @extends Controller
  6. */
  7. export default class LTBLController extends Controller {
  8. /**
  9. * Triggered by a click event on a hidden pixel on the page.
  10. * Get the current background color of the <body> tag.
  11. * If it hasn't changed then naviagte to /game/make-it-brighter-before-you-can-continue/ which is a hint
  12. * If it has changed but isn't white then navigate to /game/try-another-color/ which is another hint
  13. * If it is white then navigate to the next puzzle.
  14. *
  15. * @instance
  16. * @memberof Game.LTBLController
  17. * @returns {void} N/A
  18. * */
  19. next() {
  20. const body = document.querySelector("body")
  21. const backgroundColor = window.getComputedStyle(body).getPropertyValue("background-color")
  22. switch (backgroundColor) {
  23. case "rgb(34, 34, 37)":
  24. location.href = "/game/make-it-brighter-before-you-can-continue/"
  25. break;
  26. case "rgb(255, 255, 255)":
  27. location.href = "/game/go-to-the-source/"
  28. break;
  29. default:
  30. location.href = "/game/try-another-color/"
  31. }
  32. }
  33. }