previous

page 31

next
only empty cells should be clickable

Recall that every cell has cn set to zero at the start - this changes when the cell is clicked. So all we have to do in cell_clicked is check whether cn is zero.

function cell_clicked(image) {
var cn=image.getAttribute('cn');
if (cn==0) {
image.src='counters/' + pick + '.png';
image.setAttribute('cn',pick);
var id=image.id;
var row=parseInt(id/5);
var arr=get_cns(row);
var score=worth(arr);
var element=document.getElementById('s' + row);
element.textContent=score;
var col=id % 5;
var arr=get_col_cns(col);
var score=worth(arr);
var element=document.getElementById('s' + (col + 5));
element.textContent=score;
pick=Random(9);
show_pick();
}
}
previous
next