-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
930d429
commit 2d4189c
Showing
13 changed files
with
300 additions
and
814 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import Card from './card.js'; | ||
|
||
class Deck { | ||
constructor() { | ||
this.moveCards = Card.allCards; | ||
this.currentCards = []; | ||
for (let i = 0; i < 16; i++) { | ||
this.cards.push(new Card()); | ||
} | ||
} | ||
|
||
makeCards() { | ||
while (this.cards.length < Card.allCards.length) { | ||
|
||
} | ||
} | ||
|
||
getCard() { | ||
let cardIdx = Math.floor(Math.random * this.cards.length); | ||
return this.cards[cardIdx]; | ||
} | ||
deal() { | ||
let card = getCard(); | ||
this.currentCards.push(card); | ||
return card; | ||
} | ||
|
||
|
||
|
||
} | ||
// shuffle and card.pop() ? | ||
// Game obj should be in charge of getting the card and giving it to the player | ||
|
||
export default Deck; | ||
|
||
|
||
|
||
// should deal() a random card and remove from deck | ||
// dealtCards should include the card |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,66 @@ | ||
import Board from "./board"; | ||
import Player from './player'; | ||
import Deck from './deck'; | ||
import Board from './board'; | ||
|
||
class Game { | ||
constructor() { | ||
this.board = new Board() | ||
// this.currentPlayer = ? | ||
this.activeGame = false; | ||
this.currentPlayerIdx = 0; // to aid with dealing cards | ||
this.players = [new Player(), new Player()]; | ||
this.deck = new Deck(); | ||
this.board = new Board(); | ||
} | ||
|
||
gameOver() { | ||
|
||
get currentPlayer() { | ||
return this.players[this.currentPlayerIdx]; | ||
} | ||
// getter, accessed like a property | ||
|
||
swapMoveCards() { | ||
swapTurn() { | ||
this.currentPlayerIdx = (this.currentPlayerIdx + 1) % 2; | ||
// ensures always 0 or 1 ! | ||
} | ||
|
||
dealCard() { | ||
this.currentPlayer.dealCard(this.deck.deal()); // calling itself? | ||
this.swapTurn(); // deals to each player until 4 cards dealt | ||
} | ||
|
||
swapTurn() { | ||
if (this.currentPlayer === 2) { | ||
this.currentPlayer === 1 | ||
} else { | ||
this.currentPlayer === 2 | ||
start() { | ||
for (let i = 0; i < 4; i++) { | ||
this.dealCard(); | ||
} | ||
this.onDeckCard = this.deck.deal(); | ||
this.activeGame = true; | ||
} | ||
} | ||
|
||
export default Game; | ||
|
||
|
||
// consider adding a KEY:value list of variables like pawn, master, or player | ||
// also where to keep card objects? | ||
|
||
|
||
|
||
// function addGlobalEventListener(type, selector, callback) { | ||
// document.addEventListener(type, e => { | ||
// if (e.target.matches(selector)) callback(e); | ||
// }); | ||
// } | ||
|
||
|
||
// function createGrid() { | ||
// const gameBoard = document.getElementById("board"); | ||
|
||
// for (let i = 0; i < 5; i++) { | ||
// for (let j = 0; j < 5; j++) { | ||
// let square = document.createElement("div"); | ||
// square.classList.add("square"); | ||
// square.setAttribute("id", [i, j]); | ||
// // gameBoard.appendChild(square); | ||
// } | ||
// } | ||
// } | ||
|
||
// createGrid(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
|
||
|
||
class Piece { | ||
constructor() { | ||
|
||
constructor(type, color) { | ||
this.type = type; | ||
this.color = color; | ||
} | ||
} | ||
} | ||
|
||
// piece types: student or master | ||
|
||
export default Piece; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
class Player { | ||
constructor() { | ||
this.hand = []; // possible object? array okay for two things. | ||
} | ||
|
||
dealCard(card) { | ||
this.hand.push(card); | ||
} | ||
|
||
} | ||
|
||
export default Player; |
Oops, something went wrong.