Kind gents, I have another little twist I hope you could help with.
In looking to recreate my original primitive hOpy casino, without the array of other games offered by skilled maintainers, I've had some luck in boiling it down to the original simple hOopy casino, and I think the game mechanics are working just as they should. Perfect.
–Except, in this .js version, the hoopy_theme starts only once the game is selected in the menu, and then stops and restarts with each screen change which isn't too pleasant.
Code: Select all
"use strict";
this.name = "hoopy_casino";
this.author = "Paul Wilkins (updated by Eric Walch, further updated by spara)";
this.copyright = "(C) 2009 Paul Wilkins";
this.license = "CC BY-NC-SA 3.0";
//add interface
this.startUpComplete = this.shipExitedWitchspace = function() {
var casinos = system.shipsWithPrimaryRole("casinoship");
if (casinos.length > 0) {
for (var i = 0; i < casinos.length; i++) {
casinos[i].setInterface("hoopy-hoops",{
title: expandMissionText("hoopy-hoops-title"),
category: expandMissionText("hoopy-gambling-category"),
summary: expandMissionText("hoopy-hoops-summary"),
callback: this.$startGambling.bind(this)
});
}
}
}
//init the hoops
this.shipDockedWithStation = function (station) {
if (player.ship.docked && station.primaryRole === 'casinoship') {
missionVariables.hoopy_casino = 'NOT_NOW';
this.setBoundaries();
}
};
this.missionScreenOpportunity = function ()
{
if (player.ship.docked && player.ship.dockedStation.primaryRole === 'casinoship')
{
this.gamble();
}
};
this.setBoundaries = function () {
/*
In the legacy version the random distribution was bad. One could win after analysing the odds
during some time. This is a feature that should stay in. So we prepare the gamble table now a bit.
*/
this.boundary1 = 1 + Math.random() - Math.random();
this.boundary2 = 2 + Math.random() - Math.random();
if (this.boundary1 > this.boundary2) this.boundary1 = this.boundary2;
this.startCapital = player.credits;
};
this.$startGambling = function() {
missionVariables.hoopy_casino = 'HOOPY_ENTER';
this.gambleChoices('YES_HOOPY');
}
this.gamble = function () {
/*
if (missionVariables.hoopy_casino === 'HOOPY_REVISIT') {
if (player.credits >= 100) {
mission.runScreen({title: "Hoopy Casino", messageKey: 'hoopy_casino_intro', overlay: 'hoopy_front.png', choicesKey: 'hoopy_casino_enter_yesno', music: "hoopy_theme.ogg"}, this.gambleChoices);
missionVariables.hoopy_casino = 'HOOPY_ENTER';
return;
}
}*/
if (missionVariables.hoopy_casino === 'HOOPY_GAMEON') {
mission.runScreen({title: "Hoopy Casino", messageKey: 'hoopy_casino_choices', overlay: 'hoopy_cover.png', choicesKey: 'hoopy_casino_pick_hoop', music: "hoopy_theme.ogg"}, this.gambleChoices);
this.hoopy_casino_hoop = Math.random() * 3;
missionVariables.hoopy_casino = 'HOOPY_MAKE_CHOICE';
return;
}
if (player.credits > this.startCapital + 2000) {
mission.runScreen({title: "Hoopy Casino", messageKey: 'hoopy_casino_new_table', overlay: 'hoopy_front.png', choicesKey: 'hoopy_casino_new_table_yesno', music: "hoopy_theme.ogg"}, this.gambleChoices);
missionVariables.hoopy_casino = 'HOOPY_NEW_TABLE';
this.setBoundaries();
} else {
if (missionVariables.hoopy_casino === 'HOOPY_WINNER') {
mission.runScreen({title: "Hoopy Casino", messageKey: 'hoopy_casino_win', overlay: this.hoopy_casino_image, choicesKey: 'hoopy_casino_replay_winner_yesno', music: "hoopy_theme.ogg"}, this.gambleChoices);
player.credits += 100;
missionVariables.hoopy_casino = 'HOOPY_REPLAY';
}
if (missionVariables.hoopy_casino === 'HOOPY_LOSER') {
mission.runScreen({title: "Hoopy Casino", messageKey: 'hoopy_casino_loss', overlay: this.hoopy_casino_image, choicesKey: 'hoopy_casino_replay_loser_yesno', music: "hoopy_theme.ogg"}, this.gambleChoices);
player.credits -= 100;
missionVariables.hoopy_casino = 'HOOPY_REPLAY';
}
}
if (missionVariables.hoopy_casino === 'NOT_NOW') {
delete this.hoopy_casino_hoop;
delete this.hoopy_casino_image;
delete missionVariables.hoopy_casino;
}
};
this.gambleChoices = function (choice){
if (missionVariables.hoopy_casino === 'HOOPY_ENTER') {
if (choice === 'YES_HOOPY') {
if (player.credits >= 100) {
mission.runScreen({title: "Hoopy Casino", messageKey: 'hoopy_casino_desc', overlay: 'hoopy_clean.png', choicesKey: 'hoopy_casino_gamble_yesno', music: "hoopy_theme.ogg"}, this.gambleChoices);
missionVariables.hoopy_casino = 'HOOPY_GAMBLE';
}
else {
missionVariables.hoopy_casino = 'HOOPY_REPLAY';
this.gambleChoices('YES_HOOPY');
return;
}
} else if (choice === 'NO_HOOPY') {
missionVariables.hoopy_casino = 'NOT_NOW';
}
return;
}
if (missionVariables.hoopy_casino === 'HOOPY_GAMBLE') {
if (choice === '0_HOOPY') {
mission.runScreen({title: "Hoopy Casino", messageKey: 'hoopy_casino_desc', overlay: 'hoopy_clean.png', choicesKey: 'hoopy_casino_gamble_yesno', music: "hoopy_theme.ogg"}, this.gambleChoices);
} else if (choice === 'YES_HOOPY') {
missionVariables.hoopy_casino = 'HOOPY_GAMEON';
} else if (choice === 'NO_HOOPY') {
missionVariables.hoopy_casino = 'NOT_NOW';
}
return;
}
if (missionVariables.hoopy_casino === 'HOOPY_MAKE_CHOICE') {
missionVariables.hoopy_casino = 'HOOPY_LOSER';
if (this.hoopy_casino_hoop < this.boundary1) {
this.hoopy_casino_image = 'hoopy_Lwin.png';
if (choice === 'LEFT_HOOPY') {
missionVariables.hoopy_casino = 'HOOPY_WINNER';
}
}
if (this.hoopy_casino_hoop >= this.boundary1 && this.hoopy_casino_hoop < this.boundary2) {
this.hoopy_casino_image = 'hoopy_Cwin.png';
if (choice === 'MIDDLE_HOOPY') {
missionVariables.hoopy_casino = 'HOOPY_WINNER';
}
}
if (this.hoopy_casino_hoop >= this.boundary2) {
this.hoopy_casino_image = 'hoopy_Rwin.png';
if (choice === 'RIGHT_HOOPY') {
missionVariables.hoopy_casino = 'HOOPY_WINNER';
}
}
return;
}
if (missionVariables.hoopy_casino === 'HOOPY_NEW_TABLE') {
if (choice === 'NEW_TABLE_HOOPY') {
mission.runScreen({title: "Hoopy Casino", messageKey: 'hoopy_casino_desc', overlay: 'hoopy_clean.png', choicesKey: 'hoopy_casino_gamble_yesno', music: "hoopy_theme.ogg"}, this.gambleChoices);
missionVariables.hoopy_casino = 'HOOPY_GAMBLE';
} else if (choice === 'NO_HOOPY') {
missionVariables.hoopy_casino = 'NOT_NOW';
}
return;
}
if (missionVariables.hoopy_casino === 'HOOPY_REPLAY') {
if (choice === '0-WINNER_HOOPY') {
mission.runScreen({title: "Hoopy Casino", messageKey: 'hoopy_casino_win', overlay: this.hoopy_casino_image, choicesKey: 'hoopy_casino_replay_winner_yesno', music: "hoopy_theme.ogg"}, this.gambleChoices);
}
if (choice === '0-LOSER_HOOPY') {
mission.runScreen({title: "Hoopy Casino", messageKey: 'hoopy_casino_loss', overlay: this.hoopy_casino_image, choicesKey: 'hoopy_casino_replay_loser_yesno', music: "hoopy_theme.ogg"}, this.gambleChoices);
}
if (choice === 'YES_HOOPY') {
if (player.credits >= 100) {
mission.runScreen({title: "Hoopy Casino", messageKey: 'hoopy_casino_again', overlay: 'hoopy_clean.png', music: "hoopy_theme.ogg"});
missionVariables.hoopy_casino = 'HOOPY_GAMEON';
} else {
mission.runScreen({title: "Hoopy Casino", messageKey: 'hoopy_casino_nofunds', overlay: 'hoopy_front.png', music: "hoopy_theme.ogg"});
missionVariables.hoopy_casino = 'NOT_NOW';
}
}
if (choice === 'NO_HOOPY') {
mission.runScreen({title: "Hoopy Casino", messageKey: 'hoopy_casino_goodbye', overlay: 'hoopy_front.png', music: "hoopy_theme.ogg"});
missionVariables.hoopy_casino = 'NOT_NOW';
}
}
};
Since I would much rather that the music begins instantly once docked at the casino and plays all the way through until space launch, so I gather I would remove all the current instances of music: "hoopy_theme.ogg", but where would I place the one I want for the play at arrival effect?
That, and I wish I could have the "Play hOopy" option appear at the very top of the menu, but I've learned to accept I can't always get what I want.