forked from gbtami/pychess-variants
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathround.ts
82 lines (77 loc) · 2.76 KB
/
round.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
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
import { h, VNode } from "snabbdom";
import { RoundController } from './roundCtrl';
import { gameInfo } from './gameInfo';
import { renderTimeago } from './datetime';
import { VARIANTS } from './variants';
import { PyChessModel } from "./types";
function runGround(vnode: VNode, model: PyChessModel) {
const el = vnode.elm as HTMLElement;
const ctrl = new RoundController(el, model);
const cg = ctrl.chessground;
window['cg'] = cg;
}
export function roundView(model: PyChessModel): VNode[] {
const variant = VARIANTS[model.variant];
renderTimeago();
return [
h('aside.sidebar-first', [
gameInfo(model),
h('div#roundchat'),
]),
h('div.round-app', [
h(`selection#mainboard.${variant.boardFamily}.${variant.pieceFamily}.${variant.ui.boardMark}`, [
h('div.cg-wrap.' + variant.board.cg, {
hook: {
insert: (vnode) => runGround(vnode, model)
},
}),
]),
h('div.material.material-top.' + variant.pieceFamily + '.disabled'),
h('div.pocket-top', [
h('div.' + variant.pieceFamily + '.' + model["variant"], [
h('div.cg-wrap.pocket', [
h('div#pocket0'),
]),
]),
]),
h('div.info-wrap0', [
h('div.clock-wrap', [
h('div#clock0'),
h('div#more-time'),
h('div#berserk0'),
]),
h('div#misc-info0'),
]),
h('div#expiration-top'),
h('round-player0#rplayer0'),
h('div#move-controls'),
h('div.movelist-block', [
h('div#movelist'),
]),
h('div#offer-dialog'),
h('div#game-controls'),
h('round-player1#rplayer1'),
h('div#expiration-bottom'),
h('div.info-wrap1', [
h('div.clock-wrap', [
h('div#clock1'),
h('div#berserk1'),
]),
h('div#misc-info1'),
]),
h('div.pocket-bot', [
h('div.' + variant.pieceFamily + '.' + model["variant"], [
h('div.cg-wrap.pocket', [
h('div#pocket1'),
]),
]),
]),
h('div.material.material-bottom.' + variant.pieceFamily + '.disabled'),
]),
h('under-left#spectators'),
h('under-board', [
h('div#janggi-setup-buttons'),
h('div.ctable-container'),
]),
];
}