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

Method clickedFileSave

code/main/Save.ts:80–112  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

78 }
79
80 private clickedFileSave(): void{
81 // Save some special variables by calling the save() methods of various objects
82 this.getGame().save(); // Various variables owned by the game object
83 this.getGame().getPlayer().save(); // The player
84
85 // We now show the warning
86 this.showFileSaveWarning = true;
87
88 // Reset the textarea content
89 this.fileSaveTextareaContent = "";
90
91 // Write bools
92 for(var str in Saving.getAllBools()){
93 if(this.fileSaveTextareaContent != "") this.fileSaveTextareaContent += ", "; // We add a comma if we're not adding the very first variable
94 this.fileSaveTextareaContent += "bool " + str + "=" + Saving.boolToString(Saving.getAllBools()[str]);
95 }
96
97 // Write numbers
98 for(var str in Saving.getAllNumbers()){
99 if(this.fileSaveTextareaContent != "") this.fileSaveTextareaContent += ", "; // We add a comma if we're not adding the very first variable
100 this.fileSaveTextareaContent += "number " + str + "=" + Saving.numberToString(Saving.getAllNumbers()[str]);
101 }
102
103 // Write strings
104 for(var str in Saving.getAllStrings()){
105 if(this.fileSaveTextareaContent != "") this.fileSaveTextareaContent += ", "; // We add a comma if we're not adding the very first variable
106 this.fileSaveTextareaContent += "string " + str + "=" + Saving.getAllStrings()[str];
107 }
108
109 // Update
110 this.update();
111 this.getGame().updatePlace();
112 }
113
114 private clickedSave(): void{
115 // Save on the selected slot

Callers

nothing calls this directly

Calls 5

updateMethod · 0.95
getPlayerMethod · 0.80
updatePlaceMethod · 0.80
saveMethod · 0.45
getGameMethod · 0.45

Tested by

no test coverage detected