Skip to content

Commit

Permalink
Added configuration to stop remaining tiles penalty
Browse files Browse the repository at this point in the history
  • Loading branch information
yahiaetman committed Dec 16, 2018
1 parent 5b30856 commit d475d7a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Server configuration is found in `config.json`, which contains the following con
- `ping interval`: defines the time interval for the ping/pong handshake in the heartbeat system (Format: `MM:ss.s`).
- `rack size`: defines the rack size for each player (currently must be 7).
- `bingo`: defines the bingo bonus points (should be 50 in a standard game).
- `penalize remaining tiles`: determines whether to penalize player remaining tiles in rack at the game end or not.
- `design`: defines the board design. It is a 2D Array which contains the type of each square (currently, the array size must be 15x15). The square types can be:
- `0` - Normal Square.
- `1` - Double Letter Square.
Expand Down
3 changes: 2 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"ping interval": "00:01",
"rack size": 7,
"bingo": 50,
"penalize remaining tiles": false,
"design":[
[4,0,0,1,0,0,0,4,0,0,0,1,0,0,4],
[0,3,0,0,0,2,0,0,0,2,0,0,0,3,0],
Expand Down Expand Up @@ -79,7 +80,7 @@
"Z":1,
"_":2
},
"starting timespans": ["10:00", "10:00"],
"starting timespans": ["10", "10"],
"challenge timespan": "00:05",
"penalty":{
"points": 10,
Expand Down
4 changes: 3 additions & 1 deletion main/scrabble.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class Scrabble {
this.rackSize = config['rack size'];
// Bingo score (usually 50)
this.bingo = config.bingo;
// Determines whether to penalize player remaining tiles in rack at the game end or not
this.penalizeRemainingTiles = config['penalize remaining tiles'];
// Convert score dictionary in config to use tilecodes instead of tilenames
this.tileScores = _.zipObject(
ScrabbleUtils.tileCodes,
Expand Down Expand Up @@ -415,7 +417,7 @@ class Scrabble {
next.players.forEach((player) => {
player.score
-= this.calculateTimePenalty(player.time)
+ this.calculateRemainingTilesPenalty(player.rack);
+ (this.penalizeRemainingTiles ? this.calculateRemainingTilesPenalty(player.rack) : 0);
});
const scores = _.map(next.players, player => player.score);
// check who is the winner (0: player 1 won, 1: player 2 won, null: draw)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "scrabble-server",
"version": "0.0.2",
"version": "0.0.3",
"description": "A 2-Player TCP Scrabble Judge",
"main": "main.js",
"scripts": {
Expand Down

0 comments on commit d475d7a

Please sign in to comment.