def test_MinDmgAlwaysOne(self): testCharacter1 = Character() testCharacter2 = Character() testCharacter1.strength = 1 roll = 20 attack = Attack(testCharacter1, testCharacter2, roll) attack.attemptAttack() self.assertEqual(4, testCharacter2.hitPoints)
def test_ifRollIs20CriticalHitDoubleDamage(self): testCharacter1 = Character() testCharacter2 = Character() roll = 20 attack = Attack(testCharacter1, testCharacter2, roll) attack.attemptAttack() self.assertEqual(3, testCharacter2.hitPoints)
def test_CharacterGainsTenExperienceOnSuccessful(self): testCharacter1 = Character() testCharacter2 = Character() roll = testCharacter2.armor + 1 attack = Attack(testCharacter1, testCharacter2, roll) attack.attemptAttack() self.assertEqual(10, testCharacter1.experiencePoints)
def test_tripleDmgOnCritHit(self): testCharacter1 = Rogue() testCharacter2 = Character() roll = Roll(testCharacter1, testCharacter2, 20) attack = Attack(testCharacter1, testCharacter2, roll.initialRoll) attack.attemptAttack() self.assertEqual(2, testCharacter2.hitPoints)
def test_ifTargetCharacterHitTakesOneDamage(self): testCharacter1 = Character() testCharacter2 = Character() roll = testCharacter2.armor attack = Attack(testCharacter1, testCharacter2, roll) attack.attemptAttack() self.assertEqual(4, testCharacter2.hitPoints)
def test_CharacterLevelsAfter1000ExperiencePoints(self): testCharacter1 = Character() testCharacter2 = Character() testCharacter1.experiencePoints = 990 roll = testCharacter2.armor attack = Attack(testCharacter1, testCharacter2, roll) attack.attemptAttack() self.assertEqual(testCharacter1.level, 2)
def test_StrModIsAppliedToAttack(self): testCharacter1 = Character() testCharacter2 = Character() testCharacter1.strength = 12 roll = testCharacter2.armor - 1 attack = Attack(testCharacter1, testCharacter2, roll) attack.attemptAttack() self.assertEqual(3, testCharacter2.hitPoints)
def test_ifOpponentDexModIsPositiveModIsNotAppliedToArmor(self): testCharacter1 = Rogue() testCharacter2 = Character() testCharacter2.dexterity = 12 roll = Roll(testCharacter1, testCharacter2, 10) attack = Attack(testCharacter1, testCharacter2, roll.initialRoll) attack.attemptAttack() self.assertEqual(4, testCharacter2.hitPoints)
def test_does3DmgInsteadOf1OnSuccessfulAttack(self): testCharacter1 = Monk() testCharacter2 = Character() roll = Roll(testCharacter1, testCharacter2, testCharacter2.armor) attack = Attack(testCharacter1, testCharacter2, roll.initialRoll) attack.attemptAttack() self.assertEqual(2, testCharacter2.hitPoints)
def test_attackRollNotIncreasedIfNot2ndOr3rdLevel(self): testCharacter1 = Monk() testCharacter2 = Character() roll = Roll(testCharacter1, testCharacter2, testCharacter2.armor-1) attack = Attack(testCharacter1, testCharacter2, roll.initialRoll) attack.attemptAttack() self.assertEqual(5, testCharacter2.hitPoints)
def test_addsDexModToAttacksInsteadOfStrength(self): testCharacter1 = Rogue() testCharacter2 = Character() testCharacter1.dexterity = 12 roll = Roll(testCharacter1, testCharacter2, testCharacter2.armor - 1) attack = Attack(testCharacter1, testCharacter2, roll.initialRoll) attack.attemptAttack() self.assertEqual(3, testCharacter2.hitPoints)
def test_monkGains6HPPerLevel(self): testCharacter1 = Monk() testCharacter2 = Character() testCharacter1.experiencePoints = 990 roll = Roll(testCharacter1, testCharacter2, testCharacter2.armor) attack = Attack(testCharacter1, testCharacter2, roll.initialRoll) attack.attemptAttack() self.assertEqual(11, testCharacter1.hitPoints)
def test_attackRollIncreasedBy1Every3rdLevel(self): testCharacter1 = Monk() testCharacter2 = Character() testCharacter1.level = 3 roll = Roll(testCharacter1, testCharacter2, testCharacter2.armor-1) attack = Attack(testCharacter1, testCharacter2, roll.initialRoll) attack.attemptAttack() self.assertEqual(2, testCharacter2.hitPoints)
def test_dontAddWisdomModIfNegativeToArmor(self): testCharacter1 = Character() testCharacter2 = Monk() testCharacter2.wisdom = 8 roll = Roll(testCharacter1, testCharacter2, testCharacter2.armor) attack = Attack(testCharacter1, testCharacter2, roll.initialRoll) attack.attemptAttack() self.assertEqual(4, testCharacter2.hitPoints)
def test_CharacterOnlyLevelsEvery1000ExperiencePoints(self): testCharacter1 = Character() testCharacter2 = Character() testCharacter1.experiencePoints = 1001 testCharacter1.level = 2 roll = testCharacter2.armor attack = Attack(testCharacter1, testCharacter2, roll) attack.attemptAttack() self.assertEqual(testCharacter1.level, 2)
def test_ifTargetCharacterHP0OrLessTargetIsDead(self): testCharacter1 = Character() testCharacter2 = Character() testCharacter2.hitPoints = 1 roll = testCharacter2.armor attack = Attack(testCharacter1, testCharacter2, roll) attack.attemptAttack() testCharacter2.checkLivingStatus() self.assertFalse(testCharacter2.isAlive)
def test_DeadCharacterCannotBeAttacked(self): testCharacter1 = Character() testCharacter2 = Character() testCharacter2.isAlive = False testCharacter2.hitPoints = 0 roll = testCharacter2.armor attack = Attack(testCharacter1, testCharacter2, roll) attack.attemptAttack() self.assertEqual(0, testCharacter2.hitPoints)
def test_StrModIsDoubleOnCritHit(self): testCharacter1 = Character() testCharacter2 = Character() testCharacter1.strength = 12 testCharacter2.hitPoints = 6 roll = 20 attack = Attack(testCharacter1, testCharacter2, roll) attack.attemptAttack() testCharacter2.checkLivingStatus() self.assertFalse(testCharacter2.isAlive)