@@ -4,7 +4,9 @@ let enemyHp = 160;
4
4
let playerMaxHp = 100 ;
5
5
let enemyMaxHp = 160 ;
6
6
let playerExtraDmg = 1 ;
7
+ let playerDef = 0 ;
7
8
let enemyExtraDmg = 1.05 ;
9
+ let enemyDef = 0 ;
8
10
let moveNames = [ ] ;
9
11
let selectableMoves = [ ] ;
10
12
let movePool = [ ] ;
@@ -94,6 +96,8 @@ function roundAndUpdate() {
94
96
} else if ( enemyExtraDmg >= 1 ) {
95
97
$ ( "#enemyBoost" ) . switchClass ( "nerf" , "boost" , 1000 , "easeInOutQuad" ) ;
96
98
}
99
+ $ ( "#player-defense" ) . html ( playerDef ) ;
100
+ $ ( "#enemy-defense" ) . html ( enemyDef ) ;
97
101
}
98
102
99
103
function display ( top , bottom ) {
@@ -143,25 +147,23 @@ function evalUse(name, user) {
143
147
}
144
148
145
149
class Move {
146
- constructor ( name , dmg , target , effect , heal , codeName , specialMsg ) {
150
+ constructor ( name , dmg , target , effect , effectType , heal , codeName , specialMsg ) {
147
151
this . name = name ;
148
152
this . dmg = dmg ;
149
- if ( target != "$D " ) {
153
+ if ( target != "attack " ) {
150
154
this . target = target ;
151
155
this . effect = effect ;
156
+ } else {
157
+ this . target = "attack" ;
152
158
}
153
159
this . heal = heal ;
154
- if ( heal >= 0 ) {
155
- this . healType = "heal" ;
156
- } else {
157
- this . healType = "recoil" ;
158
- } ;
160
+ this . effectType = effectType ;
159
161
this . codeName = codeName ;
160
162
moveNames . push ( codeName ) ;
161
163
selectableMoves = [ ...moveNames ] ;
162
164
this . addFunction = `${ codeName } .addToMoves()` ;
163
165
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>` ) ;
165
167
if ( dmg > 0 && target === "attack" ) {
166
168
$ ( `#add-${ codeName } ` ) . addClass ( "damageMove" ) ;
167
169
} else if ( dmg > 0 ) {
@@ -192,16 +194,27 @@ class Move {
192
194
let randomDamageBoost = Math . random ( ) / 5
193
195
randomDamageBoost += 0.9
194
196
pDamageDealt *= randomDamageBoost
197
+ pDamageDealt -= enemyDef
198
+ pDamageDealt = Math . max ( pDamageDealt , ( pDamageDealt + enemyDef ) / 2 )
195
199
enemyHp -= pDamageDealt ;
196
200
playerHp += this . heal * playerExtraDmg ;
201
+ console . log ( this . codeName )
197
202
playerHp = Math . min ( playerHp , playerMaxHp ) ;
198
203
enemyHp = Math . min ( enemyHp , enemyMaxHp )
199
204
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
+ }
202
211
} 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
+ }
205
218
}
206
219
207
220
if ( this . dmg > 0 && this . heal >= 0 ) {
@@ -211,9 +224,17 @@ class Move {
211
224
display ( `You used ${ this . name } !` , `It dealt ${ Math . round ( pDamageDealt ) } damage.` )
212
225
}
213
226
} 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
+ }
215
232
} 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
+ }
217
238
} else if ( this . heal > 0 ) {
218
239
display ( `You used ${ this . name } !` , `It brought your HP back up to ${ Math . round ( playerHp ) } .` )
219
240
} else if ( this . heal < 0 ) {
@@ -240,16 +261,26 @@ class Move {
240
261
let eRandomDamageBoost = Math . random ( ) / 5
241
262
eRandomDamageBoost += 0.9
242
263
eDamageDealt *= eRandomDamageBoost
264
+ eDamageDealt -= playerDef ;
265
+ eDamageDealt = Math . max ( eDamageDealt , ( eDamageDealt + playerDef ) / 2 )
243
266
playerHp -= eDamageDealt ;
244
267
enemyHp += this . heal * enemyExtraDmg ;
245
268
enemyHp = Math . min ( enemyHp , enemyMaxHp ) ;
246
269
playerHp = Math . min ( playerHp , playerMaxHp ) ;
247
270
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
+ }
250
277
} 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
+ }
253
284
}
254
285
if ( this . dmg > 0 && this . heal >= 0 ) {
255
286
if ( this . target != "attack" || this . heal > 0 ) {
@@ -258,9 +289,17 @@ class Move {
258
289
display ( `The opponent used ${ this . name } !` , `It dealt ${ Math . round ( eDamageDealt ) } damage.` )
259
290
}
260
291
} 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
+ }
262
297
} 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
+ }
264
303
} else if ( this . heal > 0 ) {
265
304
display ( `The opponent used ${ this . name } !` , `It brought its HP back up to ${ Math . round ( enemyHp ) } .` )
266
305
} else if ( this . heal < 0 ) {
@@ -285,17 +324,20 @@ class Move {
285
324
286
325
}
287
326
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 )
299
341
// Kalob was a special child. He belittled people so they could not lick their wounds using a baseball bat to bonk them
300
342
document . addEventListener ( "keydown" , debug ) ;
301
343
setupAi ( )
0 commit comments