+ const boardElt = document.querySelector(".game");
+ if (this.choices.length > 0 && !!boardElt) //no choices to show at first drawing
+ {
+ const squareWidth = boardElt.offsetWidth / sizeY;
+ const offset = [boardElt.offsetTop, boardElt.offsetLeft];
+ const choices = h(
+ 'div',
+ {
+ attrs: { "id": "choices" },
+ 'class': { 'row': true },
+ style: {
+ "top": (offset[0] + (sizeY/2)*squareWidth-squareWidth/2) + "px",
+ "left": (offset[1] + squareWidth*(sizeY - this.choices.length)/2) + "px",
+ "width": (this.choices.length * squareWidth) + "px",
+ "height": squareWidth + "px",
+ },
+ },
+ this.choices.map(m => { //a "choice" is a move
+ return h('div',
+ {
+ 'class': {
+ 'board': true,
+ ['board'+sizeY]: true,
+ },
+ style: {
+ 'width': (100/this.choices.length) + "%",
+ 'padding-bottom': (100/this.choices.length) + "%",
+ },
+ },
+ [h('img',
+ {
+ attrs: { "src": '/images/pieces/' +
+ V.getPpath(m.appear[0].c+m.appear[0].p) + '.svg' },
+ 'class': { 'choice-piece': true },
+ on: {
+ "click": e => { this.play(m); this.choices=[]; },
+ },
+ })
+ ]
+ );
+ })
+ );
+ elementArray.unshift(choices);
+ }