@@ -7,7 +7,9 @@ import { CorrectionStrategy } from "../correction-strategy.js";
77import { drawCard } from "./draw-card.js" ;
88import { getCardWidth } from "./card-utils.js" ;
99import { SelectionStrategy } from "../selection-strategy.js" ;
10- import { GameStateScene } from "../enums.js" ;
10+ import { Colors , GameStateScene } from "../enums.js" ;
11+ import { colorize } from "./colorize-card.js" ;
12+ import { emojify } from "node-emoji" ;
1113
1214/**
1315 * A UI for cards questions.
@@ -68,7 +70,7 @@ export class CardScene extends Scene {
6870 const question = getOneSideText ( gs . getSideA ( item ) ) ;
6971 const hintText = hint ? `(${ this . hintStrategy . getHint ( item ) } )` : "" ;
7072 const card = drawCard ( [ question , hintText ] , getCardWidth ( this . tWidth ) ) ;
71- this . setContent ( "card" , card ) ;
73+ this . setContent ( "card" , colorize ( card ) ) ;
7274 }
7375
7476 /**
@@ -121,12 +123,12 @@ export class CardScene extends Scene {
121123 const isCorrect = this . correctionStrategy . isCorrect ( this . item , answer ) ;
122124 this . handleAnswer ( displayedQuestion , answer , isCorrect ) ;
123125 if ( ! isCorrect ) {
124- this . setContent ( "info" , `WRONG !` ) ;
126+ gs . setCardColor ( Colors . Red ) ;
125127 gs . setLivesRemaining ( ( gs . getLivesRemaining ( ) ?? 1 ) - 1 ) ;
128+ this . showQuestion ( this . item , this . hint ) ;
126129 this . checkEnd ( this . item ) ;
127130 return ;
128131 }
129- this . setContent ( "info" , `Correct :-)` ) ;
130132 this . nextQuestion ( ) ;
131133 }
132134
@@ -162,6 +164,7 @@ export class CardScene extends Scene {
162164 * @private
163165 */
164166 private nextQuestion ( ) {
167+ gs . setCardColor ( Colors . Blue ) ;
165168 gs . setQuestionIndex ( gs . getQuestionIndex ( ) + 1 ) ;
166169 const item = this . selectItem ( ) ;
167170 if ( this . checkEnd ( item ) ) {
@@ -190,6 +193,7 @@ export class CardScene extends Scene {
190193 }
191194 const cardLimit = gs . getCardsLimit ( ) ;
192195 if ( ! item || ! cardLimit || gs . getQuestionIndex ( ) >= cardLimit ) {
196+ gs . setCardColor ( Colors . Blue ) ;
193197 this . exit ( GameStateScene . RESULTS ) ;
194198 return true ;
195199 }
@@ -229,6 +233,11 @@ export class CardScene extends Scene {
229233 this . updateBanner ( ) ;
230234 }
231235
236+ /**
237+ * Generate and print a "game-settings" banner, to let the user know
238+ * the current settings and some game states.
239+ * @private
240+ */
232241 private updateBanner ( ) {
233242 const gameMode = gs . getGameMode ( ) ;
234243 const selectionStrategy = gs . getSelectionStrategy ( ) ;
@@ -241,19 +250,19 @@ export class CardScene extends Scene {
241250 const lives = gs . getLivesRemaining ( ) ;
242251 const hints = gs . getHintRemaining ( ) ;
243252 const time = gs . getTime ( ) ;
244- let questionCounter = `Q: ${ questionIndex + 1 } `;
253+ let questionCounter = emojify ( `:books:: ${ questionIndex + 1 } `) ;
245254 if ( cardLimit !== Infinity ) {
246255 questionCounter = `${ questionCounter } /${ cardLimit } ` ;
247256 }
248257 gameInfos . push ( questionCounter ) ;
249258 if ( lives !== Infinity ) {
250- gameInfos . push ( `L: ${ lives } `) ;
259+ gameInfos . push ( emojify ( `:heart: : ${ lives } `) ) ;
251260 }
252261 if ( hints !== Infinity ) {
253- gameInfos . push ( `H: ${ hints } `) ;
262+ gameInfos . push ( emojify ( `:bulb:: ${ hints } `) ) ;
254263 }
255264 if ( time !== Infinity ) {
256- gameInfos . push ( `T: ${ time } `) ;
265+ gameInfos . push ( emojify ( `:hourglass_flowing_sand:: ${ time } `) ) ;
257266 }
258267 this . setContent ( "mode" , mode , true ) ;
259268 this . setContent ( "game" , gameInfos . join ( " - " ) , false ) ;
0 commit comments