improved crafting, added tutorial, impl max level, fixed item equip, gms can now give away items

main
hecht 7 years ago
parent 4849678ab6
commit d20bf44c2a

@ -21,6 +21,20 @@ defineIfNotDefined('KAMPF_RUNDEN', 10);
$char_id = validateUnsignedInteger($_GET['char_id'], null); $char_id = validateUnsignedInteger($_GET['char_id'], null);
function getExcludeIds($userId, $excludeCharId) {
$ids = array();
$qry = db_query('SELECT kampf_item from chars WHERE besitzer = '.$userId.' AND id != '.$excludeCharId);
while ($row = mysqli_fetch_row($qry)) {
foreach (explode(',', $row[0]) as $id) {
if(is_numeric($id) && $id > 0) {
$ids[] = $id;
}
}
}
return $ids;
}
function stelledar($char_id,$user_ida,$name) { function stelledar($char_id,$user_ida,$name) {
//Alle Chardaten laden //Alle Chardaten laden
//TODO: chardaten gefällt mir absolut nicht! Das muss man anders regeln =/ //TODO: chardaten gefällt mir absolut nicht! Das muss man anders regeln =/
@ -57,6 +71,7 @@ function stelledar($char_id,$user_ida,$name) {
$e_schild = db_query("SELECT i.name, w.id, i.level FROM ware w LEFT JOIN item i ON(i.id=w.item_id) WHERE (i.type='$char_1[type]' OR i.type='ALL') AND w.user='$user_ida[id]' AND w.ru_mal='1' AND i.s_type='Schild' AND i.level <='$char_1[level]' group by i.name order by i.level desc"); $e_schild = db_query("SELECT i.name, w.id, i.level FROM ware w LEFT JOIN item i ON(i.id=w.item_id) WHERE (i.type='$char_1[type]' OR i.type='ALL') AND w.user='$user_ida[id]' AND w.ru_mal='1' AND i.s_type='Schild' AND i.level <='$char_1[level]' group by i.name order by i.level desc");
$e_helm = db_query("SELECT i.name, w.id, i.level FROM ware w LEFT JOIN item i ON(i.id=w.item_id) WHERE (i.type='$char_1[type]' OR i.type='ALL') AND w.user='$user_ida[id]' AND w.ru_mal='1' AND i.s_type='Helm' AND i.level <='$char_1[level]' group by i.name order by i.level desc"); $e_helm = db_query("SELECT i.name, w.id, i.level FROM ware w LEFT JOIN item i ON(i.id=w.item_id) WHERE (i.type='$char_1[type]' OR i.type='ALL') AND w.user='$user_ida[id]' AND w.ru_mal='1' AND i.s_type='Helm' AND i.level <='$char_1[level]' group by i.name order by i.level desc");
$checked = explode(',',$char_1['kampf_item']); $checked = explode(',',$char_1['kampf_item']);
$excludeIds = getExcludeIds($user_ida['id'], $char_id);
?> ?>
<body> <body>
<form action="index.php?as=char_profil&char_id=<?php echo $char_id; ?>" <form action="index.php?as=char_profil&char_id=<?php echo $char_id; ?>"
@ -252,6 +267,9 @@ function stelledar($char_id,$user_ida,$name) {
<option value="0">Nix</option> <option value="0">Nix</option>
<?php <?php
while($helm_e_w = mysqli_fetch_array($e_helm)) { while($helm_e_w = mysqli_fetch_array($e_helm)) {
if(array_search($helm_e_w['id'], $excludeIds) !== FALSE) {
continue;
}
if($checked[0] == $helm_e_w['id'] && !$checked_helm) { $checked_helm = 'selected'; } if($checked[0] == $helm_e_w['id'] && !$checked_helm) { $checked_helm = 'selected'; }
else { $checked_helm=''; } else { $checked_helm=''; }
echo '<option value="'.$helm_e_w['id'].'" '.$checked_helm.'>'.$helm_e_w['name'].' (Level: '.$helm_e_w['level'].')</option>'; echo '<option value="'.$helm_e_w['id'].'" '.$checked_helm.'>'.$helm_e_w['name'].' (Level: '.$helm_e_w['level'].')</option>';
@ -267,6 +285,9 @@ function stelledar($char_id,$user_ida,$name) {
<option value="0">Nix</option> <option value="0">Nix</option>
<?php <?php
while($rustung_e_w = mysqli_fetch_array($e_rustung)) { while($rustung_e_w = mysqli_fetch_array($e_rustung)) {
if(array_search($rustung_e_w['id'], $excludeIds) !== FALSE) {
continue;
}
if($checked[1] == $rustung_e_w['id'] && !$checked_rustung) { $checked_rustung = 'selected'; } if($checked[1] == $rustung_e_w['id'] && !$checked_rustung) { $checked_rustung = 'selected'; }
else { $checked_rustung=''; } else { $checked_rustung=''; }
echo '<option value="'.$rustung_e_w['id'].'" '.$checked_rustung.'>'.$rustung_e_w['name'].' (Level: '.$rustung_e_w['level'].')</option>'; echo '<option value="'.$rustung_e_w['id'].'" '.$checked_rustung.'>'.$rustung_e_w['name'].' (Level: '.$rustung_e_w['level'].')</option>';
@ -282,6 +303,9 @@ function stelledar($char_id,$user_ida,$name) {
<option value="0">Nix</option> <option value="0">Nix</option>
<?php <?php
while($schild_e_w = mysqli_fetch_array($e_schild)) { while($schild_e_w = mysqli_fetch_array($e_schild)) {
if(array_search($schild_e_w['id'], $excludeIds) !== FALSE) {
continue;
}
if($checked[2] == $schild_e_w['id'] && !$checked_schild) { $checked_schild = 'selected'; } if($checked[2] == $schild_e_w['id'] && !$checked_schild) { $checked_schild = 'selected'; }
else { $checked_schild=''; } else { $checked_schild=''; }
echo '<option value="'.$schild_e_w['id'].'" '.$checked_schild.'>'.$schild_e_w['name'].' (Level: '.$schild_e_w['level'].')</option>'; echo '<option value="'.$schild_e_w['id'].'" '.$checked_schild.'>'.$schild_e_w['name'].' (Level: '.$schild_e_w['level'].')</option>';
@ -297,6 +321,9 @@ function stelledar($char_id,$user_ida,$name) {
<option value="0">Nix</option> <option value="0">Nix</option>
<?php <?php
while($schwert_e_w = mysqli_fetch_array($e_schwert)) { while($schwert_e_w = mysqli_fetch_array($e_schwert)) {
if(array_search($schwert_e_w['id'], $excludeIds) !== FALSE) {
continue;
}
if($checked[3] == $schwert_e_w['id'] && !$checked_schwert) { $checked_schwert = 'selected'; } if($checked[3] == $schwert_e_w['id'] && !$checked_schwert) { $checked_schwert = 'selected'; }
else { $checked_schwert=''; } else { $checked_schwert=''; }
echo '<option value="'.$schwert_e_w['id'].'" '.$checked_schwert.'>'.$schwert_e_w['name'].' (Level: '.$schwert_e_w['level'].')</option>'; echo '<option value="'.$schwert_e_w['id'].'" '.$checked_schwert.'>'.$schwert_e_w['name'].' (Level: '.$schwert_e_w['level'].')</option>';
@ -312,6 +339,9 @@ function stelledar($char_id,$user_ida,$name) {
<option value="0">Nix</option> <option value="0">Nix</option>
<?php <?php
while($schuhe_e_w = mysqli_fetch_array($e_schuhe)) { while($schuhe_e_w = mysqli_fetch_array($e_schuhe)) {
if(array_search($schuhe_e_w['id'], $excludeIds) !== FALSE) {
continue;
}
if($checked[4] == $schuhe_e_w['id'] && !$checked_schuhe) { $checked_schuhe = 'selected'; } if($checked[4] == $schuhe_e_w['id'] && !$checked_schuhe) { $checked_schuhe = 'selected'; }
else { $checked_schuhe=''; } else { $checked_schuhe=''; }
echo '<option value="'.$schuhe_e_w['id'].'" '.$checked_schuhe.'>'.$schuhe_e_w['name'].' (Level: '.$schuhe_e_w['level'].')</option>'; echo '<option value="'.$schuhe_e_w['id'].'" '.$checked_schuhe.'>'.$schuhe_e_w['name'].' (Level: '.$schuhe_e_w['level'].')</option>';

@ -65,13 +65,18 @@ function wuenscheTeufelsfrucht($user){
return true; return true;
} }
function wuenscheSpecialChar($user, $specialcharname, $newname = ''){ function wuenscheSpecialChar($user, $specialcharid, $newname = ''){
if($specialcharname == 'Kaioshin'){ $specialRaceIds = getSpecialRaceIds();
$spitem = 3; $race = NULL;
} else if($specialcharname == 'Shichibukai'){ foreach ($specialRaceIds as $specialRace) {
$spitem = 15; if ($specialRace['item'] !== NULL && $specialRace['id'] == $specialcharid) {
} else{ $race = $specialRace;
displayErrorMessage(NULL,'Es koennen nur Kaioshin und Shichibukai gewünscht werden!!',displayHistoryBackLink()); break;
}
}
if ($race == NULL) {
displayErrorMessage(NULL,'Diese Rasse kann nicht gew&uuml;nscht werden!!',displayHistoryBackLink());
return false; return false;
} }
@ -81,7 +86,7 @@ function wuenscheSpecialChar($user, $specialcharname, $newname = ''){
} }
// Hat der User überhaupt das Item ??? // Hat der User überhaupt das Item ???
$qry = db_query('SELECT count(*) AS anzahl FROM sp_ware WHERE item='.$spitem.' AND user='.$user['id']); $qry = db_query('SELECT count(*) AS anzahl FROM sp_ware WHERE item='.$race['item'].' AND user='.$user['id']);
$row = mysqli_fetch_assoc($qry); $row = mysqli_fetch_assoc($qry);
if($row['anzahl'] < 1){ if($row['anzahl'] < 1){
// Er hat das Item garnicht!! // Er hat das Item garnicht!!
@ -89,7 +94,7 @@ function wuenscheSpecialChar($user, $specialcharname, $newname = ''){
return false; return false;
} }
$rasse = getRaceByName($specialcharname); $rasse = $race;
$chars = getCharsOfUser($user['id']); $chars = getCharsOfUser($user['id']);
foreach($chars as $char) { foreach($chars as $char) {
@ -105,7 +110,7 @@ function wuenscheSpecialChar($user, $specialcharname, $newname = ''){
} }
// Slotüberprüfung beendet! // Slotüberprüfung beendet!
db_query('DELETE FROM sp_ware WHERE item='.$spitem.' AND user='.$user['id'].' LIMIT 1'); db_query('DELETE FROM sp_ware WHERE item='.$race['item'].' AND user='.$user['id'].' LIMIT 1');
return true; return true;
} }
@ -145,14 +150,12 @@ function worker($charm,$wunsch,$user,$newname){
$result = wuenscheGeld($user); $result = wuenscheGeld($user);
} else if($wunsch == 2) { } else if($wunsch == 2) {
$result = wuenschePotaras($user); $result = wuenschePotaras($user);
} else if($wunsch == 3) {
$result = wuenscheSpecialChar($user,'Kaioshin',$newname);
} else if($wunsch == 4) {
$result = wuenscheSpecialChar($user,'Shichibukai',$newname);
} else if($wunsch == 5) { } else if($wunsch == 5) {
$result = wuenscheTeufelsfrucht($user); $result = wuenscheTeufelsfrucht($user);
} else if($wunsch == 6) { } else if($wunsch == 6) {
$result = wuenscheUserRename($user,$newname); $result = wuenscheUserRename($user,$newname);
} else if($wunsch > 10) {
$result = wuenscheSpecialChar($user,$wunsch - 10,$newname);
} }
} }
if($result){ if($result){
@ -186,22 +189,34 @@ $items = db_query('SELECT distinct(i1.id) FROM sp_ware i INNER JOIN sp_item i1 O
</tr> </tr>
<tr> <tr>
<td align="center"> <td align="center">
<?php
$specialRaceIds = getSpecialRaceIds();
$races = array();
foreach ($specialRaceIds as $race) {
if ($race['item'] !== NULL) {
$races[] = $race;
}
}
?>
<select id="input" name="wunsch"> <select id="input" name="wunsch">
<option value="1">10.000.000 &#165;</option> <option value="1">10.000.000 &#165;</option>
<option value="2">2x Potara Ohrringe</option> <option value="2">2x Potara Ohrringe</option>
<option value="6">Nutzernamen &auml;ndern</option> <option value="6">Nutzernamen &auml;ndern</option>
<?php <?php
while($row = mysqli_fetch_assoc($items)) { while($row = mysqli_fetch_assoc($items)) {
if($row['id'] == 3) { ?> foreach ($races as $race) {
<option value="3">Kaioshin befreien</option> if ($row['id'] == $race['item']) {
<?php echo '<option value="'.($race['id']+10).'">'.$race['name'].' befreien</option>'."\n";
} else if($row['id'] == 15) { ?> }
<option value="4">Shichibukai befreien</option> }
<?php
} else if($row['id'] == 33) { ?> if($row['id'] == 33) {
?>
<option value="5">Naturfrucht</option> <option value="5">Naturfrucht</option>
<?php <?php
} }
} }
?> ?>

@ -7,8 +7,10 @@
* *
*/ */
session_start(); session_start();
?>
<?php // error_reporting(E_ALL);
// ini_set('display_errors', 1);
/****************************************************************************** /******************************************************************************
* Dieser Skript ist ein Kontrollpanel fuer GM's * Dieser Skript ist ein Kontrollpanel fuer GM's
******************************************************************************* *******************************************************************************
@ -28,27 +30,22 @@ include_once(ROOT_PATH.'/include/rassen.inc.php');
include_once(ROOT_PATH.'/include/user.inc.php'); include_once(ROOT_PATH.'/include/user.inc.php');
include_once(ROOT_PATH.'/include/usergroup.inc.php'); include_once(ROOT_PATH.'/include/usergroup.inc.php');
include_once(ROOT_PATH.'/gm/include/arena.inc.php');
include_once(ROOT_PATH.'/gm/include/attacken.inc.php');
include_once(ROOT_PATH.'/gm/include/bilderschau.inc.php');
include_once(ROOT_PATH.'/gm/include/clan.inc.php');
include_once(ROOT_PATH.'/gm/include/geheim.inc.php');
include_once(ROOT_PATH.'/gm/include/info.inc.php');
include_once(ROOT_PATH.'/gm/include/item.inc.php');
include_once(ROOT_PATH.'/gm/include/rezept.inc.php');
include_once(ROOT_PATH.'/gm/include/monster.inc.php');
include_once(ROOT_PATH.'/gm/include/npc.inc.php');
include_once(ROOT_PATH.'/gm/include/shop.inc.php');
include_once(ROOT_PATH.'/gm/include/user.inc.php');
include_once(ROOT_PATH.'/gm/include/rassen.inc.php');
include_once(ROOT_PATH.'/gm/include/tournament.inc.php');
function logaction($message){ function logaction($message){
$sql = 'Insert into gm_actions(userid, time, message, ip) values('.$_SESSION['user'].', now(), \''.$message.'\', \''.$_SERVER['REMOTE_ADDR'].'\')'; $sql = 'Insert into gm_actions(userid, time, message, ip) values('.$_SESSION['user'].', now(), \''.$message.'\', \''.$_SERVER['REMOTE_ADDR'].'\')';
// echo $sql.'<br>';
db_query($sql); db_query($sql);
} }
// Include all sub-pages
if ($handle = opendir(ROOT_PATH.'/gm/include')) {
while (false !== ($entry = readdir($handle))) {
if ($entry[0] != '.') {
include_once(ROOT_PATH.'/gm/include/'.$entry);
}
}
closedir($handle);
}
function showActionLog(){ function showActionLog(){
$qry = db_query('Select g.time, u.nickname, g.ip, g.message from gm_actions as g inner join user as u on g.userid = u.id order by time desc LIMIT 100'); $qry = db_query('Select g.time, u.nickname, g.ip, g.message from gm_actions as g inner join user as u on g.userid = u.id order by time desc LIMIT 100');
@ -137,8 +134,12 @@ function displayOptions(){
"news" => "News bearbeiten", "news" => "News bearbeiten",
"cheat" => "Multiuser und Cheater", "cheat" => "Multiuser und Cheater",
"log" => "Log ansehen", "log" => "Log ansehen",
"logout" => "Log out" "tutorial" => "Tutorial bearbeiten",
"defines" => "Konstanten anpassen",
"present" => "Geschenke verteilen"
); );
asort($entries, SORT_STRING);
$entries["logout"] = "Log out";
echo '<table>'."\n"; echo '<table>'."\n";
foreach($entries as $key => $value) { foreach($entries as $key => $value) {
@ -212,6 +213,12 @@ if(checkLoginData($_SESSION['user'],$_SESSION['password'])){
displayGeheim($_REQUEST); displayGeheim($_REQUEST);
} else if($_REQUEST['choose'] == 'arena') { } else if($_REQUEST['choose'] == 'arena') {
displayArena($_REQUEST); displayArena($_REQUEST);
} else if($_REQUEST['choose'] == 'tutorial') {
displayTutorial($_REQUEST);
} else if($_REQUEST['choose'] == 'present') {
displayPresent($_REQUEST);
} else if($_REQUEST['choose'] == 'defines') {
displayDefines($_REQUEST);
} else if($_REQUEST['choose'] == 'tournament'){ } else if($_REQUEST['choose'] == 'tournament'){
//_POST['name'] anstatt _REQUEST weil schon durch username überschrieben wird //_POST['name'] anstatt _REQUEST weil schon durch username überschrieben wird
displayTournamentMenu($_REQUEST['action'], $_REQUEST['klein'], $_REQUEST['wochen'], $_REQUEST['wochenst'], $_REQUEST['minlevel'], $_REQUEST['maxlevel'], $_REQUEST['fusion'], $_REQUEST['special'], $_REQUEST['gain'], $_REQUEST['randomize'], $_POST['name'], $_REQUEST['anzahl']); displayTournamentMenu($_REQUEST['action'], $_REQUEST['klein'], $_REQUEST['wochen'], $_REQUEST['wochenst'], $_REQUEST['minlevel'], $_REQUEST['maxlevel'], $_REQUEST['fusion'], $_REQUEST['special'], $_REQUEST['gain'], $_REQUEST['randomize'], $_POST['name'], $_REQUEST['anzahl']);

@ -0,0 +1,45 @@
<?php
/*
* Created on 28.08.2017
*
* @copyright (c) 2011 animegame.eu
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public Licence
*
*/
// 1 => Text (will be rendered on display)
function displayDefines($request) {
$defines = getDefines();
if (isset($request['persist'])) {
foreach ($defines as $define) {
if ($request[$define['key']] != $define['value']) {
setDefine($define['key'], $request[$define['key']]);
}
}
$defines = getDefines();
}
?>
<form method="POST" action="">
<input name="persist" value="true" type="hidden" />
<table>
<?php
foreach ($defines as $define) {
?>
<tr>
<th align="left"><?php echo $define['key']; ?></th>
<td><input name="<?php echo $define['key']; ?>" value="<?php echo $define['value']; ?>" /></td>
</tr>
<?php
}
?>
</tr><td colspan="2"><input type="submit" value="&auml;ndern" /></td></tr>
<tr>
<td colspan="3"><a href="<?php echo $_SERVER['PHP_SELF']; ?>">Zum Hauptmenu</a>
</td>
</tr>
</table>
</form>
<?php
}

@ -0,0 +1,74 @@
<?php
/*
* Created on 28.08.2017
*
* @copyright (c) 2011 animegame.eu
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public Licence
*
*/
function displayPresent($request) {
$tables = getItemsMap();
if (isset($request['persist'])) {
$item = lookupItem($tables, $request['item']);
$user = mysqli_fetch_assoc(db_query('SELECT id, nickname FROM user where id = '.$request['user']));
if ($item && $user ) {
logaction('Hat das item '.$item['name'].' von Tabelle '.$item['table_name'].' an User '.$user['nickname'].' verschenkt');
if (createItemForUser($item, $user['id'])) {
echo '<p>Das item '.$item['name'].' von Tabelle '.$item['table_name'].' an User '.$user['nickname'].' erfolgreich verschenkt!</p>';
} else {
echo '<p>FEHLER!! Das item '.$item['name'].' von Tabelle '.$item['table_name'].' an User '.$user['nickname'].' wurde nicht verschenkt!</p>';
}
}
}
?>
<form method="POST" action="">
<input name="persist" value="true" type="hidden" />
<table>
<tr>
<th colspan="2">Verschenken von Items</th>
</tr>
<tr>
<th>Item</th>
<td>
<select name="item">
<?php
foreach ($tables as $table) {
foreach ($table as $item) {
echo '<option value="'.item2Value($item).'">'.item2Name($item).'</option>'."\n";
}
}
?>
</select>
</td>
</tr>
<tr>
<th>User</th>
<td>
<select name="user">
<?php
$qry = db_query('SELECT id, nickname FROM `user` ORDER BY nickname');
while ($row = mysqli_fetch_assoc($qry)) {
echo '<option value="'.$row['id'].'">'.$row['nickname'].'</option>'."\n";
}
?>
</select>
</td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="verschenken" /></td>
</tr>
<tr>
<td colspan="2">Bedenke, dass das Verschenken aufgezeichnet wird, also nicht cheaten!!</td>
</tr>
<tr>
<td colspan="2"><a href="<?php echo $_SERVER['PHP_SELF']; ?>">Zum Hauptmenu</a>
</td>
</tr>
</form>
<?php
}

@ -142,7 +142,8 @@ function getDefaultData() {
'lck' => 100, 'lck' => 100,
'stm' => 100, 'stm' => 100,
'tp' => 500, 'tp' => 500,
'special' => true 'special' => true,
'item' => 15
), ),
array( array(
'name' => 'Kaioshin', 'name' => 'Kaioshin',
@ -156,7 +157,8 @@ function getDefaultData() {
'lck' => 100, 'lck' => 100,
'stm' => 100, 'stm' => 100,
'tp' => 500, 'tp' => 500,
'special' => true 'special' => true,
'item' => 3
), ),
// Continue 'One Piece' // Continue 'One Piece'
array( array(
@ -216,22 +218,75 @@ function getDefaultData() {
return $array; return $array;
} }
function createLink($name, $values, $confirmation = NULL) {
if ( $confirmation !== NULL ) {
$link = '<a href="javascript:if(prompt(\'Best&auml;tige mit der Eingabe von \\\''.$confirmation.'\\\'\')==\''.$confirmation.'\') window.location.href=\'?choose=rassen';
} else {
$link = '<a href="?choose=rassen';
}
foreach ($values as $key => $value) {
$link .= '&'.$key.'='.$value;
}
if ( $confirmation !== NULL ) {
$link .= '\'">'.$name.'</a>';
} else {
$link .= '">'.$name.'</a>';
}
return $link;
}
function displayRassen($request) { function displayRassen($request) {
if($request['setup'] == 1) { $showOverview = true;
$array = getDefaultData(); if($request['action'] == 'setup') {
foreach($array['race_type'] as $race_type) { $showOverview = displayRassenSetup( $request );
db_query('INSERT INTO rassen_type(id, name, gm_only) values('.$race_type['id'].', \''.$race_type['name'].'\', '.($race_type['gm_only']?'1':'0').')'); } else if ($request['action'] == 'edit') {
} $showOverview = displayRassenEdit( $request );
foreach($array['race'] as $r) { } else if ($request['action'] == 'delete') {
db_query('INSERT INTO rassen(name, type, id, hp, mp, str, def, spd, lck, stm, special) '. $showOverview = displayRassenDelete( $request );
'values(\''.$r['name'].'\', '.$r['type'].','.$r['id'].', '.$r['hp'].','.$r['mp'].','.$r['str'].','.$r['def'].','.$r['spd'].','.$r['lck'].','.$r['stm'].','.($r['special']?'1':'0').')'); } else if ($request['action'] == 'edit_type') {
} $showOverview = displayRassenTypeEdit( $request );
} } else if ($request['action'] == 'delete_type') {
?> $showOverview = displayRassenTypeDelete( $request );
} else if ($request['action'] == 'create') {
$showOverview = displayRassenCreate( $request );
} else if ($request['action'] == 'create_type') {
$showOverview = displayRassenTypeCreate( $request );
}
?>
<table> <table>
<?php
$num = mysqli_num_rows(db_query('SELECT * FROM rassen_type'));
if($num == 0) {
echo '<tr><th colspan="4">'.createLink('setup rassen database', array('action' => 'setup')).'</a></th></tr>';
} else if ( $showOverview ) {
$race_types = getRaceTypes();
?>
<tr>
<th colspan="4">
Rassen-Typ &Uuml;bersicht
</th>
</tr>
<tr>
<th align="center">Name</th>
<th align="center">GM-Only</th>
<th align="center" colspan="2">Aktion</th>
</tr>
<?php
foreach ($race_types as $type) {
$editLink = createLink('Edit', array('action' => 'edit_type', 'id' => $type['id']));
$deleteLink = createLink('Delete', array('action' => 'delete_type', 'id' => $type['id']), $type['name']);
echo '<tr><td>'.$type['name'].'</td><td>'.($type['gm_only']?'Ja':'Nein').'</td><td>'.$editLink.'</td><td>'.$deleteLink.'</td></tr>'."\n";
}
?>
<tr><td colspan="4" align="center"><?php echo createLink('Neuer Rassentyp', array('action' => 'create_type')); ?></td></tr>
<tr><th colspan="4"><hr/></th></tr>
<tr> <tr>
<th colspan="4"> <th colspan="4">
Rassen Übersicht Rassen &Uuml;bersicht
</th> </th>
</tr> </tr>
<tr> <tr>
@ -240,17 +295,26 @@ function displayRassen($request) {
<th align="center" colspan="2">Aktion</th> <th align="center" colspan="2">Aktion</th>
</tr> </tr>
<?php <?php
$num = mysqli_num_rows(db_query('SELECT * FROM rassen_type')); foreach ($race_types as $type) {
if($num == 0) {
echo '<tr><th colspan="4"><a href="?choose=rassen&setup=1">setup rassen database</a></th></tr>';
} else {
$race_types = getRaceTypes();
foreach($race_types as $type) {
$races = getRacesByType($type); $races = getRacesByType($type);
foreach($races as $race) { foreach ($races as $race) {
echo '<tr><td>'.$race['name'].'</td><td>'.$type['name'].'</td><td>Edit</td><td>Delete</td>'."\n"; $editLink = createLink('Edit', array('action' => 'edit', 'id' => $race['id']));
$deleteLink = createLink('Delete', array('action' => 'delete', 'id' => $race['id']), $race['name']);
echo '<tr><td>'.$race['name'].'</td><td>'.$type['name'].'</td><td>'.$editLink.'</td><td>'.$deleteLink.'</td></tr>'."\n";
} }
} }
?>
<tr><td colspan="4" align="center"><?php echo createLink('Neue Rasse', array('action' => 'create')); ?></td></tr>
<tr><th colspan="4"><hr/></th></tr>
<?php
} else {
?>
<tr>
<td>
<?php echo createLink('Zur &Uuml;bersicht', array())."\n"; ?>
</td>
</tr>
<?php
} }
?> ?>
<tr> <tr>
@ -261,3 +325,183 @@ function displayRassen($request) {
</table> </table>
<?php <?php
} }
function displayRassenSetup( $request ) {
$array = getDefaultData();
foreach($array['race_type'] as $race_type) {
db_query('INSERT INTO rassen_type(id, name, gm_only) values('.$race_type['id'].', \''.$race_type['name'].'\', '.($race_type['gm_only']?'1':'0').')');
}
foreach($array['race'] as $r) {
db_query('INSERT INTO rassen(name, type, id, hp, mp, str, def, spd, lck, stm, special) '.
'values(\''.$r['name'].'\', '.$r['type'].','.$r['id'].', '.$r['hp'].','.$r['mp'].','.$r['str'].','.$r['def'].','.$r['spd'].','.$r['lck'].','.$r['stm'].','.($r['special']?'1':'0').')');
}
return true;
}
function createRassenForm( $data = NULL ) {
$action = ($data === NULL) ? 'create' : 'edit';
$items = array();
$qry = db_query('SELECT id, name FROM sp_item ORDER BY name');
while ($row = mysqli_fetch_assoc($qry)) {
$items[] = array('name' => $row['name'], 'id' => $row['id']);
}
?>
<form action="" method="POST">
<input name="persist" value="true" type="hidden" />
<?php
if ($data !== NULL) {
?>
<input name="id" value="<?php echo $data['id']; ?>" type="hidden" />
<?php
}
?>
<table>
<tr><th colspan="2">Rasse</th></tr>
<tr><th>Name</th><td><input name="name" value="<?php echo $data['name']; ?>" /></td></tr>
<tr><th>Typ</th><td>
<select name="type">
<?php
$race_types = getRaceTypes();
foreach ($race_types as $race_type) {
$selected = ($race_type['id'] == $data['type']);
?>
<option value="<?php echo $race_type['id']; ?>" <?php echo $selected?'selected':''; ?>><?php echo $race_type['name']; ?></option>
<?php
}
?>
</select>
<tr><th>HP</th><td><input name="hp" value="<?php echo $data['hp']; ?>" /></td></tr>
<tr><th>MP</th><td><input name="mp" value="<?php echo $data['mp']; ?>" /></td></tr>
<tr><th>St&auml;rke</th><td><input name="str" value="<?php echo $data['str']; ?>" /></td></tr>
<tr><th>Verteidigung</th><td><input name="def" value="<?php echo $data['def']; ?>" /></td></tr>
<tr><th>Geschwindigkeit</th><td><input name="spd" value="<?php echo $data['spd']; ?>" /></td></tr>
<tr><th>Gl&uuml;ck</th><td><input name="lck" value="<?php echo $data['lck']; ?>" /></td></tr>
<tr><th>Ausdauer</th><td><input name="stm" value="<?php echo $data['stm']; ?>" /></td></tr>
<tr><th>Special</th><td><input name="special" <?php echo $data['special']?'checked':''; ?> type="checkbox" /></td></tr>
<tr>
<th>Item (nur Special)</th>
<td>
<select name="item">
<option value="">- Keins -</option>
<?php
foreach ($items as $item) {
$selected = $item['id'] == $data['item'] ? 'selected':'';
echo '<option value="'.$item['id'].'" '.$selected.'>'.$item['name'].'</option>'."\n";
}
?>
</select>
</td>
</tr>
<tr><td colspan="2" align="center"><input type="submit" value="<?php echo $action; ?>" /></td></tr>
</table>
</form>
<?php
}
function displayRassenCreate( $request ) {
if ( $request['persist'] ) {
$special = ($request['special']=='on') ? 'true' : 'false';
$item = ($request['item'] != NULL) ? $request['item'] : 'NULL';
$id = mysqli_fetch_row(db_query('SELECT max(id) + 1 FROM rassen'));
$id = $id[0];
$data = array('"'.$request['name'].'"', $request['type'], $request['hp'], $request['mp'], $request['str'], $request['def'], $request['spd'], $request['lck'], $request['stm'], $special, $item);
db_query('INSERT INTO rassen(id, name, type, hp, mp, str, def, spd, lck, stm, special, item) values('.$id.', '.join(',', $data).')');
return true;
} else {
createRassenForm();
return false;
}
}
function displayRassenEdit( $request ) {
if ( $request['persist'] ) {
$special = ($request['special']=='on') ? 'true' : 'false';
$item = ($request['item'] != NULL) ? $request['item'] : 'NULL';
$data = array(
'name' => '"'.$request['name'].'"',
'type' => $request['type'],
'hp' => $request['hp'],
'mp' => $request['mp'],
'str' => $request['str'],
'def' => $request['def'],
'spd' => $request['spd'],
'lck' => $request['lck'],
'stm' => $request['stm'],
'special' => $special,
'item' => $item
);
$data_entries = array();
foreach ($data as $key => $value) {
$data_entries[] = $key.'='.$value;
}
db_query('UPDATE rassen SET '.join(', ', $data_entries).' WHERE id = '.$request['id']);
return true;
} else {
createRassenForm(getRaceById($request['id']));
return false;
}
}
function displayRassenDelete( $request ) {
db_query('DELETE FROM rassen WHERE id = '.$request['id']);
return true;
}
function createRassenTypeForm( $data = NULL ) {
$action = ($data === NULL) ? 'create' : 'edit';
?>
<form action="" method="POST">
<input name="persist" value="true" type="hidden" />
<?php
if ($data !== NULL) {
?>
<input name="id" value="<?php echo $data['id']; ?>" type="hidden" />
<?php
}
?>
<table>
<tr><th colspan="2">Rassen-typ</th></tr>
<tr><th>Name</th><td><input name="name" value="<?php echo $data['name']; ?>" /></td></tr>
<tr><th>GM-Only</th><td><input name="gm_only" type="checkbox" <?php echo $data['gm_only']?'checked':''; ?> /></td></tr>
<tr><td colspan="2" align="center"><input type="submit" value="<?php echo $action; ?>" /></td></tr>
</table>
</form>
<?php
}
function displayRassenTypeCreate( $request ) {
if ( $request['persist'] ) {
$gm_only = ($request['gm_only']=='on') ? 'true' : 'false';
$id = mysqli_fetch_row(db_query('SELECT max(id) + 1 FROM rassen_type'));
$id = $id[0];
db_query('INSERT INTO rassen_type(id, name, gm_only) values('.$id.', "'.$request['name'].'", '.$gm_only.')');
return true;
} else {
createRassenTypeForm();
return false;
}
}
function displayRassenTypeEdit( $request ) {
if ( $request['persist'] ) {
$gm_only = ($request['gm_only']=='on') ? 'true' : 'false';
db_query('UPDATE rassen_type SET name = "'.$request['name'].'", gm_only = '.$gm_only.' WHERE id = '.$request['id']);
return true;
} else {
createRassenTypeForm(getRaceTypeById($request['id']));
return false;
}
}
function displayRassenTypeDelete( $request ) {
db_query('DELETE FROM rassen_type WHERE id = '.$request['id']);
return true;
}

@ -7,74 +7,11 @@
* *
*/ */
function getItemsMap() { include_once(ROOT_PATH.'/include/items.inc.php');
$items_map = array();
$qry = db_query('SELECT * from sp_item WHERE type != \'Teufels Frucht\'');
while( $row = mysqli_fetch_assoc($qry) ) {
$row['table_name'] = 'sp_item';
$items_map['sp_item'][$row['id']] = $row;
}
$qry = db_query('SELECT * from item');
while( $row = mysqli_fetch_assoc($qry)) {
$row['table_name'] = 'item';
$items_map['item'][$row['id']] = $row;
}
$qry = db_query('SELECT * from wochen_markt');
while( $row = mysqli_fetch_assoc($qry) ) {
$row['name'] = $row['item'];
$row['table_name'] = 'wochen_markt';
$items_map['wochen_markt'][$row['id']] = $row;
}
return $items_map;
}
function item2Name($item) {
return $item['name'].'('.$item['table_name'].')';
}
function item2Value($item) {
return $item['id'].'_'.$item['table_name'];
}
function get_set_definitions() {
$items_map = getItemsMap();
$qry = db_query('SELECT * from sp_sets');
$sets = array();
while( $row = mysqli_fetch_assoc($qry) ) {
$set = array();
$set['item'] = $items_map[$row['table_name']][$row['item_id']];
$dep_items = array();
$qry2 = db_query('SELECT * from sp_set_ingredient WHERE set_id = '.$row['set_id']);
while( $row2 = mysqli_fetch_assoc($qry2) ) {
$dep_items[] = $items_map[$row2['table_name']][$row2['item_id']];
}
$set['deps'] = $dep_items;
$set['id'] = $row['set_id'];
$sets[] = $set;
}
return $sets;
}
function getSetDefinition($set_id) {
$sets = get_set_definitions();
foreach ($sets as $set) {
if ($set['id'] == $set_id) {
return $set;
}
}
return NULL;
}
function lookupItem($items, $itemIdHash) {
$pair = explode('_', $itemIdHash, 2);
return $items[$pair[1]][$pair[0]];
}
function getSetDefinitionFromRequest($request) { function getSetDefinitionFromRequest($request) {
$items = getItemsMap(); $items = getItemsMap();
$craft_item = lookupItem($items, $request['crafted']); $craft_item = lookupItem($items, $request['crafted']);
$deps = array(); $deps = array();
for ($i=0; $i<5;$i++) { for ($i=0; $i<5;$i++) {
@ -85,6 +22,9 @@ function getSetDefinitionFromRequest($request) {
} }
$set['item'] = $craft_item; $set['item'] = $craft_item;
$set['deps'] = $deps; $set['deps'] = $deps;
if ( isset($request['topic']) ) {
$set['topic_id'] = $request['topic'] == 0 ? NULL : $request['topic'];
}
return $set; return $set;
} }
@ -100,6 +40,21 @@ function displayRezepte($request) {
case 'delete': case 'delete':
displayRezepteDeleteMenu($request); displayRezepteDeleteMenu($request);
break; break;
case 'create_topic':
displayRezepteTopicCreateMenu($request);
break;
case 'edit_topic':
displayRezepteTopicEditMenu($request);
break;
case 'delete_topic':
displayRezepteTopicDeleteMenu($request);
break;
case 'up_topic':
displayRezepteTopicUpMenu($request);
break;
case 'down_topic':
displayRezepteTopicDownMenu($request);
break;
default: default:
displayRezepteMainMenu($request); displayRezepteMainMenu($request);
break; break;
@ -112,20 +67,52 @@ function displayRezepteMainMenu($request) {
<tr> <tr>
<th colspan="3">Rezepte</th> <th colspan="3">Rezepte</th>
</tr> </tr>
<tr>
<th>Item</th><th width="50%">Zutaten</th><th>Action</th>
</tr>
<?php <?php
$sets = get_set_definitions(); $sets = get_set_definitions();
$prev_topic = '#INVALID_TOPIC#';
foreach ($sets as $set) { foreach ($sets as $set) {
$dep_item_names = array(); $dep_item_names = array();
foreach( $set['deps'] as $dep_item ) { foreach( $set['deps'] as $dep_item ) {
$dep_item_names[]=$dep_item['name']; $dep_item_names[]=$dep_item['name'];
} }
if ($set['topic'] != $prev_topic) {
$prev_topic = $set['topic'];
$print_topic = ($set['topic'] === NULL) ? '- Kein Topic -' : $set['topic'];
?>
<tr>
<th colspan="3"><hr></th>
</tr>
<tr>
<th colspan="3"><?php echo $print_topic; ?></th>
</tr>
<tr>
<th>Item</th><th width="50%">Zutaten</th><th>Action</th>
</tr>
<?php
}
echo '<tr><td>'.$set['item']['name'].'</td><td align="center">'.join(',',$dep_item_names).'</td><td align="center"><a href="?choose=rezept&action=edit&set='.$set['id'].'">Edit</a> | <a href="?choose=rezept&action=delete&set='.$set['id'].'">Delete</a></td></tr>'; echo '<tr><td>'.$set['item']['name'].'</td><td align="center">'.join(',',$dep_item_names).'</td><td align="center"><a href="?choose=rezept&action=edit&set='.$set['id'].'">Edit</a> | <a href="?choose=rezept&action=delete&set='.$set['id'].'">Delete</a></td></tr>';
} }
?> ?>
<tr><td colspan="3" align="center"><a href="?choose=rezept&action=create">Neues Rezept erstellen</a></td></tr> <tr><td colspan="3" align="center"><a href="?choose=rezept&action=create">Neues Rezept erstellen</a></td></tr>
<tr><th colspan="3"><hr /></th></tr>
<tr>
<th colspan="3">Rezept Topics</th>
</tr>
<?php
$set_topics = getItemTopicsMap();
foreach ($set_topics as $set_topic) {
$id = $set_topic['id'];
?>
<tr>
<td><?php echo $set_topic['name']; ?></td>
<td colspan="2" align="right"><a href="?choose=rezept&action=edit_topic&id=<?php echo $id; ?>">Edit</a> | <a href="?choose=rezept&action=up_topic&id=<?php echo $id; ?>">Up</a> | <a href="?choose=rezept&action=down_topic&id=<?php echo $id; ?>">Down</a> | <a href="?choose=rezept&action=delete_topic&id=<?php echo $id; ?>">Delete</a></td>
</tr>
<?php
}
?>
<tr><td colspan="3" align="center"><a href="?choose=rezept&action=create_topic">Neues Rezept Topic erstellen</a></td></tr>
<tr> <tr>
<td colspan="3"><a href="<?php echo $_SERVER['PHP_SELF']; ?>">Zum Hauptmenu</a> <td colspan="3"><a href="<?php echo $_SERVER['PHP_SELF']; ?>">Zum Hauptmenu</a>
</td> </td>
@ -135,10 +122,6 @@ function displayRezepteMainMenu($request) {
<?php <?php
} }
function itemEquals($lhs, $rhs) {
return $lhs['id'] == $rhs['id'] && $lhs['table_name'] == $rhs['table_name'];
}
function createRezeptEntry($set) { function createRezeptEntry($set) {
$qry = db_query('Select max(set_id) FROM sp_sets'); $qry = db_query('Select max(set_id) FROM sp_sets');
$new_id = mysqli_fetch_row($qry)[0]; $new_id = mysqli_fetch_row($qry)[0];
@ -153,9 +136,8 @@ function updateRezept($base, $edit) {
if ($base['id'] === NULL) { if ($base['id'] === NULL) {
$base['id'] = createRezeptEntry($edit); $base['id'] = createRezeptEntry($edit);
} else { } else {
if ( !itemEquals($base['item'], $edit['item']) ) { $topic_id = ($edit['topic_id'] == NULL) ? 'NULL' : $edit['topic_id'];
db_query('UPDATE sp_sets SET table_name=\''.$edit['item']['table_name'].'\', item_id='.$edit['item']['id'].' WHERE set_id='.$base['id']); db_query('UPDATE sp_sets SET table_name=\''.$edit['item']['table_name'].'\', item_id='.$edit['item']['id'].', set_topic_id='.$topic_id.' WHERE set_id='.$base['id']);
}
} }
if( $base['deps'] === NULL ) { if( $base['deps'] === NULL ) {
$base['deps'] = array(); $base['deps'] = array();
@ -239,6 +221,23 @@ function displayForm($request, $set) {
<tr> <tr>
<th colspan="2">Rezept <?php echo $set['id']; ?></th> <th colspan="2">Rezept <?php echo $set['id']; ?></th>
</tr> </tr>
<tr>
<td>Topic</td>
<td>
<select name="topic">
<option value="0">- Kein Topic -</option>
<?php
$topics = getItemTopicsMap();
foreach ($topics as $topic) {
$selected = ($set['topic'] == $topic['name'])?'selected':'';
?>
<option value="<?php echo $topic['id']; ?>" <?php echo $selected; ?>><?php echo $topic['name']; ?></option>
<?php
}
?>
</td>
</tr>
<tr> <tr>
<td>Item</td> <td>Item</td>
<td> <td>
@ -312,3 +311,104 @@ function displayRezepteDeleteMenu($request) {
displayRezepteMainMenu(array()); displayRezepteMainMenu(array());
} }
function displayRezepteTopicCreateMenu($request) {
if(isset($request['persist'])) {
$id = mysqli_fetch_row(db_query('SELECT max(id) +1 from sp_set_topics'))[0];
if ($id === NULL) {
$id = 1;
}
db_query('INSERT INTO sp_set_topics(id, name) values('.$id.', "'.$request['name'].'")');
displayRezepteMainMenu(array());
} else {
?>
<form action="" method="POST">
<input name="persist" value="true" type="hidden" />
<table>
<tr>
<th colspan="2">Neues Rezept Topic erstellen</th>
</tr>
<tr>
<th>Name:</th>
<td><input name="name" value="" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="create" /></td>
</tr>
<tr>
<td colspan="2"><a href="<?php echo $_SERVER['PHP_SELF']; ?>">Zum Hauptmenu</a>
</td>
</tr>
</table>
</form>
<?php
}
}
function displayRezepteTopicDeleteMenu($request) {
db_query('DELETE FROM sp_set_topics WHERE id = '. $request['id']);
displayRezepteMainMenu(array());
}
function displayRezepteTopicEditMenu($request) {
if(isset($request['persist'])) {
db_query('UPDATE sp_set_topics SET name = "'.$request['name'].'" WHERE id = '.$request['id']);
displayRezepteMainMenu(array());
} else {
$topic = getItemTopicsMap()[$request['id']];
?>
<form action="" method="POST">
<input name="persist" value="true" type="hidden" />
<input name="id" value="<?php echo $topic['id']; ?>" type="hidden" />
<table>
<tr>
<th colspan="2">Topic editieren</th>
</tr>
<tr>
<th>Name:</th>
<td><input name="name" value="<?php echo $topic['name']; ?>" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="edit" /></td>
</tr>
<tr>
<td colspan="2"><a href="<?php echo $_SERVER['PHP_SELF']; ?>">Zum Hauptmenu</a>
</td>
</tr>
</table>
</form>
<?php
}
}
function swapRezepteTopicOrder( $lhs_id, $rhs_id ) {
if ( $lhs_id !== NULL && $rhs_id !== NULL ) {
db_query('UPDATE sp_set_topics SET id = 0 WHERE id = '.$lhs_id );
db_query('UPDATE sp_set_topics SET id = '.$lhs_id.' WHERE id = '.$rhs_id );
db_query('UPDATE sp_set_topics SET id = '.$rhs_id.' WHERE id = 0' );
}
}
function displayRezepteTopicUpMenu($request) {
$topic_id = $request['id'];
$other = mysqli_fetch_row(db_query('SELECT max(id) from sp_set_topics WHERE id < '.$topic_id));
if ( $other ) {
swapRezepteTopicOrder($topic_id, $other[0]);
}
displayRezepteMainMenu(array());
}
function displayRezepteTopicDownMenu($request) {
$topic_id = $request['id'];
$other = mysqli_fetch_row(db_query('SELECT min(id) from sp_set_topics WHERE id > '.$topic_id));
if ( $other ) {
swapRezepteTopicOrder($topic_id, $other[0]);
}
displayRezepteMainMenu(array());
}

@ -0,0 +1,33 @@
<?php
/*
* Created on 28.08.2017
*
* @copyright (c) 2011 animegame.eu
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public Licence
*
*/
// 1 => Text (will be rendered on display)
function displayTutorial($request) {
if (isset($request['data'])) {
$content = encodeNoHTMLNoBB($request['data']);
db_query('UPDATE tutorial SET content = "'.$content.'" WHERE id = 1');
if (db_affected_rows() == 0) {
silent_query('INSERT INTO tutorial(id, content) value(1, "'.$content.'")');
}
}
$content = mysqli_fetch_row(db_query('SELECT content FROM tutorial WHERE id = 1'))[0];
?>
<form method="POST" action="">
<p><textarea name="data" style="width: 90%;height: 80%"><?php echo $content; ?></textarea></p>
<p><input type="submit" value="&auml;ndern" /></p>
<p><a href="<?php echo $_SERVER['PHP_SELF']; ?>">Zum Hauptmenu</a></p>
</form>
<?php
}

@ -53,13 +53,13 @@ function getDefines($prefix = NULL) {
$appendix = NULL; $appendix = NULL;
// readout the database (where editable true) // readout the database (where editable true)
if($prefix === NULL) { if($prefix === NULL) {
$appendix = '1'; $appendix = '';
} else { } else {
$appendix = 'key like \''.$prefix.'%\''; $appendix = 'AND key like \''.$prefix.'%\'';
} }
$sql = 'SELECT * FROM defines WHERE editable = 1 AND ' . $appendix; $sql = 'SELECT * FROM defines WHERE editable = 1 ' . $appendix;
$qry = silent_query(); $qry = db_query($sql);
if(!$qry) { if(!$qry) {
return 'Fehler in SQL-Anweisung'; return 'Fehler in SQL-Anweisung';

@ -11,6 +11,7 @@ include_once (ROOT_PATH . '/include/arena.inc.php');
include_once (ROOT_PATH . '/include/defines.inc.php'); include_once (ROOT_PATH . '/include/defines.inc.php');
defineIfNotDefined('CHAR_LEVEL_EXP_FACTOR', 1); defineIfNotDefined('CHAR_LEVEL_EXP_FACTOR', 1);
defineIfNotDefined('CHAR_MAX_LEVEL', 110);
function beautifyNumericValue($value, $step){ function beautifyNumericValue($value, $step){
// RUNDEN(POTENZ(10;ABRUNDEN(MAX(LOG(I3;10);2)))/4;0) // RUNDEN(POTENZ(10;ABRUNDEN(MAX(LOG(I3;10);2)))/4;0)
@ -151,7 +152,7 @@ function addExpToChar($char_id, $n_exp){
$lvls = 0; $lvls = 0;
$tp = 0; $tp = 0;
$lp = 0; $lp = 0;
while($char_exp[0] >= $char_exp[1]){ while($char['level'] < CHAR_MAX_LEVEL && $char_exp[0] >= $char_exp[1]){
// Level UP!! // Level UP!!
$lvls++; $lvls++;
$char['level']++; $char['level']++;
@ -162,6 +163,10 @@ function addExpToChar($char_id, $n_exp){
$lp += 10; $lp += 10;
} }
if ($char['level'] == CHAR_MAX_LEVEL) {
$char_exp[0] = 0;
}
if($lvls > 0){ // Ist Char um mindestens ein Level gestiegen? if($lvls > 0){ // Ist Char um mindestens ein Level gestiegen?
echo '<script language="JavaScript">alert(\''.$char['name'].' ist um '.$lvls.' Level gestiegen!\');</script>'; echo '<script language="JavaScript">alert(\''.$char['name'].' ist um '.$lvls.' Level gestiegen!\');</script>';
$sql = 'Update chars set exp = \''.$char_exp[0].','.$char_exp[1].'\', lernpunkte = lernpunkte +'.$lp.', training_points = training_points + '.$tp.', level = level + '.$lvls.' where id = '.$char_id; $sql = 'Update chars set exp = \''.$char_exp[0].','.$char_exp[1].'\', lernpunkte = lernpunkte +'.$lp.', training_points = training_points + '.$tp.', level = level + '.$lvls.' where id = '.$char_id;
@ -199,4 +204,4 @@ function addExpToArena($user_id, $n_exp){
} }
} }
?> ?>

@ -0,0 +1,112 @@
<?php
/*
* Created on 01.09.2016
*
* @copyright (c) 2016 animegame.eu
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public Licence
*
*/
function getItemTopicsMap() {
$qry = db_query('SELECT * from sp_set_topics ORDER BY id');
$topics_map = array();
while( $row = mysqli_fetch_assoc($qry) ) {
$topics_map[$row['id']] = $row;
}
return $topics_map;
}
function getItemsMap() {
$items_map = array();
$qry = db_query('SELECT * from sp_item WHERE type != \'Teufels Frucht\'');
while( $row = mysqli_fetch_assoc($qry) ) {
$row['table_name'] = 'sp_item';
$items_map['sp_item'][$row['id']] = $row;
}
$qry = db_query('SELECT * from item');
while( $row = mysqli_fetch_assoc($qry)) {
$row['table_name'] = 'item';
$items_map['item'][$row['id']] = $row;
}
$qry = db_query('SELECT * from wochen_markt');
while( $row = mysqli_fetch_assoc($qry) ) {
$row['name'] = $row['item'];
$row['table_name'] = 'wochen_markt';
$items_map['wochen_markt'][$row['id']] = $row;
}
return $items_map;
}
function item2Name($item) {
return $item['name'].'('.$item['table_name'].')';
}
function item2Value($item) {
return $item['id'].'_'.$item['table_name'];
}
function getSetDefinitions() {
$items_map = getItemsMap();
$topics_map = getItemTopicsMap();
$qry = db_query('SELECT * from sp_sets order by set_topic_id');
$sets = array();
while( $row = mysqli_fetch_assoc($qry) ) {
$set = array();
$set['item'] = $items_map[$row['table_name']][$row['item_id']];
$dep_items = array();
$qry2 = db_query('SELECT * from sp_set_ingredient WHERE set_id = '.$row['set_id']);
while( $row2 = mysqli_fetch_assoc($qry2) ) {
$dep_items[] = $items_map[$row2['table_name']][$row2['item_id']];
}
$set['deps'] = $dep_items;
$set['id'] = $row['set_id'];
$set['topic_id'] = $row['set_topic_id'];
if ( $set['topic_id'] !== NULL ) {
$set['topic'] = $topics_map[$set['topic_id']]['name'];
}
$sets[] = $set;
}
return $sets;
}
function get_set_definitions() {
return getSetDefinitions();
}
function getSetDefinition($set_id) {
$sets = get_set_definitions();
foreach ($sets as $set) {
if ($set['id'] == $set_id) {
return $set;
}
}
return NULL;
}
function lookupItem($items, $itemIdHash) {
$pair = explode('_', $itemIdHash, 2);
return $items[$pair[1]][$pair[0]];
}
function itemEquals($lhs, $rhs) {
return $lhs['id'] == $rhs['id'] && $lhs['table_name'] == $rhs['table_name'];
}
/**
* @return, true in case item creation was successful!
*/
function createItemForUser($item, $user_id, $amount = 1) {
$ware_table=array('item' => 'ware', 'sp_item' => 'sp_ware', 'wochen_markt' => 'wochen_ware');
if ( $ware_table[$item['table_name']] == 'ware' ) {
$ru = $item['s_type']=='Trank'?' ':'1';
db_query('INSERT ware(user,item_id,ru_mal) values('.$user_id.', '.$item['id'].', \''.$ru.'\')');
} else {
db_query('INSERT '.$ware_table[$item['table_name']].'(user, item) values('.$user_id.', '.$item['id'].')');
}
return db_affected_rows() > 0;
}

@ -190,9 +190,10 @@ function bbcode($messagetext) {
'#\[s](.*?)\[/s\]#', '#\[s](.*?)\[/s\]#',
'#\[sub](.*?)\[/sub\]#', '#\[sub](.*?)\[/sub\]#',
'#\[sup](.*?)\[/sup\]#', '#\[sup](.*?)\[/sup\]#',
'#\[color=\#?([0-9a-fA-F]{6})\](.*?)\[/color]#', '#\[color=\#?([0-9a-fA-F]{6})\](.*?)\[/color\]#',
'#\[color=([a-zA-Z]+?)\](.*?)\[/color]#', '#\[color=([a-zA-Z]+?)\](.*?)\[/color\]#',
'#\[text=(.*?)\](.*?)\[/text]#', '#\[text=(.*?)\](.*?)\[/text\]#',
'#\[h(\d)\](.*?)\[/h\d\]#',
'#\n#' '#\n#'
//'#\[img]([a-z]+?://){1}(.*?)\[/img]#', //'#\[img]([a-z]+?://){1}(.*?)\[/img]#',
//'#\[img](.*?)\[/img\]#' //'#\[img](.*?)\[/img\]#'
@ -212,6 +213,7 @@ function bbcode($messagetext) {
'<span style="color:#\1">\2</span>', '<span style="color:#\1">\2</span>',
'<span style="color:\1">\2</span>', '<span style="color:\1">\2</span>',
'<span title="\1">\2</span>', '<span title="\1">\2</span>',
'<h\1>\2</h\1>',
'<br>' '<br>'
//'<img src="\1\2">', //'<img src="\1\2">',
//'<img src="\1\2" />' //'<img src="\1\2" />'

@ -86,6 +86,9 @@ if (top != self)
<div style="position:absolute; top:90px; left:355px; z-index:2"> <div style="position:absolute; top:90px; left:355px; z-index:2">
<a href="https://www.animegame.eu/game/blog" target="_blank"><img border="0" src="design/bilder/buttons/blog.jpg" ></a> <a href="https://www.animegame.eu/game/blog" target="_blank"><img border="0" src="design/bilder/buttons/blog.jpg" ></a>
</div> </div>
<div style="position:absolute; top:90px; left:435px; z-index:2">
<a href="?as=tutorial"><img border="0" src="design/bilder/buttons/tutorial.jpg"></a>
</div>
</div> </div>
</div> </div>

@ -36,6 +36,7 @@ function create_set(id, name){
function get_set_definitions() { function get_set_definitions() {
$items_map = array(); $items_map = array();
$topics_map = array();
$qry = db_query('SELECT * from sp_item'); $qry = db_query('SELECT * from sp_item');
while( $row = mysqli_fetch_assoc($qry) ) { while( $row = mysqli_fetch_assoc($qry) ) {
@ -56,7 +57,13 @@ function get_set_definitions() {
$items_map['wochen_markt'][$row['id']] = $row; $items_map['wochen_markt'][$row['id']] = $row;
} }
$qry = db_query('SELECT * from sp_sets'); $qry = db_query('SELECT * from sp_set_topics ORDER BY id');
while( $row = mysqli_fetch_assoc($qry) ) {
$topics_map[$row['id']] = $row;
}
$qry = db_query('SELECT * from sp_sets ORDER BY set_topic_id');
$sets = array(); $sets = array();
while( $row = mysqli_fetch_assoc($qry) ) { while( $row = mysqli_fetch_assoc($qry) ) {
$set = array(); $set = array();
@ -68,6 +75,11 @@ function get_set_definitions() {
} }
$set['deps'] = $dep_items; $set['deps'] = $dep_items;
$set['id'] = $row['set_id']; $set['id'] = $row['set_id'];
$set['topic_id'] = $row['set_topic_id'];
if ( $set['topic_id'] !== NULL ) {
$set['topic'] = $topics_map[$set['topic_id']]['name'];
}
$sets[] = $set; $sets[] = $set;
} }
return $sets; return $sets;
@ -98,9 +110,10 @@ function displaySets($user_ida) {
?> ?>
<table> <table>
<tr><th colspan="3">Rezepte f&uuml;rs Crafting</th></tr> <tr><th colspan="3">Rezepte f&uuml;rs Crafting</th></tr>
<tr><th>Item</th><th>Zutaten</th><th>Aktion</th>
<?php <?php
$sets = get_set_definitions(); $sets = get_set_definitions();
$prev_topic = '#INVALID_TOPIC#';
$user_items = get_user_items($user_ida); $user_items = get_user_items($user_ida);
foreach( $sets as $set ) { foreach( $sets as $set ) {
$deps = array(); $deps = array();
@ -113,6 +126,21 @@ function displaySets($user_ida) {
$enable = false; $enable = false;
} }
} }
if ($set['topic'] != $prev_topic) {
$prev_topic = $set['topic'];
$print_topic = ($set['topic'] === NULL) ? '- Kein Topic -' : $set['topic'];
?>
<tr>
<th colspan="3"><hr></th>
</tr>
<tr>
<th colspan="3"><?php echo $print_topic; ?></th>
</tr>
<tr>
<th>Item</th><th width="50%">Zutaten</th><th>Aktion</th>
</tr>
<?php
}
?> ?>
<tr> <tr>
<td><?php echo $set['item']['name']; ?></td> <td><?php echo $set['item']['name']; ?></td>

@ -0,0 +1,19 @@
<?php
/*
*
* @copyright (c) 2010 animegame.eu
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public Licence
*
*/
include_once('path.inc.php'); // get the path ;)
include_once (ROOT_PATH . '/include/config.inc.php');
include_once (ROOT_PATH . '/include/parse.inc.php');
$content = mysqli_fetch_row(db_query('SELECT content FROM tutorial WHERE id = 1'))[0];
?>
<table border="0">
<tr><td width="500px"><?php echo encodeNoHTMLWithBB($content); ?></td></tr>
</table>
Loading…
Cancel
Save