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
*******************************************************************************/
include_once('../path.inc.php'); // get the path ;)
include_once(ROOT_PATH.'/include/config/db.inc.php');
include_once(ROOT_PATH.'/include/designfunctions.inc.php');
include_once(ROOT_PATH.'/include/fehlerausgabe.inc.php');

@ -9,7 +9,19 @@
?>
<?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() {
$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);
}
function displayEditNPC($charid) {
echo "\t".'<input type="hidden" name="action" value="edit"></input>'."\n";
echo "\t".'<input type="hidden" name="task" value="dochange"></input>'."\n";
function displayNPCInfo($action, $task, $charid) {
//Form-Variablen
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_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');
$attset = getCharAttackSet($charid, NORMALKAMPF);
$attset_names = getAttackNamesFromAttackSet($attset);
$attacks = getNPCAttacks();
$attset = array(-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1);
$attset_names = array(' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');
//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;
$qry = mysql_query($sql);
$row = mysql_fetch_assoc($qry);
$attacks = getNPCAttacks();
$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";
$j = 0;
//allgemeine informationen
@ -128,6 +154,7 @@ function displayEditNPC($charid) {
}
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"><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() {
$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";
function createNPC($data, $att_ids) {
$d_array = array('charakter', 'name', 'type', 'hp', 'mp', 'starke', 'verteidigung', 'speed',
'ausdauer', 'glueck', 'zeit_rec', 'level', 'lvlmin', 'lvlmax', 'bild');
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) {
@ -253,17 +321,22 @@ function displayNPC($action, $task, $charid, $table, $page, $data, $att_ids){
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="charid" value="'.$charid.'"></input>'."\n";
echo "\t".'<table width="80%" border="0">'."\n";
if($action == 'edit'){
echo "\t".'<input type="hidden" name="action" value="edit"></input>'."\n";
if($task == 'dochange') {
echo "\t".'<table width="80%" border="1">'."\n";
if($action == ACTION_EDIT){
echo "\t".'<input type="hidden" name="action" value="'.ACTION_EDIT.'"></input>'."\n";
if($task == TASK_EDIT) {
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 {
displayEditNPC($charid);
displayNPCInfo(ACTION_CREATE, TASK_CREATE, $charid);
}
} else if($action == 'create'){
displayCreateNPC();
} else if($action == 'delete'){
if($task == 'dodelete') {
deleteNPC($charid);

@ -6,7 +6,7 @@
*
*/
include_once (ROOT_PATH . '/include/defines.inc.php');
include_once (ROOT_PATH.'/include/defines.inc.php');
//Set-Arten
defineIfNotDefined('NORMALKAMPF', 1);
@ -41,12 +41,11 @@ function getCharAttackSet($char_id, $type) {
if(is_numeric($char_id)) {
$qry = mysql_query('SELECT attack_id, round FROM attackenset WHERE char_id = '.$char_id.' AND type = '.$type);
}
while ($result = mysql_fetch_assoc($qry)) {
$set[$result['round']] = $result['attack_id'];
while ($result = mysql_fetch_assoc($qry)) {
$set[$result['round']] = $result['attack_id'];
}
}
return $set;
}
@ -88,7 +87,7 @@ function getAttackTypesFromAttackSet($attset) {
if($attset == NULL || count($attset) == 0) {
return array();
}
$qry = mysql_query('SELECT l.id,a.type FROM attacken a INNER JOIN lernen l ON a.id=l.at_id WHERE l.id in ('.implode(',', $attset).');');
while ($result = mysql_fetch_assoc($qry)) {
$set[$result['id']] = $result['type'];
@ -101,12 +100,12 @@ function validateAttackSetTypes($attset) {
if($attset == NULL) {
return 'Es wurden garkeine Attacken ausgewählt!';
}
$types = getAttackTypesFromAttackSet($attset);
$types = getAttackTypesFromAttackSet($attset);
if(count($types)==0) {
return 'Es wurden garkeine Attacken ausgewählt!';
}
foreach ($attset as $att_id) {
if($types[$att_id] == "tausch") { $kampf_tausch_n++;
}elseif($types[$att_id] == "SSJ") { $kampf_ssj_n++;

@ -22,14 +22,14 @@ function erstelleUser(){
}
// 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
$type = '';
$trainingspoints = 0;
$special_char = false;
$dbz = 'Dragonball';
$op = 'Onepiece';
$c_type = '';
$c_type = '';
if($newname == ''){
displayErrorMessage(NULL,'Name ist nicht erlaubt!!',displayHistoryBackLink());
@ -142,47 +142,67 @@ function erstelleChar($user, $specialcharname, $newname = '', $picture = '', $lv
$special_char = true;
$type = $op;
$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 {
displayErrorMessage(NULL,'Rasse nicht vorhanden!!',displayHistoryBackLink());
return false;
}
// If-Anweisungen ende
// Werte hinzufügen, falls ein Testcharakter erstellt wird
$HP += ($hp*10);
$MP += ($mp*5);
$Starke += $str;
$Verteidigung += $def;
$Geschwindigkeit += $spd;
$Gluck += $lck;
$Ausdauer += $end;
$trainingspoints += $lp*2;
$LP = ($lvl - 1) * 10;
// Ueberprüfe ob ein Slot frei ist
$chars = getCharsOfUser($user['id']);
$normal = 0;
$special = 0;
foreach($chars as $row){
if($row['rasse'] == 'Kaioshin' || $row['fusion_rasse'] == 'Kaioshin' || $row['rasse'] == 'Shichibukai' || $row['fusion_rasse'] == 'Shichibukai'){
$special++;
// Werte hinzufügen, falls ein Testcharakter erstellt wird
$HP += ($hp*10);
$MP += ($mp*5);
$Starke += $str;
$Verteidigung += $def;
$Geschwindigkeit += $spd;
$Gluck += $lck;
$Ausdauer += $end;
$trainingspoints += $lp*2;
$LP = ($lvl - 1) * 10;
if($specialcharname != 'NPC') {
// Ueberprüfe ob ein Slot frei ist
$chars = getCharsOfUser($user['id']);
$normal = 0;
$special = 0;
foreach($chars as $row){
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{
$normal++;
$slots_used = $normal + $special - 1;
}
}
$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>';
// echo 'Slots used: '.$slots_used.'<br>Slots available: '.$slots_avail.'<br>';
if($slots_used >= $user['char_max']){
displayErrorMessage(NULL,'Alle Slots sind schon belegt!!',displayHistoryBackLink());
return false;
if($slots_used >= $user['char_max']){
displayErrorMessage(NULL,'Alle Slots sind schon belegt!!',displayHistoryBackLink());
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) ' .
'values(\''.$newname.'\',' .
' '.$Starke.',' .
@ -203,7 +223,7 @@ function erstelleChar($user, $specialcharname, $newname = '', $picture = '', $lv
'\'0,'.calculateRequiredExpChars($lvl).'\'' .
')';
//echo $sql.'<br>';
$identifier = mysql_query($sql);
$identifier = mysql_query($sql);
if($identifier == FALSE){
if(mysql_fetch_assoc(mysql_query('Select * from chars where name = \''.$newname.'\''))){
displayErrorMessage(NULL,'Name schon vorhanden!!',displayHistoryBackLink());
@ -213,12 +233,13 @@ function erstelleChar($user, $specialcharname, $newname = '', $picture = '', $lv
return false; // Hat nich geklappt
}
$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');
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');
}
return true; // Hat geklappt
}

Loading…
Cancel
Save