NPC Übersicht erweitert, man kann nun auch NPC löschen!

main
radiskull 13 years ago
parent 8af6f264fa
commit aff658fa52

@ -17,6 +17,7 @@ session_start();
* Zuletzt verändert: 03.10.2007 * Zuletzt verändert: 03.10.2007
*******************************************************************************/ *******************************************************************************/
include_once('../path.inc.php'); // get the path ;)
include_once(ROOT_PATH.'/include/config/db.inc.php'); include_once(ROOT_PATH.'/include/config/db.inc.php');
include_once(ROOT_PATH.'/include/designfunctions.inc.php'); include_once(ROOT_PATH.'/include/designfunctions.inc.php');
include_once(ROOT_PATH.'/include/fehlerausgabe.inc.php'); include_once(ROOT_PATH.'/include/fehlerausgabe.inc.php');

@ -9,7 +9,19 @@
?> ?>
<?php <?php
include_once($_SERVER['DOCUMENT_ROOT'].'/include/attackenset.inc.php'); include_once(ROOT_PATH.'/include/attackenset.inc.php');
include_once(ROOT_PATH.'/include/erstellfunctions.inc.php');
defineIfNotDefined('ACTION_EDIT', 'edit');
defineIfNotDefined('ACTION_CREATE', 'create');
defineIfNotDefined('TASK_EDIT', 'dochange');
defineIfNotDefined('TASK_CREATE', 'docreate');
defineIfNotDefined('NPC_USER_NAME', 'animegame-npc');
function getNPCUser() {
$qry = mysql_query('SELECT * FROM user WHERE nickname = "'.NPC_USER_NAME.'";');
return mysql_fetch_assoc($qry);
}
function getNPCAttacks() { function getNPCAttacks() {
$qry = mysql_query('SELECT name,id FROM attacken a WHERE info like "%NPC%";'); $qry = mysql_query('SELECT name,id FROM attacken a WHERE info like "%NPC%";');
@ -79,25 +91,39 @@ function buildAttackSet($charid, $att_ids) {
return getAttackSet($charid, $att_ids); return getAttackSet($charid, $att_ids);
} }
function displayEditNPC($charid) { function displayNPCInfo($action, $task, $charid) {
echo "\t".'<input type="hidden" name="action" value="edit"></input>'."\n"; //Form-Variablen
echo "\t".'<input type="hidden" name="task" value="dochange"></input>'."\n"; echo "\t".'<input type="hidden" name="action" value="'.$action.'"></input>'."\n";
echo "\t".'<input type="hidden" name="task" value="'.$task.'"></input>'."\n";
//initialisierung der Variablen für Inhalt
$d_select_array = array(array('Dragonball', 'Onepiece'), array(300, 1200, 3600)); $d_select_array = array(array('Dragonball', 'Onepiece'), array(300, 1200, 3600));
$d_array = array('charakter', 'name', 'type', 'hp', 'mp', 'starke', 'verteidigung', 'speed', $d_array = array('charakter', 'name', 'type', 'hp', 'mp', 'starke', 'verteidigung', 'speed',
'ausdauer', 'glueck', 'zeit_rec', 'level', 'lvlmin', 'lvlmax', 'bild'); 'ausdauer', 'glueck', 'zeit_rec', 'level', 'lvlmin', 'lvlmax', 'bild');
$desc_select_array = array(array('Dragonball', 'Onepiece'), array('5min', '20min', '60min')); $desc_select_array = array(array('Dragonball', 'Onepiece'), array('5min', '20min', '60min'));
$desc_array = array('ID', 'Name', 'Type', 'HP', 'MP', 'Stärke', 'Verteidigung', 'Geschwindigkeit', $desc_array = array('ID', 'Name', 'Type', 'HP', 'MP', 'Stärke', 'Verteidigung', 'Geschwindigkeit',
'Ausdauer', 'Glück', 'Kampfdauer in Sekunden', 'Level', 'Min-Level', 'Max-Level', 'Bild'); 'Ausdauer', 'Glück', 'Kampfdauer in Sekunden', 'Level', 'Min-Level', 'Max-Level', 'Bild');
$attset = getCharAttackSet($charid, NORMALKAMPF); $attset = array(-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1);
$attset_names = getAttackNamesFromAttackSet($attset); $attset_names = array(' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');
$attacks = getNPCAttacks(); //initialisieren falls editiert wird (dort existieren schon Inhalte)
if($task == TASK_EDIT) {
$attset = getCharAttackSet($charid, NORMALKAMPF);
$attset_names = getAttackNamesFromAttackSet($attset);
//$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;
$sql = 'SELECT * FROM chars c inner join kampf_list kl on c.id = kl.charakter WHERE c.id ='.$charid;
$qry = mysql_query($sql);
$row = mysql_fetch_assoc($qry);
}
$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; $attacks = getNPCAttacks();
$qry = mysql_query($sql);
$row = mysql_fetch_assoc($qry);
$colspan = 2; $colspan = 2;
echo "\t".'<tr><td colspan="'.$colspan.'"><h1 style="text-align:center">NPC bearbeiten</h1></td></tr>'."\n"; if($task == TASK_EDIT) {
echo "\t".'<tr><td colspan="'.$colspan.'"><h1 style="text-align:center">NPC bearbeiten</h1></td></tr>'."\n";
} else {
echo "\t".'<tr><td colspan="'.$colspan.'"><h1 style="text-align:center">NPC erstellen</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"; echo "\t\t".'<tr><td>'.$desc_array[0].'</td><td style="text-align:center">'.$row[$d_array[0]].'</td></tr>'."\n";
$j = 0; $j = 0;
//allgemeine informationen //allgemeine informationen
@ -128,6 +154,7 @@ function displayEditNPC($charid) {
} }
echo '</select></td></tr>'."\n"; echo '</select></td></tr>'."\n";
} }
//menü
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"><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";
} }
@ -179,10 +206,51 @@ function editNPC($charid, $data, $att_ids) {
} }
} }
function displayCreateNPC() { function createNPC($data, $att_ids) {
$colspan = 1; $d_array = array('charakter', 'name', 'type', 'hp', 'mp', 'starke', 'verteidigung', 'speed',
echo "\t".'<tr><td colspan="'.$colspan.'"><h1 style="text-align:center">NPC erstellen</h1></td></tr>'."\n";; 'ausdauer', 'glueck', 'zeit_rec', 'level', 'lvlmin', 'lvlmax', 'bild');
echo "\t".'<tr><td colspan="'.$colspan.'" style="text-align:center"><a href="'.$_SERVER['PHP_SELF'].'?choose=npc">NPC Übersicht</a></td></tr>'."\n";
foreach ($data as $info) {
if($info == NULL) {
//TODO: FEHLER!
echo 'fehler dude!';
} else {
$info = encodeNoHTMLWithBB($info);
}
}
//Char erstellen, wichtig für die restlichen Sachen
$success = erstelleChar(getNPCUser(), 'NPC', $data['name'], $data['bild'], $data['level'], 0, $data['hp'], $data['mp'], $data['starke'], $data['verteidigung'], $data['speed'],
$data['ausdauer'], $data['glueck'], $data['type']);
if($success) {
//Char ID holen
$qry = mysql_query('SELECT id FROM chars c WHERE name = "'.$data['name'].'";');
$result = mysql_fetch_assoc($qry);
$char_id = $result['id'];
//zur Kampfliste hinzufügen :)
$sql = 'INSERT INTO kampf_list(kampfname,charakter,rasse,besitzer,zeit,zeit_rec,lvlmax,ip,lvlmin) VALUES("NPC Kampf",'.$char_id.',"NPC","'.NPC_USER_NAME.'",0,'.
$data['zeit_rec'].','.$data['lvlmax'].',0,'.$data['lvlmin'].');';
mysql_query($sql);
//Attacksets soweit einbinden
$attset = buildAttackSet($char_id, $att_ids);
$error = validateAttackSetTypes($attset);
echo "\t".'<tr><td colspan="2" style="text-align:center">NPC '.$data['name'].' wurde erfolgreich erstellt!</td></tr>'."\n";
if($error != null) {
echo "\t".'<tr><td colspan="2" style="text-align:center">Es gab Probleme beim erstellen des Attacksets!</td></tr>'."\n";
echo "\t".'<tr><td colspan="2" style="text-align:center">'.$error.'</td></tr>'."\n";
} else {
updateCharAttackSet($char_id, $attset, NORMALKAMPF);
//alter müll
$qry = 'UPDATE chars SET attacken=\''.implode(',', $attset).'\', '.
'attacken2=\''.implode(',', $attset).'\' WHERE id='.$char_id.' LIMIT 1';
mysql_query($qry);
}
}
echo "\t".'<tr><td colspan="2" style="text-align:center"><a href="'.$_SERVER['PHP_SELF'].'?choose=npc">NPC Übersicht</a></td></tr>'."\n";
} }
function displayDeleteNPC($charid) { function displayDeleteNPC($charid) {
@ -253,17 +321,22 @@ function displayNPC($action, $task, $charid, $table, $page, $data, $att_ids){
echo '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">'."\n"; echo '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">'."\n";
echo "\t".'<input type="hidden" name="choose" value="npc"></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".'<input type="hidden" name="charid" value="'.$charid.'"></input>'."\n";
echo "\t".'<table width="80%" border="0">'."\n"; echo "\t".'<table width="80%" border="1">'."\n";
if($action == 'edit'){ if($action == ACTION_EDIT){
echo "\t".'<input type="hidden" name="action" value="edit"></input>'."\n"; echo "\t".'<input type="hidden" name="action" value="'.ACTION_EDIT.'"></input>'."\n";
if($task == 'dochange') { if($task == TASK_EDIT) {
editNPC($charid, $data, $att_ids); editNPC($charid, $data, $att_ids);
displayEditNPC($charid); displayNPCInfo(ACTION_EDIT, TASK_EDIT, $charid);
} else {
displayNPCInfo(ACTION_EDIT, TASK_EDIT, $charid);
}
} else if($action == ACTION_CREATE){
echo "\t".'<input type="hidden" name="action" value="'.ACTION_CREATE.'"></input>'."\n";
if($task == TASK_CREATE) {
createNPC($data, $att_ids);
} else { } else {
displayEditNPC($charid); displayNPCInfo(ACTION_CREATE, TASK_CREATE, $charid);
} }
} else if($action == 'create'){
displayCreateNPC();
} else if($action == 'delete'){ } else if($action == 'delete'){
if($task == 'dodelete') { if($task == 'dodelete') {
deleteNPC($charid); deleteNPC($charid);

@ -6,7 +6,7 @@
* *
*/ */
include_once (ROOT_PATH . '/include/defines.inc.php'); include_once (ROOT_PATH.'/include/defines.inc.php');
//Set-Arten //Set-Arten
defineIfNotDefined('NORMALKAMPF', 1); defineIfNotDefined('NORMALKAMPF', 1);
@ -41,12 +41,11 @@ function getCharAttackSet($char_id, $type) {
if(is_numeric($char_id)) { if(is_numeric($char_id)) {
$qry = mysql_query('SELECT attack_id, round FROM attackenset WHERE char_id = '.$char_id.' AND type = '.$type); $qry = mysql_query('SELECT attack_id, round FROM attackenset WHERE char_id = '.$char_id.' AND type = '.$type);
}
while ($result = mysql_fetch_assoc($qry)) { while ($result = mysql_fetch_assoc($qry)) {
$set[$result['round']] = $result['attack_id']; $set[$result['round']] = $result['attack_id'];
}
} }
return $set; return $set;
} }

@ -22,7 +22,7 @@ function erstelleUser(){
} }
// Muss aus einem sicheren Kontext gestartet werden // 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){ 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'){
// If-Anweisungen muessen noch durch Datenbankabfragen ersetzt werden // If-Anweisungen muessen noch durch Datenbankabfragen ersetzt werden
$type = ''; $type = '';
$trainingspoints = 0; $trainingspoints = 0;
@ -142,6 +142,24 @@ function erstelleChar($user, $specialcharname, $newname = '', $picture = '', $lv
$special_char = true; $special_char = true;
$type = $op; $type = $op;
$c_type = $specialcharname; $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 { } else {
displayErrorMessage(NULL,'Rasse nicht vorhanden!!',displayHistoryBackLink()); displayErrorMessage(NULL,'Rasse nicht vorhanden!!',displayHistoryBackLink());
return false; return false;
@ -149,38 +167,40 @@ function erstelleChar($user, $specialcharname, $newname = '', $picture = '', $lv
// If-Anweisungen ende // If-Anweisungen ende
// Werte hinzufügen, falls ein Testcharakter erstellt wird // Werte hinzufügen, falls ein Testcharakter erstellt wird
$HP += ($hp*10); $HP += ($hp*10);
$MP += ($mp*5); $MP += ($mp*5);
$Starke += $str; $Starke += $str;
$Verteidigung += $def; $Verteidigung += $def;
$Geschwindigkeit += $spd; $Geschwindigkeit += $spd;
$Gluck += $lck; $Gluck += $lck;
$Ausdauer += $end; $Ausdauer += $end;
$trainingspoints += $lp*2; $trainingspoints += $lp*2;
$LP = ($lvl - 1) * 10; $LP = ($lvl - 1) * 10;
// Ueberprüfe ob ein Slot frei ist if($specialcharname != 'NPC') {
$chars = getCharsOfUser($user['id']); // Ueberprüfe ob ein Slot frei ist
$normal = 0; $chars = getCharsOfUser($user['id']);
$special = 0; $normal = 0;
foreach($chars as $row){ $special = 0;
if($row['rasse'] == 'Kaioshin' || $row['fusion_rasse'] == 'Kaioshin' || $row['rasse'] == 'Shichibukai' || $row['fusion_rasse'] == 'Shichibukai'){ foreach($chars as $row){
$special++; if($row['rasse'] == 'Kaioshin' || $row['fusion_rasse'] == 'Kaioshin' || $row['rasse'] == 'Shichibukai' || $row['fusion_rasse'] == 'Shichibukai'){
$special++;
} else{
$normal++;
}
}
$slots_avail = $user['char_max'];
if(!$special_char && $special <= 0){
$slots_used = $normal;
} else{ } else{
$normal++; $slots_used = $normal + $special - 1;
} }
} // echo 'Slots used: '.$slots_used.'<br>Slots available: '.$slots_avail.'<br>';
$slots_avail = $user['char_max'];
if(!$special_char && $special <= 0){
$slots_used = $normal;
} else{
$slots_used = $normal + $special - 1;
}
// echo 'Slots used: '.$slots_used.'<br>Slots available: '.$slots_avail.'<br>';
if($slots_used >= $user['char_max']){ if($slots_used >= $user['char_max']){
displayErrorMessage(NULL,'Alle Slots sind schon belegt!!',displayHistoryBackLink()); displayErrorMessage(NULL,'Alle Slots sind schon belegt!!',displayHistoryBackLink());
return false; return false;
}
} }
// Slotüberprüfung beendet! // Slotüberprüfung beendet!
$sql = 'Insert into chars(name, starke, verteidigung, speed, glueck, ausdauer, hp, mp, level, type, rasse, besitzer, char_type, training_points, lernpunkte, bild, exp) ' . $sql = 'Insert into chars(name, starke, verteidigung, speed, glueck, ausdauer, hp, mp, level, type, rasse, besitzer, char_type, training_points, lernpunkte, bild, exp) ' .
@ -213,12 +233,13 @@ function erstelleChar($user, $specialcharname, $newname = '', $picture = '', $lv
return false; // Hat nich geklappt return false; // Hat nich geklappt
} }
$charsw_id = mysql_fetch_assoc(mysql_query('SELECT id FROM chars WHERE name=\''.$newname.'\'')); if($specialcharname != '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');
mysql_query('INSERT lernen SET at_id=2, aktiv=1, besitzer='.$charsw_id['id'].', name=\'Kick\', dauer=0');
mysql_query('INSERT lernen SET at_id=3, aktiv=1, besitzer='.$charsw_id['id'].', name=\'Block\', dauer=0');
mysql_query('INSERT lernen SET at_id=1, aktiv=1, besitzer='.$charsw_id['id'].', name=\'Schlag\', dauer=0');
mysql_query('INSERT lernen SET at_id=2, aktiv=1, besitzer='.$charsw_id['id'].', name=\'Kick\', dauer=0');
mysql_query('INSERT lernen SET at_id=3, aktiv=1, besitzer='.$charsw_id['id'].', name=\'Block\', dauer=0');
}
return true; // Hat geklappt return true; // Hat geklappt
} }

Loading…
Cancel
Save