私はプレイヤーA対Bの戦いのための簡単なドロップ式を書いています-レベルの違いがドロップ率を決定します。0: > 10 ||| 1 vs. 1 = 10%
ここでの私の問題は、それが与える代わりに0: > 10 ||| 1 vs. 1 = 0%
-なぜですか?
PhpFiddle:http ://www.phpfiddle.org/main/code/n1q-dw7
<?php
# lets simulate high level player A attacks low level player B
for ($A = 1; $A <= 100; $A++) {
$B = 1;
calculateMoneyDrop($A,$B);
}
# lets simulate low level player A attacks high level player B
for ($B = 1; $B <= 100; $B++) {
$A = 1;
calculateMoneyDrop($A,$B);
}
function calculateMoneyDrop($A,$B) {
$X = $A - $B;
echo '<strong>', $X, '</strong>: ';
switch ($X) {
case $X > 10:
echo "> 10 ||| ";
$X = 10;
break;
case $X < -90:
echo "< -90 ||| ";
$X = -90;
break;
}
$dropRate = 10 - $X;
echo $A, ' vs. ', $B, ' = ', $dropRate, '%<br>';
}