- https://www.codewars.com/kata/536e9a7973130a06eb000e9f Pokemon Damage Calculator.
Started at 23:24 10.11.2020 Tuesday Nov.
Finished at 23:16 11.11.2020 Wednesday Nov.
<?php | |
# https://www.codewars.com/kata/536e9a7973130a06eb000e9f | |
function calculateDamage(string $yourType, string $opponentType, int $attack, int $defense): int | |
{ | |
$x = 1; | |
$a = $yourType; $b = $opponentType; | |
if("fire" == $a){ | |
if('fire' == $b) $x = 0.5; | |
if('grass' == $b) $x = 2; | |
if('water' == $b) $x = 0.5; | |
if('electric' == $b) $x = 1; | |
} | |
if("water" == $a){ | |
if('fire' == $b) $x = 2; | |
if('grass' == $b) $x = 0.5; | |
if('water' == $b) $x = 0.5; | |
if('electric' == $b) $x = 0.5; | |
} | |
if("electric" == $a){ | |
if('fire' == $b) $x = 1; | |
if('grass' == $b) $x =1; | |
if('water' == $b) $x = 2; | |
if('electric' == $b) $x = 0.5; | |
} | |
if("grass" == $a){ | |
if('fire' == $b) $x = 0.5; | |
if('grass' == $b) $x = 0.5; | |
if('water' == $b) $x = 2; | |
if('electric' == $b) $x = 1; | |
} | |
return 50 * ($attack/$defense) * $x; | |
} |
Started at 23:24 10.11.2020 Tuesday Nov.
Finished at 23:16 11.11.2020 Wednesday Nov.