@ -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);