Skip to content

Commit

Permalink
dead or alive you're coming with me
Browse files Browse the repository at this point in the history
  • Loading branch information
guyroyse committed Aug 1, 2015
1 parent 056ce9f commit 95578b2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions evercraft.py
Expand Up @@ -16,6 +16,10 @@ def armor_class(self):
def hit_points(self):
return 5 - self._damage

@property
def alive(self):
return self.hit_points > 0

def damage(self, points):
self._damage = self._damage + points

Expand Down
11 changes: 11 additions & 0 deletions tests/test_evercraft.py
Expand Up @@ -32,6 +32,17 @@ def test_armor_class_has_expected_default(self):
def test_hit_points_has_expected_default(self):
self.assertEqual(self.subject.hit_points, 5)

def test_is_alive_when_undamaged(self):
self.assertTrue(self.subject.alive)

def test_is_alive_when_damaged(self):
self.subject.damage(3)
self.assertTrue(self.subject.alive)

def test_is_dead_when_out_of_hit_points(self):
self.subject.damage(5)
self.assertFalse(self.subject.alive)

class TestCombat(TestCase):

def setUp(self):
Expand Down

0 comments on commit 95578b2

Please sign in to comment.