einfache Zufallsmethode beim erstellen von Testchars gebaut (somit müssen werte nicht unbedingt per Hand eingegeben werden)

main
radiskull 13 years ago
parent 9756a4d6aa
commit 6b1c04e26c

@ -27,6 +27,7 @@ $char_name = validateName($_GET['char_name']);
$char_1_type = validateString($_GET['char_1_Type']); $char_1_type = validateString($_GET['char_1_Type']);
$char_bild = validateURL($_GET['char_bild']); $char_bild = validateURL($_GET['char_bild']);
$char_lvl = validateInteger($_GET['char_lvl'], NULL); $char_lvl = validateInteger($_GET['char_lvl'], NULL);
$randomize = validateInteger($_GET['random'], NULL);
// Unkritisch // Unkritisch
$charm = $_REQUEST['charm']; $charm = $_REQUEST['charm'];
@ -147,9 +148,9 @@ function handleSecondPhase($type, $name){
function handleSecondPhaseForTester($type, $name){ function handleSecondPhaseForTester($type, $name){
?> ?>
<form action="index.php" method="GET"> <form action="index.php" method="GET">
<input type="hidden" name="as" value="char"> <input type="hidden" name="as" value="char"> <input type="hidden"
<input type="hidden" name="charm" value="3"> name="charm" value="3"> <input type="hidden" name="char_name"
<input type="hidden" name="char_name" value="<?php echo $name; ?>"> value="<?php echo $name; ?>">
<table border="0" cellpadding="0" cellspacing="0" <table border="0" cellpadding="0" cellspacing="0"
style="border-collapse: collapse" bordercolor="#111111" width="100%" style="border-collapse: collapse" bordercolor="#111111" width="100%"
height="20"> height="20">
@ -192,10 +193,15 @@ function handleSecondPhaseForTester($type, $name){
</td> </td>
</tr> </tr>
<tr> <tr>
<th align="left">Level(1-150): </th> <th align="left">Level(1-150):</th>
<td><input name="char_lvl" id="input"> <td><input name="char_lvl" id="input">
</td> </td>
</tr> </tr>
<tr>
<th align="left">Zufall:</th>
<td><input type="checkbox" name="random" value="1">
</td>
</tr>
<tr> <tr>
<td></td> <td></td>
<td><input id="input" type=submit value="weiter"> <td><input id="input" type=submit value="weiter">
@ -206,21 +212,39 @@ function handleSecondPhaseForTester($type, $name){
<?php <?php
} }
function handleThirdPhaseForTester($type, $name, $char_lvl){ function handleThirdPhaseForTester($type, $name, $char_lvl, $random, $user){
if(($char_lvl >= 1 && $char_lvl <= 150) && $char_lvl !== NULL && is_numeric($char_lvl)) { if(($char_lvl >= 1 && $char_lvl <= 150) && $char_lvl !== NULL && is_numeric($char_lvl)) {
$lp = 0; $lp = 0;
for ($i = 1; $i < $char_lvl; $i++) { for ($i = 1; $i < $char_lvl; $i++) {
$lp += calculateTrainingPoints($i); $lp += calculateTrainingPoints($i);
} }
$lp = round($lp / 2); $lp = round($lp / 2);
if($random == 1) {
$tmp_lp = $lp;
$hp = rand(0, $lp/2);
$lp -= $hp;
$mp = rand(0, $lp/2);
$lp -= $mp;
$str = rand(0, $lp);
$lp -= $str;
$def = rand(0, $lp);
$lp -= $def;
$spd = rand(0, $lp);
$lp -= $spd;
$lck = rand(0, $lp);
$lp -= $lck;
$end = rand(0, $lp);
$lp -= $end;
handleErstelleCharRequestOfTestUser($user, $type, $name, '', $char_lvl, $tmp_lp, $hp, $mp, $str, $def, $spd, $end, $lck);
} else {
?> ?>
<form action="index.php" method="POST"> <form action="index.php" method="POST">
<input type="hidden" name="as" value="char"> <input type="hidden" name="as" value="char"> <input type="hidden"
<input type="hidden" name="charm" value="4"> name="charm" value="4"> <input type="hidden" name="char_type"
<input type="hidden" name="char_type" value="<?php echo $type; ?>"> value="<?php echo $type; ?>"> <input type="hidden" name="char_name"
<input type="hidden" name="char_name" value="<?php echo $name; ?>"> value="<?php echo $name; ?>"> <input type="hidden" name="lvl"
<input type="hidden" name="lvl" value="<?php echo $char_lvl; ?>"> value="<?php echo $char_lvl; ?>"> <input type="hidden" name="lp"
<input type="hidden" name="lp" value="<?php echo $lp; ?>"> value="<?php echo $lp; ?>">
<table border="0" cellpadding="0" cellspacing="0" <table border="0" cellpadding="0" cellspacing="0"
style="border-collapse: collapse" bordercolor="#111111" width="100%" style="border-collapse: collapse" bordercolor="#111111" width="100%"
height="20"> height="20">
@ -228,50 +252,52 @@ function handleThirdPhaseForTester($type, $name, $char_lvl){
<th colspan="2" align="center">Charakter erstellen (3/3)</th> <th colspan="2" align="center">Charakter erstellen (3/3)</th>
</tr> </tr>
<tr> <tr>
<th align="left">CharakterTyp: </th> <th align="left">CharakterTyp:</th>
<td><?php echo $type;?> </td> <td><?php echo $type;?>
</td>
</tr> </tr>
<tr> <tr>
<th align="left">Charakterlevel: </th> <th align="left">Charakterlevel:</th>
<td><?php echo $char_lvl;?> </td> <td><?php echo $char_lvl;?>
</td>
</tr> </tr>
<tr> <tr>
<th align="left">verfügbare LP: </th> <th align="left">verfügbare LP:</th>
<td><?php echo $lp?></td> <td><?php echo $lp?></td>
</tr> </tr>
<tr> <tr>
<th align="left">HP (1LP = 10HP): </th> <th align="left">HP (1LP = 10HP):</th>
<td><input name="hp" value = "0" id="input"> <td><input name="hp" value="0" id="input">
</td> </td>
</tr> </tr>
<tr> <tr>
<th align="left">MP (1LP = 5MP): </th> <th align="left">MP (1LP = 5MP):</th>
<td><input name="mp" value = "0" id="input"> <td><input name="mp" value="0" id="input">
</td> </td>
</tr> </tr>
<tr> <tr>
<th align="left">St&auml;rke: </th> <th align="left">St&auml;rke:</th>
<td><input name="str" value = "0" id="input"> <td><input name="str" value="0" id="input">
</td> </td>
</tr> </tr>
<tr> <tr>
<th align="left">Verteidigung: </th> <th align="left">Verteidigung:</th>
<td><input name="def" value = "0" id="input"> <td><input name="def" value="0" id="input">
</td> </td>
</tr> </tr>
<tr> <tr>
<th align="left">Geschwindigkeit: </th> <th align="left">Geschwindigkeit:</th>
<td><input name="spd" value = "0" id="input"> <td><input name="spd" value="0" id="input">
</td> </td>
</tr> </tr>
<tr> <tr>
<th align="left">Ausdauer: </th> <th align="left">Ausdauer:</th>
<td><input name="end" value = "0" id="input"> <td><input name="end" value="0" id="input">
</td> </td>
</tr> </tr>
<tr> <tr>
<th align="left">Glück: </th> <th align="left">Glück:</th>
<td><input name="lck" value = "0" id="input"> <td><input name="lck" value="0" id="input">
</td> </td>
</tr> </tr>
<tr> <tr>
@ -281,11 +307,13 @@ function handleThirdPhaseForTester($type, $name, $char_lvl){
</tr> </tr>
</table> </table>
</form> </form>
<?php } else <?php
}
} else
echo 'Ungültiger Levelbereich!'; echo 'Ungültiger Levelbereich!';
} }
function handleFirstPhase(){ function handleFirstPhase(){
?> ?>
<form action="index.php" method="get" name="charz" <form action="index.php" method="get" name="charz"
onsubmit="return isAPhoneNumber()"> onsubmit="return isAPhoneNumber()">
@ -317,19 +345,19 @@ function handleFirstPhase(){
</table> </table>
</form> </form>
<?php <?php
} }
$user_daten= mysql_fetch_assoc(mysql_query("SELECT char_max, id FROM user WHERE nickname='".$_COOKIE['name']."' LIMIT 1")); $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'])); $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']."'")); $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) { if ($anzahl_spezialchars >= 1 AND $user_daten['char_max'] == 7) {
$chars_max= 8; $chars_max= 8;
} else { } else {
$chars_max= $user_daten['char_max']; $chars_max= $user_daten['char_max'];
} }
if ($anzahl_charactere < $chars_max) { if ($anzahl_charactere < $chars_max) {
if($charm === NULL){ if($charm === NULL){
handleFirstPhase($user_daten,$anzahl_charactere); handleFirstPhase($user_daten,$anzahl_charactere);
} else if($charm == 1){ } else if($charm == 1){
@ -341,14 +369,14 @@ if ($anzahl_charactere < $chars_max) {
} else if($charm == 2){ } else if($charm == 2){
handleErstelleCharRequest($user_ida, $char_1_type, $char_name, $char_bild); handleErstelleCharRequest($user_ida, $char_1_type, $char_name, $char_bild);
} else if($charm == 3) { } else if($charm == 3) {
handleThirdPhaseForTester($char_1_type, $char_name, $char_lvl); handleThirdPhaseForTester($char_1_type, $char_name, $char_lvl, $randomize, $user_ida);
} else if($charm == 4) { } else if($charm == 4) {
handleErstelleCharRequestOfTestUser($user_ida, $_REQUEST['char_type'], $_REQUEST['char_name'], $_REQUEST['char_bild'], $_REQUEST['lvl'], $_REQUEST['lp'], 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']); $_REQUEST['hp'], $_REQUEST['mp'], $_REQUEST['str'], $_REQUEST['def'], $_REQUEST['spd'], $_REQUEST['end'], $_REQUEST['lck']);
} }
} else { } else {
echo 'Du hast bereits die maximal mögliche Menge an Characteren erstellt, die du erstellen kannst.<br />Nämlich '.$anzahl_charactere.' von '.$chars_max.' Charaktere.'; echo 'Du hast bereits die maximal mögliche Menge an Characteren erstellt, die du erstellen kannst.<br />Nämlich '.$anzahl_charactere.' von '.$chars_max.' Charaktere.';
} }
?> ?>

@ -178,7 +178,7 @@ function erstelleChar($user, $specialcharname, $newname = '', $picture = '', $lv
$LP = ($lvl - 1) * 10; $LP = ($lvl - 1) * 10;
if($specialcharname != 'NPC') { if($specialcharname != 'NPC') {
// Ueberprüfe ob ein Slot frei ist //Ueberprüfe ob ein Slot frei ist
$chars = getCharsOfUser($user['id']); $chars = getCharsOfUser($user['id']);
$normal = 0; $normal = 0;
$special = 0; $special = 0;

Loading…
Cancel
Save