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

Method pressedKey

code/main/TheComputer.ts:352–368  ·  view source on GitHub ↗
(key: string)

Source from the content-addressed store, hash-verified

350 }
351
352 private pressedKey(key: string): void{
353 // If we're currently waiting for a command
354 if(this.state == TheComputerState.WAITING_FOR_COMMAND){
355 // Create an array of words from the current command text (for checking purposes)
356 var words: string[] = this.currentCommandText.split(" ");
357
358 // If the last word of the current command text isn't too big and the current command text itself isn't too big either
359 if((words.length == 0 || words[words.length-1].length < 25 || key == " ") && this.currentCommandText.length < 100){
360 // We add the letter to the command
361 this.currentCommandText = this.currentCommandText + key;
362
363 // We update
364 this.update();
365 this.getGame().updatePlace();
366 }
367 }
368 }
369
370 private switchOnOff(): void{
371 // If the computer was on

Callers

nothing calls this directly

Calls 3

updateMethod · 0.95
updatePlaceMethod · 0.80
getGameMethod · 0.45

Tested by

no test coverage detected