Turnierstarten funktion eingebaut, npc bearbeiten ein wenig erweitert

main
radiskull 13 years ago
parent d25852a079
commit abd335c68d

@ -1,4 +1,4 @@
<?php
<?php
/*
* Created on 31.05.2011
*
@ -8,60 +8,107 @@
*/
?>
<?php
<?php
function displayNPC($action, $task, $charid, $table, $page, $data){
echo '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">'."\n";
echo "\t".'<input type="hidden" name="choose" value="items"></input>'."\n";
echo "\t".'<input type="hidden" name="choose" value="npc"></input>'."\n";
echo "\t".'<input type="hidden" name="charid" value="'.$charid.'"></input>'."\n";
echo "\t".'<table width="80%">'."\n";
if($action == 'edit'){
$d_array = array('charakter', 'name', 'type', 'hp', 'mp', 'starke', 'verteidigung', 'speed',
'ausdauer', 'glueck', 'zeit_rec', 'lvlmin', 'lvlmax');
$desc_array = array('ID', 'Name', 'Type', 'HP', 'MP', 'Stärke', 'Verteidigung', 'Geschwindigkeit',
'Ausdauer', 'Glück', 'Kampfdauer in Sekunden', 'Min-Level', 'Max-Level');
$sql = 'SELECT * FROM chars c inner join npc_item ni on ni.charakter = c.id inner join kampf_list kl on ni.charakter = kl.charakter WHERE c.id ='.$charid;
$qry = mysql_query($sql);
$row = mysql_fetch_assoc($qry);
$colspan = 2;
echo "\t".'<tr><td colspan="'.$colspan.'"><h1 style="text-align:center">NPC bearbeiten</h1></td></tr>'."\n";
echo "\t".'<input type="hidden" name="action" value="edit"></input>'."\n";
if($task == 'dochange') {
$d_array = array('name', 'type', 'hp', 'mp', 'starke', 'verteidigung', 'speed',
'ausdauer', 'glueck', 'level', 'bild');
$sql = 'UPDATE chars c INNER JOIN kampf_list kl ON c.id=kl.charakter SET c.';
$sql .= $d_array[0].' = \''.encodeNoHTMLWithBB($data[$d_array[0]]).'\'';
for($i=1;$i<count($d_array);$i++){
$sql .= ', c.'.$d_array[$i].' = \''.encodeNoHTMLWithBB($data[$d_array[$i]]).'\'';
}
$d_array = array('zeit_rec', 'lvlmin', 'lvlmax');
for($i=0;$i<count($d_array);$i++){
$sql .= ', kl.'. $d_array[$i].' = \''.encodeNoHTMLWithBB($data[$d_array[$i]]).'\'';
}
$sql .= ' WHERE c.id=\''.$charid.'\'';
//echo $sql.'<br>';
$u = mysql_query($sql);
if(mysql_affected_rows() == 0 || $u2 === FALSE) {
echo "\t\t\t".'<tr><td colspan="2" style="color:red">Fehler! Änderungen konnten nicht übernommen werden!</td></tr>';
} else{
logaction('Ein NPC wurde geändert (id = '.$charid.','.encodeNoHTMLWithBB(join($data,',')).')');
echo "\t\t\t".'<tr><td colspan="2">Änderungen wurden übernommen!</td></tr>';
}
displayNPC($action, null, $charid, $table, $page, $data);
} else {
echo "\t".'<input type="hidden" name="task" value="dochange"></input>'."\n";
$d_select_array = array(array('Dragonball', 'Onepiece'), array(300, 1200, 3600));
$d_array = array('charakter', 'name', 'type', 'hp', 'mp', 'starke', 'verteidigung', 'speed',
'ausdauer', 'glueck', 'zeit_rec', 'level', 'lvlmin', 'lvlmax', 'bild');
$desc_select_array = array(array('Dragonball', 'Onepiece'), array('5min', '20min', '60min'));
$desc_array = array('ID', 'Name', 'Type', 'HP', 'MP', 'Stärke', 'Verteidigung', 'Geschwindigkeit',
'Ausdauer', 'Glück', 'Kampfdauer in Sekunden', 'Level', 'Min-Level', 'Max-Level', 'Bild');
$sql = 'SELECT * FROM chars c inner join npc_item ni on ni.charakter = c.id inner join kampf_list kl on ni.charakter = kl.charakter WHERE c.id ='.$charid;
$qry = mysql_query($sql);
$row = mysql_fetch_assoc($qry);
$colspan = 2;
echo "\t\t".'<tr><td>'.$desc_array[0].'</td><td style="text-align:center">'.$row[$d_array[0]].'</td></tr>'."\n";
for($i = 1;$i<count($d_array);$i++){
echo "\t\t".'<tr><td>'.$desc_array[$i].'</td><td style="text-align:center"><input name="data['.$d_array[$i].']" value="'.debbcode($row[$d_array[$i]]).'"></input></td></tr>'."\n";
echo "\t".'<tr><td colspan="'.$colspan.'"><h1 style="text-align:center">NPC bearbeiten</h1></td></tr>'."\n";
echo "\t\t".'<tr><td>'.$desc_array[0].'</td><td style="text-align:center">'.$row[$d_array[0]].'</td></tr>'."\n";
$j = 0;
for($i = 1;$i<count($d_array);$i++){
if($i == 2 || $i == 10) {
echo "\t\t".'<tr><td>'.$desc_array[$i].'</td><td style="text-align:center"><select id="input" name="data['.$d_array[$i].']">';
for($k = 0; $k < count($d_select_array[$j]); $k++) {
echo "<option value=\"".$d_select_array[$j][$k]."\" ";
if($d_select_array[$j][$k] == debbcode($row[$d_array[$i]])) {
echo " selected";
}
echo ">".$desc_select_array[$j][$k]."</option>";
}
echo '</select></td></tr>'."\n";
$j++;
} else {
echo "\t\t".'<tr><td>'.$desc_array[$i].'</td><td style="text-align:center"><input name="data['.$d_array[$i].']" value="'.debbcode($row[$d_array[$i]]).'"></input></td></tr>'."\n";
}
}
echo "\t".'<tr><td colspan="'.$colspan.'" style="text-align:center"><input type="submit" value="speichern"></td></tr>'."\n";
echo "\t".'<tr><td colspan="'.$colspan.'" style="text-align:center"><a href="'.$_SERVER['PHP_SELF'].'?choose=npc">NPC Übersicht</a></td></tr>'."\n";
}
echo "\t".'<tr><td colspan="'.$colspan.'" style="text-align:center"><a href="'.$_SERVER['PHP_SELF'].'?choose=npc">NPC Übersicht</a></td></tr>'."\n";
} else if($action == 'create'){
$colspan = 1;
echo "\t".'<tr><td colspan="'.$colspan.'"><h1 style="text-align:center">NPC erstellen</h1></td></tr>'."\n";;
echo "\t".'<tr><td colspan="'.$colspan.'" style="text-align:center"><a href="'.$_SERVER['PHP_SELF'].'?choose=npc">NPC Übersicht</a></td></tr>'."\n";
} else if($action == 'delete'){
$colspan = 1;
$sql = 'SELECT * FROM chars WHERE id = '.$charid;
$qry = mysql_query($sql);
$row = mysql_fetch_assoc($qry);
$row = mysql_fetch_assoc($qry);
echo "\t".'<tr><td colspan="'.$colspan.'"><h1 style="text-align:center">NPC löschen</h1></td></tr>'."\n";;
if(is_null($task)){
echo "\t".'<tr><td colspan="'.$colspan.'" style="text-align:center">Soll der NPC '.$row['name'].' wirklich gelöscht werden</td></tr>'."\n";;
echo "\t".'<tr><td style="text-align:center"><a href="'.$_SERVER['PHP_SELF'].'?choose=npc&action=delete&task=do&charid='.$charid.'">ja</a>, <a href="'.$_SERVER['PHP_SELF'].'?choose=npc&action=">nein</a>, <a href="'.$_SERVER['PHP_SELF'].'?choose=npc&action=delete&charid='.$charid.'">vielleicht</a></td></tr>'."\n";
echo "\t".'<tr><td style="text-align:center"><a href="'.$_SERVER['PHP_SELF'].'?choose=npc&action=delete&task=do&charid='.$charid.'">ja</a>, <a href="'.$_SERVER['PHP_SELF'].'?choose=npc&action=">nein</a>, <a href="'.$_SERVER['PHP_SELF'].'?choose=npc&action=delete&charid='.$charid.'">vielleicht</a></td></tr>'."\n";
} else {
$sql = 'DELETE c,ni,kl,l FROM chars c inner join npc_item ni on ni.charakter = c.id inner join kampf_list kl on ni.charakter = kl.charakter inner join lernen l on l.besitzer = c.id where c.id = '.$charid;
// echo $sql.'<br>';
// echo $sql.'<br>';
$qry = mysql_query($sql);
if($qry === FALSE || mysql_affected_rows() <= 0){
echo "\t".'<tr><td colspan="'.$colspan.'" style="text-align:center;color:red">Der NPC '.$row['name'].' konnte nicht gelöscht werden!</td></tr>'."\n";;
} else {
echo "\t".'<tr><td colspan="'.$colspan.'" style="text-align:center">Der NPC '.$row['name'].' wurde gelöscht!</td></tr>'."\n";;
}
// SELECT * FROM chars c inner join npc_item ni on ni.charakter = c.id inner join kampf_list kl on ni.charakter = kl.charakter
// SELECT * FROM chars c inner join npc_item ni on ni.charakter = c.id inner join kampf_list kl on ni.charakter = kl.charakter
}
echo "\t".'<tr><td colspan="'.$colspan.'" style="text-align:center"><a href="'.$_SERVER['PHP_SELF'].'?choose=npc">NPC Übersicht</a></td></tr>'."\n";
} else{
$d_array = array('id', 'name', 'level');
$desc_array = array('id', 'Name', 'Level');
$sql = 'SELECT '.join($d_array,',').' from chars where rasse = \'NPC\' ORDER BY level';
$qry = mysql_query($sql.' LIMIT '.($page*20).', 20');
$anzahlSeiten = ceil(mysql_num_rows(mysql_query($sql))/20);
@ -73,7 +120,7 @@ function displayNPC($action, $task, $charid, $table, $page, $data){
}
echo "\t\t".'<td style="text-align:center">Bearbeiten</td>'."\n";
echo "\t".'</tr>'."\n";
echo "\t".'<tr><td colspan="'.$colspan.'"><hr></td></tr>'."\n";
while($row = mysql_fetch_assoc($qry)){
@ -87,18 +134,19 @@ function displayNPC($action, $task, $charid, $table, $page, $data){
// Echo the delete and the edit button :)
echo "\t\t\t".'<a href="'.$_SERVER['PHP_SELF'].'?choose=npc&action=edit&charid='.$row[$d_array[0]].'">Edit</a>, '."\n";
echo "\t\t\t".'<a href="'.$_SERVER['PHP_SELF'].'?choose=npc&action=delete&charid='.$row[$d_array[0]].'">Delete</a>'."\n";
echo "\t\t".'</td>'."\n";
echo "\t".'</tr>'."\n";
}
echo "\t".'<tr><td colspan="'.$colspan.'" style="text-align:center"><a href="'.$_SERVER['PHP_SELF'].'?choose=npc&action=create">Create a new NPC</a></td></tr>'."\n";
echo "\t".'<tr><td colspan="'.$colspan.'" style="text-align:center"><hr></td></tr>'."\n";
}
//TODO: ändern, dass man nicht 2x Zum Hauptmenü hat xD
echo "\t".'<tr><td colspan="'.$colspan.'" style="text-align:center"><a href="'.$_SERVER['PHP_SELF'].'">Zum Hauptmenu</a></td></tr>'."\n";
echo "\t".'</table>'."\n";
echo '</form>'."\n";
}
?>

@ -9,119 +9,146 @@
?>
<?php
function displayTournamentOptions($action, $klein, $wochen) {
if($action == 'starttnmt') {
/*if($action === "starttnmt") {
if(is_numeric($_REQUEST['anzahl']) && is_numeric($_REQUEST['minlevel']) && is_numeric($_REQUEST['maxlevel'])
&& is_numeric($_REQUEST['grp_size']) && is_numeric($_REQUEST['grp_proceed'])) {
include_once($_SERVER['DOCUMENT_ROOT'].'cronjob/generic_turnier.php');
} else {
echo 'Keine gültige Eingabe<br>';
echo '<a href="'.$_SERVER['PHP_SELF'].'?choose=tournament">Zur&uuml;ck</a>';
}
} else {*/
?>
if($action == 'checktnmt') {
if(is_numeric($_REQUEST['minlevel']) && is_numeric($_REQUEST['maxlevel'])) {?>
<table width="80%">
<tr>
<th colspan="2"><h1 style="text-align: center">Übersicht</h1></th>
</tr>
<tr>
<td>Art</td>
<td style="text-align: center"><select id="input" name="name">
<option value="klein">Anf&auml;ngerturnier</option>
<option value="wochen">Wochenturnier</option>
<option value="gross">Weltturnier</option>
</select>
</td>
</tr>
<tr>
<td>Anzahl</td>
<td style="text-align: center"><input name="anzahl" value=""></td>
<th colspan="2" style="text-align: center">Turnier wirklich starten?</th>
</tr>
<tr>
<td>Fusion erlaubt?</td>
<td style="text-align: center"><select id="input" name="fusion">
<option value="1">ja</option>
<option value="0">nein</option>
</select>
<td style="text-align: center">
<a href="<?php echo 'http://ag04.animegame.eu/ag_crond/generic_turnier.php?fusion='.$_POST['fusion'].'&special='.
$_POST['special'].'&minlevel='.$_POST['minlevel'].'&maxlevel='.$_POST['maxlevel'].'&gain='.$_POST['gain'].'&randomize='.
$_POST['randomize'].'&name='.$_POST['name'].'&anzahl='.$_POST['anzahl'];?>"
target="_blank">Turnier starten!</a>
</td>
</tr>
<tr>
<td>Spezialcharaktere erlaubt? (Kaio/Shichi)</td>
<td style="text-align: center"><select id="input" name="fusion">
<option value="1">ja</option>
<option value="0">nein</option>
</select>
</td>
</tr>
<tr>
<td>Min. Level</td>
<td style="text-align: center"><input name="minlevel" value="1"></td>
</tr>
<tr>
<td>Max. Level</td>
<td style="text-align: center"><input name="maxlevel" value="150"></td>
</tr>
<tr>
<td>Teilnehmer</td>
<td style="text-align: center"><select id="input" name="gain">
<option value="Anmeldung">Anmeldung</option>
<option value="PL">Powerlevel</option>
<option value="Level">Level</option>
</select>
</td>
</tr>
<tr>
<td>Zufällige Reihenfolge?</td>
<td style="text-align: center"><select id="input" name="randomize">
<option value="1">ja</option>
<option value="0">nein</option>
</select>
</td>
</tr>
<tr>
<td>Gruppenphase?</td>
<td style="text-align: center"><select id="input" name="gruppenphase">
<option value="0">nein</option>
<option value="1">ja</option>
</select>
</td>
</tr>
<tr>
<td>Gruppengr&ouml;sse</td>
<td style="text-align: center"><input name="grp_size" value="0"></td>
</tr>
<tr>
<td>Anzahl der Sieger die eine Gruppe verlassen</td>
<td style="text-align: center"><input name="grp_proceed" value="0"></td>
</tr>
<tr>
<td align="center" colspan="2">
<a href="<?php $_SERVER['DOCUMENT_ROOT'].'cronjob/generic_turnier.php'?>"
target="_blank">Turnier starten!</a>
</td>
</tr>
<tr>
<td align="center" colspan="2">
<a href="<?php echo $_SERVER['PHP_SELF'].'?choose=tournament'; ?>">Zur&uuml;ck</a>
</td>
</tr>
<tr>
<td align="center" colspan="2"><a
href="<?php echo $_SERVER['PHP_SELF']; ?>">Zum Hauptmenu</a>
<td style="text-align: center">
<a href="<?php echo $_SERVER['PHP_SELF'].'?choose=tournament&action=tnmt'; ?>">Doch nicht</a>
</td>
</tr>
</table>
<?php
<?php
} else {
echo 'Keine gültige Eingabe von Min. oder Max. Level<br>';
echo '<a href="'.$_SERVER['PHP_SELF'].'?choose=tournament&action=tnmt">Zur&uuml;ck</a>';
}
} elseif($action == 'tnmt') {
?>
<form method="POST">
<input type="hidden" name="choose" value="tournament">
<input type="hidden" name="action" value="checktnmt">
<table width="80%">
<tr>
<th colspan="2"><h1 style="text-align: center">Übersicht</h1></th>
</tr>
<tr>
<td>Art</td>
<td style="text-align: center"><select id="input" name="name">
<option value="klein">Anf&auml;ngerturnier</option>
<option value="wochen">Wochenturnier</option>
<option value="gross">Weltturnier</option>
</select>
</td>
</tr>
<tr>
<td>Anzahl</td>
<td style="text-align: center"><select id="input" name="anzahl">
<option value="2">2</option>
<option value="4">4</option>
<option value="8">8</option>
<option value="16">16</option>
<option value="32">32</option>
<option value="64">64</option>
<option value="128">128</option>
<option value="256">256</option>
<option value="512">512</option>
</select>
</tr>
<tr>
<td>Fusion erlaubt?</td>
<td style="text-align: center"><select id="input" name="fusion">
<option value="1">ja</option>
<option value="0">nein</option>
</select>
</td>
</tr>
<tr>
<td>Spezialcharaktere erlaubt? (Kaio/Shichi)</td>
<td style="text-align: center"><select id="input" name="special">
<option value="1">ja</option>
<option value="0">nein</option>
</select>
</td>
</tr>
<tr>
<td>Min. Level</td>
<td style="text-align: center"><input name="minlevel" value="1"></td>
</tr>
<tr>
<td>Max. Level</td>
<td style="text-align: center"><input name="maxlevel" value="150"></td>
</tr>
<tr>
<td>Teilnehmer</td>
<td style="text-align: center"><select id="input" name="gain">
<option value="Anmeldung">Anmeldung</option>
<option value="PL">Powerlevel</option>
<option value="Level">Level</option>
</select>
</td>
</tr>
<tr>
<td>Zufällige Reihenfolge?</td>
<td style="text-align: center"><select id="input" name="randomize">
<option value="1">ja</option>
<option value="0">nein</option>
</select>
</td>
</tr>
<!-- <tr>
<td>Gruppenphase?</td>
<td style="text-align: center"><select id="input" name="gruppenphase">
<option value="0">nein</option>
<option value="1">ja</option>
</select>
</td>
</tr>
<tr>
<td>Gruppengr&ouml;sse</td>
<td style="text-align: center"><input name="grp_size" value="0"></td>
</tr>
<tr>
<td>Anzahl der Sieger die eine Gruppe verlassen</td>
<td style="text-align: center"><input name="grp_proceed" value="0"></td>
</tr>-->
<tr>
<td align="center" colspan="2"><input type="submit" value="starten">
</td>
</tr>
<tr>
<td align="center" colspan="2"><a
href="<?php echo $_SERVER['PHP_SELF'].'?choose=tournament'; ?>">Zur&uuml;ck</a>
</td>
</tr>
<tr>
<td align="center" colspan="2"><a
href="<?php echo $_SERVER['PHP_SELF']; ?>">Zum Hauptmenu</a>
</td>
</tr>
</table>
</form>
<?php
} else if($action == 'fee') {
$qry = mysql_query('SELECT * FROM turnier_gebuehr;');
while ($fee = mysql_fetch_assoc($qry)) {
while ($fee = mysql_fetch_assoc($qry)) {
if($fee['art'] == 'wochen') {
$fee_wochen = $fee['gebuehr'];
} else if($fee['art'] == 'klein') {
$fee_klein = $fee['gebuehr'];
$fee_klein = $fee['gebuehr'];
}
}
$change = FALSE;
if($klein !== NULL || $wochen !== null) {
if($klein !== NULL && $klein != $fee_klein) {
@ -136,80 +163,71 @@ function displayTournamentOptions($action, $klein, $wochen) {
}
}
?>
<form method="get">
<input type="hidden" name="choose" value="tournament">
<input type="hidden" name="action" value="fee">
<table width="80%">
<tr>
<th colspan="2"><h1 style="text-align: center">Übersicht</h1></th>
</tr>
<form method="get">
<input type="hidden" name="choose" value="tournament"> <input
type="hidden" name="action" value="fee">
<table width="80%">
<tr>
<th colspan="2"><h1 style="text-align: center">Übersicht</h1></th>
</tr>
<?php if($change === TRUE) {?>
<tr>
<td colspan="2" align="center">
&Auml;nderungen &uuml;bernommen!
</td>
<td colspan="2" align="center">&Auml;nderungen &uuml;bernommen!</td>
</tr>
<?php }?>
<tr>
<td colspan="2" align="center">
<b>Anf&auml;ngerturnier</b>
<td colspan="2" align="center"><b>Anf&auml;ngerturnier</b>
</td>
</tr>
</tr>
<tr>
<td align="left">
Anmeldegeb&uuml;hr:
</td>
<td>
<input type="text" name="klein" value=<?php echo $fee_klein;?>>
<td align="left">Anmeldegeb&uuml;hr:</td>
<td><input type="text" name="klein" value=<?php echo $fee_klein;?>>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<b>Wochenturnier</b>
<td colspan="2" align="center"><b>Wochenturnier</b>
</td>
</tr>
<tr>
<td align="left">
Anmeldegeb&uuml;hr:
</td>
<td>
<input type="text" name="wochen" value=<?php echo $fee_wochen;?>>
<td align="left">Anmeldegeb&uuml;hr:</td>
<td><input type="text" name="wochen" value=<?php echo $fee_wochen;?>>
</td>
</tr>
<tr>
<td align="center" colspan="2">
<input type="submit" value="&auml;ndern">
<td align="center" colspan="2"><input type="submit"
value="&auml;ndern">
</td>
</tr>
<tr>
<td align="center" colspan="2">
<a href="<?php echo $_SERVER['PHP_SELF'].'?choose=tournament'; ?>">Zur&uuml;ck</a>
<td align="center" colspan="2"><a
href="<?php echo $_SERVER['PHP_SELF'].'?choose=tournament'; ?>">Zur&uuml;ck</a>
</td>
</tr>
<tr>
<td align="center" colspan="2">
<a href="<?php echo $_SERVER['PHP_SELF']; ?>">Zum Hauptmenu</a>
<td align="center" colspan="2"><a
href="<?php echo $_SERVER['PHP_SELF']; ?>">Zum Hauptmenu</a>
</td>
</tr>
</table>
</table>
</form>
<?php
<?php
} else {
?>
<table>
<tr>
<td>
<a href="<?php $_SERVER['PHP_SELF'] ?>?choose=tournament&action=starttnmt">Turnier starten (in Arbeit)</a>
<td><a
href="<?php $_SERVER['PHP_SELF'] ?>?choose=tournament&action=tnmt">Turnier
starten</a>
</td>
</tr>
<tr>
<td>
<a href="<?php $_SERVER['PHP_SELF'] ?>?choose=tournament&action=fee"> Anmeldegebühren bearbeiten</a>
<td><a
href="<?php $_SERVER['PHP_SELF'] ?>?choose=tournament&action=fee">
Anmeldegebühren bearbeiten</a>
</td>
</tr>
<tr>
<td>
<a href="<?php echo $_SERVER['PHP_SELF']; ?>">Zum Hauptmenu</a>
<td><a href="<?php echo $_SERVER['PHP_SELF']; ?>">Zum Hauptmenu</a>
</td>
</tr>
</table>

Loading…
Cancel
Save