Skip to content

Commit

Permalink
first pass at allbadcards config
Browse files Browse the repository at this point in the history
  • Loading branch information
tannerkrewson committed Sep 13, 2020
1 parent 06e2c16 commit cf540db
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 7 deletions.
57 changes: 57 additions & 0 deletions config/games/allbadcards.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { ServerGame } from "../../types/types";
import { postJson } from "../../utils/utils";

const fetchWithCookies = require("fetch-cookie")(fetch);

const game: ServerGame = {
id: "allbadcards",
name: "All Bad Cards",
author: "Jake Lauer",
basedOn: {
game: "Cards Against Humanity",
link: "https://cardsagainsthumanity.com/",
},
description:
"Be rude. Be irreverent. Be hilarious! Select the card from your hand that you think is best described by a card played by the judge!",
displayUrlText: "allbad.cards",
displayUrlHref: "https://allbad.cards/",
donationUrlText: "Support Jake on Patreon!",
donationUrlHref: "https://www.patreon.com/Allbadcards",
category: ["easy"],
players: "4-20+",
familyFriendly: false,
getJoinGameUrl: async () => {
const { guid } = await fetchWithCookies(
"https://allbad.cards/api/user/register"
).then((res) => res.json());

const { id } = await postJson(
"https://allbad.cards/api/game/create",
{
guid,
nickname: "rocketcrab, leaving in 20 seconds!",
isFamily: false,
isPublic: false,
},
fetchWithCookies
);

setTimeout(() => {
postJson(
"https://allbad.cards/api/game/kick",
{
gameId: id,
targetGuid: guid,
guid: guid,
},
fetchWithCookies
)
.then((a) => console.log(a))
.catch((e) => console.error(e));
}, 20 * 1000);

return { playerURL: "https://allbad.cards/game/" + id };
},
};

export default game;
15 changes: 10 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"body-parser": "^1.19.0",
"cross-env": "^7.0.2",
"express": "^4.17.1",
"fetch-cookie": "^0.10.1",
"fontsource-inconsolata": "^3.0.5",
"next": "^9.5.1",
"nookies": "^2.4.0",
Expand Down
8 changes: 6 additions & 2 deletions utils/utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { PromiseWebSocket } from "../types/types";
import WebSocket from "ws";

export const postJson = (url = "", data = {}): Promise<any> =>
fetch(url, {
export const postJson = (
url = "",
data = {},
customFetch?: (input: RequestInfo, init?: RequestInit) => Promise<Response>
): Promise<any> =>
(customFetch || fetch)(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Expand Down

0 comments on commit cf540db

Please sign in to comment.