generated from snakemode/vite-typescript-azure-functions
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathscript.ts
52 lines (40 loc) · 1.19 KB
/
script.ts
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
import { Game } from "./games/rps/Game";
import { GameEndSummary } from "./games/IGame";
import { GameRunner } from "./games/GameRunner";
import { ArcadeUI } from "./ArcadeUI";
import { HubSpotUi } from "./HubSpotUi";
console.log("Oh hai! 🖤");
const requireSignup = true;
const arcadeInstanceId = "non-conf";
const arcadeUi = new ArcadeUI(arcadeInstanceId);
let runner: GameRunner = null;
arcadeUi.spectateButton.addEventListener("click", () => {
HubSpotUi.hideForm();
startGame(true);
arcadeUi.showGame(true);
});
if (requireSignup) {
HubSpotUi.createForm((form) => {
HubSpotUi.hideForm();
// (╯°□°)╯︵ ┻━┻
const username = form.data.data[0].value;
arcadeUi.setPlayerName(`${username}`);
startGame();
arcadeUi.showGame();
});
} else {
HubSpotUi.hideForm();
startGame();
arcadeUi.showGame();
}
async function startGame(spectator: boolean = false) {
if (runner) {
runner.stop();
}
const game = new Game(arcadeInstanceId, arcadeUi.gameRoot, spectator);
await game.loadMap();
runner = new GameRunner(game);
runner.run(arcadeUi.playerName);
arcadeUi.bind(runner);
}
export { };