… function unitstats($unit) { …
/* gets the stats of a particular unit */
$stats = array();
if ($unit == 'l') {
$stats['atk'] = 24;
$stats['def'] = 18;
} elseif ($unit == ‘e’) {
$stats['atk'] = 4;
$stats['def'] = 2;
} elseif ($unit == ’s’) {
$stats['atk'] = 12;
$stats['def'] = 4;
} elseif ($unit == ‘r’) {
$stats['atk'] = 2;
$stats['def'] = 4;
} elseif ($unit == ‘o’) {
$stats['atk'] = 12;
$stats['def'] = 6;
} elseif ($unit == ‘a’) {
$stats['atk'] = 12;
$stats['def'] = 4;
}
return $stats;
}
… $avb = round($stats1['atk'] / $stats2['def']); …
$bva = round($stats2['atk'] / $stats1['def']);
$health1 -= $bva;
$health2 -= $avb;
This should totally be an array shouldn’t it.