Message improvements; CSS fixes

This commit is contained in:
Lurkars
2017-04-19 17:17:24 +02:00
parent 18215f4e71
commit 40ff34ba0e
2 changed files with 22 additions and 26 deletions
+12 -17
View File
@@ -138,10 +138,8 @@ Game.prototype.rollDices = function(all) {
self.Interface.setPlayer(self.player); self.Interface.setPlayer(self.player);
} }
self.Interface.showMessage("CPU's turn!", self.messageTime, function() {
self.endRound(); self.endRound();
}); });
});
} else { } else {
self.cpu.zilch++; self.cpu.zilch++;
@@ -175,10 +173,8 @@ Game.prototype.rollDices = function(all) {
self.Interface.setCpu(self.cpu); self.Interface.setCpu(self.cpu);
} }
self.Interface.showMessage("Player's turn!", 0, function() {
self.endRound(); self.endRound();
}); });
});
} }
}); });
@@ -290,12 +286,12 @@ Game.prototype.calculatePoints = function(all) {
} }
// left Ones // left Ones
if (pairs < 3 && triple1 != 1 && triple2 != 1) { if (!straight && pairs < 3 && triple1 != 1 && triple2 != 1) {
points += result[0] * 100; points += result[0] * 100;
} }
// left Fives // left Fives
if (pairs < 3 && triple1 != 5 && triple2 != 5) { if (!straight && pairs < 3 && triple1 != 5 && triple2 != 5) {
points += result[4] * 50; points += result[4] * 50;
} }
@@ -348,15 +344,7 @@ Game.prototype.takePoints = function() {
self.Interface.disableRollDices(true); self.Interface.disableRollDices(true);
self.Interface.setPoints(self.points); self.Interface.setPoints(self.points);
if (self.playing) {
self.Interface.showMessage("CPU's turn!", self.messageTime, function() {
self.endRound(); self.endRound();
});
} else {
self.Interface.showMessage("Player's turn!", 0, function() {
self.endRound();
});
}
}; };
Game.prototype.endRound = function() { Game.prototype.endRound = function() {
@@ -384,13 +372,17 @@ Game.prototype.endRound = function() {
var checkScore = self.playing && self.cpuStarts || !self.playing && !self.cpuStarts; var checkScore = self.playing && self.cpuStarts || !self.playing && !self.cpuStarts;
if (checkScore && self.player.score >= 10000 && self.player.score > self.cpu.score) { if (checkScore && self.player.score >= 10000 && self.player.score > self.cpu.score) {
self.Interface.showMessage("Player wins!") self.Interface.disableRestart(false);
self.Interface.showMessage("Player wins!");
} else if (checkScore && self.cpu.score >= 10000 && self.cpu.score > self.player.score) { } else if (checkScore && self.cpu.score >= 10000 && self.cpu.score > self.player.score) {
self.Interface.showMessage("CPU wins!") self.Interface.disableRestart(false);
self.Interface.showMessage("CPU wins!");
} else if (self.player.score >= 10000 && self.player.score == self.cpu.score) { } else if (self.player.score >= 10000 && self.player.score == self.cpu.score) {
self.Interface.showMessage("Remi!") self.Interface.disableRestart(false);
self.Interface.showMessage("Remi!");
} else { } else {
self.playing = !self.playing; self.playing = !self.playing;
self.Interface.setPlaying(self.playing); self.Interface.setPlaying(self.playing);
// continue // continue
if (self.playing) { if (self.playing) {
@@ -398,11 +390,14 @@ Game.prototype.endRound = function() {
self.Interface.disableRestart(false); self.Interface.disableRestart(false);
} }
self.Interface.showMessage(self.playing ? "Player's Turn!" : "CPU's turn!", self.messageTime, function() {
if (!self.playing) { if (!self.playing) {
setTimeout(function() { setTimeout(function() {
self.rollDices(); self.rollDices();
}, self.cpuspeed); }, self.cpuspeed);
} }
});
} }
} }
+2 -1
View File
@@ -112,7 +112,8 @@ hr {
color: gray; color: gray;
font-weight: normal; font-weight: normal;
display: block; display: block;
height: 13px; height: 25px;
width: 100%;
position: relative; position: relative;
bottom: 5px; bottom: 5px;
} }