@@ -4,7 +4,9 @@ let enemyHp = 160;
44let playerMaxHp = 100 ;
55let enemyMaxHp = 160 ;
66let playerExtraDmg = 1 ;
7+ let playerDef = 0 ;
78let enemyExtraDmg = 1.05 ;
9+ let enemyDef = 0 ;
810let moveNames = [ ] ;
911let selectableMoves = [ ] ;
1012let movePool = [ ] ;
@@ -94,6 +96,8 @@ function roundAndUpdate() {
9496 } else if ( enemyExtraDmg >= 1 ) {
9597 $ ( "#enemyBoost" ) . switchClass ( "nerf" , "boost" , 1000 , "easeInOutQuad" ) ;
9698 }
99+ $ ( "#player-defense" ) . html ( playerDef ) ;
100+ $ ( "#enemy-defense" ) . html ( enemyDef ) ;
97101}
98102
99103function display ( top , bottom ) {
@@ -143,25 +147,23 @@ function evalUse(name, user) {
143147}
144148
145149class Move {
146- constructor ( name , dmg , target , effect , heal , codeName , specialMsg ) {
150+ constructor ( name , dmg , target , effect , effectType , heal , codeName , specialMsg ) {
147151 this . name = name ;
148152 this . dmg = dmg ;
149- if ( target != "$D " ) {
153+ if ( target != "attack " ) {
150154 this . target = target ;
151155 this . effect = effect ;
156+ } else {
157+ this . target = "attack" ;
152158 }
153159 this . heal = heal ;
154- if ( heal >= 0 ) {
155- this . healType = "heal" ;
156- } else {
157- this . healType = "recoil" ;
158- } ;
160+ this . effectType = effectType ;
159161 this . codeName = codeName ;
160162 moveNames . push ( codeName ) ;
161163 selectableMoves = [ ...moveNames ] ;
162164 this . addFunction = `${ codeName } .addToMoves()` ;
163165 this . useFunction = `${ codeName } .useMove("player")` ;
164- $ ( "#key" ) . before ( `<button class="move" id="add-${ codeName } " onclick="${ this . addFunction } ">${ name } </button>` ) ;
166+ $ ( "#key" ) . before ( `<button class="move-select " id="add-${ codeName } " onclick="${ this . addFunction } ">${ name } </button>` ) ;
165167 if ( dmg > 0 && target === "attack" ) {
166168 $ ( `#add-${ codeName } ` ) . addClass ( "damageMove" ) ;
167169 } else if ( dmg > 0 ) {
@@ -192,16 +194,27 @@ class Move {
192194 let randomDamageBoost = Math . random ( ) / 5
193195 randomDamageBoost += 0.9
194196 pDamageDealt *= randomDamageBoost
197+ pDamageDealt -= enemyDef
198+ pDamageDealt = Math . max ( pDamageDealt , ( pDamageDealt + enemyDef ) / 2 )
195199 enemyHp -= pDamageDealt ;
196200 playerHp += this . heal * playerExtraDmg ;
201+ console . log ( this . codeName )
197202 playerHp = Math . min ( playerHp , playerMaxHp ) ;
198203 enemyHp = Math . min ( enemyHp , enemyMaxHp )
199204 if ( this . target === "user" ) {
200- playerExtraDmg += this . effect ;
201- playerExtraDmg = Math . max ( playerExtraDmg , 0.5 ) ;
205+ if ( this . effectType === 1 ) {
206+ playerExtraDmg += this . effect ;
207+ playerExtraDmg = Math . max ( playerExtraDmg , 0.5 ) ;
208+ } else if ( this . effectType === 2 ) {
209+ playerDef += this . effect ;
210+ }
202211 } else if ( this . target === "enemy" ) {
203- enemyExtraDmg += this . effect ;
204- enemyExtraDmg = Math . max ( enemyExtraDmg , 0.5 ) ;
212+ if ( this . effectType === 1 ) {
213+ enemyExtraDmg += this . effect ;
214+ enemyExtraDmg = Math . max ( enemyExtraDmg , 0.5 ) ;
215+ } else if ( this . effectType === 2 ) {
216+ enemyDef += this . effect ;
217+ }
205218 }
206219
207220 if ( this . dmg > 0 && this . heal >= 0 ) {
@@ -211,9 +224,17 @@ class Move {
211224 display ( `You used ${ this . name } !` , `It dealt ${ Math . round ( pDamageDealt ) } damage.` )
212225 }
213226 } else if ( this . target === "user" ) {
214- display ( `You used ${ this . name } !` , `Your attack increased by ${ this . effect * 100 } %.` )
227+ if ( this . effectType === 1 ) {
228+ display ( `You used ${ this . name } !` , `Your attack increased by ${ this . effect * 100 } %.` )
229+ } else {
230+ display ( `You used ${ this . name } !` , `Your defense increased by ${ this . effect } .` )
231+ }
215232 } else if ( this . target === "enemy" ) {
216- display ( `You used ${ this . name } !` , `The opponent's attack decreased by ${ this . effect * - 100 } %.` )
233+ if ( this . effectType === 1 ) {
234+ display ( `You used ${ this . name } !` , `The opponent's attack decreased by ${ this . effect * - 100 } %.` )
235+ } else {
236+ display ( `You used ${ this . name } !` , `The opponent's defense decreased by ${ this . effect * - 1 } .` )
237+ }
217238 } else if ( this . heal > 0 ) {
218239 display ( `You used ${ this . name } !` , `It brought your HP back up to ${ Math . round ( playerHp ) } .` )
219240 } else if ( this . heal < 0 ) {
@@ -240,16 +261,26 @@ class Move {
240261 let eRandomDamageBoost = Math . random ( ) / 5
241262 eRandomDamageBoost += 0.9
242263 eDamageDealt *= eRandomDamageBoost
264+ eDamageDealt -= playerDef ;
265+ eDamageDealt = Math . max ( eDamageDealt , ( eDamageDealt + playerDef ) / 2 )
243266 playerHp -= eDamageDealt ;
244267 enemyHp += this . heal * enemyExtraDmg ;
245268 enemyHp = Math . min ( enemyHp , enemyMaxHp ) ;
246269 playerHp = Math . min ( playerHp , playerMaxHp ) ;
247270 if ( this . target === "user" ) {
248- enemyExtraDmg += this . effect ;
249- enemyExtraDmg = Math . max ( enemyExtraDmg , 0.5 ) ;
271+ if ( this . effectType === 1 ) {
272+ enemyExtraDmg += this . effect ;
273+ enemyExtraDmg = Math . max ( enemyExtraDmg , 0.5 ) ;
274+ } else if ( this . effectType === 2 ) {
275+ enemyDef += this . effect ;
276+ }
250277 } else if ( this . target === "enemy" ) {
251- playerExtraDmg += this . effect ;
252- playerExtraDmg = Math . max ( playerExtraDmg , 0.5 ) ;
278+ if ( this . effectType === 1 ) {
279+ playerExtraDmg += this . effect ;
280+ playerExtraDmg = Math . max ( playerExtraDmg , 0.5 ) ;
281+ } else if ( this . effectType === 2 ) {
282+ playerDef += this . effect ;
283+ }
253284 }
254285 if ( this . dmg > 0 && this . heal >= 0 ) {
255286 if ( this . target != "attack" || this . heal > 0 ) {
@@ -258,9 +289,17 @@ class Move {
258289 display ( `The opponent used ${ this . name } !` , `It dealt ${ Math . round ( eDamageDealt ) } damage.` )
259290 }
260291 } else if ( this . target === "user" ) {
261- display ( `The opponent used ${ this . name } !` , `The opponent's attack increased by ${ this . effect * 100 } %.` )
292+ if ( this . effectType === 1 ) {
293+ display ( `The opponent used ${ this . name } !` , `The opponent's attack increased by ${ this . effect * 100 } %.` )
294+ } else {
295+ display ( `The opponent used ${ this . name } !` , `The opponent's defense increased by ${ this . effect * 1 } .` )
296+ }
262297 } else if ( this . target === "enemy" ) {
263- display ( `The opponent used used ${ this . name } !` , `Your attack decreased by ${ this . effect * - 100 } %.` )
298+ if ( this . effectType === 1 ) {
299+ display ( `The opponent used ${ this . name } !` , `Your attack decreased by ${ this . effect * - 100 } %.` )
300+ } else {
301+ display ( `The opponent used ${ this . name } !` , `Your defense decreased by ${ this . effect * - 1 } .` )
302+ }
264303 } else if ( this . heal > 0 ) {
265304 display ( `The opponent used ${ this . name } !` , `It brought its HP back up to ${ Math . round ( enemyHp ) } .` )
266305 } else if ( this . heal < 0 ) {
@@ -285,17 +324,20 @@ class Move {
285324
286325}
287326
288- // let name = new Move("name", dmg, effectTarget, effectPower, heal, "codename")
289- let bonk = new Move ( "Bonk" , 40 , "attack" , 0 , 0 , "bonk" , false ) ;
290- let stronk = new Move ( "Stronkify" , 0 , "user" , 0.15 , 0 , "stronk" , false ) ;
291- let belittle = new Move ( "Belittle" , 0 , "enemy" , - 0.15 , 0 , "belittle" , false ) ;
292- let tickle = new Move ( "Tickle" , 10 , "enemy" , - 0.1 , 0 , "tickle" , false ) ;
293- let lick = new Move ( "Lick Wounds" , 0 , "attack" , 0 , 30 , "lick" , false ) ;
294- let hyperbonk = new Move ( "HYPERBONK" , 50 , "attack" , 0 , - 40 , "hyperbonk" , false ) ;
295- let triangulate = new Move ( "Triangulate 🤓" , 15 , "user" , 0.05 , 10 , "triangulate" , false ) ;
296- let munch = new Move ( "Gremlin Munch" , 30 , "attack" , 0 , 15 , "munch" , false )
297- let beast = new Move ( "MRBEASTTTT" , - 20 , "attack" , 0 , 40 , "beast" , true )
298- let saiyan = new Move ( "Super Saiyan" , 0 , "user" , 0.3 , - 30 , "saiyan" , true )
327+ // let name = new Move("name", dmg, "effectTarget", effectPower, effectType, heal, "codename", hasSpeicalDisplay)
328+ let bonk = new Move ( "Bonk" , 40 , "attack" , 0 , 0 , 0 , "bonk" , false ) ;
329+ let stronk = new Move ( "Stronkify" , 0 , "user" , 0.15 , 1 , 0 , "stronk" , false ) ;
330+ let belittle = new Move ( "Belittle" , 0 , "enemy" , - 0.15 , 1 , 0 , "belittle" , false ) ;
331+ let tickle = new Move ( "Tickle" , 10 , "enemy" , - 0.1 , 1 , 0 , "tickle" , false ) ;
332+ let lick = new Move ( "Lick Wounds" , 0 , "attack" , 0 , 0 , 30 , "lick" , false ) ;
333+ let hyperbonk = new Move ( "HYPERBONK" , 50 , "attack" , 0 , 0 , - 40 , "hyperbonk" , false ) ;
334+ let triangulate = new Move ( "Triangulate 🤓" , 15 , "user" , 0.05 , 1 , 10 , "triangulate" , false ) ;
335+ let munch = new Move ( "Gremlin Munch" , 30 , "attack" , 0 , 0 , 15 , "munch" , false )
336+ let beast = new Move ( "MRBEASTTTT" , - 20 , "attack" , 0 , 0 , 40 , "beast" , true )
337+ let saiyan = new Move ( "Super Saiyan" , 0 , "user" , 0.3 , 1 , - 30 , "saiyan" , true )
338+ let rock = new Move ( "El Rock" , 0 , "user" , 5 , 2 , 0 , "rock" , false )
339+ let pickaxe = new Move ( "Diamond Pickaxe" , 0 , "enemy" , - 5 , 2 , 0 , "pickaxe" , false )
340+ let l = new Move ( "L" , 25 , "enemy" , - 0.05 , 1 , 0 , "l" , false )
299341// Kalob was a special child. He belittled people so they could not lick their wounds using a baseball bat to bonk them
300342document . addEventListener ( "keydown" , debug ) ;
301343setupAi ( )
0 commit comments