// Introcard.js
(function () {
/* global AdventureJS A */
/**
* @class AdventureJS.Introcard
* @ajsinternal
* @param {Game} game A reference to the game instance.
* @ajsnavheading EngineClasses
* @summary Manages the introcard for a {@link AdventureJS.Game|Game} instance.
* @classdesc
* <p>
* <strong>Introcard</strong> is a repository for properties
* used to print an introductory screen
* at the start of the game. Introcard is created automatically
* by {@link AdventureJS.Game|Game}. This is an internal class
* that authors should not need to construct. However, authors
* can set intro options from their game file as shown below.
* </p>
* <h3 class="examples">Example:</h3>
* <pre class="display"><code class="language-javascript">var MyGame = new AdventureJS.Game( "MyGame", "GameDisplay" );
* MyGame.introcard.set({
* });
* </code></pre>
*/
class Introcard {
constructor(game) {
this.game = game;
/**
* Optional text to show at the top of the introcard.
* @var {String} AdventureJS.Introcard#text
* @default ""
*/
this.text = ``;
/**
* Optional text to show when prompting user to press a key.
* @var {String} AdventureJS.Introcard#prompt_text
* @default ""
*/
this.prompt_text = ``;
/**
* If true, prompt the user to press a key to continue.
* @var {boolean} AdventureJS.Introcard#prompt_to_continue
* @default false
*/
this.prompt_to_continue = false;
/**
* If true, clear the screen before continuing the game.
* @var {Boolean} AdventureJS.Introcard#clear_on_continue
* @default false
*/
this.clear_on_continue = false;
/**
* Hide statusbar when introcard is shown
* @var {Boolean} AdventureJS.Introcard#hide_statusbar
* @default false
*/
this.hide_statusbar = false;
/**
* If statusbar was hidden on showing the introcard,
* restore it on hiding the introcard.
* @var {Boolean} AdventureJS.Introcard#show_statusbar_on_continue
* @default true
*/
this.show_statusbar_on_continue = true;
/**
* Hide titlebar when introcard is shown.
* @var {Boolean} AdventureJS.Introcard#hide_titlebar
* @default false
*/
this.hide_titlebar = false;
/**
* If titlebar was hidden on showing the introcard,
* restore it on hiding the introcard.
* @var {Boolean} AdventureJS.Introcard#show_titlebar_on_continue
* @default true
*/
this.show_titlebar_on_continue = true;
}
/**
* Show the introcard.
* @method AdventureJS.Introcard#show
*/
show() {
if (this.hide_statusbar) {
this.game.display.hideStatusbar();
}
if (this.hide_titlebar) {
this.game.display.hideTitlebar();
}
if (this.text) {
let msg = A.FX.getSAF.call(this.game, this.text);
this.game.print(msg);
}
if (this.prompt_to_continue) {
if (this.clear_on_continue) {
this.game.state_vars.clear_on_continue = true;
}
if (this.show_statusbar_on_continue) {
this.game.state_vars.show_statusbar = true;
}
if (this.show_titlebar_on_continue) {
this.game.state_vars.show_titlebar = true;
}
this.game.promptUser(this.prompt_text);
}
}
/**
* Provides a chainable shortcut method for setting a number of properties on the instance.
* @method AdventureJS.Introcard#set
* @param {Object} props A generic object containing properties to copy to the instance.
* @returns {AdventureJS.Introcard} Returns the instance the method is called on (useful for chaining calls.)
* @chainable
*/
// set(introcard) {
// for (let prop in introcard) {
// this[prop] = introcard[prop];
// }
// return this;
// }
set(props) {
return A.FX.deepSet.call(this.game, props, this);
}
}
AdventureJS.Introcard = Introcard;
})();