Skip to content

Commit

Permalink
Remove console.log and debuggers
Browse files Browse the repository at this point in the history
  • Loading branch information
Bill-the-dev committed Apr 13, 2022
1 parent 9fafa13 commit 4a73584
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 2,371 deletions.
681 changes: 2 additions & 679 deletions dist/main.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/main.css.map

Large diffs are not rendered by default.

1,609 changes: 2 additions & 1,607 deletions dist/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/main.js.map

Large diffs are not rendered by default.

43 changes: 12 additions & 31 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ document.addEventListener("DOMContentLoaded", () => {

// pawn - select and highlight
addGlobalEventListener("click", "#pawn", e => {
console.log("You clicked a pawn");
// console.log("You clicked a pawn");
let allPawns = document.querySelectorAll("#pawn");
allPawns.forEach(function (pawn) {
if (pawn.classList.contains("active-pawn")) {
Expand All @@ -38,15 +38,15 @@ document.addEventListener("DOMContentLoaded", () => {
e.target.classList.remove("inactive-pawn");
e.target.classList.add("active-pawn");
if (game.checkHighlight()) {
console.log("Check highlight pass");
// console.log("Check highlight pass");
} else {
console.log("Check highlight fail");
// console.log("Check highlight fail");
}
});

// card - select and highlight
addGlobalEventListener("click", ".back", e => {
console.log("You clicked a card");
// console.log("You clicked a card");
let allCards = document.querySelectorAll(".back");
allCards.forEach(function (card) {
card.classList.remove("active-card");
Expand All @@ -55,9 +55,9 @@ document.addEventListener("DOMContentLoaded", () => {
e.target.classList.remove("inactive-card");
e.target.classList.add("active-card");
if (game.checkHighlight()) {
console.log("Check highlight pass");
// console.log("Check highlight pass");
} else {
console.log("Check highlight fail");
// console.log("Check highlight fail");
}

});
Expand All @@ -76,14 +76,14 @@ document.addEventListener("DOMContentLoaded", () => {
// Modal How To on
addGlobalEventListener("click", "#how-to-play", e => {
e.preventDefault();
console.log("on");
// console.log("on");
modalHowTo.classList.add("modal__fill-active");
});

// Modal How To off
modalHowTo.addEventListener("click", e => {
e.preventDefault();
console.log("off");
// console.log("off");
modalHowTo.classList.remove("modal__fill-active");
});

Expand All @@ -95,7 +95,7 @@ document.addEventListener("DOMContentLoaded", () => {
let turnBlueCircle = document.querySelector(".turn-blue-circle")

if (game.activeGame === false) {
console.log("You clicked start");
// console.log("You clicked start");
game.start();

startEle.classList.remove("start-inactive");
Expand All @@ -106,7 +106,7 @@ document.addEventListener("DOMContentLoaded", () => {
turnRedCircle.style.visibility = 'hidden';
turnBlueCircle.style.visibility = 'visible';
} else {
console.log("You clicked end game");
// console.log("You clicked end game");
body.classList.add("turn-null");

setTimeout(() => {
Expand All @@ -123,7 +123,7 @@ document.addEventListener("DOMContentLoaded", () => {
body.classList.add("turn-null");

setTimeout(() => {
console.log('restart')
// console.log('restart')
body.classList.remove("turn-blue");
body.classList.remove("turn-red");
history.go(0);
Expand All @@ -133,23 +133,4 @@ document.addEventListener("DOMContentLoaded", () => {

});

// addGlobalEventListener("click", ".start-active", e => {
// });


// bindEvents() {
// document.querySelectorAll("ul li").forEach((li) => {
// li.addEventListener("click", this.handleClick);
// });
// }

// // Get this:
// addGlobalEventListener("click", "div", e => {
// console.log("hi")
// })
// // From this:
// document.addEventListener("click", e => {
// if (e.target.matches("div")) {
// console.log("you clicked a div");
// }
// })

13 changes: 3 additions & 10 deletions src/scripts/board.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,17 @@ export default class Board {

// win condition shrine
checkWinStream() {
debugger;
let that = this;
let masterRed = document.querySelector(".red-master-piece");
let masterBlue = document.querySelector(".blue-master-piece");
console.log(masterBlue);
console.log(masterRed);
// console.log(masterBlue);
// console.log(masterRed);
if (masterRed.parentElement.id === "[0,2]") {
return ["Red", "Stream"];
} else if (masterBlue.parentElement.id === "[4,2]") {
return ["Blue", "Stream"];
} else {
console.log("nobody wins yet");
// console.log("nobody wins yet");
return false
}
}
Expand Down Expand Up @@ -147,12 +146,6 @@ export default class Board {
this.placePiece([4, 4], pawnR5);

}

sayHi() {
console.log('hiiiiii');
}


}

// export default Board;
Expand Down
3 changes: 1 addition & 2 deletions src/scripts/deck.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export default class Deck {
deal() {
let card = this.getCard();
if (!this.currentCards.includes(card)) {
// debugger
this.viewDealCard(card);
this.viewToggleFlipAll();
this.currentCards.push(card);
Expand All @@ -39,7 +38,7 @@ export default class Deck {
async viewToggleFlipTurn() {
let that = this;
let turnCard = document.querySelector(".move-card .active-card");
// debugger

turnCard.parentElement.classList.toggle("is_flipped")

let deckCard = document.querySelector("#on-deck-card");
Expand Down
50 changes: 10 additions & 40 deletions src/scripts/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export default class Game {
let that = this;
for (let i = 0; i < that.player.hand.length; i++) {
if (that.player.hand[i] === card) { // changed from includes
console.log("ok");
// console.log("ok");
let moves = that.player.hand[i].slice(1);
let possiblePos = [];
for (let j = 0; j < moves.length; j++) {
Expand All @@ -109,14 +109,14 @@ export default class Game {
}
return possiblePos;
} else {
console.log("Card is not in your hand"); // all returning else
// console.log("Card is not in your hand"); // all returning else
}
}
}

oppMoves(moves) { // flips opponent possible pos
let newMoves = [];
console.log(moves);
// console.log(moves);
for (let i = 0; i < moves.length; i++) {
let subArr = [];
for (let j = 0; j < moves[0].length; j++) {
Expand Down Expand Up @@ -146,7 +146,7 @@ export default class Game {
}
return possiblePos;
} else {
console.log("Card is not in your hand");
// console.log("Card is not in your hand");
}
}
}
Expand All @@ -159,25 +159,24 @@ export default class Game {
if (pawn.classList.contains("active-pawn")) {
that.activePawn = pawn;
that.targetPos = that.currentPos(pawn);
console.log("Found active pawn!");
// console.log("Found active pawn!");
}
});

allCards.forEach(function (card) {
if (card.classList.contains("active-card")) {
console.log("Found active card!");
// console.log("Found active card!");
that.activeCard = card;
that.targetCard = that.currentCard(card);
}
});

if (that.activePawn !== null && that.activeCard !== null) {
console.log("Both Active!");
// console.log("Both Active!");
that.targetMoves = that.viewMoves(); // highlight pos
} else {
return false;
}
// debugger
}

// sets game.targetPos in checkHighlight
Expand All @@ -194,7 +193,7 @@ export default class Game {

// sets game.targetCard in checkHighlight
currentCard(cardEl) {
console.log("in currentCard");
// console.log("in currentCard");
let that = this;
let cardStr = cardEl.id.slice(4);
let cardNum = parseInt(cardStr);
Expand All @@ -209,19 +208,16 @@ export default class Game {
let that = this;
let posStart = that.currentPos(that.activePawn);
let posEnd = that.convertStrPos(posEndEle.id);
// debugger;
if (board.grid[posEnd[0]][posEnd[1]] !== null) {
that.board.removePiece(posEnd);
that.board.viewRemovePiece(posEnd); // takes piece
}
that.board.movePiece(posStart, posEnd);
// coded movePiece calls viewPlacePiece
let piece = that.board.getPiece(posEnd); // Piece
// debugger
that.board.viewRemovePiece(posStart); // remove old pos

// WIN CHECK
debugger;
setTimeout(() => {
if (that.checkWin()) {
that.modalWin()
Expand All @@ -235,14 +231,13 @@ export default class Game {
}

async viewSwapUsedCard(playedCardEl, deckCardEl) {
console.log("in swap used");
// console.log("in swap used");
let that = this;
let currentHand = that.player.hand;
let playedCard = that.currentCard(playedCardEl);
let deckCard = that.onDeckCard;
let playedCardIdx = null;
for (let i = 0; i < currentHand.length; i++) {
// debugger
if (playedCard === currentHand[i]) playedCardIdx = i;
}
// board swap
Expand All @@ -251,18 +246,16 @@ export default class Game {
currentHand[playedCardIdx] = newPlayerCard;
deckCard = newDeckCard;
this.onDeckCard = newDeckCard; // new
// debugger;

// view swap
that.deck.viewDealSwap(newPlayerCard, playedCardEl);
that.deck.viewDealSwap(newDeckCard, deckCardEl);
}

checkWin() {
debugger

let that = this;
if (that.board.checkWinStone() !== false ){
debugger
let winResults = that.board.checkWinStone()
this.activeGame = false
this.gameWin = true
Expand All @@ -271,7 +264,6 @@ export default class Game {
return true
}
if (that.board.checkWinStream() !== false) {
debugger
let winResults = that.board.checkWinStream()
this.activeGame = false
this.gameWin = true;
Expand All @@ -291,31 +283,9 @@ export default class Game {
modalWin.style.display = 'flex';
}

// checkWinStream() {
// debugger;
// let that = this
// let masterRed = document.querySelector(".red-master-piece");
// let masterBlue = document.querySelector(".blue-master-piece");
// console.log(masterBlue)
// console.log(masterRed)
// if (masterRed.parentElement.id === "[0,2]") {
// return this.gameWin("red", "stream")
// } else if (masterBlue.parentElement.id === "[4,2]") {
// return this.gameWin("blue", "stream")
// }
// }

// checkWinStone() {

// }

// gameWin(colorStr, typeStr) {
// console.log(`${colorStr} wins by ${typeStr}!`)
// }

viewSwapTurn() {
let that = this;
// debugger
let playedCard = document.querySelector(".active-card");
let deckCard = document.querySelector("#back3");
let body = document.querySelector(".body");
Expand Down

0 comments on commit 4a73584

Please sign in to comment.