heroClasses = {
warrior: {
charClass: "Warrior",
life: 30,
damage: 4
},
rogue: {
charClass: "Rogue",
life: 25,
damage: 3
},
sorcerer: {
charClass: "Sorcerer",
life: 20,
damage: 5
}
}
monsterClasses = {
zombie: {
charClass: "Zombie",
life: 8,
damage: 4
},
skeleton: {
charClass: "Skeleton",
life: 10,
damage: 6
},
holem: {
charClass: "Holem",
life: 15,
damage: 6
}
}
statuses = {
idle : "Idle",
progress : "In progress",
finished : "Finished"
}
maxMonsters = 2
game = {
status // string, current game status, "Idle" is the initial one
hero // object - hero object that is in game
monsters // array of monsters in game, max = maxMonsters
}
// Change game status from "Idle" to "In progress", should be possible only if hero and monsters are defined
// returns:
// "Your journey has started, fight monsters" - if ok
// throw new Error(
// "Cannot start journey, populate the world with hero and monsters first") - if smth went wrong
beginJourney()
// Change game status from "In progress" to "Finished", possible only if hero or both monsters are dead(their life equals 0)
// retures:
// "The Game is finished. Monstrs are dead. Congratulations" - if both monsters are dead
// "The Game is finished. Hero is dead :(" - if hero is dead
// "Don`t stop. Some monsters are still alive. Kill`em all" - if its not time yet
finishJourney()
// set game.hero to hero instance
// accepts: instance of Hero class
// throw:
// "Only one hero can exist" - if hero is already defined
// "Only hero instance can be hero" - if not hero was passed to function
// returns:
// "Hero created, welcome HERO_NAME" - if ok
addHero()
// adds monster to game.monsters array
// accepts: instance of Monster class
// throw:
// "Only 2 monsters can exist" - if there are already 2 monsters defined
// "Only monster Instances can become monsters" - if not monster was passed to function
// returns:
// "Monster Created, MONSTER_CHARACTER_CLASS appeared in the world" - if ok
addMonster()
// Initiate a battle between hero and monster, one after another, they should attack each other, starting from hero,
// and until someone life is not 0
// returns string 'Hero win' or 'Monster win', depending on who has life points left
fight()
// instance of hero should have
.name // string
.charClass // sting
.life // number
.damage // number
.getName() // function returning name
.getCharClass() // function returning character class
// accepts - target - instance of Monster
// returns:
// "I will attack only monsters" - in not monster was passed as target
// "Hero attacked, " + GENERAL_ATTACK_MESSAGE
.attack(target) //
// instance of Monster should have
.charClass // sting
.life // number
.damage // number
.getName() // function returning "I am MONSTER_CHARACTER_CLASS I don`t have name"
.getCharClass() // function returning character class
// accepts - target - instance of Hero
// returns:
// "I will attack only Hero" - in not hero was passed as target
// "Monster attacked, " + GENERAL_ATTACK_MESSAGE
.attack(target) //
// attack logic
// decrease amount of target life on the value of attackers damage
// accepts - target - instance of Monster or Hero
// returns GENERAL_ATACK_MESSAGE:
// "CHARACTER_CLASS killed" - this action will kill target
// "done AMOUNT_OF_DAMAGE damage to CHARACTER_CLASS";
.attack(target)
// decrease amount of target life on the value of attackers damage
// accepts - target - instance of Monster or Hero
// returns:
// "CHARACTER_CLASS killed" - this action will kill target
// "done AMOUNT_OF_DAMAGE damage to CHARACTER_CLASS";
.attack(target)
Should have properties
Should have methods