Skip to content
This repository has been archived by the owner on Jul 20, 2018. It is now read-only.
/ pokemon Public archive

A boilerplate for the pokemon interview question

Notifications You must be signed in to change notification settings

midu/pokemon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The most advanced Pokémon game, ever.

Exercise

Implement a Pokémon game with three different Pokémon:

Pokémon
Name Bulbasaur Charmander Squirtle
Type Grass Fire Water
HP 100 100 100
Strength 10 10 10
  • Each Pokémon has 10 points of strength, which means that when they attack another Pokémon, they deal 10 damage points.
  • Each Pokémon has 100 health points.
  • Some Pokémon types do extra damage to other types, see chart below

Pokemon damage chart

type Grass Fire Water
Grass 1x 1x 2x
Water 1x 2x 1x
Fire 2x 1x 1x
  • Fire Pokémon do double damage to Grass Pokémon
  • Water Pokémon do double to Fire Pokémon
  • Grass Pokémon do double damage on Water Pokémon

Game rules

This Pokémon game can be played in Ruby, based on the following instruction:

  • Each Pokémon is created by instantiating a class with the type of Pokémon (eg, squirtle = Squirtle.new)
  • To attack, a Pokémon uses its method attack on another Pokémon (eg, squirtle.attack(bulbasaur))
  • You can check how many HP's are left by calling hp on a Pokémon (eg, squirtle.hp)
  • When a Pokémon is KO'd, its HP's stay at 0, they can't be negative.
squirtle = Squirtle.new
squirtle.hp
# => 100

bulbasaur = Bulbasaur.new
bulbasaur.hp = 100

squirtle.attack(bulbasaur)

bulbasaur.hp
# => 90
squirtle.hp
# => 100

bulbasaur.attack(squirtle)

bulbasaur.hp
# => 90
squirtle.hp
# => 80

How would you implement this?

You may run rspec in the root of this directory to run a basic test suite that will verify that your game respects the rules.


Build Status

About

A boilerplate for the pokemon interview question

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages