@mnbroatch/boardgame.io 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +102 -0
- package/ai/package.json +7 -0
- package/client/package.json +7 -0
- package/core/package.json +7 -0
- package/debug/package.json +7 -0
- package/dist/boardgameio.es.js +14238 -0
- package/dist/boardgameio.js +14277 -0
- package/dist/boardgameio.min.js +16 -0
- package/dist/cjs/Debug-9d141c06.js +9586 -0
- package/dist/cjs/ai-e0e8a768.js +377 -0
- package/dist/cjs/ai.js +20 -0
- package/dist/cjs/client-76dec77b.js +258 -0
- package/dist/cjs/client-a22d7500.js +524 -0
- package/dist/cjs/client.js +26 -0
- package/dist/cjs/core.js +52 -0
- package/dist/cjs/debug.js +18 -0
- package/dist/cjs/filter-player-view-bb02e2f6.js +89 -0
- package/dist/cjs/initialize-267fcd69.js +61 -0
- package/dist/cjs/internal.js +25 -0
- package/dist/cjs/master-2904879d.js +320 -0
- package/dist/cjs/master.js +18 -0
- package/dist/cjs/multiplayer.js +23 -0
- package/dist/cjs/plugin-random-7425844d.js +229 -0
- package/dist/cjs/plugins.js +59 -0
- package/dist/cjs/react-native.js +182 -0
- package/dist/cjs/react.js +727 -0
- package/dist/cjs/reducer-16eec232.js +1203 -0
- package/dist/cjs/server.js +4087 -0
- package/dist/cjs/socketio-7a0837eb.js +478 -0
- package/dist/cjs/testing.js +30 -0
- package/dist/cjs/transport-b1874dfa.js +37 -0
- package/dist/cjs/turn-order-b2ff8740.js +1136 -0
- package/dist/cjs/util-fcfd8fb8.js +140 -0
- package/dist/esm/Debug-0141fe2d.js +9577 -0
- package/dist/esm/ai-5c06e761.js +371 -0
- package/dist/esm/ai.js +8 -0
- package/dist/esm/client-2e653027.js +522 -0
- package/dist/esm/client-5f57c3f2.js +255 -0
- package/dist/esm/client.js +16 -0
- package/dist/esm/core.js +40 -0
- package/dist/esm/debug.js +10 -0
- package/dist/esm/filter-player-view-2c6cc96f.js +87 -0
- package/dist/esm/initialize-11d626ca.js +59 -0
- package/dist/esm/internal.js +10 -0
- package/dist/esm/master-fa8f2e43.js +318 -0
- package/dist/esm/master.js +10 -0
- package/dist/esm/multiplayer.js +14 -0
- package/dist/esm/plugin-random-087f861e.js +226 -0
- package/dist/esm/plugins.js +55 -0
- package/dist/esm/react-native.js +173 -0
- package/dist/esm/react.js +716 -0
- package/dist/esm/reducer-c46da7e5.js +1198 -0
- package/dist/esm/socketio-c22ffa65.js +455 -0
- package/dist/esm/testing.js +26 -0
- package/dist/esm/transport-ce07b771.js +35 -0
- package/dist/esm/turn-order-376d315e.js +1091 -0
- package/dist/esm/util-b6147cef.js +135 -0
- package/dist/types/packages/ai.d.ts +5 -0
- package/dist/types/packages/client.d.ts +3 -0
- package/dist/types/packages/core.d.ts +5 -0
- package/dist/types/packages/debug.d.ts +2 -0
- package/dist/types/packages/internal.d.ts +8 -0
- package/dist/types/packages/master.d.ts +2 -0
- package/dist/types/packages/multiplayer.d.ts +3 -0
- package/dist/types/packages/plugins.d.ts +3 -0
- package/dist/types/packages/react-native.d.ts +2 -0
- package/dist/types/packages/react.d.ts +3 -0
- package/dist/types/packages/server.d.ts +6 -0
- package/dist/types/packages/testing.d.ts +1 -0
- package/dist/types/src/ai/ai.d.ts +53 -0
- package/dist/types/src/ai/ai.test.d.ts +1 -0
- package/dist/types/src/ai/bot.d.ts +40 -0
- package/dist/types/src/ai/mcts-bot.d.ts +60 -0
- package/dist/types/src/ai/random-bot.d.ts +27 -0
- package/dist/types/src/client/client.d.ts +104 -0
- package/dist/types/src/client/client.test.d.ts +1 -0
- package/dist/types/src/client/debug/tests/debug.test.d.ts +1 -0
- package/dist/types/src/client/manager.d.ts +61 -0
- package/dist/types/src/client/react.d.ts +75 -0
- package/dist/types/src/client/react.ssr.test.d.ts +4 -0
- package/dist/types/src/client/react.test.d.ts +1 -0
- package/dist/types/src/client/transport/dummy.d.ts +18 -0
- package/dist/types/src/client/transport/local.d.ts +59 -0
- package/dist/types/src/client/transport/local.test.d.ts +1 -0
- package/dist/types/src/client/transport/socketio.d.ts +45 -0
- package/dist/types/src/client/transport/socketio.test.d.ts +1 -0
- package/dist/types/src/client/transport/transport.d.ts +50 -0
- package/dist/types/src/client/transport/transport.test.d.ts +1 -0
- package/dist/types/src/core/action-creators.d.ts +144 -0
- package/dist/types/src/core/action-types.d.ts +10 -0
- package/dist/types/src/core/backwards-compatibility.d.ts +12 -0
- package/dist/types/src/core/constants.d.ts +6 -0
- package/dist/types/src/core/errors.d.ts +15 -0
- package/dist/types/src/core/flow.d.ts +28 -0
- package/dist/types/src/core/flow.test.d.ts +1 -0
- package/dist/types/src/core/game-methods.d.ts +9 -0
- package/dist/types/src/core/game.d.ts +26 -0
- package/dist/types/src/core/game.test.d.ts +1 -0
- package/dist/types/src/core/initialize.d.ts +9 -0
- package/dist/types/src/core/logger.d.ts +2 -0
- package/dist/types/src/core/player-view.d.ts +7 -0
- package/dist/types/src/core/player-view.test.d.ts +1 -0
- package/dist/types/src/core/reducer.d.ts +155 -0
- package/dist/types/src/core/reducer.test.d.ts +1 -0
- package/dist/types/src/core/turn-order.d.ts +179 -0
- package/dist/types/src/core/turn-order.test.d.ts +8 -0
- package/dist/types/src/lobby/client.d.ts +194 -0
- package/dist/types/src/lobby/client.test.d.ts +1 -0
- package/dist/types/src/lobby/connection.d.ts +44 -0
- package/dist/types/src/lobby/connection.test.d.ts +1 -0
- package/dist/types/src/lobby/create-match-form.d.ts +26 -0
- package/dist/types/src/lobby/login-form.d.ts +23 -0
- package/dist/types/src/lobby/match-instance.d.ts +31 -0
- package/dist/types/src/lobby/react.d.ts +113 -0
- package/dist/types/src/lobby/react.ssr.test.d.ts +4 -0
- package/dist/types/src/lobby/react.test.d.ts +1 -0
- package/dist/types/src/master/filter-player-view.d.ts +96 -0
- package/dist/types/src/master/filter-player-view.test.d.ts +1 -0
- package/dist/types/src/master/master.d.ts +94 -0
- package/dist/types/src/master/master.test.d.ts +1 -0
- package/dist/types/src/plugins/events/events.d.ts +54 -0
- package/dist/types/src/plugins/events/events.test.d.ts +1 -0
- package/dist/types/src/plugins/main.d.ts +75 -0
- package/dist/types/src/plugins/main.test.d.ts +1 -0
- package/dist/types/src/plugins/plugin-events.d.ts +5 -0
- package/dist/types/src/plugins/plugin-immer.d.ts +7 -0
- package/dist/types/src/plugins/plugin-immer.test.d.ts +1 -0
- package/dist/types/src/plugins/plugin-log.d.ts +14 -0
- package/dist/types/src/plugins/plugin-log.test.d.ts +1 -0
- package/dist/types/src/plugins/plugin-player.d.ts +29 -0
- package/dist/types/src/plugins/plugin-player.test.d.ts +1 -0
- package/dist/types/src/plugins/plugin-random.d.ts +4 -0
- package/dist/types/src/plugins/plugin-serializable.d.ts +7 -0
- package/dist/types/src/plugins/plugin-serializable.test.d.ts +1 -0
- package/dist/types/src/plugins/random/random.alea.d.ts +19 -0
- package/dist/types/src/plugins/random/random.d.ts +54 -0
- package/dist/types/src/plugins/random/random.test.d.ts +1 -0
- package/dist/types/src/server/api.d.ts +13 -0
- package/dist/types/src/server/api.test.d.ts +1 -0
- package/dist/types/src/server/auth.d.ts +38 -0
- package/dist/types/src/server/auth.test.d.ts +1 -0
- package/dist/types/src/server/cors.d.ts +4 -0
- package/dist/types/src/server/cors.test.d.ts +1 -0
- package/dist/types/src/server/db/base.d.ts +192 -0
- package/dist/types/src/server/db/flatfile.d.ts +44 -0
- package/dist/types/src/server/db/flatfile.test.d.ts +1 -0
- package/dist/types/src/server/db/index.d.ts +4 -0
- package/dist/types/src/server/db/index.test.d.ts +1 -0
- package/dist/types/src/server/db/inmemory.d.ts +43 -0
- package/dist/types/src/server/db/inmemory.test.d.ts +1 -0
- package/dist/types/src/server/db/localstorage.d.ts +7 -0
- package/dist/types/src/server/db/localstorage.test.d.ts +1 -0
- package/dist/types/src/server/index.d.ts +68 -0
- package/dist/types/src/server/index.test.d.ts +1 -0
- package/dist/types/src/server/transport/pubsub/generic-pub-sub.d.ts +6 -0
- package/dist/types/src/server/transport/pubsub/in-memory-pub-sub.d.ts +7 -0
- package/dist/types/src/server/transport/pubsub/in-memory-pub-sub.test.d.ts +1 -0
- package/dist/types/src/server/transport/socketio-simultaneous.test.d.ts +1 -0
- package/dist/types/src/server/transport/socketio.d.ts +65 -0
- package/dist/types/src/server/transport/socketio.test.d.ts +1 -0
- package/dist/types/src/server/util.d.ts +35 -0
- package/dist/types/src/testing/mock-random.d.ts +15 -0
- package/dist/types/src/testing/mock-random.test.d.ts +1 -0
- package/dist/types/src/types.d.ts +387 -0
- package/internal/package.json +7 -0
- package/master/package.json +7 -0
- package/multiplayer/package.json +7 -0
- package/package.json +211 -0
- package/plugins/package.json +7 -0
- package/react/package.json +7 -0
- package/react-native/package.json +7 -0
- package/server/package.json +6 -0
- package/src/ai/ai.test.ts +433 -0
- package/src/ai/ai.ts +84 -0
- package/src/ai/bot.ts +122 -0
- package/src/ai/mcts-bot.ts +331 -0
- package/src/ai/random-bot.ts +20 -0
- package/src/client/client.test.ts +993 -0
- package/src/client/client.ts +588 -0
- package/src/client/debug/Debug.svelte +239 -0
- package/src/client/debug/Menu.svelte +65 -0
- package/src/client/debug/ai/AI.svelte +215 -0
- package/src/client/debug/ai/Options.svelte +48 -0
- package/src/client/debug/info/Info.svelte +22 -0
- package/src/client/debug/info/Item.svelte +24 -0
- package/src/client/debug/log/Log.svelte +157 -0
- package/src/client/debug/log/LogEvent.svelte +149 -0
- package/src/client/debug/log/LogMetadata.svelte +7 -0
- package/src/client/debug/log/PhaseMarker.svelte +27 -0
- package/src/client/debug/log/TurnMarker.svelte +23 -0
- package/src/client/debug/main/ClientSwitcher.svelte +59 -0
- package/src/client/debug/main/Controls.svelte +58 -0
- package/src/client/debug/main/Hotkey.svelte +84 -0
- package/src/client/debug/main/InteractiveFunction.svelte +85 -0
- package/src/client/debug/main/Main.svelte +121 -0
- package/src/client/debug/main/Move.svelte +68 -0
- package/src/client/debug/main/PlayerInfo.svelte +70 -0
- package/src/client/debug/mcts/Action.svelte +22 -0
- package/src/client/debug/mcts/MCTS.svelte +78 -0
- package/src/client/debug/mcts/Table.svelte +98 -0
- package/src/client/debug/tests/JSONTree.mock.svelte +3 -0
- package/src/client/debug/tests/debug.test.ts +183 -0
- package/src/client/debug/utils/shortcuts.js +50 -0
- package/src/client/debug/utils/shortcuts.test.js +49 -0
- package/src/client/manager.ts +177 -0
- package/src/client/react-native.js +136 -0
- package/src/client/react-native.test.js +229 -0
- package/src/client/react.ssr.test.tsx +24 -0
- package/src/client/react.test.tsx +213 -0
- package/src/client/react.tsx +192 -0
- package/src/client/transport/dummy.ts +19 -0
- package/src/client/transport/local.test.ts +353 -0
- package/src/client/transport/local.ts +230 -0
- package/src/client/transport/socketio.test.ts +328 -0
- package/src/client/transport/socketio.ts +210 -0
- package/src/client/transport/transport.test.ts +27 -0
- package/src/client/transport/transport.ts +95 -0
- package/src/core/action-creators.ts +159 -0
- package/src/core/action-types.ts +18 -0
- package/src/core/backwards-compatibility.ts +23 -0
- package/src/core/constants.ts +6 -0
- package/src/core/errors.ts +35 -0
- package/src/core/flow.test.ts +2433 -0
- package/src/core/flow.ts +897 -0
- package/src/core/game-methods.ts +9 -0
- package/src/core/game.test.ts +286 -0
- package/src/core/game.ts +114 -0
- package/src/core/initialize.ts +77 -0
- package/src/core/logger.test.js +90 -0
- package/src/core/logger.ts +18 -0
- package/src/core/player-view.test.ts +50 -0
- package/src/core/player-view.ts +39 -0
- package/src/core/reducer.test.ts +991 -0
- package/src/core/reducer.ts +532 -0
- package/src/core/turn-order.test.ts +1123 -0
- package/src/core/turn-order.ts +473 -0
- package/src/lobby/client.test.ts +385 -0
- package/src/lobby/client.ts +358 -0
- package/src/lobby/connection.test.ts +207 -0
- package/src/lobby/connection.ts +162 -0
- package/src/lobby/create-match-form.tsx +122 -0
- package/src/lobby/login-form.tsx +75 -0
- package/src/lobby/match-instance.tsx +135 -0
- package/src/lobby/react.ssr.test.tsx +22 -0
- package/src/lobby/react.test.tsx +594 -0
- package/src/lobby/react.tsx +402 -0
- package/src/master/filter-player-view.test.ts +381 -0
- package/src/master/filter-player-view.ts +102 -0
- package/src/master/master.test.ts +1068 -0
- package/src/master/master.ts +492 -0
- package/src/plugins/events/events.test.ts +108 -0
- package/src/plugins/events/events.ts +209 -0
- package/src/plugins/main.test.ts +411 -0
- package/src/plugins/main.ts +314 -0
- package/src/plugins/plugin-events.ts +40 -0
- package/src/plugins/plugin-immer.test.ts +86 -0
- package/src/plugins/plugin-immer.ts +37 -0
- package/src/plugins/plugin-log.test.ts +37 -0
- package/src/plugins/plugin-log.ts +40 -0
- package/src/plugins/plugin-player.test.ts +172 -0
- package/src/plugins/plugin-player.ts +100 -0
- package/src/plugins/plugin-random.ts +40 -0
- package/src/plugins/plugin-serializable.test.ts +40 -0
- package/src/plugins/plugin-serializable.ts +55 -0
- package/src/plugins/random/random.alea.ts +109 -0
- package/src/plugins/random/random.test.ts +167 -0
- package/src/plugins/random/random.ts +198 -0
- package/src/server/api.test.ts +1699 -0
- package/src/server/api.ts +527 -0
- package/src/server/auth.test.ts +275 -0
- package/src/server/auth.ts +89 -0
- package/src/server/cors.test.ts +121 -0
- package/src/server/cors.ts +7 -0
- package/src/server/db/base.ts +296 -0
- package/src/server/db/flatfile.test.ts +221 -0
- package/src/server/db/flatfile.ts +228 -0
- package/src/server/db/index.test.ts +8 -0
- package/src/server/db/index.ts +12 -0
- package/src/server/db/inmemory.test.ts +143 -0
- package/src/server/db/inmemory.ts +143 -0
- package/src/server/db/localstorage.test.ts +73 -0
- package/src/server/db/localstorage.ts +44 -0
- package/src/server/index.test.ts +265 -0
- package/src/server/index.ts +175 -0
- package/src/server/transport/pubsub/generic-pub-sub.ts +11 -0
- package/src/server/transport/pubsub/in-memory-pub-sub.test.ts +47 -0
- package/src/server/transport/pubsub/in-memory-pub-sub.ts +28 -0
- package/src/server/transport/socketio-simultaneous.test.ts +603 -0
- package/src/server/transport/socketio.test.ts +303 -0
- package/src/server/transport/socketio.ts +279 -0
- package/src/server/util.ts +85 -0
- package/src/testing/mock-random.test.ts +45 -0
- package/src/testing/mock-random.ts +27 -0
- package/src/types.ts +511 -0
- package/testing/package.json +7 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
export let client;
|
|
3
|
+
|
|
4
|
+
import { getContext, onDestroy } from 'svelte';
|
|
5
|
+
|
|
6
|
+
const { secondaryPane } = getContext('secondaryPane');
|
|
7
|
+
|
|
8
|
+
import { CreateGameReducer } from '../../../core/reducer';
|
|
9
|
+
import TurnMarker from './TurnMarker.svelte';
|
|
10
|
+
import PhaseMarker from './PhaseMarker.svelte';
|
|
11
|
+
import LogEvent from './LogEvent.svelte';
|
|
12
|
+
import MCTS from '../mcts/MCTS.svelte';
|
|
13
|
+
|
|
14
|
+
const reducer = CreateGameReducer({ game: client.game });
|
|
15
|
+
const initialState = client.getInitialState();
|
|
16
|
+
let { log } = $client;
|
|
17
|
+
let pinned = null;
|
|
18
|
+
|
|
19
|
+
function rewind(logIndex) {
|
|
20
|
+
let state = initialState;
|
|
21
|
+
for (let i = 0; i < log.length; i++) {
|
|
22
|
+
const { action, automatic } = log[i];
|
|
23
|
+
|
|
24
|
+
if (!automatic) {
|
|
25
|
+
state = reducer(state, action);
|
|
26
|
+
|
|
27
|
+
if (logIndex == 0) {
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
logIndex--;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return { G: state.G, ctx: state.ctx, plugins: state.plugins };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function OnLogClick(e) {
|
|
38
|
+
const { logIndex } = e.detail;
|
|
39
|
+
const state = rewind(logIndex);
|
|
40
|
+
const renderedLogEntries = log.filter(e => !e.automatic);
|
|
41
|
+
client.overrideGameState(state);
|
|
42
|
+
|
|
43
|
+
if (pinned == logIndex) {
|
|
44
|
+
pinned = null;
|
|
45
|
+
secondaryPane.set(null);
|
|
46
|
+
} else {
|
|
47
|
+
pinned = logIndex;
|
|
48
|
+
const { metadata } = renderedLogEntries[logIndex].action.payload;
|
|
49
|
+
if (metadata) {
|
|
50
|
+
secondaryPane.set({ component: MCTS, metadata });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function OnMouseEnter(e) {
|
|
56
|
+
const { logIndex } = e.detail;
|
|
57
|
+
if (pinned === null) {
|
|
58
|
+
const state = rewind(logIndex);
|
|
59
|
+
client.overrideGameState(state);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function OnMouseLeave() {
|
|
64
|
+
if (pinned === null) {
|
|
65
|
+
client.overrideGameState(null);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function Reset() {
|
|
70
|
+
pinned = null;
|
|
71
|
+
client.overrideGameState(null);
|
|
72
|
+
secondaryPane.set(null);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
onDestroy(Reset);
|
|
76
|
+
|
|
77
|
+
function OnKeyDown(e) {
|
|
78
|
+
// ESC.
|
|
79
|
+
if (e.keyCode == 27) {
|
|
80
|
+
Reset();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
let renderedLogEntries;
|
|
85
|
+
let turnBoundaries = {};
|
|
86
|
+
let phaseBoundaries = {};
|
|
87
|
+
|
|
88
|
+
$: {
|
|
89
|
+
log = $client.log;
|
|
90
|
+
renderedLogEntries = log.filter(e => !e.automatic);
|
|
91
|
+
|
|
92
|
+
let eventsInCurrentPhase = 0;
|
|
93
|
+
let eventsInCurrentTurn = 0;
|
|
94
|
+
|
|
95
|
+
turnBoundaries = {};
|
|
96
|
+
phaseBoundaries = {};
|
|
97
|
+
|
|
98
|
+
for (let i = 0; i < renderedLogEntries.length; i++) {
|
|
99
|
+
const { action, payload, turn, phase } = renderedLogEntries[i];
|
|
100
|
+
|
|
101
|
+
eventsInCurrentTurn++;
|
|
102
|
+
eventsInCurrentPhase++;
|
|
103
|
+
|
|
104
|
+
if (
|
|
105
|
+
i == renderedLogEntries.length - 1 ||
|
|
106
|
+
renderedLogEntries[i + 1].turn != turn
|
|
107
|
+
) {
|
|
108
|
+
turnBoundaries[i] = eventsInCurrentTurn;
|
|
109
|
+
eventsInCurrentTurn = 0;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (
|
|
113
|
+
i == renderedLogEntries.length - 1 ||
|
|
114
|
+
renderedLogEntries[i + 1].phase != phase
|
|
115
|
+
) {
|
|
116
|
+
phaseBoundaries[i] = eventsInCurrentPhase;
|
|
117
|
+
eventsInCurrentPhase = 0;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
</script>
|
|
122
|
+
|
|
123
|
+
<style>
|
|
124
|
+
.gamelog {
|
|
125
|
+
display: grid;
|
|
126
|
+
grid-template-columns: 30px 1fr 30px;
|
|
127
|
+
grid-auto-rows: auto;
|
|
128
|
+
grid-auto-flow: column;
|
|
129
|
+
}
|
|
130
|
+
</style>
|
|
131
|
+
|
|
132
|
+
<svelte:window on:keydown={OnKeyDown}/>
|
|
133
|
+
|
|
134
|
+
<div class="gamelog" class:pinned>
|
|
135
|
+
{#each renderedLogEntries as { turn }, i}
|
|
136
|
+
{#if i in turnBoundaries}
|
|
137
|
+
<TurnMarker {turn} numEvents={turnBoundaries[i]} />
|
|
138
|
+
{/if}
|
|
139
|
+
{/each}
|
|
140
|
+
|
|
141
|
+
{#each renderedLogEntries as { action, metadata }, i}
|
|
142
|
+
<LogEvent
|
|
143
|
+
pinned={i === pinned}
|
|
144
|
+
logIndex={i}
|
|
145
|
+
on:click={OnLogClick}
|
|
146
|
+
on:mouseenter={OnMouseEnter}
|
|
147
|
+
on:mouseleave={OnMouseLeave}
|
|
148
|
+
{action}
|
|
149
|
+
{metadata} />
|
|
150
|
+
{/each}
|
|
151
|
+
|
|
152
|
+
{#each renderedLogEntries as { phase }, i}
|
|
153
|
+
{#if i in phaseBoundaries}
|
|
154
|
+
<PhaseMarker {phase} numEvents={phaseBoundaries[i]} />
|
|
155
|
+
{/if}
|
|
156
|
+
{/each}
|
|
157
|
+
</div>
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
export let logIndex;
|
|
3
|
+
export let action;
|
|
4
|
+
export let pinned;
|
|
5
|
+
export let metadata;
|
|
6
|
+
export let metadataComponent;
|
|
7
|
+
|
|
8
|
+
import LogMetadata from './LogMetadata.svelte';
|
|
9
|
+
import { createEventDispatcher } from 'svelte';
|
|
10
|
+
|
|
11
|
+
const dispatch = createEventDispatcher();
|
|
12
|
+
|
|
13
|
+
const args = action.payload.args;
|
|
14
|
+
const renderedArgs = Array.isArray(args)
|
|
15
|
+
? args.map(arg => JSON.stringify(arg, null, 2)).join(',')
|
|
16
|
+
: JSON.stringify(args, null, 2) || '';
|
|
17
|
+
const playerID = action.payload.playerID;
|
|
18
|
+
let actionType;
|
|
19
|
+
switch (action.type) {
|
|
20
|
+
case 'UNDO':
|
|
21
|
+
actionType = 'undo';
|
|
22
|
+
break;
|
|
23
|
+
case 'REDO':
|
|
24
|
+
actionType = 'redo';
|
|
25
|
+
case 'GAME_EVENT':
|
|
26
|
+
case 'MAKE_MOVE':
|
|
27
|
+
default:
|
|
28
|
+
actionType = action.payload.type;
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<style>
|
|
34
|
+
.log-event {
|
|
35
|
+
grid-column: 2;
|
|
36
|
+
cursor: pointer;
|
|
37
|
+
overflow: hidden;
|
|
38
|
+
display: flex;
|
|
39
|
+
flex-direction: column;
|
|
40
|
+
justify-content: center;
|
|
41
|
+
background: #fff;
|
|
42
|
+
border: 1px dotted #ccc;
|
|
43
|
+
border-left: 5px solid #ccc;
|
|
44
|
+
padding: 5px;
|
|
45
|
+
text-align: center;
|
|
46
|
+
color: #666;
|
|
47
|
+
font-size: 14px;
|
|
48
|
+
min-height: 25px;
|
|
49
|
+
line-height: 25px;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.log-event:hover,
|
|
53
|
+
.log-event:focus {
|
|
54
|
+
border-style: solid;
|
|
55
|
+
background: #eee;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.log-event.pinned {
|
|
59
|
+
border-style: solid;
|
|
60
|
+
background: #eee;
|
|
61
|
+
opacity: 1;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.args {
|
|
65
|
+
text-align: left;
|
|
66
|
+
white-space: pre-wrap;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.player0 {
|
|
70
|
+
border-left-color: #ff851b;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.player1 {
|
|
74
|
+
border-left-color: #7fdbff;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.player2 {
|
|
78
|
+
border-left-color: #0074d9;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.player3 {
|
|
82
|
+
border-left-color: #39cccc;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.player4 {
|
|
86
|
+
border-left-color: #3d9970;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.player5 {
|
|
90
|
+
border-left-color: #2ecc40;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.player6 {
|
|
94
|
+
border-left-color: #01ff70;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.player7 {
|
|
98
|
+
border-left-color: #ffdc00;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.player8 {
|
|
102
|
+
border-left-color: #001f3f;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.player9 {
|
|
106
|
+
border-left-color: #ff4136;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.player10 {
|
|
110
|
+
border-left-color: #85144b;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.player11 {
|
|
114
|
+
border-left-color: #f012be;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.player12 {
|
|
118
|
+
border-left-color: #b10dc9;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.player13 {
|
|
122
|
+
border-left-color: #111111;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.player14 {
|
|
126
|
+
border-left-color: #aaaaaa;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.player15 {
|
|
130
|
+
border-left-color: #dddddd;
|
|
131
|
+
}
|
|
132
|
+
</style>
|
|
133
|
+
|
|
134
|
+
<button
|
|
135
|
+
class="log-event player{playerID}"
|
|
136
|
+
class:pinned
|
|
137
|
+
on:click={() => dispatch('click', { logIndex })}
|
|
138
|
+
on:mouseenter={() => dispatch('mouseenter', { logIndex })}
|
|
139
|
+
on:focus={() => dispatch('mouseenter', { logIndex })}
|
|
140
|
+
on:mouseleave={() => dispatch('mouseleave')}
|
|
141
|
+
on:blur={() => dispatch('mouseleave')}
|
|
142
|
+
>
|
|
143
|
+
<div class="args">{actionType}({renderedArgs})</div>
|
|
144
|
+
{#if metadataComponent}
|
|
145
|
+
<svelte:component this={metadataComponent} {metadata} />
|
|
146
|
+
{:else}
|
|
147
|
+
<LogMetadata {metadata} />
|
|
148
|
+
{/if}
|
|
149
|
+
</button>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
export let phase;
|
|
3
|
+
export let numEvents;
|
|
4
|
+
|
|
5
|
+
const style = `grid-row: span ${numEvents}`;
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<style>
|
|
9
|
+
.phase-marker {
|
|
10
|
+
grid-column: 3;
|
|
11
|
+
background: #555;
|
|
12
|
+
border: 1px solid #888;
|
|
13
|
+
color: #eee;
|
|
14
|
+
text-align: center;
|
|
15
|
+
font-weight: bold;
|
|
16
|
+
padding-top: 10px;
|
|
17
|
+
padding-bottom: 10px;
|
|
18
|
+
text-orientation: sideways;
|
|
19
|
+
writing-mode: vertical-rl;
|
|
20
|
+
line-height: 30px;
|
|
21
|
+
width: 100%;
|
|
22
|
+
}
|
|
23
|
+
</style>
|
|
24
|
+
|
|
25
|
+
<div class="phase-marker" style={style}>
|
|
26
|
+
{phase || ''}
|
|
27
|
+
</div>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
export let turn;
|
|
3
|
+
export let numEvents;
|
|
4
|
+
const style = `grid-row: span ${numEvents}`;
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<style>
|
|
8
|
+
.turn-marker {
|
|
9
|
+
display: flex;
|
|
10
|
+
justify-content: center;
|
|
11
|
+
align-items: center;
|
|
12
|
+
grid-column: 1;
|
|
13
|
+
background: #555;
|
|
14
|
+
color: #eee;
|
|
15
|
+
text-align: center;
|
|
16
|
+
font-weight: bold;
|
|
17
|
+
border: 1px solid #888;
|
|
18
|
+
}
|
|
19
|
+
</style>
|
|
20
|
+
|
|
21
|
+
<div class="turn-marker" style={style}>
|
|
22
|
+
{turn}
|
|
23
|
+
</div>
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
export let clientManager;
|
|
3
|
+
|
|
4
|
+
$: ({ client, debuggableClients } = $clientManager);
|
|
5
|
+
$: selected = debuggableClients.indexOf(client);
|
|
6
|
+
|
|
7
|
+
const selectId = 'bgio-debug-select-client';
|
|
8
|
+
const handleSelection = (e) => {
|
|
9
|
+
// Request to switch to the selected client.
|
|
10
|
+
const selectedClient = debuggableClients[e.target.value];
|
|
11
|
+
clientManager.switchToClient(selectedClient);
|
|
12
|
+
// Maintain focus on the client select menu after switching clients.
|
|
13
|
+
// Necessary because switching clients will usually trigger a mount/unmount.
|
|
14
|
+
const select = document.getElementById(selectId);
|
|
15
|
+
if (select) select.focus();
|
|
16
|
+
};
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<style>
|
|
20
|
+
* { box-sizing: border-box; }
|
|
21
|
+
|
|
22
|
+
section.switcher {
|
|
23
|
+
position: sticky;
|
|
24
|
+
bottom: 0;
|
|
25
|
+
transform: translateY(20px);
|
|
26
|
+
margin: 40px -20px 0;
|
|
27
|
+
border-top: 1px solid #999;
|
|
28
|
+
padding: 20px;
|
|
29
|
+
background: #fff;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
label {
|
|
33
|
+
display: flex;
|
|
34
|
+
align-items: baseline;
|
|
35
|
+
gap: 5px;
|
|
36
|
+
font-weight: bold;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
select { min-width: 140px; }
|
|
40
|
+
</style>
|
|
41
|
+
|
|
42
|
+
{#if debuggableClients.length > 1}
|
|
43
|
+
<section class="switcher">
|
|
44
|
+
<label>
|
|
45
|
+
Client
|
|
46
|
+
<!-- svelte-ignore a11y-no-onchange -->
|
|
47
|
+
<select id={selectId} on:change={handleSelection} bind:value={selected}>
|
|
48
|
+
{#each debuggableClients as clientOption, index}
|
|
49
|
+
<option value={index}>
|
|
50
|
+
{index} —
|
|
51
|
+
playerID: {JSON.stringify(clientOption.playerID)},
|
|
52
|
+
matchID: {JSON.stringify(clientOption.matchID)}
|
|
53
|
+
({clientOption.game.name})
|
|
54
|
+
</option>
|
|
55
|
+
{/each}
|
|
56
|
+
</select>
|
|
57
|
+
</label>
|
|
58
|
+
</section>
|
|
59
|
+
{/if}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
export let client;
|
|
3
|
+
export let ToggleVisibility;
|
|
4
|
+
|
|
5
|
+
import Hotkey from './Hotkey.svelte';
|
|
6
|
+
import { sync } from '../../../core/action-creators';
|
|
7
|
+
import { parse, stringify } from 'flatted';
|
|
8
|
+
|
|
9
|
+
function Save() {
|
|
10
|
+
// get state to persist and overwrite deltalog, _undo, and _redo
|
|
11
|
+
const state = client.getState();
|
|
12
|
+
const json = stringify({
|
|
13
|
+
...state,
|
|
14
|
+
_undo: [],
|
|
15
|
+
_redo: [],
|
|
16
|
+
deltalog: [],
|
|
17
|
+
});
|
|
18
|
+
window.localStorage.setItem('gamestate', json);
|
|
19
|
+
window.localStorage.setItem('initialState', stringify(client.initialState));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function Restore() {
|
|
23
|
+
const gamestateJSON = window.localStorage.getItem('gamestate');
|
|
24
|
+
const initialStateJSON = window.localStorage.getItem('initialState');
|
|
25
|
+
if (gamestateJSON !== null && initialStateJSON !== null) {
|
|
26
|
+
const gamestate = parse(gamestateJSON);
|
|
27
|
+
const initialState = parse(initialStateJSON);
|
|
28
|
+
client.store.dispatch(sync({ state: gamestate, initialState }));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<style>
|
|
34
|
+
ul {
|
|
35
|
+
padding-left: 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
li {
|
|
39
|
+
list-style: none;
|
|
40
|
+
margin: 0;
|
|
41
|
+
margin-bottom: 5px;
|
|
42
|
+
}
|
|
43
|
+
</style>
|
|
44
|
+
|
|
45
|
+
<ul id="debug-controls" class="controls">
|
|
46
|
+
<li>
|
|
47
|
+
<Hotkey value="1" onPress={client.reset} label="reset" />
|
|
48
|
+
</li>
|
|
49
|
+
<li>
|
|
50
|
+
<Hotkey value="2" onPress={Save} label="save" />
|
|
51
|
+
</li>
|
|
52
|
+
<li>
|
|
53
|
+
<Hotkey value="3" onPress={Restore} label="restore" />
|
|
54
|
+
</li>
|
|
55
|
+
<li>
|
|
56
|
+
<Hotkey value="." onPress={ToggleVisibility} label="hide" />
|
|
57
|
+
</li>
|
|
58
|
+
</ul>
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
export let value;
|
|
3
|
+
export let onPress = null;
|
|
4
|
+
export let label = null;
|
|
5
|
+
export let disable = false;
|
|
6
|
+
|
|
7
|
+
import { getContext } from 'svelte';
|
|
8
|
+
|
|
9
|
+
const { disableHotkeys } = getContext('hotkeys');
|
|
10
|
+
|
|
11
|
+
let active = false;
|
|
12
|
+
let id = `key-${value}`;
|
|
13
|
+
|
|
14
|
+
function Deactivate() {
|
|
15
|
+
active = false;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function Activate() {
|
|
19
|
+
active = true;
|
|
20
|
+
setTimeout(Deactivate, 200);
|
|
21
|
+
if (onPress) {
|
|
22
|
+
setTimeout(onPress, 1);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function Keypress(e) {
|
|
27
|
+
if (
|
|
28
|
+
!$disableHotkeys && !disable &&
|
|
29
|
+
!e.ctrlKey && !e.metaKey &&
|
|
30
|
+
e.key == value
|
|
31
|
+
) {
|
|
32
|
+
e.preventDefault();
|
|
33
|
+
Activate();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<style>
|
|
39
|
+
.key {
|
|
40
|
+
display: flex;
|
|
41
|
+
flex-direction: row;
|
|
42
|
+
align-items: center;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
button {
|
|
46
|
+
cursor: pointer;
|
|
47
|
+
min-width: 10px;
|
|
48
|
+
padding-left: 5px;
|
|
49
|
+
padding-right: 5px;
|
|
50
|
+
height: 20px;
|
|
51
|
+
line-height: 20px;
|
|
52
|
+
text-align: center;
|
|
53
|
+
border: 1px solid #ccc;
|
|
54
|
+
box-shadow: 1px 1px 1px #888;
|
|
55
|
+
background: #eee;
|
|
56
|
+
color: #444;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
button:hover {
|
|
60
|
+
background: #ddd;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.key.active button {
|
|
64
|
+
background: #ddd;
|
|
65
|
+
border: 1px solid #999;
|
|
66
|
+
box-shadow: none;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
label {
|
|
70
|
+
margin-left: 10px;
|
|
71
|
+
}
|
|
72
|
+
</style>
|
|
73
|
+
|
|
74
|
+
<svelte:window on:keydown={Keypress} />
|
|
75
|
+
|
|
76
|
+
<div class="key" class:active>
|
|
77
|
+
<button {id} on:click={Activate} disabled={disable}>{value}</button>
|
|
78
|
+
{#if label}
|
|
79
|
+
<label for={id}>
|
|
80
|
+
{label}
|
|
81
|
+
<span class="screen-reader-only">{`(shortcut: ${value})`}</span>
|
|
82
|
+
</label>
|
|
83
|
+
{/if}
|
|
84
|
+
</div>
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
export let Activate;
|
|
3
|
+
export let Deactivate;
|
|
4
|
+
export let name;
|
|
5
|
+
export let active;
|
|
6
|
+
let value;
|
|
7
|
+
let span;
|
|
8
|
+
|
|
9
|
+
import { afterUpdate, createEventDispatcher } from 'svelte';
|
|
10
|
+
const dispatch = createEventDispatcher();
|
|
11
|
+
|
|
12
|
+
function Submit() {
|
|
13
|
+
try {
|
|
14
|
+
const value = span.innerText;
|
|
15
|
+
let argArray = new Function(`return [${value}]`)();
|
|
16
|
+
dispatch('submit', argArray);
|
|
17
|
+
} catch (error) {
|
|
18
|
+
dispatch('error', error);
|
|
19
|
+
}
|
|
20
|
+
span.innerText = '';
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function OnKeyDown(e) {
|
|
24
|
+
if (e.key == 'Enter') {
|
|
25
|
+
e.preventDefault();
|
|
26
|
+
Submit();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (e.key == 'Escape') {
|
|
30
|
+
e.preventDefault();
|
|
31
|
+
Deactivate();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
afterUpdate(() => {
|
|
36
|
+
if (active) {
|
|
37
|
+
span.focus();
|
|
38
|
+
} else {
|
|
39
|
+
span.blur();
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<style>
|
|
45
|
+
.move {
|
|
46
|
+
display: flex;
|
|
47
|
+
flex-direction: row;
|
|
48
|
+
cursor: pointer;
|
|
49
|
+
margin-left: 10px;
|
|
50
|
+
color: #666;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.move:hover {
|
|
54
|
+
color: #333;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.move.active {
|
|
58
|
+
color: #111;
|
|
59
|
+
font-weight: bold;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.move-error {
|
|
63
|
+
color: #a00;
|
|
64
|
+
font-weight: bold;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.arg-field {
|
|
68
|
+
outline: none;
|
|
69
|
+
font-family: monospace;
|
|
70
|
+
}
|
|
71
|
+
</style>
|
|
72
|
+
|
|
73
|
+
<div class="move" class:active on:click={Activate}>
|
|
74
|
+
<span>{name}</span>
|
|
75
|
+
<span>(</span>
|
|
76
|
+
<span
|
|
77
|
+
class="arg-field"
|
|
78
|
+
bind:this={span}
|
|
79
|
+
on:focus={Activate}
|
|
80
|
+
on:blur={Deactivate}
|
|
81
|
+
on:keypress|stopPropagation={() => {}}
|
|
82
|
+
on:keydown={OnKeyDown}
|
|
83
|
+
contentEditable />
|
|
84
|
+
<span>)</span>
|
|
85
|
+
</div>
|