MCPcopy Create free account
hub / github.com/Monogatari/Monogatari / constructor

Method constructor

src/actions/Dialog.ts:178–212  ·  view source on GitHub ↗
(args: string[])

Source from the content-addressed store, hash-verified

176 id: string = '';
177
178 constructor(args: string[]) {
179 super();
180 const [character, ...dialog] = args;
181
182 // id:expression:class Dialog
183 const [id, expression, classes] = character.split(':');
184
185 this.dialog = dialog.join(' ');
186 this.clearDialog = TypeWriter.stripActionMarkers(this.dialog);
187
188 this.nvl = false;
189
190 this.classes = (classes && classes.trim() !== '') ? classes.split('|') : [];
191
192 if (typeof this.engine.character(id) !== 'undefined') {
193 this._setCharacter(id, expression);
194 } else if (id === 'centered') {
195 this.id = 'centered';
196 } else {
197 this.id = '_narrator';
198
199 if (typeof this.engine.character('_narrator') !== 'undefined') {
200 this._setCharacter('_narrator', expression);
201 }
202
203 if (id === 'nvl') {
204 this.nvl = true;
205 } else if (id === 'narrator') {
206 // Do nothing, just consume 'narrator'
207 } else {
208 this.dialog = `${character} ${this.dialog}`;
209 this.clearDialog = `${character} ${this.clearDialog}`;
210 }
211 }
212 }
213
214 override async willApply(): Promise<void> {
215 this.engine.element().find('[data-character]').removeClass('focus');

Callers

nothing calls this directly

Calls 3

_setCharacterMethod · 0.95
stripActionMarkersMethod · 0.80
characterMethod · 0.80

Tested by

no test coverage detected