Skip to content

Commit

Permalink
new change
Browse files Browse the repository at this point in the history
  • Loading branch information
sanchitrathore2004 committed May 22, 2024
1 parent 7149e03 commit d8b8775
Show file tree
Hide file tree
Showing 7 changed files with 211 additions and 11 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
</div>
<div class="rowup">
<div id="box17" class="dabba"></div>
<div id="box18" class="dabba semirico red">SEMIRICO</div>
<div id="box19" class="dabba rico red">RICO</div>
<div id="box18" class="dabba semirico red"><span class="rotatee">SEMIRICO</span></div>
<div id="box19" class="dabba rico red"><span class="rotatee">RICO</span></div>
<div id="box20" class="dabba"></div>
<div id="box21" class="dabba"></div>
<div id="box22" class="dabba"></div>
Expand Down Expand Up @@ -69,8 +69,8 @@
<div id="box43" class="dabba"></div>
<div id="box44" class="dabba"></div>
<div id="box45" class="dabba"></div>
<div id="box46" class="dabba semirico aqua">SEMIRICO</div>
<div id="box47" class="dabba rico aqua">RICO</div>
<div id="box46" class="dabba semirico aqua"><span class="rotatee">SEMIRICO</span></div>
<div id="box47" class="dabba rico aqua"><span class="rotatee">RICO</span></div>
<div id="box48" class="dabba"></div>
</div>
<div class="rowdown">
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions rules.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// import { arr, rotateObjLeft, rotateObjRight } from "./scriptAll.js";
// import { colarr } from "./supportScript.js";

// let turn = "aqua";
// let classy;
// let identify;
// let red=[];
// let IDD;
// let aqua=[];
// let i=0;
// let j=0;


// export function switchTurn() {
// for(let k=0;k<arr.length;k++)
// {
// console.log("function chala");
// if(arr[k])
// {
// classy=arr[k].className;
// console.log(classy);
// identify=classy.split(" ");
// console.log(identify);
// if(identify[2]=="red")
// {
// red[i]=k;
// i++;
// }
// else if(identify[2]=="aqua")
// {
// aqua[j]=k;
// j++;
// }
// }
// }
// console.log(red);
// }
11 changes: 8 additions & 3 deletions scriptAll.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Movement } from "./supportScript.js";
import { Movement, switchTurn} from "./supportScript.js";
// import { switchTurn } from "./.js";

let dabba8 = document.querySelectorAll(".dabba8");
console.log(dabba8);
Expand All @@ -17,6 +18,9 @@ export let arr=[];
export let info ;
export let posPiece;

export let rotateObjLeft = document.querySelector(".left");
export let rotateObjRight = document.querySelector(".right");

export let brr= [];
export function callFunc(){
for(let i=0;i<=64;i++)
Expand All @@ -26,8 +30,9 @@ for(let i=0;i<=64;i++)
{
posPiece = arr[i];
arr[i].addEventListener("click", Movement);

}
}

}
callFunc();
callFunc();
switchTurn();
46 changes: 46 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,52 @@
cursor: pointer;
overflow: auto;
}

.semirico,
.rico{
text-decoration: underline;

}
.rico.red > span{
transform: rotate(45deg);
background-color: #000000;
color: white;
border-radius: 3px;
width: 90px;
text-decoration: underline;
text-align: center;
height: 20px;
}
.semirico.red > span{
transform: rotate(-45deg);
background-color: black;
color: white;
border-radius: 3px;
width: 90px;
text-decoration: underline;
text-align: center;
height: 20px;
}
.rico.aqua > span{
transform: rotate(135deg);
background-color: black;
color: white;
border-radius: 3px;
width: 90px;
height: 20px;
text-align: center;
text-decoration: underline;
}
.semirico.aqua > span{
transform: rotate(-135deg);
background-color: black;
color: white;
border-radius: 3px;
width: 90px;
text-decoration: underline;
text-align: center;
height: 20px;
}
#box8,
#box14,
#box4,
Expand Down
120 changes: 116 additions & 4 deletions supportScript.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { arr, callFunc, posPiece, rotation } from "./scriptAll.js";
import { arr, callFunc, posPiece, rotation, rotateObjLeft, rotateObjRight } from "./scriptAll.js";
let red=[];
let aqua=[];
var turn="aqua";
let i=0;
let j=0;
let brr=[];
let ID;
let html;
let classTitle;
let colour;
let colarr;
export let colarr;
let crr = [];
let flag=0;
export function Movement(){
Expand All @@ -20,12 +25,14 @@ classTitle= this.className;
colarr=classTitle.split(" ");
colour=colarr[2];
console.log(colour);
arr[ID].innerHTML=`*${html}`;
// arr[ID].innerHTML=`*${html}`;
arr[ID].style.backgroundColor="cornsilk";
console.log(colarr[1]);
if(colarr[1]=="semirico" || colarr[1]=="rico")
{
rotation.classList.add("rico");
rotateObjLeft.addEventListener("click", rotate);
rotateObjRight.addEventListener("click", rotate);
flag=1;
}
if(colarr[1]=="CANON")
Expand Down Expand Up @@ -113,6 +120,7 @@ for (let i=0;i<brr.length;i++) {
this.innerHTML = html;
if(flag=1)
{
// rotateObjLeft.addEventListener("click", rotateLeft);
rotation.classList.remove("rico");
}
console.log(html);
Expand All @@ -135,6 +143,7 @@ for (let i=0;i<brr.length;i++) {
console.log(this.className);
removeTankListener(this);
callFunc();
switchTurn();

}

Expand All @@ -147,4 +156,107 @@ for (let i=0;i<brr.length;i++) {
}

}
}
}

let rotationAngle=0;

function rotate () {
if(colarr[1]=="semirico" && colarr[2]=="red")
{
rotationAngle=-45;
}
else if (colarr[1]=="rico" && colarr[2]=="red")
{
rotationAngle=45;
}
else if (colarr[1]=="rico" && colarr[2]=="aqua")
{
rotationAngle=135;
}
else if (colarr[1]=="semirico" && colarr[2]=="aqua")
{
rotationAngle=-135;
}
if(rotateObjLeft.innerHTML=="LEFT")
{
rotationAngle += 90; // Increase the angle by 45 degrees
arr[ID].querySelector(".rotatee").style.transform = `rotate(${rotationAngle}deg)`;
}
else if (rotateObjRight.innerHTML=="RIGHT")
{
rotationAngle += -90; // Increase the angle by 45 degrees
arr[ID].querySelector(".rotatee").style.transform = `rotate(${rotationAngle}deg)`;
}
rotation.classList.remove("rico");
brr = [arr[ID-1],arr[ID+1],arr[ID-7],arr[ID-8],arr[ID-9],arr[ID+7],arr[ID+8],arr[ID+9]];
for (const e of brr) {
if(e.innerHTML=="")
{
e.style.backgroundColor="cornsilk";
}
}
arr[ID].style.backgroundColor=`${colour}`;
}


export function switchTurn() {
for(let k=0;k<arr.length;k++)
if(arr[k] && arr[k].innerHTML!=="")
{
var classy=arr[k].className;
var identify=classy.split(" ");
if(identify[2]=="red")
{
red[i]=k;
i++
}
else if (identify[2]=="aqua")
{
aqua[j]=k;
j++
}
}
console.log(`red=${red}`);
console.log(`aqua=${aqua}`);
console.log(turn);
if(turn=="aqua")
{
for (const a of aqua) {
enableDiv(arr[a]);
}
for (const r of red) {
disableDiv(arr[r]);
}
turn = "red";
}
else if (turn == "red")
{
for (const r of red) {
enableDiv(arr[r]);
}
for (const a of aqua) {
disableDiv(arr[a]);
}
turn = "aqua";
}

}




function disableDiv(div) {
div.addEventListener('click', preventInteraction, true);
div.style.opacity = '0.8'; // Optional: visual feedback
}

function enableDiv(div) {
div.removeEventListener('click', preventInteraction, true);
div.style.opacity = ''; // Optional: visual feedback
}

function preventInteraction(event) {
event.stopPropagation();
event.preventDefault();
}

0 comments on commit d8b8775

Please sign in to comment.