From 77a42412c9e6e353cacc65323bb7581e6fb08262 Mon Sep 17 00:00:00 2001 From: Svornost <11434-svornost@users.noreply.gitgud.io> Date: Tue, 24 Mar 2020 16:14:39 -0700 Subject: [PATCH] Add JS Random Event event name to storyCaption to assist in debugging. --- src/events/001-base/baseEvent.js | 8 ++++++++ src/events/randomEvent.js | 4 ++-- src/gui/storyCaption.tw | 3 +++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/events/001-base/baseEvent.js b/src/events/001-base/baseEvent.js index 8fe3d9f7c03..822c0b1251a 100644 --- a/src/events/001-base/baseEvent.js +++ b/src/events/001-base/baseEvent.js @@ -56,6 +56,14 @@ App.Events.BaseEvent = class BaseEvent { return JSON.reviveWrapper(`new App.Events.${this.constructor.name}(${JSON.stringify(this.actors)},${JSON.stringify(this.params)})`); } + /** get the event's (human-readable) name. must not include ":". + * default implementation should generally suffice (though we might want to de-camelcase here or something). + * @returns {string} + */ + get eventName() { + return this.constructor.name; + } + /** build the actual list of actors that will be involved in this event. * default implementation should suffice for child classes with a fixed number of actors; may be overridden for events with variable actor count. * @param {App.Entity.SlaveState} firstActor - if non-null, the first actor should be this slave (fail if she is not qualified) diff --git a/src/events/randomEvent.js b/src/events/randomEvent.js index 84ad32ee14c..dc12e6eac0b 100644 --- a/src/events/randomEvent.js +++ b/src/events/randomEvent.js @@ -39,13 +39,13 @@ App.Events.getNonindividualEvents = function() { /** get a stringified list of possible individual events as fake passage names - TODO: kill me */ App.Events.getIndividualEventsPassageList = function(slave) { const events = App.Events.getIndividualEvents(slave); - return events.map(e => `JSRE ${e.constructor.name}:${JSON.stringify(e.toJSON())}`); + return events.map(e => `JSRE ${e.eventName}:${JSON.stringify(e.toJSON())}`); }; /** get a stringified list of possible individual events as fake passage names - TODO: kill me */ App.Events.getNonindividualEventsPassageList = function() { const events = App.Events.getNonindividualEvents(); - return events.map(e => `JSRE ${e.constructor.name}:${JSON.stringify(e.toJSON())}`); + return events.map(e => `JSRE ${e.eventName}:${JSON.stringify(e.toJSON())}`); }; /** execute a fake event passage from the embedded JSON - TODO: kill me */ diff --git a/src/gui/storyCaption.tw b/src/gui/storyCaption.tw index 1789dc6fdb3..48970224aa2 100644 --- a/src/gui/storyCaption.tw +++ b/src/gui/storyCaption.tw @@ -62,6 +62,9 @@ <<if $ui != "start" && _Pass != "Encyclopedia">> <<if $cheatMode || $debugMode>> <div>_Pass</div> + <<if _Pass == "JS Random Event">> + <div><<= $event.eventName>></div> + <</if>> <</if>> <div> <span id="week">''Week $week''</span> -- GitLab