From 5db0542833ab8d702641a9d7ff5c3771c79e8313 Mon Sep 17 00:00:00 2001 From: hecht Date: Mon, 1 Dec 2014 19:48:55 +0000 Subject: [PATCH] replaced the check for determining if there are enough slots available. --- ag/char.php | 18 +++++++----------- ag/include/erstellfunctions.inc.php | 22 ++++++++++++++++++++++ 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/ag/char.php b/ag/char.php index 9b21095..653d24a 100644 --- a/ag/char.php +++ b/ag/char.php @@ -330,7 +330,7 @@ function handleThirdPhaseForTester($type, $name, $char_lvl, $random, $user){ echo 'Ungültiger Levelbereich!'; } - function handleFirstPhase($user_daten,$anzahl_charactere,$tester){ + function handleFirstPhase($user_daten, $tester){ ?>
@@ -399,18 +399,12 @@ function handleThirdPhaseForTester($type, $name, $char_lvl, $random, $user){ } } - #$anzahl_spezialchars = mysql_num_rows(mysql_query('SELECT char_type,name from chars WHERE (rasse = "Kaioshin" OR fusion_rasse = "Kaioshin" OR rasse = "Shichibukai" OR fusion_rasse = "Shichibukai") AND besitzer='.$user_daten['id'])); - $anzahl_charactere= mysql_num_rows(mysql_query("SELECT id FROM chars WHERE besitzer='".$user_daten['id']."'")); + + $check = hasUserFreeCharSlot($user_daten); - if ($anzahl_spezialchars >= 1 AND $user_daten['char_max'] == 7) { - $chars_max= 8; - } else { - $chars_max= $user_daten['char_max']; - } - - if ($anzahl_charactere < $chars_max) { + if ($check) { if($charm === NULL){ - handleFirstPhase($user_daten,$anzahl_charactere, isUserInGroup($usergroups, TESTER)); + handleFirstPhase($user_daten, isUserInGroup($usergroups, TESTER)); } else if($charm == 1){ if(isUserInGroup($usergroups, TESTER)) { handleSecondPhaseForTester($char_type, $char_name); @@ -426,6 +420,8 @@ function handleThirdPhaseForTester($type, $name, $char_lvl, $random, $user){ $_REQUEST['hp'], $_REQUEST['mp'], $_REQUEST['str'], $_REQUEST['def'], $_REQUEST['spd'], $_REQUEST['end'], $_REQUEST['lck']); } } else { + $anzahl_charactere = count(getCharsOfUser($user_daten['id'])); + $chars_max = $user_daten['char_max']; echo 'Du hast bereits die maximal mögliche Menge an Characteren erstellt, die du erstellen kannst.
Nämlich '.$anzahl_charactere.' von '.$chars_max.' Charaktere.'; } diff --git a/ag/include/erstellfunctions.inc.php b/ag/include/erstellfunctions.inc.php index 40d6be4..3ed67b7 100644 --- a/ag/include/erstellfunctions.inc.php +++ b/ag/include/erstellfunctions.inc.php @@ -22,6 +22,28 @@ function erstelleUser(){ } +function hasUserFreeCharSlot($user) { + $chars = getCharsOfUser($user['id']); + $special_chars = 0; + $normal_chars = 0; + foreach($chars as $row){ + if($char['rasse_a']['special']) { + $special_chars++; + } else { + $normal_chars++; + } + } + // The first special char is always on its special slot! + if($special_chars > 0) + $special_chars--; + + $chars_avail = $normal_chars + $special_chars; + $slots_avail = $user['char_max']; + if($chars_avail < $slots_avail) { + return true; + } +} + // Muss aus einem sicheren Kontext gestartet werden function erstelleChar($user, $rassen_id, $newname = '', $picture = '', $lvl = 1, $lp = 0, $hp = 0, $mp = 0, $str = 0, $def = 0, $spd = 0, $end = 0, $lck = 0, $chartype = 'Dragonball'){ // If-Anweisungen muessen noch durch Datenbankabfragen ersetzt werden