-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert Chip model from constructor to class
- Loading branch information
Showing
1 changed file
with
12 additions
and
10 deletions.
There are no files selected for viewing
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,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; |