This commit is contained in:
Flummi 2018-08-06 20:49:02 +02:00
parent 39dff70a1b
commit 975dcb9919
2 changed files with 14 additions and 7 deletions

View File

@ -33,13 +33,11 @@ const dragEnd = e => {
(last.val + 1 === from.val ? to : pile).push(from);
if(last.val + 1 === 12) {
console.log(from.val);
render.mainstack[mpileid] = [];
console.log(render.mainstack);
}
if(last.val + 1 === 12)
render.mainstack[mpileid].length = 0; // clear stack
render.renderAll();
render.render(render.stackables.getName(parseInt(pstack.slice(-1))));
render.renderMain();
//dropto.insertAdjacentHTML("beforeend", `<div class="card_outer" data-val="${activeElement.dataset.val}">${activeElement.innerHTML}</div>`);
//activeElement.parentNode.removeChild(activeElement);

View File

@ -19,6 +19,8 @@ export const clearAll = () => {
};
export const render = player => {
console.log(`render ${player}`);
clear(player);
const _player = stackables.get(player);
document.querySelector(`#player${_player.id}_name`).innerHTML = player.toString();
_player.pile.forEach((slots, slotid) => {
@ -31,6 +33,8 @@ export const render = player => {
events.createCardEvents();
};
export const renderMain = () => {
console.log("render Main");
clearMain();
mainstack.forEach((cards, slotid) => {
cards.forEach(card => {
document.querySelector(`#mainstock_pile_slot_${slotid}`).insertAdjacentHTML("beforeend",
@ -40,7 +44,7 @@ export const renderMain = () => {
});
};
export const renderAll = () => {
clearAll();
//clearAll();
stackables.forEach((e, player) => render(player));
renderMain();
};
@ -50,3 +54,8 @@ Map.prototype.getID = function(id) {
if(val.id === id)
return val;
};
Map.prototype.getName = function(id) {
for(let [key, val] of this.entries())
if(val.id === id)
return key;
};