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.

This commit is contained in:
Z. Cliffe Schreuders
2025-10-25 23:43:16 +01:00
parent 2e23d50aec
commit 946cae2b16
4 changed files with 14 additions and 60 deletions

View File

@@ -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) {

View File

@@ -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"
},
{

View File

@@ -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 villains 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",

View File

@@ -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",