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

Method handleSentences

code/main/Yourself.ts:117–172  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

115 }
116
117 private handleSentences(): void{
118 // If it's time to add sentences
119 if(this.sentencesTimer <= 0){
120 // If we don't have the crown
121 if(this.getGame().isEquipped("hat", "eqItemHatOctopusKingCrown") == false){
122 // We possibly add a randomly-chosen sentence
123 if(this.sentences.length == 0 || Random.oneChanceOutOf(10))
124 this.sentences.push(new YourselfSentence(this,
125 Random.fromArray(["You need to be more self-confident",
126 "You need more confidence!",
127 "My crown is called content, a crown that seldom kings enjoy",
128 "Self-confidence is having confidence in oneself",
129 "The Octopus King helps those who help themselves",
130 "It's hard to beat yourself",
131 "If my head looks like an \"o\", what does my belly look like?",
132 "What does the squirrel do all the day?",
133 "I wonder what is inside the first house",
134 "I guess it's time for me to become a King",
135 "With a crown on your head, you just feel they will never hurt you",
136 "Look at all these flying sentences",
137 "Am I talking to myself?",
138 "There are three shark fins",
139 "Did you look under the carpet?",
140 "Look at this bar above",
141 "Maybe you could change its corners",
142 "Nonsense",
143 "Confidence confidence confidence",
144 "If there be no enemy there's no fight. If no fight, no victory and if no victory there is no crown",
145 "A crown is merely a hat that lets the rain in",
146 "I spent a lot of time with a crown on my head",
147 "Sometime I wish the aliens would abduct me and crown me as their leader",
148 "The crown of life is neither happiness nor annihilation; it is understanding",
149 "Tentacles tentacles tentacles"]),
150 Random.flipACoin(), Random.between(1, 12)));
151 }
152 // Else, we have the crown
153 else{
154 // We possibly add the sentence
155 if(this.sentences.length == 0 || Random.oneChanceOutOf(20))
156 this.sentences.push(new YourselfSentence(this, Random.fromArray(["You are very self-confident."]), Random.flipACoin(), Random.between(1, 12)));
157 }
158 }
159 // Else, we decrease the timer
160 else{
161 this.sentencesTimer -= 1;
162 }
163
164 // Call the sentences update methods
165 for(var i = 0; i < this.sentences.length; i++){
166 // If it should be deleted, we remove it from the array
167 if(this.sentences[i].update()){
168 this.sentences.splice(i, 1);
169 i--;
170 }
171 }
172 }
173
174 private thePlayerWon(): boolean{

Callers 1

updateMethod · 0.95

Calls 3

isEquippedMethod · 0.80
getGameMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected