tsgammon-core
Version:
A Backgammon library for Typescript, formerly developed as a part of tsgammon-ui
23 lines (22 loc) • 780 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.applyStakeConf = void 0;
/**
* キューブ、終局状態、ルール設定からスコアを算出する
*
* @param cubeState キューブ状態
* @param eogStatus 終局状態
* @param stakeConf ルール設定
* @returns
*/
function applyStakeConf(cubeState, eogStatus, stakeConf = { jacobyRule: false }) {
const jacobyApplied = stakeConf.jacobyRule && cubeState.owner === undefined;
const eog = jacobyApplied
? Object.assign(Object.assign({}, eogStatus), { isGammon: false, isBackgammon: false }) : eogStatus;
return {
eogStatus: eog,
stake: eog.calcStake(cubeState.value),
jacobyApplied,
};
}
exports.applyStakeConf = applyStakeConf;