General fixes

+Fixed a bug that didn't delete artifacts when a player deleted his
account
+Added "(artifact)" if a village has an artifact in the village overview
+Added the artifact section in the multihunter panel (return to natars
doesn't work yet)

NOTE: To play this version of the game, you have to run this query first
(where "s1_" is the prefix of your server):

ALTER TABLE `s1_artefacts` ADD `del` TINYINT(1) NULL DEFAULT '0' AFTER
`lastupdate`;
ALTER TABLE `testtravian`.`s1_artefacts` ADD INDEX
`active-owner-conquered-del` (`active`, `owner`, `conquered`, `del`);
This commit is contained in:
iopietro
2018-06-21 14:43:47 +02:00
parent 8861a578e4
commit c574a71b3a
13 changed files with 587 additions and 420 deletions
+33 -48
View File
@@ -74,55 +74,40 @@ Treasury <b>' . $reqlvl . '</b>, Effect <b>' . $effect . '</b>
<?php
$count = mysqli_fetch_array(mysqli_query($database->dblink,"SELECT Count(*) as Total FROM " . TB_PREFIX . "artefacts"), MYSQLI_ASSOC);
$count = $count['Total'];
if($count == 0) {
echo '<td colspan="4" class="none">'.NO_ARTIFACTS_AREA.'</td>';
} else {
function haversine($l1, $o1, $l2, $o2) {
$l1 = deg2rad($l1);
$sinl1 = sin($l1);
$l2 = deg2rad($l2);
$o1 = deg2rad($o1);
$o2 = deg2rad($o2);
return (7926 - 26 * $sinl1) * asin(min(1, 0.707106781186548 * sqrt((1 - (sin($l2) * $sinl1) - cos($l1) * cos($l2) * cos($o2 - $o1)))));
}
unset($reqlvl);
unset($effect);
$arts = mysqli_query($database->dblink,"SELECT type, vref, id, name, size, owner, effect FROM " . TB_PREFIX . "artefacts");
$rows = array();
while($row = mysqli_fetch_array($arts)) {
$query = mysqli_query($database->dblink,'SELECT x, y FROM `' . TB_PREFIX . 'wdata` WHERE `id` = ' . (int) $row['vref']);
$coor2 = mysqli_fetch_assoc($query);
$dist = $database->getDistance($coor['x'], $coor['y'], $coor2['x'], $coor2['y']);
$rows[$dist] = $row;
}
ksort($rows);
foreach($rows as $row) {
$wref = $village->wid;
$coor = $database->getCoor($wref);
$wref2 = $row['vref'];
$coor2 = $database->getCoor($wref2);
echo '<tr>';
echo '<td class="icon"><img class="artefact_icon_' . $row['type'] . '" src="img/x.gif" alt="" title=""></td>';
echo '<td class="nam">';
echo '<a href="build.php?id=' . $id . '&show='.$row['id'].'">' . $row['name'] . '</a> <span class="bon">' . $row['effect'] . '</span>';
echo '<div class="info">';
if($row['size'] == 1 && $row['type'] != 11){
$reqlvl = 10;
$effect = VILLAGE;
}else{
$reqlvl = $row['type'] != 11 ? 20 : 10;
$effect = ACCOUNT;
}
echo '<div class="info">'.TREASURY.' <b>' . $reqlvl . '</b>, '.EFFECT.' <b>' . $effect . '</b>';
echo '</div></td><td class="pla"><a href="karte.php?d=' . $row['vref'] . '&c=' . $generator->getMapCheck($row['vref']) . '">' . $database->getUserField($row['owner'], "username", 0) . '</a></td>';
echo '<td class="dist">'.$database->getDistance($coor['x'], $coor['y'], $coor2['x'], $coor2['y']).'</td>';
echo '</tr>';
if($count == 0) echo '<td colspan="4" class="none">'.NO_ARTIFACTS_AREA.'</td>';
else
{
$arts = mysqli_query($database->dblink,"SELECT type, vref, id, name, size, owner, effect FROM " . TB_PREFIX . "artefacts");
$rows = array();
while($row = mysqli_fetch_array($arts)) {
$query = mysqli_query($database->dblink,'SELECT x, y FROM `' . TB_PREFIX . 'wdata` WHERE `id` = ' . (int) $row['vref']);
$coor2 = mysqli_fetch_assoc($query);
$dist = $database->getDistance($coor['x'], $coor['y'], $coor2['x'], $coor2['y']);
$rows[$dist] = $row;
}
ksort($rows);
foreach($rows as $row) {
$wref = $village->wid;
$coor = $database->getCoor($wref);
$wref2 = $row['vref'];
$coor2 = $database->getCoor($wref2);
echo '<tr>';
echo '<td class="icon"><img class="artefact_icon_' . $row['type'] . '" src="img/x.gif" alt="" title=""></td>';
echo '<td class="nam">';
echo '<a href="build.php?id=' . $id . '&show='.$row['id'].'">' . $row['name'] . '</a> <span class="bon">' . $row['effect'] . '</span>';
echo '<div class="info">';
if($row['size'] == 1 && $row['type'] != 11){
$reqlvl = 10;
$effect = VILLAGE;
}else{
$reqlvl = $row['type'] != 11 ? 20 : 10;
$effect = ACCOUNT;
}
echo '<div class="info">'.TREASURY.' <b>' . $reqlvl . '</b>, '.EFFECT.' <b>' . $effect . '</b>';
echo '</div></td><td class="pla"><a href="karte.php?d=' . $row['vref'] . '&c=' . $generator->getMapCheck($row['vref']) . '">' . $database->getUserField($row['owner'], "username", 0) . '</a></td>';
echo '<td class="dist">'.$database->getDistance($coor['x'], $coor['y'], $coor2['x'], $coor2['y']).'</td>';
echo '</tr>';
}
}
?>
+20 -75
View File
@@ -1,97 +1,42 @@
<?php
$artefact = $database->getArtefactDetails($_GET['show']);
if(empty($artefact)){
include_once("GameEngine/Artifacts.php");
$artifact = $database->getArtefactDetails($_GET['show']);
if(empty($artifact)){
header("location: build.php?gid=27");
exit;
}
if($artefact['size'] == 1 && $artefact['type'] != 11){
$reqlvl = 10;
$effect = VILLAGE;
}else{
$reqlvl = $artefact['type'] != 11 ? 20 : 10;
$effect = ACCOUNT;
}
$activationTime = 86400 / (SPEED == 2 ? 1.5 : (SPEED == 3 ? 2 : SPEED));
$time = time();
$nextEffect = "-";
if($artefact['owner'] == 3) $active = "-";
elseif(!$artefact['active'] && $artefact['conquered'] < $time - $activationTime) $active = "<b>Can't be activated</b>";
elseif (!$artefact['active']) $active = date("d.m.Y H:i:s", $artefact['conquered'] + $activationTime);
else
{
$active = "<b>".ACTIVE."</b>";
$nextEffect = date("d.m.Y H:i:s", $artefact['lastupdate'] + (86400 / (SPEED == 2 ? 1.5 : (SPEED == 3 ? 2 : SPEED))));
}
//// Added by brainiac - thank you
if ($artefact['type'] == 8)
{
$kind = $artefact['kind'];
$effecty = $artefact['effect2'];
}else{
$kind = $artefact['type'];
$effecty = $artefact['effect'];
}
$artefactBadEffect = $artefact['type'] == 8 && $artefact['bad_effect'] == 1;
switch($kind){
case 1:
$betterorbadder = $artefactBadEffect ? BUILDING_WEAKER : BUILDING_STRONGER;
break;
case 2:
$betterorbadder = $artefactBadEffect ? TROOPS_SLOWEST : TROOPS_FASTER;
break;
case 3:
$betterorbadder = $artefactBadEffect ? SPIES_DECRESE : SPIES_INCREASE;
break;
case 4:
$betterorbadder = $artefactBadEffect ? CONSUME_HIGH : CONSUME_LESS;
break;
case 5:
$betterorbadder = $artefactBadEffect ? TROOPS_MAKE_SLOWEST : TROOPS_MAKE_FASTER;
break;
case 6:
$betterorbadder = $artefactBadEffect ? YOU_CONSTRUCT : YOU_CONSTRUCT;
break;
case 7:
$betterorbadder = $artefactBadEffect ? CRANNY_DECRESE : CRANNY_INCREASED;
break;
case 8:
$betterorbadder = $artefactBadEffect ? SPIES_INCREASE : SPIES_DECRESE;
break;
}
$bonus = isset($betterorbadder) ? $betterorbadder." (<b>".str_replace(["(", ")"], "" , $effecty)."</b>)" : (($kind == 11 && $artefact['active']) ? "<b>".WW_BUILDING_PLAN."</b>" : "<b>Not yet active</b>");
$artifactInfo = Artifacts::getArtifactInfo($artifact);
?>
<div class="artefact image-<?php echo str_replace(['type', '.gif'], '', $artefact['img']); ?>">
<div class="artefact image-<?php echo str_replace(['type', '.gif'], '', $artifact['img']); ?>">
<table id="art_details" cellpadding="1" cellspacing="1">
<thead>
<tr>
<th colspan="2"><?php echo $artefact['name'];?></th>
<th colspan="2"><?php echo $artifact['name'];?></th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="2" class="desc">
<span class="detail"><?php echo $artefact['desc'];?></span>
<span class="detail"><?php echo $artifact['desc'];?></span>
</td>
</tr>
<tr>
<th><?php echo OWNER; ?></th>
<td>
<a href="spieler.php?uid=<?php echo $artefact['owner'];?>"><?php echo $database->getUserField($artefact['owner'], "username", 0);?></a>
<a href="spieler.php?uid=<?php echo $artifact['owner'];?>"><?php echo $database->getUserField($artifact['owner'], "username", 0);?></a>
</td>
</tr>
<tr>
<th><?php echo VILLAGE; ?></th>
<td>
<?php if($database->checkVilExist($artefact['vref'])){?>
<a href="karte.php?d=<?php echo $artefact['vref'];?>&c=<?php echo $generator->getMapCheck($artefact['vref']);?>"><?php echo $database->getVillageField($artefact['vref'], "name");?> </a>
<?php if($database->checkVilExist($artifact['vref'])){?>
<a href="karte.php?d=<?php echo $artifact['vref'];?>&c=<?php echo $generator->getMapCheck($artifact['vref']);?>"><?php echo $database->getVillageField($artifact['vref'], "name");?> </a>
<?php }else{?>
<span>[?]</span>
<?php }?>
@@ -100,7 +45,7 @@ $bonus = isset($betterorbadder) ? $betterorbadder." (<b>".str_replace(["(", ")"]
<tr>
<th><?php echo ALLIANCE; ?></th>
<td>
<?php if(($alliance = $database->getUserField($artefact['owner'], "alliance", 0)) > 0){ ?>
<?php if(($alliance = $database->getUserField($artifact['owner'], "alliance", 0)) > 0){ ?>
<a href="allianz.php?aid=<?php echo $alliance;?>"><?php echo $database->getAllianceName($alliance); ?></a>
<?php }else{?>
<span>-</span>
@@ -109,33 +54,33 @@ $bonus = isset($betterorbadder) ? $betterorbadder." (<b>".str_replace(["(", ")"]
</tr>
<tr>
<th><?php echo AREA_EFFECT; ?></th>
<td><?php echo $effect; ?></td>
<td><?php echo $artifactInfo['effectInfluence']; ?></td>
</tr>
<tr>
<th><?php echo BONUS; ?></th>
<td><?php echo $bonus; ?></td>
<td><?php echo $artifactInfo['bonus']; ?></td>
</tr>
<tr>
<th><?php echo REQUIRED_LEVEL; ?></th>
<td><?php echo TREASURY; ?> <?php echo LEVEL; ?> <b><?php echo $reqlvl; ?></b></td>
<td><?php echo TREASURY; ?> <?php echo LEVEL; ?> <b><?php echo $artifactInfo['requiredLevel']; ?></b></td>
</tr>
<tr>
<th><?php echo TIME_CONQUER; ?></th>
<td><?php echo ($artefact['owner'] != 3) ? date("d.m.Y H:i:s",$artefact['conquered']) : "-";?></td>
<td><?php echo ($artifact['owner'] != 3) ? date("d.m.Y H:i:s", $artifact['conquered']) : "-";?></td>
</tr>
<tr>
<th><?php echo TIME_ACTIVATION; ?></th>
<td><?php echo $active;?></td>
<td><?php echo $artifactInfo['active'];?></td>
</tr>
<?php if($artefact['type'] == 8){?>
<?php if($artifact['type'] == 8){?>
<tr>
<th><?php echo NEXT_EFFECT; ?></th>
<td><?php echo $nextEffect;?></td>
<td><?php echo $artifactInfo['nextEffect'];?></td>
</tr>
<?php }?>