Did some changes that were required for #59. So all functions required for calculating and assigning experience are available.

main
hecht 13 years ago
parent 98fa919fc4
commit 8ff7669971

@ -89,10 +89,11 @@ function getMaximumMembers($clanid) {
function getRequiredClanExp($level) {
//return pow(2, $level) * 10;
$level = $level + 1;
$level = $level + 1;
// 12,5*(neuesLevel)^2-22,5*(neues Level)+10
$value = 12.5 * pow($level, 2) - 22.5 * $level + 10;
$value = beautifyNumericValue($value, 5);
// 10-22,5*(neues Level)+12,5*(neuesLevel)^2
$value = 12.5 * pow($level, 2) - 22.5 * $level + 5;
$value = beautifyNumericValue($value, 10);
return $value;
}
@ -331,5 +332,22 @@ function sendClanNewsletter($user, $text){
}
function addClanExp($clan_id, $exp) {
$clan = getClan($clan_id, false);
if($clan['level'] == 18)
return;
$n_exp = $clan['exp'] + $exp;
$n_level = $clan['level'];
$req_exp = getRequiredClanExp($clan['level']);
if($req_exp <= $n_exp) {
$n_exp = 0;
$n_level++;
}
mysql_query('UPDATE clan SET exp = ' .$n_exp. ', level = ' .$n_level . ' WHERE id = ' .$clan_id . ' AND exp = ' .$clan['exp'] . ' AND level = ' .$clan['level']);
if(mysql_affected_rows() == 0) {
echo 'Fehler beim zuweisen der Clanexp, dadurch sind dem Clan mit der ID ' . $clan['level'] . ' ' .$exp . ' exp fl&omul;ten gegangen!! Neue exp w&auml;ren ' . $n_exp . ' bei level ' .$n_level;
}
}
?>

@ -29,6 +29,9 @@ defineIfNotDefined('DURATION_SURVIVAL_FIGHT', 15);
defineIfNotDefined('ATTACK_SET_DAVY_BACK_FIGHT', 2);
defineIfNotDefined('ATTACK_SET_SURVIVAL', 2);
defineIfNotDefined('CLAN_EXP_FAKTOR_G', 1);
$GLOBALS['clan_challenge_buffered_instances'] = array ();
@ -972,6 +975,23 @@ function isAuthorizedClanfightCoordinator($clan_id, $user_id, $clan_fight_id = N
return true;
}
/**
* Calculates the clan exp for clan1
* @param array $clan1 the clan for whom the experience is calculated
* @param array $clan2 the other clan that was participating
* @param int $winner the id of the clan that has won
*/
function calculateClanExperience(array $clan1, array $clan2, $winner) {
$m = 1+pow(($clan2['level'] - $clan1['level'])/20,10);
$g = CLAN_EXP_FAKTOR_G;
if($clan1['id'] == $winner) {
$exp = (($clan1['level'] + $clan2['level'])/2)*$m*$g;
} else {
$exp = (($clan1['level'] + $clan2['level'])/3)*$m*$g;
}
return $exp;
}
/**
* Returns how many chars were assigned by the leader for the given fight
* @param int $clan_id

Loading…
Cancel
Save