Kaydet (Commit) a5644fea authored tarafından Tuğba Fıçıcı's avatar Tuğba Fıçıcı

Boncuk dağıtımı eklendi.

üst 10e7c3c9
This diff is collapsed.
......@@ -10,7 +10,7 @@
<body>
<div class="container">
<div id="user1hole7" class="rectangle" onclick="tikla(this.id)">hazine</div>
<div id="user1hole7" class="rectangle">hazine</div>
<div class="circle_container">
<div class="circle_wrap">
<div class="cirlce" onclick="tikla(this.id)" id="user1hole6">
......@@ -91,7 +91,7 @@
</div>
</div>
<div id="user2hole7" class="rectangle" onclick="tikla(this.id)">hazine</div>
<div id="user2hole7" class="rectangle">hazine</div>
</div>
......
class Hole {
constructor(value,id) {
this.id=id;
this.value = 4;
this.value = value;
}
}
......@@ -20,20 +21,111 @@ var treasure1=new Hole(0,"user1hole7");
var treasure2=new Hole(0,"user2hole7");
user1hole.push(treasure1);
user2hole.push(treasure2);
var player=1;
let player=1;
function tikla(id){
if(Number(id[4])==1 && player==Number(id[4])){
console.log(user1hole[Number(id[9])-1].id);
dagit(Number(id[4]),Number(id[9]));
}else if(Number(id[4])==1 && player==Number(id[4])){
console.log(user2hole[Number(id[9])-1].id);
}else if(Number(id[4])==2 && player==Number(id[4])){
console.log(id[4]);
dagit(Number(id[4]),Number(id[9]));
}
boncukCiz();
console.log(user1hole);
console.log(user2hole);
}
function dagit(user,hole){
let holeID=hole-1;
if(user==1){
if(user1hole[holeID].value==1){
user1hole[holeID].value=0;
user1hole[holeID+1].value+=1;
}else if(user1hole[holeID].value>0){
let count=user1hole[holeID].value-1;
user1hole[holeID].value=1;
holeID++;
let i=0;
let sira=1;
while(i<count){
if(holeID==7){
holeID=0;
sira*=-1;
}
if(sira==1){
user1hole[holeID].value+=1;
}else if(sira==-1){
user2hole[holeID].value+=1;
}
holeID+=1;
i++;
}
}
}else if(user==2){
if(user2hole[holeID].value==1){
user2hole[holeID].value=0;
user2hole[holeID+1].value+=1;
}else if(user2hole[holeID].value>0){
let count=user2hole[holeID].value-1;
user2hole[holeID].value=1;
holeID++;
let i=0;
let sira=1;
while(i<count){
if(holeID==7){
holeID=0;
sira*=-1;
}
if(sira==1){
user2hole[holeID].value+=1;
}else if(sira==-1){
user1hole[holeID].value+=1;
}
holeID+=1;
i++;
}
}
}
}
function boncukCiz(){
//user1hole
for(let i=0;i<7;i++){
var node = document.getElementById(user1hole[i].id);
node.innerHTML = "";
let j=0
while(j<user1hole[i].value){
var dot = document.createElement("span");
dot.className="dot_black";
node.appendChild(dot);
j++;
}
}
//user2hole
for(let i=0;i<7;i++){
var node = document.getElementById(user2hole[i].id);
node.innerHTML = "";
let j=0
while(j<user2hole[i].value){
var dot = document.createElement("span");
dot.className="dot_black";
node.appendChild(dot);
j++;
}
}
}
var clicks = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment