@@ -2,22 +2,20 @@ import { Action } from '../Action';
22import { Monogatari } from '../monogatari' ;
33import { $_ } from '@aegis-framework/artemis' ;
44
5- export class Hide extends Action {
5+ export class HideCharacter extends Action {
66
7- static matchString ( [ action ] ) {
8- return action === 'hide' ;
7+ static matchString ( [ hide , type ] ) {
8+ return hide === 'hide' && type === 'character ';
99 }
1010
11- constructor ( [ action , asset , ...classes ] ) {
11+ constructor ( [ hide , type , asset , ...classes ] ) {
1212 super ( ) ;
1313 this . asset = asset ;
1414
1515 if ( typeof Monogatari . character ( this . asset ) !== 'undefined' ) {
1616 this . element = $_ ( `${ Monogatari . selector } [data-character="${ this . asset } "]` ) ;
17- this . state = 'characters' ;
1817 } else {
19- this . element = $_ ( `${ Monogatari . selector } [data-image="${ this . asset } "]` ) ;
20- this . state = 'images' ;
18+ // TODO: Add FancyError for when the character does not exist
2119 }
2220
2321 if ( typeof classes !== 'undefined' ) {
@@ -40,16 +38,12 @@ export class Hide extends Action {
4038 this . element . remove ( ) ;
4139 }
4240
43- const show = Monogatari . state ( this . state ) . filter ( ( item ) => {
41+ const show = Monogatari . state ( 'characters' ) . filter ( ( item ) => {
4442 const [ , asset , ] = item . split ( ' ' ) ;
4543 return asset !== this . asset ;
4644 } ) ;
4745
48- if ( this . state == 'characters' ) {
49- Monogatari . state ( { characters : show } ) ;
50- } else if ( this . state == 'images' ) {
51- Monogatari . state ( { images : show } ) ;
52- }
46+ Monogatari . state ( { characters : show } ) ;
5347
5448 return Promise . resolve ( ) ;
5549 }
@@ -59,18 +53,14 @@ export class Hide extends Action {
5953 }
6054
6155 willRevert ( ) {
62- if ( typeof Monogatari . character ( this . asset ) !== 'undefined' && Monogatari . history ( 'character' ) . length > 0 ) {
63- this . history = 'character' ;
64- } else if ( typeof Monogatari . asset ( 'images' , this . asset ) !== 'undefined' && Monogatari . history ( 'image' ) . length > 0 ) {
65- this . history = 'image' ;
66- } else {
56+ if ( Monogatari . history ( 'character' ) . length <= 0 ) {
6757 return Promise . reject ( ) ;
6858 }
6959 return Promise . resolve ( ) ;
7060 }
7161
7262 revert ( ) {
73- $_ ( `${ Monogatari . selector } #game` ) . append ( Monogatari . history ( this . history ) . pop ( ) ) ;
63+ $_ ( `${ Monogatari . selector } #game` ) . append ( Monogatari . history ( 'character' ) . pop ( ) ) ;
7464 return Promise . resolve ( ) ;
7565 }
7666
@@ -79,6 +69,6 @@ export class Hide extends Action {
7969 }
8070}
8171
82- Hide . id = 'Hide' ;
72+ HideCharacter . id = 'Hide::Character ' ;
8373
84- Monogatari . registerAction ( Hide ) ;
74+ Monogatari . registerAction ( HideCharacter ) ;
0 commit comments