|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* Created on 31.05.2011
|
|
|
|
*
|
|
|
|
* @copyright (c) 2011 animegame.eu
|
|
|
|
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public Licence
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
?>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
defineIfNotDefined("CLAN_CREATION_FEE", 20000);
|
|
|
|
|
|
|
|
function displayClanItems() {
|
|
|
|
$raume_qry = mysql_query('SELECT * FROM clan_item order by tp');
|
|
|
|
?>
|
|
|
|
<table>
|
|
|
|
<tr>
|
|
|
|
<th align="center" colspan="12"><h1>Clanräume bearbeiten</h1></th>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Name</td>
|
|
|
|
<td>Stärke</td>
|
|
|
|
<td>Verteidigung</td>
|
|
|
|
<td>Glück</td>
|
|
|
|
<td>Ausdauer</td>
|
|
|
|
<td>Geschwindigkeit</td>
|
|
|
|
<td>Kaufpreis</td>
|
|
|
|
<td>Miete</td>
|
|
|
|
<td>Nutzungsgebühr</td>
|
|
|
|
<td>TP</td>
|
|
|
|
<td>Level</td>
|
|
|
|
<td>bearbeiten</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td colspan=12><hr></td>
|
|
|
|
</tr>
|
|
|
|
<?php
|
|
|
|
while($res = mysql_fetch_assoc($raume_qry)){
|
|
|
|
echo '<tr><td>'.$res['name'].'</td><td>'.$res['staerke'].'</td><td>'.$res['verteidigung'].'</td><td>'.$res['glueck'].'</td><td>'.$res['ausdauer'].'</td><td>'.$res['geschwindigkeit'].'</td><td>'.$res['preis'].'</td><td>'.$res['miete'].'</td><td>'.$res['nutzung'].'</td><td>'.$res['tp'].'</td><td>'.$res['req_level'].'</td><td><a href="'.$_SERVER['PHP_SELF'].'?choose=clan&action=editrooms&raumid='.$res['id'].'">edit</a> | <a href="'.$_SERVER['PHP_SELF'].'?choose=clan&action=deleterooms&raumid='.$res['id'].'">delete</a></td></tr>';
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
<tr>
|
|
|
|
<td colspan=12><hr></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td align="center" colspan="12"><a
|
|
|
|
href="<?php echo $_SERVER['PHP_SELF'].'?choose=clan&action=createrooms'; ?>">Raum
|
|
|
|
erstellen</a>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td align="center" colspan="12"><a
|
|
|
|
href="<?php echo $_SERVER['PHP_SELF'].'?choose=clan'; ?>">Zum
|
|
|
|
Clanmenu</a>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
|
|
|
|
function displayEditOrCreateClanRoom($action, $raumid, $raumname, $staerke, $verteidigung, $glueck, $ausdauer, $geschwindigkeit, $info, $level) {
|
|
|
|
if($raumname !== NULL){ // Sprich es wurde was geaendert!
|
|
|
|
// Berechne den TP Verbrauch
|
|
|
|
$b38 = 1.3; // Parameter aus Exceltabelle
|
|
|
|
$c38 = 0.3;
|
|
|
|
$g3 = ($staerke!=0?1:0) + ($verteidigung!=0?1:0) + ($glueck!=0?1:0) + ($ausdauer!=0?1:0) + ($geschwindigkeit!=0?1:0);
|
|
|
|
$summe_werte = ($staerke+$verteidigung+$glueck+$ausdauer+$geschwindigkeit);
|
|
|
|
$tp = round($summe_werte * (pow($b38,$g3)-$c38));
|
|
|
|
// Berechne Kaufpreis
|
|
|
|
$b33 = 1.1; // Parameter aus Exceltabelle
|
|
|
|
$c33 = 3000;
|
|
|
|
$kaufpreis = round(pow($b33,$summe_werte) * $c33);
|
|
|
|
// Berechne Miete
|
|
|
|
$b42=0.5; $c42=2; $d42=4; $e42=2; $f42=1; $g42=5; $h42=6; $i42=1.9; $j42=100;
|
|
|
|
$gewichtete_summe= $ausdauer*$b42+$staerke*$c42+$verteidigung*$d42+$geschwindigkeit*$e42+$glueck*$f42;
|
|
|
|
$miete = floor(pow($i42,log($gewichtete_summe,$h42)*$g42)*$j42/7); // Durch sieben (weil 7 Chars pro User)
|
|
|
|
// Berechne Nutzungsgebuehr
|
|
|
|
$b46 = 100; $c46 = 0.69; $d46 = -1762;
|
|
|
|
$nutz = floor(($miete*7*0.7)/log($gewichtete_summe, $b46)*$c46+$d46);
|
|
|
|
|
|
|
|
// Und jetzt poliere die Preise optisch etwas auf
|
|
|
|
$stepkp = round(pow(10,floor(max(log10($kaufpreis),2)))/4);
|
|
|
|
$stepmp = round(pow(10,floor(max(log10($miete),2)))/4);
|
|
|
|
$stepnp = round(pow(10,floor(max(log10($nutz),2)))/4);
|
|
|
|
|
|
|
|
$kaufpreis = round($kaufpreis/$stepkp)*$stepkp;
|
|
|
|
$miete = ceil($miete/$stepmp)*$stepmp;
|
|
|
|
$nutz = ceil($nutz/$stepnp)*$stepnp;
|
|
|
|
// So und nun kann weiter gemacht werden!
|
|
|
|
if($action == 'editrooms'){
|
|
|
|
logaction('Der Raum '.$raumname.' wurde editiert!');
|
|
|
|
$sql ='Update clan_item set name = \''.$raumname.'\', staerke = '.$staerke.', verteidigung = '.$verteidigung.', ausdauer = '.$ausdauer.', geschwindigkeit = '.$geschwindigkeit.', glueck = '.$glueck.', preis = '.$kaufpreis.', miete = '.$miete.', nutzung = '.$nutz.', tp = '.$tp.', info = \''.$info.'\', req_level = '.$level.' where id = '.$raumid.'';
|
|
|
|
$res = mysql_query($sql);
|
|
|
|
if(!$res)
|
|
|
|
echo $sql . '<br>';
|
|
|
|
} else if($action == 'createrooms'){
|
|
|
|
logaction('Der Raum '.$raumname.' wurde erstellt!');
|
|
|
|
$sql = 'INSERT INTO clan_item(name, staerke, verteidigung, ausdauer, geschwindigkeit, glueck, preis, miete, nutzung, tp, info, req_level) values(\''.$raumname.'\', '.$staerke.', '.$verteidigung.', '.$ausdauer.', '.$geschwindigkeit.', '.$glueck.', '.$kaufpreis.', '.$miete.', '.$nutz.', '.$tp.', \''.$info.'\', '.$level.')';
|
|
|
|
$res = mysql_query($sql);
|
|
|
|
if(!$res)
|
|
|
|
echo $sql . '<br>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($action == 'editrooms'){
|
|
|
|
$raum = mysql_fetch_assoc(mysql_query('SELECT * FROM clan_item WHERE id = '.$raumid));
|
|
|
|
$aLabel = 'editieren';
|
|
|
|
} else{
|
|
|
|
$aLabel = 'erstellen';
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
<form action="" method="POST">
|
|
|
|
<input name="choose" value="clan" type="hidden"></input> <input
|
|
|
|
name="action" value="<?php echo $action; ?>" type="hidden"></input> <input
|
|
|
|
name="raumid" value="<?php echo $raumid; ?>" type="hidden"></input>
|
|
|
|
<table>
|
|
|
|
<tr>
|
|
|
|
<th align="center" colspan="2">Clanräume <?php echo $aLabel; ?>
|
|
|
|
</th>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Name</td>
|
|
|
|
<td><input type="text" class="text" name="raumname"
|
|
|
|
value="<?php echo $raum['name']; ?>" /></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Stärke</td>
|
|
|
|
<td><input type="text" class="text" name="staerke"
|
|
|
|
value="<?php echo $raum['staerke']; ?>" /></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Verteidigung</td>
|
|
|
|
<td><input type="text" class="text" name="verteidigung"
|
|
|
|
value="<?php echo $raum['verteidigung']; ?>" /></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Glück</td>
|
|
|
|
<td><input type="text" class="text" name="glueck"
|
|
|
|
value="<?php echo $raum['glueck']; ?>" /></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Ausdauer</td>
|
|
|
|
<td><input type="text" class="text" name="ausdauer"
|
|
|
|
value="<?php echo $raum['ausdauer']; ?>" /></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Geschwindigkeit</td>
|
|
|
|
<td><input type="text" class="text" name="geschwindigkeit"
|
|
|
|
value="<?php echo $raum['geschwindigkeit']; ?>" /></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Level</td>
|
|
|
|
<td><input type="text" class="text" name="req_level"
|
|
|
|
value="<?php echo $raum['req_level']; ?>" /></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Kaufpreis</td>
|
|
|
|
<td><?php echo $raum['preis']; ?></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Miete</td>
|
|
|
|
<td><?php echo $raum['miete']; ?></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Nutzungsgebühr</td>
|
|
|
|
<td><?php echo $raum['nutzung']; ?></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Trainingspunkte</td>
|
|
|
|
<td><?php echo $raum['tp']; ?></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Info</td>
|
|
|
|
<?php
|
|
|
|
echo '<td><textarea name="info" rows="10" cols="50">'.$raum['info'].'</textarea></td>';
|
|
|
|
?>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td align="center" colspan="2"><input type="submit" /></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td align="center" colspan="2"><a
|
|
|
|
href="<?php echo $_SERVER['PHP_SELF'].'?choose=clan&action=rooms'; ?>">Zur
|
|
|
|
Übersicht</a>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td align="center" colspan="2"><a
|
|
|
|
href="<?php echo $_SERVER['PHP_SELF'].'?choose=clan'; ?>">Zum
|
|
|
|
Clanmenu</a>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
</form>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
|
|
|
|
function displayDeleteClanRoom($raumname, $raumid) {
|
|
|
|
?>
|
|
|
|
<table>
|
|
|
|
<?php
|
|
|
|
if($raumname !== NULL){
|
|
|
|
mysql_query('DELETE FROM clan_item WHERE id = '.$raumid);
|
|
|
|
mysql_query('DELETE FROM clan_ware where item_id ='.$raumid);
|
|
|
|
?>
|
|
|
|
<tr>
|
|
|
|
<td align="center" colspan="2">Der Raum "<?php echo $raumname; ?>"
|
|
|
|
wurde gelöscht</td>
|
|
|
|
</tr>
|
|
|
|
<?php
|
|
|
|
} else{
|
|
|
|
$res = mysql_fetch_assoc(mysql_query('SELECT * FROM clan_item WHERE id = '.$raumid));
|
|
|
|
?>
|
|
|
|
<tr>
|
|
|
|
<td align="center" colspan="2">Den Raum "<?php echo $res['name']; ?>"
|
|
|
|
wirklich löschen? <a
|
|
|
|
href="<?php echo $_SERVER['PHP_SELF'].'?choose=clan&action=deleterooms&raumid='.$raumid.'&raumname='.$res['name']; ?>">Löschen
|
|
|
|
bestätigen!</a>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
<tr>
|
|
|
|
<td align="center" colspan="2"><a
|
|
|
|
href="<?php echo $_SERVER['PHP_SELF'].'?choose=clan&action=rooms'; ?>">Zur
|
|
|
|
Übersicht</a>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td align="center" colspan="2"><a
|
|
|
|
href="<?php echo $_SERVER['PHP_SELF'].'?choose=clan'; ?>">Zum
|
|
|
|
Clanmenu</a>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
|
|
|
|
function displayGeneralOptions($ccfee) {
|
|
|
|
$change = false;
|
|
|
|
if($ccfee != null && $ccfee != CLAN_CREATION_FEE) {
|
|
|
|
setDefine('CLAN_CREATION_FEE', $ccfee);
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
<form method="POST">
|
|
|
|
<input type="hidden" name="choose" value="clan">
|
|
|
|
<input type="hidden" name="action" value="general">
|
|
|
|
<table width="50%">
|
|
|
|
<tr>
|
|
|
|
<th colspan="2" align="center"><h1>Übersicht</h1></th>
|
|
|
|
</tr>
|
|
|
|
<?php if($change === TRUE) {?>
|
|
|
|
<tr>
|
|
|
|
<td colspan="2" align="center">Änderungen übernommen!</td>
|
|
|
|
</tr>
|
|
|
|
<?php }?>
|
|
|
|
<tr>
|
|
|
|
<td align="left">Gründungsgebühr</td>
|
|
|
|
<td align="center"><input type="text" name="ccfee" value=<?php echo ($ccfee == null)?CLAN_CREATION_FEE:$ccfee;?>></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td align="center" colspan="2"><input type="submit" value="ändern"></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td align="center" colspan="2"><a
|
|
|
|
href="<?php echo $_SERVER['PHP_SELF'].'?choose=clan'; ?>">Zum Clanmenu</a>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
</form>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
|
|
|
|
function displayClanOptions() {
|
|
|
|
?>
|
|
|
|
<table>
|
|
|
|
<tr>
|
|
|
|
<td><a
|
|
|
|
href="<?php echo $_SERVER['PHP_SELF']; ?>?choose=clan&action=general">Clanoptionen
|
|
|
|
bearbeiten</a>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><a
|
|
|
|
href="<?php echo $_SERVER['PHP_SELF']; ?>?choose=clan&action=rooms">Clanräume
|
|
|
|
bearbeiten</a>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><a href="<?php echo $_SERVER['PHP_SELF']; ?>">Zum Hauptmenu</a><br>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
|
|
|
|
function displayClanMenu($action, $raumid, $raumname, $staerke, $verteidigung, $glueck, $ausdauer, $geschwindigkeit, $info, $level, $ccfee) {
|
|
|
|
switch ($action) {
|
|
|
|
case 'editrooms':
|
|
|
|
displayEditOrCreateClanRoom($action, $raumid, $raumname, $staerke, $verteidigung, $glueck, $ausdauer, $geschwindigkeit, $info, $level);
|
|
|
|
break;
|
|
|
|
case 'createrooms':
|
|
|
|
displayEditOrCreateClanRoom($action, $raumid, $raumname, $staerke, $verteidigung, $glueck, $ausdauer, $geschwindigkeit, $info, $level);
|
|
|
|
break;
|
|
|
|
case 'deleterooms':
|
|
|
|
displayDeleteClanRoom($raumname, $raumid);
|
|
|
|
break;
|
|
|
|
case 'rooms':
|
|
|
|
displayClanItems();
|
|
|
|
break;
|
|
|
|
case 'general':
|
|
|
|
displayGeneralOptions($ccfee);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
displayClanOptions();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|