Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Readme

Get a response from GPT for the player.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import { getRandomIndex as getRandomIndex2 } from "https://esm.town/v/ktodaz/getRandomIndex";
import { getRandomValue } from "https://esm.town/v/ktodaz/getRandomValue";
import { runVal } from "https://esm.town/v/std/runVal";
export const getGPTResponse = async (
playerName: string,
playerRank: number,
highestPlayer: string,
) => {
const getRandomIndex = getRandomIndex2;
const gpt = async () => {
let message = `${playerName}, you made it to #${playerRank} on the server. `;
if (playerRank == 1) {
if (Math.random() < 0.6) {
return `#1: ${(await runVal("patrickjm.gpt3", {
prompt: getRandomValue([
`Write a short poem about the best hell let loose player named ${playerName}. Hell Let Loose is a WW2 game. Do not include new line characters.`,
`Write a short rap about being the #1 player named ${playerName}. Do not label sections of the song. Do not include new line characters. between versus add a "."`,
`Write a short love letter to the #1 player named ${playerName}. Make the letter from "ChatGPT". End the letter with a surprise insult. Do not include new line characters.`,
]),
}))}`;
}
message += getRandomValue([
"Remember: If you're not first, you're last.",
"Everyone loves you.",
"You are beautiful and amazing.",
"The Hell Let Loose gods have shined upon you today.",
"Don't get too cocky now ;)",
"Time to get outside ;)",
]);
}
if (playerRank == 2) {
if (Math.random() < 0.6) {
return `#2: ${(await runVal("patrickjm.gpt3", {
prompt: getRandomValue([
`Write a short poem about the second best hell let loose player named ${playerName}. The best player is ${highestPlayer}. Hell Let Loose is a WW2 game. Do not include new line characters.`,
`Write a short rap about being the #2 player named ${playerName}. The #1 player is ${highestPlayer}. Do not label sections of the song. Do not include new line characters. between versus add a "."`,
`Write a very short love letter to the #2 player named ${playerName}. The #1 player is ${highestPlayer}. Make the letter from "${highestPlayer}". End the letter with End the letter with a surprise insult. Do not include new line characters.`,
`Write a very short break-up letter to the #2 player named ${playerName}. The #1 player is ${highestPlayer}, who you are pursuing. Make the letter from "ChatGPT". Do not include new line characters. Provide some reasons for the breakup.`,
]),
}))}`;
}
message += getRandomValue([
`${highestPlayer} beat you.`,
`${highestPlayer} is the number one, you are number 2.`,
`Remember: If you're not first, you're last. Especially since ${highestPlayer} is #1`,
"The Hell Let Loose gods have shined upon you today.",
"Don't get too cocky now ;)",
"Time to get outside ;)",
]);
}
if (playerRank <= 3)
message += "Congratulations!";
else if (playerRank <= 6)
message += "GG";
else if (playerRank < 10)
message += getRandomValue([
"Better luck next time!",
"Have a participation award!",
]);
else if (playerRank == 10)
message += getRandomValue([
"You came in dead last of the top players, come on!",
"Have a participation award!",
]);
const randomNumber = Math.random();
if (randomNumber < 0.9) {
// No impersonation, make fun of player
return (await runVal("patrickjm.gpt3", {
prompt:
`Write a funny variation of this message. its sometimes fun to poke fun at the player, especially for their name or score. always include the number in the message. Here is the message ${message}`,
}));
}
else {
// Impersonate random character below
const characters = [
"pirate",
"goblin",
"demon",
"hippie",
"drill sergeant",
"ninja",
"personal trainer",
"participation award giver",
"participation award giver",
"dog",
"cat",
"furry",
"robot",
"golem",
"alien",
"witch",
"cowboy",
"alien",
"viking",
"zombie",
"time traveler",
"mad scientist",
"wild west gunslinger",
"noble knight's squire",
November 21, 2023