drawful

drawing game
git clone https://git.ce9e.org/drawful.git

commit
150d601bc196a39c9b19887b46337cf9fd4740b7
parent
3631d3aec16b17dddd2d6d35a25b1f280c9d5df4
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2020-12-17 21:17
implement dixit rules

starting with 4 players

Diffstat

M drawful.js 28 +++++++++++++++++++---------

1 files changed, 19 insertions, 9 deletions


diff --git a/drawful.js b/drawful.js

@@ -45,17 +45,27 @@ var score = function() {
   45    45 	var player, pick, lier;
   46    46 
   47    47 	state.scores[state.host] = state.scores[state.host] || 0;
   48    -1 
   49    48 	for (player in state.picks) {
   50    49 		state.scores[player] = state.scores[player] || 0;
   51    -1 		pick = state.picks[player];
   52    -1 		if (pick === state.word) {
   53    -1 			state.scores[player] += 100;
   54    -1 			state.scores[state.host] += 100;
   55    -1 		} else {
   56    -1 			for (lier in state.lies) {
   57    -1 				if (pick === state.lies[lier] && player !== lier) {
   58    -1 					state.scores[lier] += 50;
   -1    50 	}
   -1    51 
   -1    52 	var values = Object.values(state.picks);
   -1    53 	var unique = new Set(values);
   -1    54 	if (values.length >= 4 && unique.size == 1) {
   -1    55 		for (player in state.picks) {
   -1    56 			state.scores[player] += 2
   -1    57 		}
   -1    58 	} else {
   -1    59 		for (player in state.picks) {
   -1    60 			pick = state.picks[player];
   -1    61 			if (pick === state.word) {
   -1    62 				state.scores[player] += 3;
   -1    63 				state.scores[state.host] += 3;
   -1    64 			} else {
   -1    65 				for (lier in state.lies) {
   -1    66 					if (pick === state.lies[lier] && player !== lier) {
   -1    67 						state.scores[lier] += 1;
   -1    68 					}
   59    69 				}
   60    70 			}
   61    71 		}