function _divRound(uint a, uint b)
internal
pure
returns(uint)
{
uint d = ((a * 100) / b);
uint r = d % 100;
d = d / 100;
if (r >= 75)
return d + 1;
return d;
}
function calcBattleInternal(uint a, uint d)
internal
pure
returns(uint)
{
uint c = _divRound(100*d,a);
if ( c <= 25 )
return c - _divRound(c,2);
if ( c <= 50 )
return c - _divRound(c,3);
if ( c <= 75 )
return c - _divRound(c,4);
if ( c < 90 )
return c - _divRound(c,8);
return c;
}
function calcBattle(uint a, uint d)
external
pure
returns(uint)
{
return calcBattleInternal(a,d);
}
function calcSack(uint a, uint d)
external
pure
returns(uint)
{
uint c = calcBattleInternal(a,d);
return _divRound(100*c,100+c);
}