feat: extract conversation data to json

This commit is contained in:
ktyl 2024-07-17 00:22:20 +01:00
parent 350fd00533
commit f19d1f37d7
2 changed files with 27 additions and 42 deletions

20
hester.json Normal file
View File

@ -0,0 +1,20 @@
[
{ "character": 1, "text": "hows space"},
{ "character": 0, "text": "trying to work out if the coffees shit but"},
{ "character": 0, "text": "my sense of taste is just not happening :/"},
{ "character": 1, "text": "maybe you're being spared"},
{ "character": 0, "text": "ur right"},
{ "character": 0, "text": "ship swill is a delicacy to exactly no one"},
{ "character": 0, "text": "at least the caffeine still works"},
{ "character": 1, "text": "lol"},
{ "character": 1, "text": "you probably got your own stash for later though, right?"},
{ "character": 1, "text": "knowing you"},
{ "character": 0, "text": "oh yea i got some on nimbus"},
{ "character": 0, "text": "donchuu worry"},
{ "character": 0, "text": "how about you?"},
{ "character": 0, "text": "new job soon, right?"},
{ "character": 1, "text": "induction tomorrow wish me luckk"},
{ "character": 0, "text": "break a leg!"},
{ "character": 1, "text": ":)"}
]

49
main.js
View File

@ -1,39 +1,3 @@
// how to we communicate...
// * in flight
// * arrived! (probably) <- this is the tricky one. we know enough time has passed for the message
// * received to have been received, but we are only halfway to the earliest possible
// * read acknowledgement.
//
// we know the length of the roundtrip: it is 2x the light lag. progress bars show a passage of time,
// it could scroll:
// * along the bottom of the message
// * across the message
// * as it is being sent, a transluscent red bar grows from right to left (towards their messages)
// * while we are waiting for acknowledgement, a similar blue bar brows from left to right
// * next to the message
messageData = [
// c for character
{ c: 1, text: "hows space"},
{ c: 0, text: "trying to work out if the coffees shit but"},
{ c: 0, text: "my sense of taste is just not happening :/"},
{ c: 1, text: "maybe you're being spared"},
{ c: 0, text: "ur right"},
{ c: 0, text: "ship swill is a delicacy to exactly no one"},
{ c: 0, text: "at least the caffeine still works"},
{ c: 1, text: "lol"},
{ c: 1, text: "you probably got your own stash for later though, right?"},
{ c: 1, text: "knowing you"},
{ c: 0, text: "oh yea i got some on nimbus"},
{ c: 0, text: "donchuu worry"},
{ c: 0, text: "how about you?"},
{ c: 0, text: "new job soon, right?"},
{ c: 1, text: "induction tomorrow wish me luckk"},
{ c: 0, text: "break a leg!"},
{ c: 1, text: ":)"}
];
let pings = 0;
const startTime = Date.now();
var conversation = null;
@ -199,7 +163,7 @@ class Conversation {
if (!messageData)
return false;
return messageData.c == 0;
return messageData.character == 0;
}
}
@ -348,11 +312,11 @@ function getRandomDelay(min, max) {
function updateChat(message) {
addMessage(message);
document.getElementById("textbox-input").value = conversation.getTypedMessageText();
const previewText = conversation.getTypedMessageText();
document.getElementById("textbox-input").value = previewText;
updatePings();
}
function pressSendButton() {
// we have interacted with the page so remove all pings
clearPings();
@ -380,7 +344,7 @@ function onMessageSent(message) {
updateChat(message);
}
function init() {
function init(messageData) {
conversation = new Conversation(messageData, "Hester Gomez", onMessageReceived, onMessageSent);
conversation.start();
@ -390,5 +354,6 @@ function init() {
startLightLagUpdateLoop();
}
init();
fetch("hester.json")
.then(response => response.json())
.then(json => init(json));