jakub 9 months ago
parent d59d1f5657
commit ce84eeca1b
  1. 0
      client/css/game.css
  2. 0
      client/css/game.css.map
  3. 0
      client/css/game.scss
  4. 0
      client/css/main.css
  5. 0
      client/css/main.css.map
  6. 0
      client/css/main.scss
  7. 2
      client/index.html
  8. 0
      client/javascript/client.js
  9. 33
      client/javascript/game-logic.js
  10. 25
      client/new.html
  11. 0
      client/resources/pieces/black-basic.svg
  12. 0
      client/resources/pieces/black-queen.svg
  13. 0
      client/resources/pieces/white-basic.svg
  14. 0
      client/resources/pieces/white-queen.svg
  15. 0
      package.json
  16. 1
      server/communication.js

@ -14,7 +14,7 @@
<div id="playfield"></div>
</section>
<script src="./javascript/game-logic.js"></script>
<script src="./javascript/client-only-logic.js">
<script src="./javascript/client.js">
</script>
</body>
</html>

@ -1,10 +1,4 @@
/*
W = Player one basic piece
V = Player one queen piece
B = Player two basic piece
P = Player two queen piece
*/
const pieceList = new Array();
currentPlayer = "white";
@ -144,8 +138,19 @@ function getCasualties(oldX, oldY, newX, newY) {
}
return casualties;
}
function getLoser() {
if (!pieceList.find(pieceRecord => pieceRecord.player == "white")) {
return "white";
}
if (!pieceList.find(pieceRecord => pieceRecord.player == "black")) {
return "black";
}
return null;
}
function continuableInDirectionForQueen(directionX, directionY, pieceRecord) {
console.log("----------------------------------");
const pieceX = pieceRecord.x;
const pieceY = pieceRecord.y;
const player = pieceRecord.player;
@ -155,7 +160,7 @@ function continuableInDirectionForQueen(directionX, directionY, pieceRecord) {
const y = pieceY + (i*directionY);
if(x > 7 || x < 0 || y > 7 || y < 0 || (x+directionX) > 7 || (x+directionX) < 0 || (y+directionY) > 7 || (y+directionY) < 0 ){
console.log("!konec!");
return false;
}
@ -163,13 +168,13 @@ function continuableInDirectionForQueen(directionX, directionY, pieceRecord) {
if (record) {
if (record.player == player) {
console.log("!je to hráč!");
return false;
}
const firstBlockRecord = getPieceRecord(x+directionX,y+directionY);
const secondBlockRecord = getPieceRecord(x-directionX,y-directionY);
console.log("fb: " + firstBlockRecord + secondBlockRecord);
return ((!firstBlockRecord || firstBlockRecord.id == pieceRecord.id) && (!secondBlockRecord || secondBlockRecord.id == pieceRecord.id));
@ -196,8 +201,8 @@ function continuable(pieceRecord){
}
if(type == "queen"){
console.log("Tady to začíná");
return (continuableInDirectionForQueen(1,1,pieceRecord) || continuableInDirectionForQueen(-1,-1,pieceRecord) || continuableInDirectionForQueen(-1,1,pieceRecord) || continuableInDirectionForQueen(-1,-1,pieceRecord));
return (continuableInDirectionForQueen(1,1,pieceRecord) || continuableInDirectionForQueen(-1,-1,pieceRecord) || continuableInDirectionForQueen(-1,1,pieceRecord) || continuableInDirectionForQueen(1,-1,pieceRecord));
}
return false;
@ -238,9 +243,9 @@ function makeMove(pieceRecord, x, y){
nukePieceRecord(casualty);
});
if (casualties.length == 0 && getOportunities(pieceRecord).length != 0) {
/*if (casualties.length == 0 && getOportunities(pieceRecord).length != 0) {
//POTŘREBA DODĚLAT SBÍRÁNÍ DÍLKŮ ZA NESKÁKÁNÍ
}
}*/
if ((player == "white" && y == 7) || (player == "black" && y == 0) && pieceRecord.type == "basic") {

@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>Socket.IO chat</title>
<style>
body { margin: 0; padding-bottom: 3rem; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
#form { background: rgba(0, 0, 0, 0.15); padding: 0.25rem; position: fixed; bottom: 0; left: 0; right: 0; display: flex; height: 3rem; box-sizing: border-box; backdrop-filter: blur(10px); }
#input { border: none; padding: 0 1rem; flex-grow: 1; border-radius: 2rem; margin: 0.25rem; }
#input:focus { outline: none; }
#form > button { background: #333; border: none; padding: 0 1rem; margin: 0.25rem; border-radius: 3px; outline: none; color: #fff; }
#messages { list-style-type: none; margin: 0; padding: 0; }
#messages > li { padding: 0.5rem 1rem; }
#messages > li:nth-child(odd) { background: #efefef; }
</style>
</head>
<body>
<ul id="messages"></ul>
<form id="form" action="">
<input id="input" autocomplete="off" /><button>Send</button>
</form>
</body>
</html>

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

@ -0,0 +1 @@
import { Server } from "socket.io";
Loading…
Cancel
Save