kyu_6.pokemon_damage_calculator package

Submodules

kyu_6.pokemon_damage_calculator.calculate_damage module

Solution for -> Pokemon Damage Calculator.

Created by Egor Kostan. GitHub: https://github.com/ikostan

kyu_6.pokemon_damage_calculator.calculate_damage.calculate_damage(your_type: str, opponent_type: str, attack, defense) int[source]

Pokemon Damage Calculator.

It’s a Pokemon battle! Your task is to calculate the damage that a particular move would do using the following formula (not the actual one from the game):

damage = 50 * (attack / defense) * effectiveness

Parameters:
  • your_type

  • opponent_type

  • attack

  • defense

Returns:

kyu_6.pokemon_damage_calculator.calculate_damage.effectiveness(your_type: str, opponent_type: str) float[source]

Effectiveness.

Super effective: 2x damage Neutral: 1x damage Not very effective: 0.5x damage

To prevent this kata from being tedious, you’ll only be dealing with four types: fire, water, grass, and electric. Here is the effectiveness of each match-up:

fire > grass fire < water fire = electric water < grass water < electric grass = electric

Parameters:
  • your_type

  • opponent_type

Returns:

kyu_6.pokemon_damage_calculator.test_calculate_damage module

Test for -> Pokemon Damage Calculator.

Created by Egor Kostan. GitHub: https://github.com/ikostan

class kyu_6.pokemon_damage_calculator.test_calculate_damage.CalculateDamageTestCase(methodName='runTest')[source]

Bases: TestCase

Testing calculate_damage function.

_classSetupFailed = False
_class_cleanups = []
test_calculate_damage = None
test_calculate_damage_0(**kw)

Testing calculate_damage with various test data [with test_data=(‘fire’, ‘water’, 100, 100), expected=25].

Returns:

test_calculate_damage_1(**kw)

Testing calculate_damage with various test data [with test_data=(‘grass’, ‘water’, 100, 100), expected=100].

Returns:

test_calculate_damage_2(**kw)

Testing calculate_damage with various test data [with test_data=(‘electric’, ‘fire’, 100, 100), expected=50].

Returns:

test_calculate_damage_3(**kw)

Testing calculate_damage with various test data [with test_data=(‘grass’, ‘electric’, 57, 19), expected=150].

Returns:

test_calculate_damage_4(**kw)

Testing calculate_damage with various test data [with test_data=(‘grass’, ‘water’, 40, 40), expected=100].

Returns:

test_calculate_damage_5(**kw)

Testing calculate_damage with various test data [with test_data=(‘grass’, ‘fire’, 35, 5), expected=175].

Returns:

test_calculate_damage_6(**kw)

Testing calculate_damage with various test data [with test_data=(‘fire’, ‘electric’, 10, 2), expected=250].

Returns:

Module contents

Pokemon Damage Calculator.