Newer
Older
/********************************************************************************
This file contains the variables and functions that allow for players to have
multiple potential forfeits.
********************************************************************************/
/**********************************************************************
***** Forfeit Object Specification *****
**********************************************************************/
var CAN_SPEAK = true;
var CANNOT_SPEAK = false;
/**********************************************************************
***** Forfeit Variables *****
**********************************************************************/
/* orgasm timer */
/* The first and last rounds a character starts heavy masturbation, counted in phases before they finish */
var HEAVY_FIRST_ROUND = 6;
var HEAVY_LAST_ROUND = 2;
/**********************************************************************
***** Forfeit Functions *****
**********************************************************************/
/************************************************************
* Sets the forfeit timer of the given player, with a random
* offset, if applicable.
************************************************************/
Player.prototype.setForfeitTimer = function() {
this.stage += 1;
this.timeInStage = -1;
this.stageChangeUpdate();

ReformCopyright
committed
/************************************************************
* Initiate masturbation for the selected player
************************************************************/
function startMasturbation (player) {
players[player].forfeit = [PLAYER_MASTURBATING, CAN_SPEAK];
players[player].out = true;

ReformCopyright
committed
players[player].outOrder = players.countTrue(function(p) { return p.out; });

ReformCopyright
committed
if (chosenDebug === player) {
chosenDebug = -1;
updateDebugState(showDebug);
}
/* update behaviour */
updateAllBehaviours(
player,
PLAYER_START_MASTURBATING,
[[players[player].gender == eGender.MALE ? MALE_START_MASTURBATING : FEMALE_START_MASTURBATING,
OPPONENT_START_MASTURBATING]]
saveAllTranscriptEntries();
players[player].setForfeitTimer();
if (player == HUMAN_PLAYER) {
$gameClothingLabel.html("You're Masturbating...");
$gamePlayerCountdown.html(humanPlayer.timer);

ReformCopyright
committed
$gamePlayerCountdown.show();

ReformCopyright
committed
/* allow progression */
endRound();
}
/************************************************************
* The forfeit timers of all players tick down, if they have
* been set.
************************************************************/
function tickForfeitTimers () {
console.log("Ticking forfeit timers...");
var masturbatingPlayers = [], heavyMasturbatingPlayers = [];

ReformCopyright
committed
for (var i = 0; i < players.length; i++) {
if (players[i] && players[i].out && !players[i].finished && players[i].timer == 0) {
finishMasturbation(i);
return true;
}
}
if (gamePhase != eGamePhase.STRIP) for (var i = 0; i < players.length; i++) {
if (players[i] && players[i].out && players[i].timer == 1) {
players[i].timer = 0;

ReformCopyright
committed
/* set the button state */
$mainButton.html("Cumming...");
$mainButton.attr('disabled', true);
actualMainButtonState = true;
if (i == HUMAN_PLAYER) {
/* player's timer is up */
$gamePlayerCountdown.hide();
console.log(players[i].label+" is finishing!");
$gameClothingLabel.html("<b>You're 'Finished'</b>");
/* finish */
finishMasturbation(i);

ReformCopyright
committed
} else {
console.log(players[i].label+" is finishing!");
/* hide everyone else's dialogue bubble */
for (var j = 1; j < players.length; j++) {
if (i != j) {
$gameDialogues[j-1].html("");
$gameBubbles[j-1].hide();
}
}
/* let the player speak again */
players[i].forfeit = [PLAYER_FINISHING_MASTURBATING, CAN_SPEAK];
/* show them cumming */
players[i].updateBehaviour(PLAYER_FINISHING_MASTURBATING);
players[i].commitBehaviourUpdate();

ReformCopyright
committed
updateGameVisual(i);
saveSingleTranscriptEntry(i);

ReformCopyright
committed
/* trigger the callback */
var player = i, tableVisible = (tableOpacity > 0);
timeoutID = window.setTimeout(function(){ allowProgression(eGamePhase.END_FORFEIT); }, ORGASM_DELAY);
globalSavedTableVisibility = tableVisible;

ReformCopyright
committed
if (AUTO_FADE) forceTableVisibility(false);
players[i].preloadStageImages(players[i].stage + 1);

ReformCopyright
committed
}
return true;
}
}
for (var i = 0; i < players.length; i++) {
if (players[i] && players[i].out && players[i].timer > 1) {
players[i].timer--;

ReformCopyright
committed
if (i == HUMAN_PLAYER) {
/* human player */

ReformCopyright
committed
/* update the player label */
$gameClothingLabel.html("<b>'Finished' in "+players[i].timer+" phases</b>");
$gamePlayerCountdown.html(players[i].timer);

ReformCopyright
committed
masturbatingPlayers.push(i); // Double the chance of commenting on human player

ReformCopyright
committed
/* random chance they go into heavy masturbation */
// CHANGE THIS TO ACTIVATE ONLY IN THE LAST 4 TURNS
var randomChance = getRandomNumber(HEAVY_LAST_ROUND, HEAVY_FIRST_ROUND);
if (randomChance > players[i].timer-1) {

ReformCopyright
committed
/* this player is now heavily masturbating */
players[i].forfeit = [PLAYER_HEAVY_MASTURBATING, CANNOT_SPEAK];

ReformCopyright
committed
masturbatingPlayers.push(i);
if (players[i].forfeit[0] == PLAYER_HEAVY_MASTURBATING) {
heavyMasturbatingPlayers.push(i);
}
if (heavyMasturbatingPlayers.length > 0) {
masturbatingPlayers = heavyMasturbatingPlayers;
}
// Show a player masturbating while dealing or after the game, if there is one available
if (masturbatingPlayers.length > 0
&& ((gamePhase == eGamePhase.DEAL && humanPlayer.out) || gamePhase == eGamePhase.EXCHANGE || gamePhase == eGamePhase.END_LOOP)) {
var playerToShow = masturbatingPlayers[getRandomNumber(0, masturbatingPlayers.length)]
var others_tags = [[players[playerToShow].gender == eGender.MALE ? MALE_MASTURBATING : FEMALE_MASTURBATING, OPPONENT_MASTURBATING]];
if (players[playerToShow].forfeit[0] == PLAYER_HEAVY_MASTURBATING) {
others_tags.unshift([
players[playerToShow].gender == eGender.MALE ? MALE_HEAVY_MASTURBATING : FEMALE_HEAVY_MASTURBATING,
OPPONENT_HEAVY_MASTURBATING
]);
updateAllBehaviours(
playerToShow,
players[playerToShow].forfeit[0],
saveAllTranscriptEntries();

ReformCopyright
committed
return false;
}
/************************************************************
* A player has 'finished' masturbating.
************************************************************/
function finishMasturbation (player) {
// HARD SET STAGE
players[player].stage += 1;
players[player].finished = true;
players[player].forfeit = [PLAYER_FINISHED_MASTURBATING, CAN_SPEAK];
players[player].stageChangeUpdate();
/* update player dialogue */
updateAllBehaviours(
player,
PLAYER_FINISHED_MASTURBATING,
[[players[player].gender == eGender.MALE ? MALE_FINISHED_MASTURBATING : FEMALE_FINISHED_MASTURBATING,
OPPONENT_FINISHED_MASTURBATING]]

ReformCopyright
committed
players[player].timeInStage = 0;
saveAllTranscriptEntries();
if (AUTO_FADE && globalSavedTableVisibility !== undefined) {
forceTableVisibility(globalSavedTableVisibility);
globalSavedTableVisibility = undefined;

ReformCopyright
committed
allowProgression();
}