Working out bugs in Volcano
Signed-off-by: James Ketrenos <james_eikona@ketrenos.com>
This commit is contained in:
parent
49d633a7c2
commit
c093d7141e
@ -175,6 +175,26 @@ const Actions = ({
|
||||
setTradeActive(true);
|
||||
}
|
||||
|
||||
let disableRoll = false;
|
||||
if (robberActions) { disableRoll = true; }
|
||||
if (turn && turn.select) { disableRoll = true; }
|
||||
if (inGame && !isTurn) { disableRoll = true; }
|
||||
if (inGame && hasRolled) { disableRoll = true; }
|
||||
if (volcanoActive && (!isTurn || hasRolled)) { disableRoll = true; }
|
||||
if (volcanoActive && isTurn ) { disableRoll = false; }
|
||||
if (inGameOrder && hasGameOrderRolled) { disableRoll = true; }
|
||||
|
||||
console.log(`actions - `, {
|
||||
disableRoll, robberActions, turn, inGame, isTurn, hasRolled, volcanoActive, inGameOrder,
|
||||
hasGameOrderRolled});
|
||||
|
||||
const disableDone =
|
||||
volcanoActive ||
|
||||
placeRoad ||
|
||||
robberActions ||
|
||||
!isTurn ||
|
||||
!hasRolled;
|
||||
|
||||
return (
|
||||
<Paper className="Actions">
|
||||
{ edit === "" && <PlayerName name={name} setName={setName}/> }
|
||||
@ -189,13 +209,7 @@ const Actions = ({
|
||||
{name && color && inLobby && <Button disabled={color ? false : true}
|
||||
onClick={houseRulesClick}>House Rules</Button>}
|
||||
{ name && !inLobby && <>
|
||||
<Button disabled={
|
||||
robberActions ||
|
||||
(turn && turn.select) ||
|
||||
(inGame && (!isTurn || hasRolled)) ||
|
||||
(inGameOrder && hasGameOrderRolled) ||
|
||||
(!inGame && !inGameOrder && (!isTurn || !volcanoActive))
|
||||
} onClick={rollClick}>Roll Dice</Button>
|
||||
<Button disabled={disableRoll} onClick={rollClick}>Roll Dice</Button>
|
||||
|
||||
<Button disabled={volcanoActive || placeRoad || robberActions || !isTurn || !hasRolled || !haveResources} onClick={tradeClick}>Trade</Button>
|
||||
|
||||
@ -204,7 +218,7 @@ const Actions = ({
|
||||
|
||||
{name && color && <Button disabled={color ? false : true}
|
||||
onClick={houseRulesClick}>House Rules</Button>}
|
||||
<Button disabled={volcanoActive || placeRoad || robberActions || !isTurn || !hasRolled} onClick={passClick}>Done</Button>
|
||||
<Button disabled={disableDone} onClick={passClick}>Done</Button>
|
||||
</> }
|
||||
{ /* inLobby &&
|
||||
<Button onClick={quitClick}>Quit</Button>
|
||||
|
@ -61,19 +61,24 @@ const ChooseCard = () => {
|
||||
}, [ws, cards]);
|
||||
|
||||
let count = 0;
|
||||
if (turn && turn.color === color) {
|
||||
count = turn.active === 'monopoly' ? 1 : 2;
|
||||
}
|
||||
if (state === 'volcano') {
|
||||
if (!turn.select) {
|
||||
count = 0;
|
||||
} else if (color in turn.select) {
|
||||
count = turn.select[color];
|
||||
} else {
|
||||
count = 0;
|
||||
if (turn && turn.actions && turn.actions.indexOf('select-resources') !== -1) {
|
||||
if (turn.active) {
|
||||
if (turn.color === color) {
|
||||
count = turn.active === 'monopoly' ? 1 : 2;
|
||||
}
|
||||
}
|
||||
|
||||
if (state === 'volcano') {
|
||||
if (!turn.select) {
|
||||
count = 0;
|
||||
} else if (color in turn.select) {
|
||||
count = turn.select[color];
|
||||
} else {
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const selectCard = useCallback((event) => {
|
||||
event.target.classList.toggle('Selected');
|
||||
|
||||
@ -93,9 +98,7 @@ const ChooseCard = () => {
|
||||
setCards(tmp);
|
||||
}, [ setCards, count ]);
|
||||
|
||||
if (!turn || !turn.active
|
||||
|| (count === 0)
|
||||
|| !turn.actions || turn.actions.indexOf('select-resources') === -1) {
|
||||
if (count === 0) {
|
||||
return <></>;
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,7 @@ const Volcano = ({ ws, rules, field, disabled }) => {
|
||||
|
||||
const toggleGold = () => {
|
||||
rules[field].gold = !gold;
|
||||
rules[field].number = number;
|
||||
setGold(rules[field].gold);
|
||||
|
||||
ws.send(JSON.stringify({
|
||||
@ -49,6 +50,7 @@ const Volcano = ({ ws, rules, field, disabled }) => {
|
||||
value = delta > 0 ? 8 : 6;
|
||||
}
|
||||
setNumber(value);
|
||||
rules[field].gold = gold;
|
||||
rules[field].number = value;
|
||||
ws.send(JSON.stringify({
|
||||
type: 'rules',
|
||||
|
@ -420,13 +420,18 @@ const isRuleEnabled = (game, rule) => {
|
||||
};
|
||||
|
||||
const processRoll = (game, session, dice) => {
|
||||
if (!dice[1]) {
|
||||
console.error(`Invalid roll sequence!`);
|
||||
return;
|
||||
}
|
||||
|
||||
addChatMessage(game, session, `${session.name} rolled ` +
|
||||
`${dice[0]}, ${dice[1]}.`);
|
||||
|
||||
const sum = dice[0] + dice[1];
|
||||
|
||||
game.turn.roll = sum;
|
||||
game.dice = dice;
|
||||
game.turn.roll = sum;
|
||||
|
||||
if (game.turn.roll !== 7) {
|
||||
let synonym = isRuleEnabled(game, 'twelve-and-two-are-synonyms')
|
||||
@ -447,27 +452,33 @@ const processRoll = (game, session, dice) => {
|
||||
}
|
||||
}
|
||||
|
||||
if (isRuleEnabled(game, 'roll-double-roll-again')) {
|
||||
if (dice[0] === dice[1]) {
|
||||
addChatMessage(game, session, `House rule 'Roll Double, Roll
|
||||
Again' activated.`);
|
||||
game.turn.roll = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (isRuleEnabled(game, 'volcano')) {
|
||||
if (sum === game.rules['volcano'].number
|
||||
|| (synonym
|
||||
&& (game.rules['volcano'].number === 2
|
||||
|| game.rules['volcano'].number === 12))) {
|
||||
addChatMessage(game, session, `House rule 'Volcano' activated. The
|
||||
Volcano is erupting! You must roll the die to determine which
|
||||
direciton the lava will flow!`);
|
||||
Volcano is erupting!`);
|
||||
|
||||
game.state = 'volcano';
|
||||
|
||||
let count = 0;
|
||||
console.log(game.rules['volcano']);
|
||||
|
||||
if (game.rules['volcano'].gold) {
|
||||
game.turn.select = {};
|
||||
const volcano = layout.tiles.find((tile, index) =>
|
||||
staticData.tiles[game.tileOrder[index]].type === 'desert');
|
||||
console.log(volcano);
|
||||
console.log({ mode: 'gold', volcano });
|
||||
volcano.corners.forEach(index => {
|
||||
const corner = game.placements.corners[index];
|
||||
console.log({ index, corner });
|
||||
if (corner.color) {
|
||||
if (!(corner.color in game.turn.select)) {
|
||||
game.turn.select[corner.color] = 0;
|
||||
@ -480,27 +491,23 @@ const processRoll = (game, session, dice) => {
|
||||
|
||||
if (count) {
|
||||
game.turn.actions = [ 'select-resources' ];
|
||||
/* To gain volcano resources, you need at least 3 settlements,
|
||||
* so Robin Hood Robber does not apply */
|
||||
if (volcano === layout.tiles[game.robber]) {
|
||||
addChatMessage(game, null, `That pesky ${game.robberName} Robber Roberson blocked ${count} resources!`);
|
||||
delete game.turn.selected;
|
||||
addChatMessage(game, null, `That pesky ${game.robberName} Robber Roberson blocked ${count} volcanic mineral resources!`);
|
||||
addChatMessage(game, null, `${game.turn.name} must roll the die to determine which direction the lava will flow!`);
|
||||
delete game.turn.select;
|
||||
} else {
|
||||
addChatMessage(game, null, `House rule 'Volcanoes have minerals' activated. Players must select which resources to receive from the Volcano!`);
|
||||
game.turn.active = 'volcano';
|
||||
}
|
||||
} else {
|
||||
addChatMessage(game, null, `${game.turn.name} must roll the die to determine which direction the lava will flow!`);
|
||||
delete game.turn.select;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isRuleEnabled(game, 'roll-double-roll-again')) {
|
||||
if (dice[0] === dice[1]) {
|
||||
addChatMessage(game, session, `House rule 'Roll Double, Roll
|
||||
Again' activated.`);
|
||||
game.turn.roll = 0;
|
||||
}
|
||||
}
|
||||
|
||||
for (let id in game.sessions) {
|
||||
if (game.sessions[id].player) {
|
||||
@ -863,9 +870,10 @@ const adminActions = (game, action, value, query) => {
|
||||
return results;
|
||||
|
||||
case "roll":
|
||||
let dice = (query.dice || '').split(',');
|
||||
let dice = (query.dice || Math.ceil(Math.random() * 6)).split(',');
|
||||
dice = dice.map(die => parseInt(die));
|
||||
|
||||
console.log({ dice });
|
||||
if (!value) {
|
||||
return `Unable to parse roll request.`;
|
||||
}
|
||||
@ -3003,6 +3011,7 @@ const selectResources = (game, session, cards) => {
|
||||
count = game.turn.select[session.color];
|
||||
delete game.turn.select[session.color];
|
||||
if (Object.getOwnPropertyNames(game.turn.select).length === 0) {
|
||||
addChatMessage(game, null, `${game.turn.name} must roll the die to determine which direction the lava will flow!`);
|
||||
delete game.turn.select;
|
||||
}
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user