From aff658fa52f0c2fe06a6ae1d1d27b5e88ca4f406 Mon Sep 17 00:00:00 2001 From: radiskull Date: Wed, 16 Nov 2011 12:48:36 +0000 Subject: [PATCH] =?UTF-8?q?NPC=20=C3=9Cbersicht=20erweitert,=20man=20kann?= =?UTF-8?q?=20nun=20auch=20NPC=20l=C3=B6schen!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ag/gm/gm_seite.php | 1 + ag/gm/include/npc.inc.php | 119 ++++++++++++++++++++++------ ag/include/attackenset.inc.php | 17 ++-- ag/include/erstellfunctions.inc.php | 101 +++++++++++++---------- 4 files changed, 166 insertions(+), 72 deletions(-) diff --git a/ag/gm/gm_seite.php b/ag/gm/gm_seite.php index 05d4365..6aa740a 100644 --- a/ag/gm/gm_seite.php +++ b/ag/gm/gm_seite.php @@ -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'); diff --git a/ag/gm/include/npc.inc.php b/ag/gm/include/npc.inc.php index 004c148..ce6b618 100644 --- a/ag/gm/include/npc.inc.php +++ b/ag/gm/include/npc.inc.php @@ -9,7 +9,19 @@ ?> '."\n"; - echo "\t".''."\n"; +function displayNPCInfo($action, $task, $charid) { + //Form-Variablen + echo "\t".''."\n"; + echo "\t".''."\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".'

NPC bearbeiten

'."\n"; + if($task == TASK_EDIT) { + echo "\t".'

NPC bearbeiten

'."\n"; + } else { + echo "\t".'

NPC erstellen

'."\n"; + } + echo "\t\t".''.$desc_array[0].''.$row[$d_array[0]].''."\n"; $j = 0; //allgemeine informationen @@ -128,6 +154,7 @@ function displayEditNPC($charid) { } echo ''."\n"; } + //menü echo "\t".''."\n"; echo "\t".'NPC Übersicht'."\n"; } @@ -179,10 +206,51 @@ function editNPC($charid, $data, $att_ids) { } } -function displayCreateNPC() { - $colspan = 1; - echo "\t".'

NPC erstellen

'."\n";; - echo "\t".'NPC Übersicht'."\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".'NPC '.$data['name'].' wurde erfolgreich erstellt!'."\n"; + if($error != null) { + echo "\t".'Es gab Probleme beim erstellen des Attacksets!'."\n"; + echo "\t".''.$error.''."\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".'NPC Übersicht'."\n"; } function displayDeleteNPC($charid) { @@ -253,17 +321,22 @@ function displayNPC($action, $task, $charid, $table, $page, $data, $att_ids){ echo '
'."\n"; echo "\t".''."\n"; echo "\t".''."\n"; - echo "\t".''."\n"; - if($action == 'edit'){ - echo "\t".''."\n"; - if($task == 'dochange') { + echo "\t".'
'."\n"; + if($action == ACTION_EDIT){ + echo "\t".''."\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".''."\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); diff --git a/ag/include/attackenset.inc.php b/ag/include/attackenset.inc.php index 12641a8..d369407 100644 --- a/ag/include/attackenset.inc.php +++ b/ag/include/attackenset.inc.php @@ -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++; diff --git a/ag/include/erstellfunctions.inc.php b/ag/include/erstellfunctions.inc.php index 0cd398b..3b99395 100644 --- a/ag/include/erstellfunctions.inc.php +++ b/ag/include/erstellfunctions.inc.php @@ -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.'
Slots available: '.$slots_avail.'
'; + // echo 'Slots used: '.$slots_used.'
Slots available: '.$slots_avail.'
'; - 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.'
'; - $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 }