diff --git a/ag/char.php b/ag/char.php index cf9c34c..3b759cc 100644 --- a/ag/char.php +++ b/ag/char.php @@ -16,6 +16,8 @@ include_once($_SERVER['DOCUMENT_ROOT'].'ag/include/designfunctions.inc.php'); include_once($_SERVER['DOCUMENT_ROOT'].'ag/include/fehlerausgabe.inc.php'); include_once($_SERVER['DOCUMENT_ROOT'].'ag/include/erstellfunctions.inc.php'); include_once($_SERVER['DOCUMENT_ROOT'].'ag/include/parse.inc.php'); +include_once($_SERVER['DOCUMENT_ROOT'].'ag/include/usergroup.inc.php'); +include_once($_SERVER['DOCUMENT_ROOT'].'ag/include/exp.inc.php'); // GET-Section @@ -23,9 +25,13 @@ include_once($_SERVER['DOCUMENT_ROOT'].'ag/include/parse.inc.php'); $char_name = validateName($_GET['char_name']); $char_1_type = validateString($_GET['char_1_Type']); $char_bild = validateURL($_GET['char_bild']); +$char_lvl = validateInteger($_GET['char_lvl'], NULL); // Unkritisch -$charm = $_GET['charm']; +if($_POST['charm'] === NULL) { + $charm = $_GET['charm']; +} else + $charm = $_POST['charm']; $char_type = $_GET['char_type']; ?> @@ -47,116 +53,277 @@ function isAPhoneNumber(){ --> -weiter'); - } + if($type != 'Mensch' && $type != 'Saiyajin' && $type != 'Dämon' && $type != 'Mutant' && $type != 'Cyborg' && $type != 'Namekianer' && $type != 'Pirat' && $type != 'Schwertkämpfer' && $type != 'Grandline Maschine'){ + displayErrorMessage(NULL,'Rasse kann nicht erstellt werden!',displayHistoryBackLink()); + return; + } + if(erstelleChar($user, $type, $name, $bild)){ + displayErrorMessage('Änderungen übernommen','','weiter'); + } +} + +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'){ + displayErrorMessage(NULL,'Rasse kann nicht erstellt werden!',displayHistoryBackLink()); + return; + } + if(!is_numeric($hp) || !is_numeric($mp) || !is_numeric($str) || !is_numeric($def) || !is_numeric($spd) || !is_numeric($end) || !is_numeric($lck)) { + displayErrorMessage(NULL,'Ungültige Eingabe bei den Stats!',displayHistoryBackLink()); + return; + } + if($lp <= ($hp+$mp+$str+$def+$spd+$end+$lck)) { + displayErrorMessage(NULL,'Es wurden mehr Lernpunkte ausgegeben als eigentlich möglich!',displayHistoryBackLink()); + return; + } + $lp -= ($hp+$mp+$str+$def+$spd+$end+$lck); + if(erstelleChar($user, $type, $name, $bild, $lvl, $lp, $hp, $mp, $str, $def, $spd, $end, $lck)){ + displayErrorMessage('Änderungen übernommen','','weiter'); + } } //if($charm !== NULL) { - + function handleSecondPhase($type, $name){ -?> + ?>
- + + = 1 && $char_lvl <= 150) && $char_lvl !== NULL && is_numeric($char_lvl)) { + $lp = 0; + for ($i = 1; $i < $char_lvl; $i++) { + $lp += calculateTrainingPoints($i); + } + $lp = round($lp / 2); + ?> + + - -= 1 AND $user_daten['char_max'] == 7) { $chars_max= 8; @@ -165,15 +332,23 @@ if ($anzahl_spezialchars >= 1 AND $user_daten['char_max'] == 7) { } if ($anzahl_charactere < $chars_max) { - if($charm === NULL){ - handleFirstPhase($user_daten,$anzahl_charactere); - } else if($charm == 1){ - handleSecondPhase($char_type, $char_name); - } else if($charm == 2){ - handleErstelleCharRequest($user_ida, $char_1_type, $char_name, $char_bild); - } + if($charm === NULL){ + handleFirstPhase($user_daten,$anzahl_charactere); + } else if($charm == 1){ + if(isUserInGroup($usergroups, tester)) { + handleSecondPhaseForTester($char_type, $char_name); + } else { + handleSecondPhase($char_type, $char_name); + } + } else if($charm == 2){ + handleErstelleCharRequest($user_ida, $char_1_type, $char_name, $char_bild); + } else if($charm == 3) { + handleThirdPhaseForTester($char_1_type, $char_name, $char_lvl); + } else if($charm == 4) { + handleErstelleCharRequestOfTestUser($user_ida, $_POST['char_type'], $_POST['char_name'], $_POST['char_bild'], $_POST['lvl'], $_POST['lp'], $_POST['hp'], $_POST['mp'], $_POST['str'], $_POST['def'], $_POST['spd'], $_POST['end'], $_POST['lck']); + } } else { - echo 'Du hast bereits die maximal mögliche Menge an Characteren erstellt, die du erstellen kannst.