Compare commits
2
Commits
498503ae59
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
44e5a01727 | ||
|
|
8fca1c2573 |
@@ -125,4 +125,15 @@ public class WebSocketController {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MessageMapping("enter-sudden-death")
|
||||||
|
public void enterSuddenDeath(@Header("room") String roomId, @Header("player") String player) {
|
||||||
|
Grid g = gm.findGrid(roomId);
|
||||||
|
try {
|
||||||
|
gm.enterSuddenDeath(g);
|
||||||
|
} catch (IllegalGameActionException e) {
|
||||||
|
publishError(player.charAt(0), e);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ public class GameManager {
|
|||||||
/**
|
/**
|
||||||
* Enters the sudden death phase
|
* Enters the sudden death phase
|
||||||
*/
|
*/
|
||||||
private void enterSuddenDeath(Grid g) {
|
private void enterSuddenDeathInternal(Grid g) {
|
||||||
newGameEvent(g, GameEvent.newSuddenDeath());
|
newGameEvent(g, GameEvent.newSuddenDeath());
|
||||||
if(allGreenRevealed(g, 'A', g.getConfig().isOnlyOneGreenGreen())) {
|
if(allGreenRevealed(g, 'A', g.getConfig().isOnlyOneGreenGreen())) {
|
||||||
// If all 'A''s greens are revealed, A is the only one to guess
|
// If all 'A''s greens are revealed, A is the only one to guess
|
||||||
@@ -209,7 +209,7 @@ public class GameManager {
|
|||||||
if(g.getUsedHints() >= g.getConfig().getMaxMaxHint()) {
|
if(g.getUsedHints() >= g.getConfig().getMaxMaxHint()) {
|
||||||
if(!g.getConfig().isSuddenDeath()) {
|
if(!g.getConfig().isSuddenDeath()) {
|
||||||
// We're entering sudden death
|
// We're entering sudden death
|
||||||
enterSuddenDeath(g);
|
enterSuddenDeathInternal(g);
|
||||||
} else {
|
} else {
|
||||||
// Only sudden death can get us out
|
// Only sudden death can get us out
|
||||||
setPhase(g, Phase.NEED_SUDDEN_DEATH);
|
setPhase(g, Phase.NEED_SUDDEN_DEATH);
|
||||||
@@ -301,6 +301,13 @@ public class GameManager {
|
|||||||
newGameEvent(g, GameEvent.newEndGuessingEvent(true, player));
|
newGameEvent(g, GameEvent.newEndGuessingEvent(true, player));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void enterSuddenDeath(Grid g) throws IllegalGameActionException {
|
||||||
|
if(!g.getPhase().isNeedMoreHints()) {
|
||||||
|
throw new IllegalGameActionException(g, "You can only enter sudden death when being out of hints");
|
||||||
|
}
|
||||||
|
enterSuddenDeathInternal(g);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UPDATE GAME CONFIG
|
* UPDATE GAME CONFIG
|
||||||
@@ -396,7 +403,7 @@ public class GameManager {
|
|||||||
setPhase(g, Phase.needMoreHints(g.getPhase().getHinting()));
|
setPhase(g, Phase.needMoreHints(g.getPhase().getHinting()));
|
||||||
} else if (g.getPhase() == Phase.NEED_SUDDEN_DEATH) {
|
} else if (g.getPhase() == Phase.NEED_SUDDEN_DEATH) {
|
||||||
// We're entering sudden death
|
// We're entering sudden death
|
||||||
enterSuddenDeath(g);
|
enterSuddenDeathInternal(g);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public class Grid {
|
|||||||
return (this == HINTING_BOTH) || (this == ((player == 'A')?HINTING_A:HINTING_B));
|
return (this == HINTING_BOTH) || (this == ((player == 'A')?HINTING_A:HINTING_B));
|
||||||
}
|
}
|
||||||
public boolean isGuessing(char player) {
|
public boolean isGuessing(char player) {
|
||||||
return (this == ((player == 'A')?GUESSING_A:GUESSING_B));
|
return this == guessing(player) || this == suddenDeathOnly(player) || this == SUDDEN_DEATH_BOTH;
|
||||||
}
|
}
|
||||||
public boolean isAnyoneGuessing() {
|
public boolean isAnyoneGuessing() {
|
||||||
return isGuessing('A') || isGuessing('B');
|
return isGuessing('A') || isGuessing('B');
|
||||||
|
|||||||
@@ -57,6 +57,11 @@ function updatePhase() {
|
|||||||
$('.card-button').css('visibility', 'hidden')
|
$('.card-button').css('visibility', 'hidden')
|
||||||
$('#end-guessing-button').hide()
|
$('#end-guessing-button').hide()
|
||||||
}
|
}
|
||||||
|
if(phase['name'] == 'need_more_hints_a' || phase['name'] == 'need_more_hints_b') {
|
||||||
|
$('#enter-sudden-death-button').show()
|
||||||
|
} else {
|
||||||
|
$('#enter-sudden-death-button').hide()
|
||||||
|
}
|
||||||
if((phase['name'] == 'waiting_for_one_more_'+p) ||
|
if((phase['name'] == 'waiting_for_one_more_'+p) ||
|
||||||
(phase[p+'-guessing'] &&
|
(phase[p+'-guessing'] &&
|
||||||
(gc['end-guessing'] || (currentHint && currentGuessCount >= currentHint['wordCount'])))) {
|
(gc['end-guessing'] || (currentHint && currentGuessCount >= currentHint['wordCount'])))) {
|
||||||
@@ -111,8 +116,10 @@ function updateCard(i) {
|
|||||||
} else {
|
} else {
|
||||||
$(`#card-${i}-a-public`).css('visibility', 'hidden')
|
$(`#card-${i}-a-public`).css('visibility', 'hidden')
|
||||||
}
|
}
|
||||||
cardDone = (card['revealed-a'] && ((player=='A')?card.otherColor:card.color == "green")) ||
|
cardDone = (
|
||||||
(card['revealed-b'] && ((player=='B')?card.otherColor:card.color == "green")) ||
|
gc["only-one-green-green"] &&
|
||||||
|
((card['revealed-a'] && ((player=='A')?card.otherColor:card.color == "green")) ||
|
||||||
|
(card['revealed-b'] && ((player=='B')?card.otherColor:card.color == "green")))) ||
|
||||||
(card['revealed-a'] && card['revealed-b']);
|
(card['revealed-a'] && card['revealed-b']);
|
||||||
if(cardDone) $(`#card-${i}`).addClass('card-done')
|
if(cardDone) $(`#card-${i}`).addClass('card-done')
|
||||||
cantTouch = cardDone ||
|
cantTouch = cardDone ||
|
||||||
@@ -282,6 +289,9 @@ function pointCard(e) {
|
|||||||
function endGuessing(e) {
|
function endGuessing(e) {
|
||||||
socket.send('/app/end-guessing', wsHeaders, "")
|
socket.send('/app/end-guessing', wsHeaders, "")
|
||||||
}
|
}
|
||||||
|
function enterSuddenDeath(e) {
|
||||||
|
socket.send('/app/enter-sudden-death', wsHeaders, "")
|
||||||
|
}
|
||||||
function onNewPhase(m) {
|
function onNewPhase(m) {
|
||||||
phase = JSON.parse(m.body)
|
phase = JSON.parse(m.body)
|
||||||
updatePhase()
|
updatePhase()
|
||||||
@@ -304,17 +314,20 @@ function onConfigChange(m) {
|
|||||||
console.log("New config option : ", key, "=", value)
|
console.log("New config option : ", key, "=", value)
|
||||||
gc[key] = value
|
gc[key] = value
|
||||||
switch(key) {
|
switch(key) {
|
||||||
case "max-hint":
|
|
||||||
updatePhase()
|
|
||||||
case "available-hint-word-count":
|
case "available-hint-word-count":
|
||||||
registeredAvailableHintWordCountInvalid = true
|
registeredAvailableHintWordCountInvalid = true
|
||||||
updatePhase()
|
updatePhase()
|
||||||
|
break
|
||||||
|
case "only-one-green-green":
|
||||||
|
for(var i = 0; i < cards.length; i++)
|
||||||
|
updateCard(i)
|
||||||
|
case "max-hint":
|
||||||
case "one-more-guess":
|
case "one-more-guess":
|
||||||
case "hint-max-length":
|
case "hint-max-length":
|
||||||
updatePhase()
|
|
||||||
case "end-guessing":
|
case "end-guessing":
|
||||||
case "only-one-green-green":
|
|
||||||
case "sudden-death":
|
case "sudden-death":
|
||||||
|
updatePhase()
|
||||||
|
break
|
||||||
case "hints-in-a-row":
|
case "hints-in-a-row":
|
||||||
// All the changes are made with phases
|
// All the changes are made with phases
|
||||||
break;
|
break;
|
||||||
@@ -327,6 +340,7 @@ function initialize() {
|
|||||||
$('#select-player-b').on('click', selectPlayer)
|
$('#select-player-b').on('click', selectPlayer)
|
||||||
$('#submit-hint button').on('click', submitHint)
|
$('#submit-hint button').on('click', submitHint)
|
||||||
$('#end-guessing-button').on('click', endGuessing)
|
$('#end-guessing-button').on('click', endGuessing)
|
||||||
|
$('#enter-sudden-death-button').on('click', enterSuddenDeath)
|
||||||
|
|
||||||
roomId = getRoomId()
|
roomId = getRoomId()
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,9 @@
|
|||||||
<div id="end-guessing" class="centered-bar">
|
<div id="end-guessing" class="centered-bar">
|
||||||
<button id="end-guessing-button">End Guessing</button>
|
<button id="end-guessing-button">End Guessing</button>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="enter-sudden-death" class="centered-bar">
|
||||||
|
<button id="enter-sudden-death-button">Enter Sudden Death</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="side-panel">
|
<div id="side-panel">
|
||||||
<div id="identity-pane">
|
<div id="identity-pane">
|
||||||
|
|||||||
Reference in New Issue
Block a user