Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions config/games/liesgame.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { ServerGame } from "../../types/types";
import { postJson, newPromiseWebSocket } from "../../utils/utils";

const game: ServerGame = {
id: "liesgame",
name: "Lies Game",
author: "Jeff Rubin",
description:
"It’s a game you play with your friends where you make up believable lies, then see if you can get your friends to believe them.",
displayUrlText: "liesgame.com",
displayUrlHref: "https://liesgame.com/",
category: ["medium"],
players: "2-8",
familyFriendly: true,
getJoinGameUrl: async () => {
const {
idToken,
localId,
} = await postJson(
"https://www.googleapis.com/identitytoolkit/v3/relyingparty/signupNewUser?key=AIzaSyAg9jt0OsDMzw8LfC0o4qLevdmjGQjP9d4",
{ returnSecureToken: true }
);

const ws = newPromiseWebSocket(
"wss://believable-lies.firebaseio.com/.ws?v=5"
);
await ws.onOpen();
ws.send(
'{"t":"d","d":{"r":2,"a":"auth","b":{"cred":"' + idToken + '"}}}'
);
ws.send(
'{"t":"d","d":{"r":3,"a":"m","b":{"p":"/prod/users/' +
localId +
'","d":{"online":true,"lastOnlineAt":{".sv":"timestamp"}}}}}'
);
ws.send(
'{"t":"d","d":{"r":4,"a":"om","b":{"p":"/prod/users/' +
localId +
'","d":{"online":null,"lastOnlineAt":{".sv":"timestamp"}}}}}'
);

await ws.onMessage();

const res = await fetch(
"https://us-central1-believable-lies.cloudfunctions.net/prodGame",
{
method: "POST",
headers: {
"Content-Type": "application/json",
authorization: "Bearer " + idToken,
},
body: '{"data":{"op":"createRoom"}}',
}
).then((res) => res.json());

const {
result: { roomCode },
} = res;

return {
playerURL: "https://liesgame.com/game/" + roomCode,
};
},
};

export default game;