/monsters-combat-game-oop

Object-Oriented Programming

Primary LanguageJavaScript

The essence of this project is a summarized representation of the logic in the battle between monsters. The code is designed to be extensible. The OOP method 'Inheritance' is at the forefront

In my project, js/index.js, I'm employing a modern approach using classes in JavaScript, whereas in js/oldWay.js, I showcase an older method relying on functions behaving as classes, demonstrating different implementation styles for the game.

Task: Create a game called "Monsters Combat"


Game description:

  • In the game, there are 2 monsters (Skeleton and Spider) and they fight each other
  • Each of them has its own attacks. Some have more, and some have fewer. Each attack has a specific damage it deals
  • The Skeleton has less health but stronger hits, whereas the Spider is the opposite
  • The attack is chosen via a random number (0-monster.attacks.length)
  • If a monster gets 2 or more consecutive attacks, its health decreases by 10, as it is considered tired

How To Play:

  • By clicking the 'Attack' button, we control the game
  • Upon clicking, we generate a number from 0 to 100. If the number is greater than 50, the attacker is the first monster in the game, if the number is less than 50, the attacker is the second monster
  • The first one to lose all health is the loser.
  • Open console to track a game