Fix House Rules to enable/disable correctly and to only activate in server if "enabled" is set
Signed-off-by: James Ketrenos <james_eikona@ketrenos.com>
This commit is contained in:
parent
c9f1e64d97
commit
3d8226a3e8
@ -155,7 +155,7 @@ const HouseRules = ({ houseRulesActive, setHouseRulesActive }) => {
|
||||
}, {
|
||||
title: `Everyone gets one re-roll`,
|
||||
key: `everyone-gets-one-reroll`,
|
||||
description: `Each player gets one chance re - roll at any point.`,
|
||||
description: `Each player gets one chance re-roll at any point.`,
|
||||
element: <NotImplemented {...{
|
||||
ws, rules,
|
||||
field: `everyone-gets-one-reroll`
|
||||
|
@ -136,7 +136,7 @@ const MediaAgent = ({setPeers}) => {
|
||||
|
||||
connection.addEventListener('icecandidateerror', (event) => {
|
||||
if (event.errorCode === 701) {
|
||||
if (connection.icegatheringstate === 'gathering') {
|
||||
if (connection.iceGatheringState === 'gathering') {
|
||||
console.log(`media-agent - Unable to reach host: ${event.url}`);
|
||||
} else {
|
||||
console.error(`media-agent - icecandidateerror - `, event.errorCode, event.hostcandidate, event.url, event.errorText);
|
||||
|
@ -292,8 +292,7 @@ const distributeResources = (game, roll) => {
|
||||
if (!tile.robber) {
|
||||
receives[active.color][resource.type] += count;
|
||||
} else {
|
||||
if (`robin-hood-robber` in game.rules
|
||||
&& game.rules[`robin-hood-robber`].enabled
|
||||
if (isRuleEnabled(game, `robin-hood-robber`)
|
||||
&& game.players[active.color].points <= 2) {
|
||||
addChatMessage(game, null, `Robber does not steal ${count}
|
||||
${resource.type} from ${game.players[active.color].name} ` +
|
||||
@ -358,13 +357,17 @@ const pickRobber = (game) => {
|
||||
}
|
||||
}
|
||||
|
||||
const isRuleEnabled = (game, rule) => {
|
||||
return rule in game.rules && game.rules[rule].enabled;
|
||||
};
|
||||
|
||||
const processRoll = (game, session, dice) => {
|
||||
addChatMessage(game, session, `${session.name} rolled ${dice[0]}, ${dice[1]}.`);
|
||||
game.turn.roll = dice[0] + dice[1];
|
||||
if (game.turn.roll !== 7) {
|
||||
distributeResources(game, game.turn.roll);
|
||||
|
||||
if ('twelve-and-two-are-synonyms' in game.rules) {
|
||||
if (isRuleEnabled(game, 'twelve-and-two-are-synonyms')) {
|
||||
if (dice[0] + dice[1] === 12) {
|
||||
addChatMessage(game, session, `House rule 'Twelve and Two are
|
||||
Synonyms' activated. Twelve was rolled, so two is triggered too!`);
|
||||
@ -377,7 +380,7 @@ const processRoll = (game, session, dice) => {
|
||||
}
|
||||
}
|
||||
|
||||
if ('roll-double-roll-again' in game.rules) {
|
||||
if (isRuleEnabled(game, 'roll-double-roll-again')) {
|
||||
if (dice[0] === dice[1]) {
|
||||
addChatMessage(game, session, `House rule 'Roll Double, Roll
|
||||
Again' activated.`);
|
||||
@ -2591,9 +2594,8 @@ const placeRoad = (game, session, index) => {
|
||||
|
||||
const getVictoryPointRule = (game) => {
|
||||
const minVP = 10;
|
||||
if (!('victory-points' in game.rules)
|
||||
|| (!('points' in game.rules['victory-points']))
|
||||
|| !game.rules['victory-points'].enabled) {
|
||||
if (!isRuleEnabled(game, 'victory-points')
|
||||
|| !('points' in game.rules['victory-points'])) {
|
||||
return minVP;
|
||||
}
|
||||
return game.rules['victory-points'].points;
|
||||
|
Loading…
x
Reference in New Issue
Block a user