modaq
Version:
Quiz Bowl Reader using TypeScript, React, and MobX
38 lines • 2.02 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.cancel = exports.changePart = exports.commit = void 0;
const AppState_1 = require("src/state/AppState");
require("src/state/Cycle");
require("src/state/Events");
function commit(cycle) {
var _a;
const appState = AppState_1.AppState.instance;
const pendingProtestEvent = appState.uiState.pendingBonusProtestEvent;
let teamName = "";
if (cycle.correctBuzz != undefined && cycle.bonusAnswer != undefined) {
const bonusTeamName = cycle.correctBuzz.marker.player.teamName;
const part = pendingProtestEvent != undefined ? cycle.bonusAnswer.parts[pendingProtestEvent.partIndex] : undefined;
// If a bonus part was wrong (points <= 0) and the part isn't assigned to anyone, or it's assigned to the team
// who got the question right, then the team protesting must be the team who got the question right
// Otherwise, some other team is protesting.
// TODO: If we ever support more than two teams, we'll have to get the protesting team from the UI
teamName =
part == undefined || (part.points <= 0 && (part.teamName === bonusTeamName || part.teamName === ""))
? bonusTeamName
: (_a = appState.game.teamNames.find((name) => name !== bonusTeamName)) !== null && _a !== void 0 ? _a : "";
}
if (pendingProtestEvent) {
cycle.addBonusProtest(pendingProtestEvent.questionIndex, pendingProtestEvent.partIndex, pendingProtestEvent.givenAnswer, pendingProtestEvent.reason, teamName);
appState.uiState.resetPendingBonusProtest();
}
}
exports.commit = commit;
function changePart(part) {
AppState_1.AppState.instance.uiState.updatePendingBonusProtestPart(part);
}
exports.changePart = changePart;
function cancel() {
AppState_1.AppState.instance.uiState.resetPendingBonusProtest();
}
exports.cancel = cancel;
//# sourceMappingURL=BonusProtestDialogController.js.map