@@ -195,9 +195,11 @@ Hero.prototype = Object.create(Humanoid.prototype);
195195 Hero . prototype . healing = ( ) => {
196196
197197 Orchaldaer . hp += 5 ;
198- return "Not this time genericBadGuy !!" ;
198+ return "Not this time swordsman2 !!" ;
199199 }
200-
200+ Hero . prototype . heaven = ( ) => {
201+ Orchaldaer . hp += 20 ;
202+ }
201203 const Orchaldaer = new Hero ( {
202204 createdAt : new Date ( ) ,
203205 dimensions : {
@@ -217,28 +219,46 @@ Hero.prototype = Object.create(Humanoid.prototype);
217219
218220 Hero . prototype . fistOfLight = ( ) => {
219221 swordsman2 . hp -= 3 ;
220- return `A huge first of light smacks genericBadGuy in the face!`
222+ return `A huge first of light smacks swordsman2 in the face!`
221223 }
222224
223225 console . log ( swordsman2 . unspeakableHorror ( ) ) ;
224226 console . log ( Orchaldaer . hp ) ;
225227 console . log ( Orchaldaer . healing ( ) ) ;
226228 console . log ( Orchaldaer . hp ) ;
227229
230+ //fight function prompts a player to enter 'p' for game to start
228231 function fight ( ) {
229- while ( Orchaldaer . hp > 0 && swordsman2 . hp > 0 ) {
232+ let chance = 0 ;
233+ while ( Orchaldaer . hp > 0 && swordsman2 . hp > 0 ) {
234+ //Please enter 'p' to start game
235+ let prompt = 's' ;
236+ if ( prompt === 'p' ) {
237+ chance = Math . random ( ) ;
238+ }
230239 console . log ( Orchaldaer . fistOfLight ( ) ) ;
231240 console . log ( Orchaldaer . healing ( ) ) ;
232241 console . log ( swordsman2 . unspeakableHorror ( ) ) ;
233- if ( Orchaldaer . hp <= 0 ) {
234- return Orchaldaer . destroy ( ) ;
235- break ;
236- }
237- else if ( swordsman2 . hp < - 0 ) {
238- return swordsman2 . destroy ( ) ;
239- break ;
242+ console . log ( Orchaldaer . hp )
243+ if ( Orchaldaer . hp <= 45 && chance <= 0.1 ) {
244+ Orchaldaer . heaven ( ) ;
245+ console . log ( "it works" ) ;
240246 }
247+ // continue;
248+ // }
249+
250+ // if (orchaldaer.hp <= 0) {
251+ // return "The forces of darkness have reigned surpreme again! ";
252+ // }
253+ // else if (genericBadGuy.hp <= 0) {
254+ // return genericBadGuy.destroy();
255+ // }
241256 }
242- }
243-
257+ if ( Orchaldaer . hp <= 0 ) {
258+ return "The forces of darkness have reigned surpreme again! " ;
259+ } else if ( swordsman2 . hp <= 0 ) {
260+ return "The forces of light have reigned surpreme again! " ;
261+ }
262+ }
263+
244264 console . log ( fight ( ) ) ;
0 commit comments