Skip to content

Commit

Permalink
pawn move bug fix, theme updated
Browse files Browse the repository at this point in the history
  • Loading branch information
keshavmahawar committed Jul 9, 2020
1 parent 3f85ded commit a52c60b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 17 deletions.
2 changes: 2 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
<title>Chess Board</title>
</head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css">
<link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@400;500;600;700;800;900&display=swap" rel="stylesheet">
<link rel="stylesheet" href="style.css">
<body>
<div class="main-heading">chess Game</div>
<div class="main-div">
<div class="chessBoard">
</div>
Expand Down
20 changes: 11 additions & 9 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function renderPieces(){
}


//----fuctions to claculate all the moveable positions starts here-----
//----functions to calculate all the moveable positions starts here-----

function getDropCutPlaces(piece){
var dropPlaces = []
Expand Down Expand Up @@ -141,11 +141,11 @@ function getPawnPlaces( x, y, dropPlaces, cutPlaces ){
dropPlaces.push( { x: x, y: y } )
}
y++
if( y < 8 && isPlayer2Piece( occupiedBy ) ){
if( y < 8 && isPlayer2Piece( board[x][y].occupied ) ){
cutPlaces.push( { x: x, y: y } )
}
y-=2
if( y > 0 && isPlayer2Piece( occupiedBy ) ){
if( y > 0 && isPlayer2Piece( board[x][y].occupied ) ){
cutPlaces.push( { x: x, y: y } )
}
}
Expand All @@ -158,11 +158,11 @@ function getPawnPlaces( x, y, dropPlaces, cutPlaces ){
dropPlaces.push( { x: x, y: y } )
}
y++
if( y < 8 && isPlayer1Piece( occupiedBy ) ){
if( y < 8 && isPlayer1Piece( board[x][y].occupied ) ){
cutPlaces.push( { x: x, y: y } )
}
y-=2
if( y > 0 && isPlayer1Piece( occupiedBy ) ){
if( y > 0 && isPlayer1Piece( board[x][y].occupied ) ){
cutPlaces.push( { x: x, y: y } )
}
}
Expand Down Expand Up @@ -307,6 +307,7 @@ function occupiedById( x, y ){
return board[x][y].occupied
}

//--future feature
function isKingInDanger( KingPlayer ){
// var kingPosX, kingPosY
// if ( KingPlayer == 1 )
Expand All @@ -317,7 +318,7 @@ function isKingInDanger( KingPlayer ){
// if
}

//higlights all the places where we can cut other player's piece
//highlights all the places where we can cut other player's piece
function activateCutPlaces(arr){
var square, place
for(i in arr)
Expand All @@ -329,7 +330,7 @@ function activateCutPlaces(arr){
}
}

//higlights all the places where we can place our piece
//highlights all the places where we can place our piece
function activateDropPlaces(arr){
var square, place
for(i in arr){
Expand All @@ -340,7 +341,7 @@ function activateDropPlaces(arr){
}
}

//invoke higlighting functions
//invoke highlighting functions
function pick(e){
pieceId = Number(e.target.id)
piece = pieces[ pieceId ]
Expand Down Expand Up @@ -432,7 +433,7 @@ function drop(e){
clearBoard()
}

//clear event listner and classes of chess board divs
//clear event listener and classes of chess board divs
function clearBoard(){
for( i = 0 ; i < 8; i++ ){
for( j = 0 ; j < 8; j++ ){
Expand Down Expand Up @@ -529,6 +530,7 @@ function reset(){
board = []
pieces = []
playerChance = 1
undoMove = null
createBoard()
renderBoard()
createPieces()
Expand Down
29 changes: 21 additions & 8 deletions style.css
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
*{
font-family: Arial, Helvetica, sans-serif;
body{
font-family: 'Orbitron', sans-serif;
background-color: black;
color: white;
}
.main-heading{
text-align: center;
font-size: 40px;
margin: 10px auto;
}
.chessBoard{
display: grid;
border: 1px solid black;
height: 600px;
width: 600px;
height: 550px;
width: 550px;
grid-template-columns: repeat(8, 1fr);
grid-template-rows: repeat(8, 1fr);
}
.chessBoard > div{
text-align: center;
padding: 10px;
background-color: #E6BA8F;
background-color: #DBDBDB;
}
.chessBoard > div:nth-child(16n+1),
.chessBoard > div:nth-child(16n+3),
Expand All @@ -22,13 +29,13 @@
.chessBoard > div:nth-child(16n+12),
.chessBoard > div:nth-child(16n+14),
.chessBoard > div:nth-child(16n+16){
background-color: #BD7D40;
background-color: #639C56;
}
.white{
color: white;
color: #AC2525;
}
.black{
color: black;
color: #2A2A2A;
}
.picked{
background-color: orange !important;
Expand All @@ -44,6 +51,9 @@
display: flex;
align-items: center;
justify-content: space-evenly;
background-color: #30452B;
margin: 5px auto;
width: 90%;
}
.main-div > div {
margin: 20px;
Expand All @@ -57,12 +67,15 @@
}
.stats button{
font-size: 20px;
font-family: 'Orbitron', sans-serif;
padding: 10px 20px;
border: none;
background-color: lime;
color: white;
border-radius: 10px;
}
.stats input{
font-family: 'Orbitron', sans-serif;
font-size: 25px;
padding: 10px;
}
Expand Down

0 comments on commit a52c60b

Please sign in to comment.