From 4b5ba4e829091e4bda5a47b62cdf71aa5347c63c Mon Sep 17 00:00:00 2001 From: hecht Date: Sun, 3 Aug 2014 20:09:35 +0000 Subject: [PATCH] =?UTF-8?q?Trac=20#130:=20Nun=20werden=20die=20Rassen=20so?= =?UTF-8?q?=20"emuliert"=20als=20ob=20sie=20in=20der=20Datenbank=20stehen?= =?UTF-8?q?=20w=C3=BCrden.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sämtliche andere scripte (dragonball wünsche, erstellen von chars, etc.) wurden angepasst. Für die meisten jedoch war eine Anpassung nicht nötig, da die Änderung rückwärtskompatibel in die getChar funktion eingebaut wurde. --- ag/char.php | 151 +++++++++----- ag/dragonballs.php | 8 +- ag/include/auktion_functions.inc.php | 2 +- ag/include/char.inc.php | 45 ++-- ag/include/erstellfunctions.inc.php | 166 ++------------- ag/include/races.inc.php | 190 ----------------- ag/include/rassen.inc.php | 295 +++++++++++++++++++++++++++ ag/include/schnell_start.inc.php | 6 +- ag/item.php | 19 +- ag/turnier.php | 21 +- 10 files changed, 488 insertions(+), 415 deletions(-) delete mode 100644 ag/include/races.inc.php create mode 100644 ag/include/rassen.inc.php diff --git a/ag/char.php b/ag/char.php index aa37e73..a6cee4f 100644 --- a/ag/char.php +++ b/ag/char.php @@ -19,6 +19,7 @@ include_once(ROOT_PATH.'/include/erstellfunctions.inc.php'); include_once(ROOT_PATH.'/include/parse.inc.php'); include_once(ROOT_PATH.'/include/usergroup.inc.php'); include_once(ROOT_PATH.'/include/exp.inc.php'); +include_once(ROOT_PATH.'/include/rassen.inc.php'); // GET-Section @@ -58,7 +59,9 @@ function isAPhoneNumber(){ // $user_ida, $char_1_Type, $char_name function handleErstelleCharRequest($user, $type, $name, $bild){ - if($type != 'Mensch' && $type != 'Saiyajin' && $type != 'Dämon' && $type != 'Mutant' && $type != 'Cyborg' && $type != 'Namekianer' && $type != 'Pirat' && $type != 'Schwertkämpfer' && $type != 'Grandline Maschine'){ + $race = getRaceById($type); + $type = getRaceTypeById($race['id']); + if($race == NULL || $race['special'] || $type['gm_only']) { displayErrorMessage(NULL,'Rasse kann nicht erstellt werden!',displayHistoryBackLink()); return; } @@ -69,8 +72,8 @@ function handleErstelleCharRequest($user, $type, $name, $bild){ function handleErstelleCharRequestOfTestUser($user, $type, $name, $bild, $lvl, $lp, $hp, $mp, $str, $def, $spd, $end, $lck){ //stats auf numeric prüfen! - if($type != 'Mensch' && $type != 'Saiyajin' && $type != 'Dämon' && $type != 'Mutant' && $type != 'Cyborg' && - $type != 'Namekianer' && $type != 'Pirat' && $type != 'Schwertkämpfer' && $type != 'Grandline Maschine' && $type != 'Kaioshin' && $type != 'Shichibukai'){ + $race = getRaceById($type); + if($race == NULL) { displayErrorMessage(NULL,'Rasse kann nicht erstellt werden!',displayHistoryBackLink()); return; } @@ -106,26 +109,34 @@ function handleSecondPhase($type, $name){ Rasse: @@ -160,30 +171,27 @@ function handleSecondPhaseForTester($type, $name){ Rasse: @@ -213,6 +221,7 @@ function handleSecondPhaseForTester($type, $name){ } function handleThirdPhaseForTester($type, $name, $char_lvl, $random, $user){ + $type_arr = getRaceById($type); if(($char_lvl >= 1 && $char_lvl <= 150) && $char_lvl !== NULL && is_numeric($char_lvl)) { $lp = 0; for ($i = 1; $i < $char_lvl; $i++) { @@ -253,7 +262,7 @@ function handleThirdPhaseForTester($type, $name, $char_lvl, $random, $user){ CharakterTyp: - + @@ -313,7 +322,7 @@ function handleThirdPhaseForTester($type, $name, $char_lvl, $random, $user){ echo 'Ungültiger Levelbereich!'; } - function handleFirstPhase(){ + function handleFirstPhase($user_daten,$anzahl_charactere,$tester){ ?>
@@ -333,8 +342,14 @@ function handleThirdPhaseForTester($type, $name, $char_lvl, $random, $user){ Type @@ -348,7 +363,35 @@ function handleThirdPhaseForTester($type, $name, $char_lvl, $random, $user){ } $user_daten= mysql_fetch_assoc(mysql_query("SELECT char_max, id FROM user WHERE nickname='".$_COOKIE['name']."' LIMIT 1")); - $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'])); + // FIXME: Check if thi works! + $anzahl_spezialchars = 0; + $all_chars = getCharsOfUser($user_daten['id']); + foreach($all_chars as $char) { + if(!is_numeric($char['rasse']) && $char['rasse'] == "Kaioshin" || $char['rasse'] == "Shichibukai") { + $anzahl_specialchars++; + continue; + } + if(is_numeric($char['rasse'])) { + $rasse = getRaceById($char['rasse']); + if($rasse != NULL && $rasse['special']){ + $anzahl_specialchars++; + continue; + } + } + if(!is_numeric($char['fusion_rasse']) && $char['fusion_rasse'] == "Kaioshin" || $char['fusion_rasse'] == "Shichibukai") { + $anzahl_specialchars++; + continue; + } + if(is_numeric($char['fusion_rasse'])) { + $rasse = getRaceById($char['fusion_rasse']); + if($rasse != NULL && $rasse['special']){ + $anzahl_specialchars++; + continue; + } + } + + } + #$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']."'")); if ($anzahl_spezialchars >= 1 AND $user_daten['char_max'] == 7) { @@ -359,7 +402,7 @@ function handleThirdPhaseForTester($type, $name, $char_lvl, $random, $user){ if ($anzahl_charactere < $chars_max) { if($charm === NULL){ - handleFirstPhase($user_daten,$anzahl_charactere); + handleFirstPhase($user_daten,$anzahl_charactere, isUserInGroup($usergroups, TESTER)); } else if($charm == 1){ if(isUserInGroup($usergroups, TESTER)) { handleSecondPhaseForTester($char_type, $char_name); @@ -368,9 +411,9 @@ function handleThirdPhaseForTester($type, $name, $char_lvl, $random, $user){ } } else if($charm == 2){ handleErstelleCharRequest($user_ida, $char_1_type, $char_name, $char_bild); - } else if($charm == 3) { + } else if($charm == 3 && isUserInGroup($usergroups, TESTER)) { handleThirdPhaseForTester($char_1_type, $char_name, $char_lvl, $randomize, $user_ida); - } else if($charm == 4) { + } else if($charm == 4 && isUserInGroup($usergroups, TESTER)) { handleErstelleCharRequestOfTestUser($user_ida, $_REQUEST['char_type'], $_REQUEST['char_name'], $_REQUEST['char_bild'], $_REQUEST['lvl'], $_REQUEST['lp'], $_REQUEST['hp'], $_REQUEST['mp'], $_REQUEST['str'], $_REQUEST['def'], $_REQUEST['spd'], $_REQUEST['end'], $_REQUEST['lck']); } diff --git a/ag/dragonballs.php b/ag/dragonballs.php index 83db966..8dbaeee 100644 --- a/ag/dragonballs.php +++ b/ag/dragonballs.php @@ -88,14 +88,16 @@ function wuenscheSpecialChar($user, $specialcharname, $newname = ''){ return false; } - $kaioshin = mysql_fetch_assoc(mysql_query('SELECT char_type,name from chars WHERE (rasse = \''.$specialcharname.'\' or fusion_rasse = \''.$specialcharname.'\') and besitzer='.$user['id'])); + $rasse = getRaceByName($specialcharname); + + $kaioshin = mysql_fetch_assoc(mysql_query('SELECT char_type,name from chars WHERE (rasse = \''.$specialcharname.'\' or rasse = \''.$rasse['id'].'\' or fusion_rasse = \''.$specialcharname.'\' or fusion_rasse = \''.$rasse['id'].'\') and besitzer='.$user['id'])); if($kaioshin != null){ displayErrorMessage(NULL,'Der '.$specialcharname.'-Slot ist schon durch '.$kaioshin['name'].' belegt!!',displayHistoryBackLink()); return false; } // Kleine Funktion grosse Wirkung - if(!erstelleChar($user, $specialcharname, $newname)){ + if(!erstelleChar($user, $rasse['id'], $newname)){ return false; } @@ -222,4 +224,4 @@ if($charm !== NULL && $wunsch !== NULL){ } else{ displayWuensche($user_ida); } -?> \ No newline at end of file +?> diff --git a/ag/include/auktion_functions.inc.php b/ag/include/auktion_functions.inc.php index e978bed..6a10e8b 100644 --- a/ag/include/auktion_functions.inc.php +++ b/ag/include/auktion_functions.inc.php @@ -318,7 +318,7 @@ function getKategorieOptions($preselect){ $total = 0; $select = false; - $qry = mysql_query('SELECT tablename,count(tablename) as anzahl FROM auktion WHERE TIMESTAMPDIFF(Minute,now(),deadline) >= 0 GROUP BY tablename'); + $qry = mysql_query('SELECT tablename,count(tablename) as anzahl FROM auktion WHERE TIMESTAMPDIFF(Minute,now(),deadline) >= 0 AND itemname != \'Geheim!\' GROUP BY tablename'); while($row = mysql_fetch_assoc($qry)){ if($preselect == $row['tablename']){ $result[$index++] = ''; diff --git a/ag/include/char.inc.php b/ag/include/char.inc.php index 4b0ba1d..b204681 100644 --- a/ag/include/char.inc.php +++ b/ag/include/char.inc.php @@ -18,6 +18,7 @@ // required for status calculation! include_once(ROOT_PATH.'/include/event.inc.php'); include_once(ROOT_PATH.'/include/clan_fights.inc.php'); +include_once(ROOT_PATH.'/include/rassen.inc.php'); /* * Char Status @@ -101,12 +102,7 @@ function getChar($charid, $buffer_enabled = true) { } // Wenn Char nicht im Puffer ist, oder nicht gepuffert werden soll if ($GLOBALS['char_buffered_instances'][$charid] == null || !$buffer_enabled) { - // Lese das Charfeld aus der Datenbank aus - $char = mysql_fetch_assoc(mysql_query('Select * from chars where id = '.$charid)); - if(!$char){return null;} - // Speichere in $char['stauts'] den aktuellen Status des Chars (buffer-Strategie ist hierbei die selbe) - $char['status'] = getStatus($char['id'],$buffer_enabled); - $char['bild'] = getPicture($char); + $char = getChar2($charid); $GLOBALS['char_buffered_instances'][$charid] = &$char; // Speichern des Chars in den Puffer } // Gebe Char zurueck @@ -123,6 +119,33 @@ function getChar2($charid) { // Speichere in $char['stauts'] den aktuellen Status des Chars (buffer-Strategie ist hierbei die selbe) $char['status'] = getStatus($char['id'],$buffer_enabled); $char['bild'] = getPicture($char); + // Check if it is new style! + if(is_numeric($char['rasse']) && $char['rasse'] != 0) { + $rasse = getRaceById($char['rasse']); + $char['rasse']=$rasse['name']; + $type=getRaceTypeById($rasse['type']); + $char['type']=$type['name']; + if($rasse['special']) { + $char['char_type'] = $rasse['name']; + } + $char['rasse_a'] = $rasse; + } else if($char['rasse'] != '0'){ + // it is old style! + $rasse = getRaceByName($char['rasse']); + $char['rasse_a'] = $rasse; + // update the old styled rasse + db_query('update chars set rasse = \''.$rasse['id'].'\', type = NULL where id = '.$charid); + } + + if(is_numeric($char['fusion_rasse']) && $char['fusion_rasse'] != 0) { + $rasse = getRaceById($char['fusion_rasse']); + $char['fusion_rasse'] = $rasse['name']; + } else if($char['fusion_rasse'] != '0') { + $rasse = getRaceByName($char['fusion_rasse']); + $char['fusion_rasse_a'] = $rasse; + // update the old styled fusion_rasse + db_query('update chars set fusion_rasse = \''.$rasse['id'].'\' where id = '.$charid); + } } return $char; } @@ -174,15 +197,9 @@ function getCharsOfUser($userid, $buffer_enabled = true) { if ($GLOBALS['chars_read_out_user'][$userid] == null || !$buffer_enabled) { $GLOBALS['chars_read_out_user'][$userid] = array(); - $qry = mysql_query('Select * from chars where besitzer = '.$userid.' order by id'); + $qry = mysql_query('Select id from chars where besitzer = '.$userid.' order by id'); while($char = mysql_fetch_assoc($qry)){ - // Speichere in $char['stauts'] den aktuellen Status des Chars (buffer-Strategie ist hierbei die selbe) - $char['status'] = getStatus($char['id'],$buffer_enabled); - $char['bild'] = getPicture($char); - // Speichere den Char in das Globale-Pufferfeld - $GLOBALS['char_buffered_instances'][$char['id']] = $char; - // Gebe dem User eine Referenz auf die globale chars-Variable - $GLOBALS['chars_read_out_user'][$userid][] = &$GLOBALS['char_buffered_instances'][$char['id']]; + $GLOBALS['chars_read_out_user'][$userid][] = &getChar($char['id']); } } return $GLOBALS['chars_read_out_user'][$userid]; // Gebe das globale Userfeld zurück. diff --git a/ag/include/erstellfunctions.inc.php b/ag/include/erstellfunctions.inc.php index 39bf1a7..40d6be4 100644 --- a/ag/include/erstellfunctions.inc.php +++ b/ag/include/erstellfunctions.inc.php @@ -11,6 +11,7 @@ include_once(ROOT_PATH.'/include/fehlerausgabe.inc.php'); include_once(ROOT_PATH.'/include/designfunctions.inc.php'); include_once(ROOT_PATH.'/include/char.inc.php'); +include_once(ROOT_PATH.'/include/rassen.inc.php'); include_once(ROOT_PATH.'/include/parse.inc.php'); include_once(ROOT_PATH.'/include/exp.inc.php'); @@ -22,162 +23,37 @@ function erstelleUser(){ } // Muss aus einem sicheren Kontext gestartet werden -function erstelleChar($user, $specialcharname, $newname = '', $picture = '', $lvl = 1, $lp = 0, $hp = 0, $mp = 0, $str = 0, $def = 0, $spd = 0, $end = 0, $lck = 0, $chartype = 'Dragonball'){ +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 - $type = ''; $trainingspoints = 0; - $special_char = false; - $dbz = 'Dragonball'; - $op = 'Onepiece'; - $c_type = ''; if($newname == ''){ displayErrorMessage(NULL,'Name ist nicht erlaubt!!',displayHistoryBackLink()); return false; } - if($specialcharname == 'Mensch') { - $HP = 150; - $MP = 30; - $Starke = 15; - $Verteidigung = 9; - $Geschwindigkeit = 13; - $Gluck = 4; - $Ausdauer = 8; - $type = $dbz; - } else if($specialcharname == 'Saiyajin') { - $HP = 120; - $MP = 30; - $Starke = 18; - $Verteidigung = 10; - $Geschwindigkeit = 9; - $Gluck = 5; - $Ausdauer = 10; - $type = $dbz; - } else if($specialcharname == 'Dämon') { - $HP = 160; - $MP = 50; - $Starke = 8; - $Verteidigung = 15; - $Geschwindigkeit = 11; - $Gluck = 0; - $Ausdauer = 9; - $type = $dbz; - } else if($specialcharname == 'Mutant') { - $HP = 180; - $MP = 15; - $Starke = 13; - $Verteidigung = 9; - $Geschwindigkeit = 18; - $Gluck = 4; - $Ausdauer = 5; - $type = $dbz; - } else if($specialcharname == 'Cyborg') { - $HP = 250; - $MP = 20; - $Starke = 11; - $Verteidigung = 30; - $Geschwindigkeit = 0; - $Gluck = 0; - $Ausdauer = 0; - $type = $dbz; - } else if($specialcharname == 'Namekianer') { - $HP = 100; - $MP = 10; - $Starke = 18; - $Verteidigung = 10; - $Geschwindigkeit = 14; - $Gluck = 6; - $Ausdauer = 10; - $type = $dbz; - } else if($specialcharname == 'Pirat') { - $HP = 100; - $MP = 25; - $Starke = 20; - $Verteidigung = 10; - $Geschwindigkeit = 15; - $Gluck = 3; - $Ausdauer = 7; - $type = $op; - } else if($specialcharname == 'Schwertkämpfer') { - $HP = 100; - $MP = 25; - $Starke = 25; - $Verteidigung = 10; - $Geschwindigkeit= 10; - $Gluck= 2; - $Ausdauer= 8; - $type = $op; - } else if($specialcharname == 'Grandline Maschine') { - $HP = 400; - $MP = 5; - $Starke = 5; - $Verteidigung = 5; - $Geschwindigkeit = 5; - $Gluck = 0; - $Ausdauer = 10; - $type = $op; - } else if($specialcharname == 'Kaioshin'){ - $HP = 1000; - $MP = 150; - $Starke = 100; - $Verteidigung = 100; - $Geschwindigkeit = 100; - $Gluck = 100; - $Ausdauer = 100; - $type = $dbz; - $trainingspoints = 500; - $special_char = true; - $c_type = $specialcharname; - } else if($specialcharname == 'Shichibukai'){ - $HP = 1000; - $MP = 150; - $Starke = 100; - $Verteidigung = 100; - $Geschwindigkeit = 100; - $Gluck = 100; - $Ausdauer = 100; - //$type = $specialcharname; <-- wird überschrieben?! - $trainingspoints = 500; - $special_char = true; - $type = $op; - $c_type = $specialcharname; - } else if($specialcharname == 'NPC') { - $type = $chartype; - $HP = $hp; - $MP = $mp; - $Starke = $str; - $Verteidigung = $def; - $Geschwindigkeit = $spd; - $Gluck = $lck; - $Ausdauer = $end; - //reseten der stats, damit kein boost dazukommt - $hp = 0; - $mp = 0; - $str = 0; - $def = 0; - $spd = 0; - $lck = 0; - $end = 0; - $lp = 0; - } else { + $race = getRaceById($rassen_id); + if($race == NULL) { displayErrorMessage(NULL,'Rasse nicht vorhanden!!',displayHistoryBackLink()); return false; } - // If-Anweisungen ende - - // Werte hinzufügen, falls ein Testcharakter erstellt wird - $HP += ($hp*10); - $MP += ($mp*5); - $Starke += $str; - $Verteidigung += $def; - $Geschwindigkeit += $spd; - $Gluck += $lck; - $Ausdauer += $end; + + // Durch $race können wir nun die chars generisch erstellen :) ... Bye bye multi-ifs :D + + $HP = $race['hp'] + $hp*10; + $MP = $race['mp'] + $mp*5; + $Starke = $race['str'] + $str; + $Verteidigung = $race['def'] + $def; + $Geschwindigkeit = $race['spd'] + $spd; + $Gluck = $race['lck'] + $lck; + $Ausdauer = $race['stm'] + $end; + $type = ''; // Not required anymore! + $c_type = ''; + $special_char = $race['special']; $trainingspoints += $lp*2; $LP = ($lvl - 1) * 10; - if($specialcharname != 'NPC') { + if($race['name'] != 'NPC') { //Ueberprüfe ob ein Slot frei ist $chars = getCharsOfUser($user['id']); $normal = 0; @@ -214,7 +90,7 @@ function erstelleChar($user, $specialcharname, $newname = '', $picture = '', $lv ' \''.$MP.','.$MP.'\',' . ' '.$lvl.',' . ' \''.$type.'\',' . - ' \''.$specialcharname.'\',' . + ' \''.$rassen_id.'\',' . ' '.$user['id'].',' . ' \''.$c_type.'\',' . ' '.$trainingspoints.',' . @@ -225,7 +101,7 @@ function erstelleChar($user, $specialcharname, $newname = '', $picture = '', $lv //echo $sql.'
'; $identifier = mysql_query($sql); if($identifier == FALSE){ - if(mysql_fetch_assoc(mysql_query('Select * from chars where name = \''.$newname.'\''))){ + if(mysql_fetch_assoc(mysql_query('Select id from chars where name = \''.$newname.'\''))){ displayErrorMessage(NULL,'Name schon vorhanden!!',displayHistoryBackLink()); } else{ displayErrorMessage(NULL,'Erstellen fehlgeschlagen!!',displayHistoryBackLink()); @@ -233,7 +109,7 @@ function erstelleChar($user, $specialcharname, $newname = '', $picture = '', $lv return false; // Hat nich geklappt } - if($specialcharname != 'NPC') { + if($race['name'] != 'NPC') { $charsw_id = mysql_fetch_assoc(mysql_query('SELECT id FROM chars WHERE name=\''.$newname.'\'')); mysql_query('INSERT lernen SET at_id=1, aktiv=1, besitzer='.$charsw_id['id'].', name=\'Schlag\', dauer=0'); diff --git a/ag/include/races.inc.php b/ag/include/races.inc.php deleted file mode 100644 index 0c52afa..0000000 --- a/ag/include/races.inc.php +++ /dev/null @@ -1,190 +0,0 @@ - diff --git a/ag/include/rassen.inc.php b/ag/include/rassen.inc.php new file mode 100644 index 0000000..55e0527 --- /dev/null +++ b/ag/include/rassen.inc.php @@ -0,0 +1,295 @@ + 'Onepiece', + 'id' => 1, + 'gm_only' => false, + ), + array( + 'name' => 'Dragonball', + 'id' => 2, + 'gm_only' => false, + ), + array( + 'name' => 'NPC', + 'id' => 3, + 'gm_only' => true, + ), +); + +// Dieses Array ist zum simulieren der Datenbank da! +$GLOBALS['TMP_DB_TABLE_RACES']=array( + + array( + 'name' => 'Mensch', + 'type' => 2, + 'id' => 1, + 'hp' => 150, + 'mp' => 30, + 'str' => 15, + 'def' => 9, + 'spd' => 13, + 'lck' => 4, + 'stm' => 8, + 'special' => false + ), + array( + 'name' => 'Saiyajin', + 'type' => 2, + 'id' => 2, + 'hp' => 120, + 'mp' => 30, + 'str' => 18, + 'def' => 10, + 'spd' => 9, + 'lck' => 5, + 'stm' => 10, + 'special' => false + ), + array( + 'name' => 'Dämon', + 'type' => 2, + 'id' => 3, + 'hp' => 160, + 'mp' => 50, + 'str' => 8, + 'def' => 9, + 'spd' => 18, + 'lck' => 4, + 'stm' => 5, + 'special' => false + ), + array( + 'name' => 'Mutant', + 'type' => 2, + 'id' => 4, + 'hp' => 180, + 'mp' => 15, + 'str' => 13, + 'def' => 9, + 'spd' => 18, + 'lck' => 4, + 'stm' => 5, + 'special' => false + ), + array( + 'name' => 'Cyborg', + 'type' => 2, + 'id' => 5, + 'hp' => 250, + 'mp' => 20, + 'str' => 11, + 'def' => 30, + 'spd' => 0, + 'lck' => 0, + 'stm' => 0, + 'special' => false + ), + array( + 'name' => 'Namekianer', + 'type' => 2, + 'id' => 6, + 'hp' => 100, + 'mp' => 10, + 'str' => 18, + 'def' => 10, + 'spd' => 14, + 'lck' => 6, + 'stm' => 10, + 'special' => false + ), + // Start 'One Piece' + array( + 'name' => 'Pirat', + 'type' => 1, + 'id' => 7, + 'hp' => 100, + 'mp' => 25, + 'str' => 20, + 'def' => 10, + 'spd' => 15, + 'lck' => 3, + 'stm' => 7, + 'special' => false + ), + // In-Between Special chars + array( + 'name' => 'Shichibukai', + 'type' => 1, + 'id' => 8, + 'hp' => 1000, + 'mp' => 150, + 'str' => 100, + 'def' => 100, + 'spd' => 100, + 'lck' => 100, + 'stm' => 100, + 'tp' => 500, + 'special' => true + ), + array( + 'name' => 'Kaioshin', + 'type' => 2, + 'id' => 9, + 'hp' => 1000, + 'mp' => 150, + 'str' => 100, + 'def' => 100, + 'spd' => 100, + 'lck' => 100, + 'stm' => 100, + 'tp' => 500, + 'special' => true + ), + // Continue 'One Piece' + array( + 'name' => 'Schwertkämpfer', + 'type' => 1, + 'id' => 10, + 'hp' => 100, + 'mp' => 25, + 'str' => 25, + 'def' => 10, + 'spd' => 10, + 'lck' => 2, + 'stm' => 8, + 'special' => false + ), + array( + 'name' => 'Grandline Maschine', + 'type' => 1, + 'id' => 11, + 'hp' => 400, + 'mp' => 5, + 'str' => 5, + 'def' => 5, + 'spd' => 5, + 'lck' => 0, + 'stm' => 10, + 'special' => false + ), + // NPC chars + array( + 'name' => 'NPC', + 'type' => 3, + 'id' => 12, + 'hp' => 0, + 'mp' => 0, + 'str' => 0, + 'def' => 0, + 'spd' => 0, + 'lck' => 0, + 'stm' => 0, + 'special' => true + ), +); + +// now sort the arrays + + +// Dieses Array ist dafuer da, dass nicht unnötig viele SQL-Abfragen gemacht werden! +// Fehlgriff im Design, aber solange wir nichts Klassenbasiert machen, gehts nicht anders +$GLOBALS['char_buffered_races'] = array (); +$GLOBALS['char_buffered_race_types'] = array(); + + +function getRassen() { + return getRaces(); +} + +/** + * Diese Funktion gibt ein array mit allen rassen aus 'id' => array('name', 'type', ...); + */ +function getRaces() { + if(count($GLOBALS['char_buffered_races']) == 0) { + // FIXME: This is a simulated SQL Request! + foreach($GLOBALS['TMP_DB_TABLE_RACES'] as $race) { + $GLOBALS['char_buffered_races'][$race['id']] = $race; + } + } + return $GLOBALS['char_buffered_races']; +} + +function getRassenTypeMapping() { + return getRaceTypes(); +} + +function getRaceTypes(){ + if(count($GLOBALS['char_buffered_race_types']) == 0) { + foreach($GLOBALS['TMP_DB_TABLE_RACE_TYPE'] as $racetype) { + $GLOBALS['char_buffered_race_types'][$racetype['id']] = $racetype; + } + } + return $GLOBALS['char_buffered_race_types']; +} + +function getRaceById($id) { + $races = getRassen(); + return $races[$id]; +} + +function getRaceByName($name) { + // TODO: Improve performance for this + $races = getRaces(); + foreach($races as $race) { + if($race['name'] == $name) { + return $race; + } + } + return NULL; +} + +function getRacesByType($type) { + $races = getRaces(); + $result = array(); + foreach($races as $race) { + if($race['type'] == $type['id']) { + $result[] = $race; + } + } + return $result; +} + +function getRaceTypeById($id) { + $types = getRaceTypes(); + return $types[$id]; +} + +function getRaceTypeName($name) { + $types = getRaceTypes(); + foreach($types as $type) { + if($type['name'] == $name) { + return $type; + } + } + return NULL; +} + +function getSpecialRaceIds() { + $races = getRaces(); + $result = array(); + foreach($races as $race) { + if($race['special']) { + $result[] = $race; + } + } + return $result; +} + +#print_r(getRassen()); + +#print_r(getRaceById(1)); + +#print_r(getRaceByName('Dämon')); + diff --git a/ag/include/schnell_start.inc.php b/ag/include/schnell_start.inc.php index a09e0a7..990ee6d 100644 --- a/ag/include/schnell_start.inc.php +++ b/ag/include/schnell_start.inc.php @@ -5,8 +5,12 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public Licence * */ + +include_once (ROOT_PATH.'/include/char.inc.php'); + function renderSchnellleiste($user){ - $Schnell_my_chars = mysql_query("SELECT name, status, id, training_points, lernpunkte, level, starke, verteidigung, speed, ausdauer, glueck FROM chars WHERE besitzer='$user[id]' LIMIT 8"); + + $Schnell_my_chars = getCharsOfUser($user[id]); $char_zahl = 0; while($my_charz = mysql_fetch_assoc($Schnell_my_chars)) { diff --git a/ag/item.php b/ag/item.php index 76001e0..36005d3 100644 --- a/ag/item.php +++ b/ag/item.php @@ -296,6 +296,16 @@ if ($charm == 6) { exit; } + if ($char_id1['type'] != 'Onepiece') { + displayErrorMessage(NULL,'Dieser Charakter ist kein One Piece char!', displayHistoryBackLink()); + exit; + } + + if ($char_id1['frucht'] != NULL) { + displayErrorMessage(NULL,'Dieser Charakter hat schon eine Teufelsfrucht gegessen!', displayHistoryBackLink()); + exit; + } + $hp1 = explode(",", $char_id1['hp']); $mp1 = explode(",", $char_id1['mp']); @@ -402,9 +412,12 @@ $item1 = mysql_query("SELECT item_id, id, ru_mal FROM ware WHERE user='$user[id] '.$row4['name'].''; + #$char4 = mysql_query('SELECT id, name FROM chars WHERE besitzer='.$user_ida['id'].' AND type=\'Onepiece\' AND frucht is NULL'); + $all_chars = getCharsOfUser($user_ida['id']); + foreach($all_chars as $row4) { + if($row4['type'] == 'Onepiece' && $row4['frucht'] == NULL) { + echo ''; + } } ?>