Skip to content

Commit

Permalink
Convert Chip model from constructor to class
Browse files Browse the repository at this point in the history
  • Loading branch information
caleb531 committed Sep 29, 2024
1 parent 0c2d6a1 commit aa85003
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions scripts/models/chip.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
// An individual chip/checker that can be placed on a game grid; each chip
// belongs to a single player
function Chip({ player, column = null, row = null, winning = false }) {
// A reference to the player who placed this chip
this.player = player;
// The index of the column on the grid where this chip was placed
this.column = column;
// The index of the row on the grid where this chip was placed
this.row = row;
// Whether or not the chip should be visually marked as a winning chip (i.e.
// apart of a winning connection)
this.winning = winning;
class Chip {
constructor({ player, column = null, row = null, winning = false }) {
// A reference to the player who placed this chip
this.player = player;
// The index of the column on the grid where this chip was placed
this.column = column;
// The index of the row on the grid where this chip was placed
this.row = row;
// Whether or not the chip should be visually marked as a winning chip (i.e.
// apart of a winning connection)
this.winning = winning;
}
}

export default Chip;

0 comments on commit aa85003

Please sign in to comment.