From 946cae2b16c4e63d79e7e98609f0f34100855e90 Mon Sep 17 00:00:00 2001 From: "Z. Cliffe Schreuders" Date: Sat, 25 Oct 2025 23:43:16 +0100 Subject: [PATCH] Refactor phone messages minigame: Remove drag-to-scroll functionality for cleaner code. Update scenario JSON files to include voice, sender, and timestamp attributes for phone messages, enhancing narrative clarity. --- js/minigames/phone/phone-messages-minigame.js | 56 ------------------- scenarios/biometric_breach.json | 6 +- scenarios/scenario1.json | 6 +- scenarios/scenario2.json | 6 +- 4 files changed, 14 insertions(+), 60 deletions(-) diff --git a/js/minigames/phone/phone-messages-minigame.js b/js/minigames/phone/phone-messages-minigame.js index 90f0d0b..9d6c845 100644 --- a/js/minigames/phone/phone-messages-minigame.js +++ b/js/minigames/phone/phone-messages-minigame.js @@ -545,62 +545,6 @@ export class PhoneMessagesMinigame extends MinigameScene { this.addEventListener(document, 'keydown', (event) => { this.handleKeyPress(event); }); - - // Set up drag-to-scroll for scrollable elements - this.setupDragToScroll(this.messagesList); - this.setupDragToScroll(this.messageDetail); - } - - setupDragToScroll(scrollableElement) { - if (!scrollableElement) return; - - let isPressed = false; - let startY = 0; - let scrollTop = 0; - - const onMouseDown = (e) => { - // Don't start drag if clicking on interactive elements - if (e.target.closest('button, a, input, select, [role="button"]')) { - return; - } - - isPressed = true; - startY = e.pageY - scrollableElement.offsetTop; - scrollTop = scrollableElement.scrollTop; - scrollableElement.style.cursor = 'grabbing'; - e.preventDefault(); - }; - - const onMouseMove = (e) => { - if (!isPressed) return; - - const y = e.pageY - scrollableElement.offsetTop; - const deltaY = startY - y; - scrollableElement.scrollTop = scrollTop + deltaY; - }; - - const onMouseUp = () => { - isPressed = false; - scrollableElement.style.cursor = 'grab'; - }; - - const onMouseLeave = () => { - isPressed = false; - scrollableElement.style.cursor = 'grab'; - }; - - // Add hover effect to show the grab cursor - scrollableElement.addEventListener('mouseenter', () => { - if (!isPressed) { - scrollableElement.style.cursor = 'grab'; - } - }); - - scrollableElement.addEventListener('mouseleave', onMouseLeave); - - this.addEventListener(scrollableElement, 'mousedown', onMouseDown); - this.addEventListener(document, 'mousemove', onMouseMove); - this.addEventListener(document, 'mouseup', onMouseUp); } handleKeyPress(event) { diff --git a/scenarios/biometric_breach.json b/scenarios/biometric_breach.json index e870708..16e1ce0 100644 --- a/scenarios/biometric_breach.json +++ b/scenarios/biometric_breach.json @@ -34,7 +34,9 @@ "name": "Reception Phone", "takeable": false, "readable": true, - "text": "Voicemail: 'Security alert: Unauthorized access detected in the biometrics lab. All personnel must verify identity at security checkpoints. Server room PIN changed to 5923. Security lockdown initiated. - Security Team'", + "voice": "Security alert: Unauthorized access detected in the biometrics lab. All personnel must verify identity at security checkpoints. Server room PIN changed to 5923. Security lockdown initiated.", + "sender": "Security Team", + "timestamp": "02:45 AM", "observations": "The reception phone's message light is blinking with an urgent message" }, { @@ -235,6 +237,8 @@ "takeable": false, "readable": true, "text": "Last call: Incoming from Security Office at 02:37 AM. Call log shows Security reporting unauthorized access to server room.", + "sender": "Security Office", + "timestamp": "02:37 AM", "observations": "The director's phone with call history displayed" }, { diff --git a/scenarios/scenario1.json b/scenarios/scenario1.json index e2f7a1a..6c6b2cf 100644 --- a/scenarios/scenario1.json +++ b/scenarios/scenario1.json @@ -24,8 +24,10 @@ "name": "Reception Phone", "takeable": false, "readable": true, - "text": ".--. / .-. / --- / ..-. / ..-. / . / ... / --- / .-.", - "observations": "You hear a series of dots and dashes on the phone. The message is directing you towards finding the villain’s identity. Maybe the first letter would be capitalised." + "voice": ".--. / .-. / --- / ..-. / ..-. / . / ... / --- / .-.", + "sender": "Anonymous Caller", + "timestamp": "Now", + "observations": "You hear a series of dots and dashes on the phone. The message is directing you towards finding the villain's identity. Maybe the first letter would be capitalised." }, { "type": "notes", diff --git a/scenarios/scenario2.json b/scenarios/scenario2.json index 8e4540d..9d79e8e 100644 --- a/scenarios/scenario2.json +++ b/scenarios/scenario2.json @@ -23,7 +23,11 @@ "type": "phone", "name": "Recorded Conversation", "takeable": false, - "observations": "Llamas are all pure evil! Jullie and Tim are the two who started this curse. Tim is 3 years old, and Jullie is 5 years old. Remember their ages!" + "readable": true, + "voice": "Llamas are all pure evil! Jullie and Tim are the two who started this curse. Tim is 3 years old, and Jullie is 5 years old. Remember their ages!", + "sender": "Mayor McFluffins", + "timestamp": "Now", + "observations": "A mysterious recording explaining the curse and the culprits" }, { "type": "notes",