function attribute_modification( $attribute ) {
$a = 2; $b = 3; $c = -4;
$return = 0;
while( ! $return ) {
if ( $attribute == 1 ) $return = $c - 1;
if ( $attribute == $a || $attribute == $b ) $return = $c;
$a += 2; $b += 2; $c++;
}
return $return;
}
function dice( $walls, $ratio, $bonus ) {
$return = 0;
for( $k = 1 ; $k <= $ratio ; $k++ ) {
$return += rand( 1
, $walls ); }
return $return + $bonus;
}
function randomize_attributes() {
for ( $i = 1 ; $i <= 6 ; $i++ ) {
$tmp = array ( dice
( 6
, 1
, 0
), dice
( 6
, 1
, 0
), dice
( 6
, 1
, 0
), dice
( 6
, 1
, 0
) );
sort( $tmp, SORT_NUMERIC
);
$dices[ $i - 1 ] = $tmp[ 1 ] + $tmp[ 2 ] + $tmp[ 3 ];
}
return $dices;
}
function test_attributes( $dices ) {
$modification_summary = 0;
for ( $i = 1 ; $i <= 6 ; $i++ ) {
$modification_summary += attribute_modification( $dices[ $i - 1 ] );
}
if ( $modification_summary < 1 || $dices[ 5 ] < 14 ) return false;
return true;
}
echo test_attributes
( randomize_attributes
() );
echo nie zwraca wyniku :/ przeglądarka cały czas czeka na odpowiedź z serwera