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

Method addEnigma

code/main/RenderArea.ts:79–107  ·  view source on GitHub ↗
(x1: number, x2: number, y: number, enigmaAnswer: EnigmaAnswer, callbackCollection: CallbackCollection, otherClass: string, wrongClass: string = null, wrongMessage: string = "Wrong")

Source from the content-addressed store, hash-verified

77 }
78
79 public addEnigma(x1: number, x2: number, y: number, enigmaAnswer: EnigmaAnswer, callbackCollection: CallbackCollection, otherClass: string, wrongClass: string = null, wrongMessage: string = "Wrong"): void{
80 this.addTag(new RenderTag(x1, "<span class=\"aroundTextInput\"><input type=\"text\" class=\"asciiTextInput noHotkeys " + otherClass + "\" style=\"width:" + (x2 - x1).toString() + "ex\"></span>"), y);
81
82 // If there should be a wrong message
83 if(wrongClass != null){
84 // We add the wrong message
85 this.drawString(wrongMessage, x1, y+2);
86 this.addTwoTags(x1, x1+wrongMessage.length, y+2, "<span class=\"enigmaWrongMessage " + wrongClass + "\">", "</span>");
87 // We add the link input which will also display the wrong message if needed
88 this.addLinkInput("." + otherClass, enigmaAnswer, callbackCollection, new CallbackCollection(
89 function(){
90 // We make the element visible
91 $("." + wrongClass).css("visibility", "visible");
92 // We add a timeout to hide it soon
93 window.setTimeout(
94 function(){
95 $("." + wrongClass).css("visibility", "hidden");
96 },
97 1000
98 );
99 }
100 ));
101 }
102 // Else, no wrong message
103 else{
104 // We add a simple link input
105 this.addLinkInput("." + otherClass, enigmaAnswer, callbackCollection, new CallbackCollection());
106 }
107 }
108
109 public addFullComment(x: number, y: number, english: string, translated: string, otherClass: string): boolean{
110 if(this.addComment(Algo.correctIfUnderZero(x - (english.length/2)), y, english, otherClass) == false)

Callers

nothing calls this directly

Calls 6

addTagMethod · 0.95
drawStringMethod · 0.95
addTwoTagsMethod · 0.95
addLinkInputMethod · 0.95
$Function · 0.85
cssMethod · 0.65

Tested by

no test coverage detected