MCPcopy Create free account
hub / github.com/candybox2/candybox2.github.io / pressedEnter

Method pressedEnter

code/main/TheComputer.ts:320–350  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

318 }
319
320 private pressedEnter(): void{
321 // Do something different depending on the current state
322 switch(this.state){
323 // If we were waiting for the return key
324 case TheComputerState.WAITING_FOR_RETURN:
325 // We change our state
326 this.state = TheComputerState.WAITING_FOR_COMMAND;
327 // We add an empty text line
328 this.addLine(new TheComputerLine(TheComputerLineType.TEXT, ""));
329 // We add an empty command line
330 this.addLine(new TheComputerLine(TheComputerLineType.COMMAND, ""));
331 // We update
332 this.update();
333 this.getGame().updatePlace();
334 break;
335 // If we were writing a command
336 case TheComputerState.WAITING_FOR_COMMAND:
337 // We try to execute the command
338 this.executeCommand(this.currentCommandText);
339 // We empty the current command text
340 this.currentCommandText = "";
341 // We add an empty text line
342 this.addLine(new TheComputerLine(TheComputerLineType.TEXT, ""));
343 // We add an empty command line
344 this.addLine(new TheComputerLine(TheComputerLineType.COMMAND, ""));
345 // We update
346 this.update();
347 this.getGame().updatePlace();
348 break;
349 }
350 }
351
352 private pressedKey(key: string): void{
353 // If we're currently waiting for a command

Callers

nothing calls this directly

Calls 5

addLineMethod · 0.95
updateMethod · 0.95
executeCommandMethod · 0.95
updatePlaceMethod · 0.80
getGameMethod · 0.45

Tested by

no test coverage detected