Newer
Older
/********************************************************************************
This file contains the variables and functions that form the options menu.
********************************************************************************/
/**********************************************************************
***** Options Variables *****
**********************************************************************/
$optionsModal = $("#options-modal");
$tableStyleOptions = [$("#options-table-style-1"), $("#options-table-style-2"), $("#options-table-style-3")];
$autoFadeOptions = [$("#options-auto-fade-1"), $("#options-auto-fade-2")];
$cardSuggestOptions = [$("#options-card-suggest-1"), $("#options-card-suggest-2")];
$AITurnTimeOptions = [$("#options-ai-turn-time-1"), $("#options-ai-turn-time-2"), $("#options-ai-turn-time-3"), $("#options-ai-turn-time-4"), $("#options-ai-turn-time-5")];
$dealSpeedOptions = [$("#options-deal-speed-1"), $("#options-deal-speed-2"), $("#options-deal-speed-3"), $("#options-deal-speed-4")];
$autoForfeitOptions = [$("#options-auto-forfeit-1"), $("#options-auto-forfeit-2"), $("#options-auto-forfeit-3"), $("#options-auto-forfeit-4")];
$masturbationTimerBox = $("#player-masturbation-timer-box");
$masturbationWarningLabel = $("#masturbation-warning-label");
/**********************************************************************
***** Option Functions *****
**********************************************************************/
/************************************************************
* The player clicked the options button. Shows the options modal.
************************************************************/
function showOptionsModal () {
$optionsModal.modal('show');
}
/************************************************************
* Displays the active option correctly.
************************************************************/
function setActiveOption (options, choice) {
/* make all inactive */
for (var i = 0; i < options.length; i++) {
options[i].removeClass("active");
}
/* set the right active option */
options[choice-1].addClass("active");
}
/************************************************************
* The player changed the table style.
************************************************************/
function setTableStyle (choice) {
/* get the tables */
$tables = $('.game-table');
$surfaces = $('.game-table-surface');
$areas = $('.opponent-area');
$player = $('.player-table-area');
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/* implement the option change */
switch (choice) {
case 1: $tables.removeClass();
$tables.addClass('bordered game-table');
$surfaces.removeClass();
$surfaces.addClass('bordered game-table-surface');
$areas.removeClass();
$areas.addClass('bordered opponent-area');
$player.removeClass();
$player.addClass('bordered player-table-area');
break;
case 2: $tables.removeClass();
$tables.addClass('bordered game-table game-table-glass');
$surfaces.removeClass();
$surfaces.addClass('bordered game-table-surface game-table-surface-glass');
$areas.removeClass();
$areas.addClass('bordered opponent-area opponent-area-glass');
$player.removeClass();
$player.addClass('bordered player-table-area player-table-area-glass');
break;
case 3: $tables.removeClass();
$tables.addClass('bordered game-table game-table-none');
$surfaces.removeClass();
$surfaces.addClass('bordered game-table-surface game-table-surface-none');
$areas.removeClass();
$areas.addClass('bordered opponent-area opponent-area-none');
$player.removeClass();
$player.addClass('bordered player-table-area player-table-area-none');
break;
default: $tables.removeClass();
$tables.addClass('bordered game-table');
$surfaces.removeClass();
$surfaces.addClass('bordered game-table-surface');
$areas.removeClass();
$areas.addClass('bordered opponent-area');
}
setActiveOption($tableStyleOptions, choice);
}
/************************************************************
* The player changed fade option.
************************************************************/
function setAutoFade (choice) {
/* implement the option change */
switch (choice) {
case 1: AUTO_FADE = true; break;
case 2: AUTO_FADE = false; break;
default: AUTO_FADE = true;
}
setActiveOption($autoFadeOptions, choice);
}
/************************************************************
* The player changed card suggestion.
************************************************************/
function setCardSuggest (choice) {
/* implement the option change */
switch (choice) {
case 1: CARD_SUGGEST = true; break;
case 2: CARD_SUGGEST = false; break;
default: CARD_SUGGEST = false;
}
setActiveOption($cardSuggestOptions, choice);
}
/************************************************************
* The player changed the AI turn time.
************************************************************/
function setAITurnTime (choice) {
/* implement the option change */
switch (choice) {
case 1: GAME_DELAY = 0; break;
case 2: GAME_DELAY = 300; break;
case 3: GAME_DELAY = 600; break;
case 4: GAME_DELAY = 800; break;
case 5: GAME_DELAY = 1200; break;
default: GAME_DELAY = 600;
}
setActiveOption($AITurnTimeOptions, choice);
}
/************************************************************
* The player changed the card animation speed.
************************************************************/
function setDealSpeed (choice) {
/* implement the option change */
switch (choice) {
case 1: ANIM_DELAY = 0;
ANIM_TIME = 0;
break;
case 2: ANIM_DELAY = 150;
break;
default: ANIM_DELAY = 350;
break;
}
setActiveOption($dealSpeedOptions, choice);
}
function setAutoForfeit (choice) {
switch (choice) {
case 4: AUTO_FORFEIT = false;
break;
default: AUTO_FORFEIT = true;
break;
}
setActiveOption($autoForfeitOptions, choice);
switch (choice) {
case 1: FORFEIT_DELAY = 4000;
break;
case 2: FORFEIT_DELAY = 7500;
break;
case 3: FORFEIT_DELAY = 10000;
break;
default: FORFEIT_DELAY = 7500;
break;
}
}
$("#options-modal").on("hidden.bs.modal", function () {

ReformCopyright
committed
/* If we're waiting specifically for the auto forfeit timer, and
auto forfeit has been turned of, cancel it and enable the
button. */
if (timeoutID == autoForfeitTimeoutID && !AUTO_FORFEIT) {
clearTimeout(autoForfeitTimeoutID);
actualMainButtonState = false;
}

ReformCopyright
committed
$mainButton.attr('disabled', actualMainButtonState);
$backgroundSettings = [$("#settings-background-1"), $("#settings-background-2"), $("#settings-background-3"), $("#settings-background-4"), $("#settings-background-5"), $("#settings-background-6"), $("#settings-background-7"), $("#settings-background-8"), $("#settings-background-9"), $("#settings-background-10"), $("#settings-background-11"), $("#settings-background-12"), $("#settings-background-13"), $("#settings-background-14"), $("#settings-background-15"), $("#settings-background-16"), $("#settings-background-17"), $("#settings-background-18"), $("#settings-background-19"), $("#settings-background-20"), $("#settings-background-21"), $("#settings-background-22"), $("#settings-background-23")];
/************************************************************
* The player clicked the options button. Shows the options modal.
************************************************************/
function showGameSettingsModal () {
loadMasturbationTimer(); //set data values
$gameSettingsModal.modal('show');
}
/************************************************************
* The player changed the background.
************************************************************/
function setBackground (choice) {
/* implement the option change */

ReformCopyright
committed
backgroundImage = new Image();
backgroundImage.src = "img/background"+choice+".png";
backgroundImage.onload = autoResizeFont;
$("body").css("background-image", "url(img/background"+choice+".png)");
setActiveOption($backgroundSettings, choice);
}
/************************************************************
* Loading the player masturbation timer.
************************************************************/
function loadMasturbationTimer () {
$masturbationTimerBox.val(players[HUMAN_PLAYER].timer);
$masturbationWarningLabel.css("visibility", "hidden");
}
/************************************************************
* The player changed their masturbation timer.
************************************************************/
function changeMasturbationTimer () {
var newTimerValue = $masturbationTimerBox.val();
var newTime = Number(newTimerValue);
var isValidTimerValue = (newTime != "NaN") && (newTime > 0);
if (isValidTimerValue){
players[HUMAN_PLAYER].timer = newTime;
}
$masturbationWarningLabel.css("visibility", isValidTimerValue ? "hidden" : "visible");