changes on the attacks and majin, now everything is using json for declaring options of the attack

main
hecht 11 years ago
parent 4548f2ce5e
commit e1f5b52c2d

@ -224,7 +224,7 @@ if(checkLoginData($_SESSION['user'],$_SESSION['password'])){
} else if($_REQUEST['choose'] == 'logout'){
logout();
} else if($_REQUEST['choose'] == 'attacken'){
displayAttackenMenu($_REQUEST['action'], $_REQUEST['attackname'], $_REQUEST['attackid'], $_REQUEST['depth'], $_REQUEST['name'], $_REQUEST['starke'], $_REQUEST['verteidigung'], $_REQUEST['speed'], $_REQUEST['hp'], $_REQUEST['mp'], $_REQUEST['rassen'], $_REQUEST['level'], $_REQUEST['geld'], $_REQUEST['type'], $_REQUEST['info'], $_REQUEST['req_atk'], $_REQUEST['req_lvl'], $_REQUEST['Frucht'], $_REQUEST['runden'], $_REQUEST['maxlvl']);
displayAttackenMenu($_REQUEST['action'], $_REQUEST['attackname'], $_REQUEST['attackid'], $_REQUEST['depth'], $_REQUEST['name'], $_REQUEST['starke'], $_REQUEST['verteidigung'], $_REQUEST['speed'], $_REQUEST['hp'], $_REQUEST['mp'], $_REQUEST['rassen'], $_REQUEST['level'], $_REQUEST['geld'], $_REQUEST['options'], $_REQUEST['type'], $_REQUEST['info'], $_REQUEST['req_atk'], $_REQUEST['req_lvl'], $_REQUEST['Frucht'], $_REQUEST['runden'], $_REQUEST['maxlvl']);
} else if($_REQUEST['choose'] == 'bann'){
displayBannOptions($_REQUEST['action'], $_REQUEST['username'],$_REQUEST['opfer'],$_REQUEST['gamebann'],$_REQUEST['shoutbann'],$_REQUEST['forenbann'],$_REQUEST['anonid']);
} else if($_REQUEST['choose'] == 'items'){
@ -267,4 +267,4 @@ if(checkLoginData($_SESSION['user'],$_SESSION['password'])){
displayLogin();
}
?>
?>

@ -8,7 +8,7 @@
*/
?>
<?php
function displayAttackenMenu($action, $attackname, $attackid, $depth, $name, $starke, $verteidigung, $speed, $hp, $mp, $rassen, $level, $geld, $type, $info, $req_atk, $req_lvl, $Frucht, $runden, $maxlvl) {
function displayAttackenMenu($action, $attackname, $attackid, $depth, $name, $starke, $verteidigung, $speed, $hp, $mp, $rassen, $level, $geld, $options, $type, $info, $req_atk, $req_lvl, $Frucht, $runden, $maxlvl) {
if($action === NULL){
?>
<table>
@ -68,11 +68,11 @@ function displayAttackenMenu($action, $attackname, $attackid, $depth, $name, $st
} else if(($action == 'create' || $action == 'edit') && $depth === NULL){
createOrEditAttack($action, $attackid);
} else if($action == 'create' && $depth == 1){
createAttack($attackname, $Frucht, $starke, $verteidigung, $speed, $hp, $mp, $rassen, $level, $geld, $type, $info, $req_atk, $req_lvl, $runden, $maxlvl);
createAttack($attackname, $Frucht, $starke, $verteidigung, $speed, $hp, $mp, $rassen, $level, $geld, $options, $type, $info, $req_atk, $req_lvl, $runden, $maxlvl);
} else if($action == 'delete' && $depth >= 1){
deleteAttack($attackid, $depth);
} else if($action == 'edit' && $depth == 1){
editAttack($attackname, $attackid, $Frucht, $starke, $verteidigung, $speed, $hp, $mp, $rassen, $level, $geld, $type, $info, $req_atk, $req_lvl, $runden, $maxlvl);
editAttack($attackname, $attackid, $Frucht, $starke, $verteidigung, $speed, $hp, $mp, $rassen, $level, $geld, $options, $type, $info, $req_atk, $req_lvl, $runden, $maxlvl);
}
}
@ -229,6 +229,12 @@ function createOrEditAttack($action, $attackid) {
</select>
</td>
</tr>
<tr>
<td>Options:</td>
<td><input name='options'
value='<?php echo $row['options']===NULL?'{}':$row['options']; ?>'></input>
</td>
</tr>
<tr>
<td>Info:</td>
<td><input name='info'
@ -354,14 +360,25 @@ function createOrEditAttack($action, $attackid) {
<?php
}
function createAttack($attackname, $Frucht, $starke, $verteidigung, $speed, $hp, $mp, $rassen, $level, $geld, $type, $info, $req_atk, $req_lvl, $runden, $maxlvl) {
function createAttack($attackname, $Frucht, $starke, $verteidigung, $speed, $hp, $mp, $rassen, $level, $geld, $options, $type, $info, $req_atk, $req_lvl, $runden, $maxlvl) {
json_decode($options, true);
if(JSON_ERROR_NONE != json_last_error()) {
echo "<br>";
echo "Attacke konnte nicht erstellt werden, syntax f&ouml;r options ist nicht korrekt!";
echo displayHistoryBackLink();
return;
}
if($Frucht != 0){
$sql = 'INSERT into attacken set name = \''.$attackname.'\', starke = '.$starke.', verteidigung = '.$verteidigung.', speed = '.$speed.', hp = '.$hp.', mp = '.$mp.', rassen = \''.$rassen.'\', level = '.$level.', geld = '.$geld.', type = \''.$type.'\', info = \''.$info.'\', req_atk = \''.$req_atk.'\', req_lvl = \''.$req_lvl.'\', Frucht = '.$Frucht.', runden = '.$runden.', maxlvl = '.$maxlvl;
$sql = 'INSERT into attacken set name = \''.$attackname.'\', starke = '.$starke.', verteidigung = '.$verteidigung.', speed = '.$speed.', hp = '.$hp.', mp = '.$mp.', rassen = \''.$rassen.'\', level = '.$level.', geld = '.$geld.', type = \''.$type.'\', info = \''.$info.'\', req_atk = \''.$req_atk.'\', req_lvl = \''.$req_lvl.'\', Frucht = '.$Frucht.', runden = '.$runden.', maxlvl = '.$maxlvl.', options = \''.addslashes($options).'\'';
} else {
$sql = 'INSERT into attacken set name = \''.$attackname.'\', starke = '.$starke.', verteidigung = '.$verteidigung.', speed = '.$speed.', hp = '.$hp.', mp = '.$mp.', rassen = \''.$rassen.'\', level = '.$level.', geld = '.$geld.', type = \''.$type.'\', info = \''.$info.'\', req_atk = \''.$req_atk.'\', req_lvl = \''.$req_lvl.'\', runden = '.$runden.', maxlvl = '.$maxlvl;
$sql = 'INSERT into attacken set name = \''.$attackname.'\', starke = '.$starke.', verteidigung = '.$verteidigung.', speed = '.$speed.', hp = '.$hp.', mp = '.$mp.', rassen = \''.$rassen.'\', level = '.$level.', geld = '.$geld.', type = \''.$type.'\', info = \''.$info.'\', req_atk = \''.$req_atk.'\', req_lvl = \''.$req_lvl.'\', runden = '.$runden.', maxlvl = '.$maxlvl.', options = \''.addslashes($options).'\'';
}
//echo $sql.'<br>';
if(!mysql_query($sql)){
echo "Fehler beim Erstellen der Attacke: &Uuml;berpr&uuml;fe deine Eingabe und melde erst DANACH dieses Statement einem Entwickler => $sql";
return;
}
echo $sql.'<br>';
mysql_query($sql);
logaction('Attacke '.$attackname.' wurde erstellt!');
?>
Attacke sollte nun erstellt sein!!
@ -399,20 +416,32 @@ sicher??
<?php
}
function editAttack($attackname, $attackid, $Frucht, $starke, $verteidigung, $speed, $hp, $mp, $rassen, $level, $geld, $type, $info, $req_atk, $req_lvl, $runden, $maxlvl) {
function editAttack($attackname, $attackid, $Frucht, $starke, $verteidigung, $speed, $hp, $mp, $rassen, $level, $geld, $options, $type, $info, $req_atk, $req_lvl, $runden, $maxlvl) {
$row = mysql_fetch_assoc(mysql_query('Select * from attacken where id ='.$attackid));
$req_atk = implode(',', $req_atk);
json_decode($options, true);
if(JSON_ERROR_NONE != json_last_error()) {
echo "<br>";
echo "Attacke konnte nicht erstellt werden, syntax f&ouml;r options ist nicht korrekt!";
echo displayHistoryBackLink();
return;
}
if($Frucht != 0){
$sql = 'UPDATE attacken set name = \''.htmlspecialchars(urldecode($attackname)).'\', starke = '.$starke.', verteidigung = '.$verteidigung.', speed = '.$speed.', hp = '.$hp.', mp = '.$mp.', rassen = \''.$rassen.'\', level = '.$level.', geld = '.$geld.', type = \''.$type.'\', info = \''.$info.'\', req_atk = \''.$req_atk.'\', req_lvl = \''.$req_lvl.'\', Frucht = '.$Frucht.', runden = '.$runden.', maxlvl = '.$maxlvl.' where id = '.$attackid;
$sql = 'UPDATE attacken set name = \''.htmlspecialchars(urldecode($attackname)).'\', starke = '.$starke.', verteidigung = '.$verteidigung.', speed = '.$speed.', hp = '.$hp.', mp = '.$mp.', rassen = \''.$rassen.'\', level = '.$level.', geld = '.$geld.', type = \''.$type.'\', info = \''.$info.'\', req_atk = \''.$req_atk.'\', req_lvl = \''.$req_lvl.'\', Frucht = '.$Frucht.', runden = '.$runden.', maxlvl = '.$maxlvl.', options = \''.$options.'\' where id = '.$attackid;
} else {
$sql = 'UPDATE attacken set name = \''.htmlspecialchars(urldecode($attackname)).'\', starke = '.$starke.', verteidigung = '.$verteidigung.', speed = '.$speed.', hp = '.$hp.', mp = '.$mp.', rassen = \''.$rassen.'\', level = '.$level.', geld = '.$geld.', type = \''.$type.'\', info = \''.$info.'\', req_atk = \''.$req_atk.'\', req_lvl = \''.$req_lvl.'\', Frucht = NULL, runden = '.$runden.', maxlvl = '.$maxlvl.' where id = '.$attackid;
$sql = 'UPDATE attacken set name = \''.htmlspecialchars(urldecode($attackname)).'\', starke = '.$starke.', verteidigung = '.$verteidigung.', speed = '.$speed.', hp = '.$hp.', mp = '.$mp.', rassen = \''.$rassen.'\', level = '.$level.', geld = '.$geld.', type = \''.$type.'\', info = \''.$info.'\', req_atk = \''.$req_atk.'\', req_lvl = \''.$req_lvl.'\', Frucht = NULL, runden = '.$runden.', maxlvl = '.$maxlvl.', options = \''.$options.'\' where id = '.$attackid;
}
if($row['name'] != $attackname){
mysql_query('Update lernen set name = \''.$attackname.'\' WHERE at_id ='.$attackid);
}
// echo 'Debugnachricht: '.$sql.'<br>';
mysql_query($sql);
//echo 'Debugnachricht: '.$sql.'<br>';
if(!mysql_query($sql)){
echo "Fehler beim Editieren der Attacke: &Uuml;berpr&uuml;fe deine Eingabe und melde erst DANACH dieses Statement einem Entwickler => $sql";
return;
}
logaction('Attacke mit dem jetzigen Namen '.$attackname.' wurde editiert!');
?>
@ -425,4 +454,4 @@ function editAttack($attackname, $attackid, $Frucht, $starke, $verteidigung, $sp
}
?>
?>

@ -6,6 +6,9 @@
*
*/
defineIfNotDefined('MAJIN_DIVIDENT', 10);
####################Majin SPIELER 1
if($technick1['type'] == "majin") {
@ -15,16 +18,33 @@ if($technick1['type'] == "majin") {
$aktion_AV1[$x] = "nein";
$k_mp[0] = 0;
} else {
$multiplikator = $technick1['starke'] / 10;
$options = php_json_decode($technick1['options'], true);
// options is now an array with following input possible ...
// 'attribute' => array('strength', 'defense', 'speed')
// Place handling here depending on the options
$k_starke[1] = $k_starke[1] * $multiplikator;
$k_speed[1] = $k_speed[1] * $multiplikator;
$k_ver[1] = $k_ver[1] * $multiplikator;
$k_starke[1] = $k_starke[1] * ($technick1['starke'] / MAJIN_DIVIDENT);
$k_speed[1] = $k_speed[1] * ($technick1['speed'] / MAJIN_DIVIDENT);
$k_ver[1] = $k_ver[1] * ($technick1['verteidigung'] / MAJIN_DIVIDENT);
$alt_hp = $k_hp[1];
$k_hp[1] = round($k_hp[1] - ($k_starke[1] / 2));
$my_dmg = 0;
foreach( $options['attribute'] as $attr ) {
if($attr == 'strength') {
$my_dmg += $k_starke[1] / 2)
} else if($attr == 'defense') {
$my_dmg += $k_ver[1] / 2)
} else if($attr == 'speed') {
$my_dmg += $k_speed[1] / 2)
}
}
$k_hp[1] = round($k_hp[1] - $my_dmg);
$schaden_1 = "$technick1[name]";
$schaden_2 = $alt_hp - $k_hp[1];
@ -44,15 +64,32 @@ if($technick1['type'] == "majin") {
$aktion_AV2[$x] = "nein";
$k_mp[1] = 0;
} else {
$multiplikator = $technick2['starke'] / 10;
$k_starke[0] = $k_starke[0] * $multiplikator;
$k_speed[0] = $k_speed[0] * $multiplikator;
$k_ver[0] = $k_ver[0] * $multiplikator;
$options = php_json_decode($technick1['options'], true);
// options is now an array with following input possible ...
// 'attribute' => array('strength', 'defense', 'speed')
// Place handling here depending on the options
$k_starke[0] = $k_starke[0] * ($technick2['starke'] / MAJIN_DIVIDENT);
$k_speed[0] = $k_speed[0] * ($technick2['speed'] / MAJIN_DIVIDENT);
$k_ver[0] = $k_ver[0] * ($technick2['verteidigung'] / MAJIN_DIVIDENT);
$alt_hp = $k_hp[0];
$k_hp[0] = round($k_hp[0] - ($k_starke[0] / 2));
$my_dmg = 0;
foreach( $options['attribute'] as $attr ) {
if($attr == 'strength') {
$my_dmg += $k_starke[0] / 2)
} else if($attr == 'defense') {
$my_dmg += $k_ver[0] / 2)
} else if($attr == 'speed') {
$my_dmg += $k_speed[0] / 2)
}
}
$k_hp[0] = round($k_hp[0] - $my_dmg);
$schaden_2 = "$technick2[name]";
$schaden_1 = $alt_hp - $k_hp[0];
@ -63,4 +100,4 @@ if($technick1['type'] == "majin") {
$aussetzten_runde = 1;
}}
?>
?>

@ -65,6 +65,11 @@ function showAttDetails($at_id) {
<p align="center"><b>Type</b></td>
<td width="340" height="25">&nbsp;<?php echo $at_info['type']; ?></td>
</tr>
<tr>
<td width="158" height="25">
<p align="center"><b>Options</b></td>
<td width="340" height="25">&nbsp;<?php echo print_r (json_decode ( $at_info['options'], true)); ?></td>
</tr>
<tr>
<td width="158" height="25">
<p align="center"><b>Info</b></td>

Loading…
Cancel
Save