0
0
Fork 0
mirror of https://gitlab.com/Oreolek/salet-module.git synced 2024-07-01 06:15:04 +03:00

Removed SimpleSituation.

This commit is contained in:
Alexander Yakovlev 2016-01-17 12:29:42 +07:00
parent c84a1c9def
commit b9d0d3028e

View file

@ -239,103 +239,6 @@ Situation.prototype.choiceData = function(character, system, situation) {
};
};
/* A simple situation has a block of content that it displays when
* the situation is entered. The content must be valid "Display
* Content" (see `System.prototype.write` for a definition). This
* constructor has options that control its behavior:
*
* heading: The optional `heading` will be used as a section title
* before the content is displayed. The heading can be any
* HTML string, it doesn't need to be "Display Content". If
* the heading is not given, no heading will be displayed. If
* a heading is given, and no optionText is specified (see
* `Situation` for more information on `optionText`), then the
* heading will also be used for the situation's option text.
*
* actions: This should be an object mapping action Ids to a
* response. The response should either be "Display Content"
* to display if this action is carried out, or it should be a
* function(character, system, action) that will process the
* action.
*
* choices: A list of situation ids and tags that, if given, will
* be used to compile an implicit option block using
* `getSituationIdChoices` (see that function for more details
* of how this works). Tags in this list should be prefixed
* with a hash # symbol, to distinguish them from situation
* ids. If just a single tag or id is needed, it can be passed
* in as a string without wrapping into a list.
*
* minChoices: If `choices` is given, and an implicit choice block
* should be compiled, set this option to require at least
* this number of options to be displayed. See
* `getSituationIdChoices` for a description of the algorithm by
* which this happens. If you do not specify the `choices`
* option, then this option will be ignored.
*
* maxChoices: If `choices` is given, and an implicit choice block
* should be compiled, set this option to require no more than
* this number of options to be displayed. See
* `getSituationIdChoices` for a description of the algorithm
* by which this happens. If you do not specify the `choices`
* option, then this option will be ignored.
*
* The remaining options in the `opts` parameter are the same as for
* the base Situation.
*/
var SimpleSituation = function(content, opts) {
Situation.call(this, opts);
this.content = content;
this.heading = opts && opts.heading;
this.actions = opts && opts.actions;
this.choices = opts && opts.choices;
this.minChoices = opts && opts.minChoices;
this.maxChoices = opts && opts.maxChoices;
};
SimpleSituation.inherits(Situation);
SimpleSituation.prototype.entering = function(character, system, from) {
if (this.heading) {
if ($.isFunction(this.heading)) {
system.writeHeading(this.heading());
} else {
system.writeHeading(this.heading);
}
}
if (this._entering) this._entering(character, system, from);
if (this.content) {
if ($.isFunction(this.content)) {
system.write(this.content());
} else {
system.write(this.content);
}
}
if (this.choices) {
var choices = system.getSituationIdChoices(this.choices,
this.minChoices,
this.maxChoices);
system.writeChoices(choices);
}
};
SimpleSituation.prototype.act = function(character, system, action) {
var response = this.actions[action];
try {
response(character, system, action);
} catch (err) {
if (response) system.write(response);
}
if (this._act) this._act(character, system, action);
};
SimpleSituation.prototype.optionText = function(character, system, sitn) {
var parentResult = Situation.prototype.optionText.call(this, character,
system, sitn);
if (parentResult === undefined) {
return this.heading;
} else {
return parentResult;
}
};
/* Instances of this class define the qualities that characters
* may possess. The title should be a string, and can contain
* HTML. Options are passed in in the opts parameter. The
@ -1691,7 +1594,6 @@ var begin = function () {
/* Export our API. */
module.exports = {
Situation: Situation,
SimpleSituation: SimpleSituation,
QualityDefinition: QualityDefinition,
IntegerQuality: IntegerQuality,