mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-08-26 21:27:15 +00:00
Reports refactor #1
-Removed 29 files from the "Templates/Notice" folder, there were a lot of duplicated/very similar kinds of report. Now, there are only 6 kinds of report (9.tpl isn't counted) +Changed a lot of codes in some .tpl reports, into a foreach Automation.php: +Modified report data, for the refactored report system +Some clean-up Battle.php: +Fixed catapults and rams, they weren't able to destroy completely a building +Fixed a possible division by 0 error
This commit is contained in:
+76
-254
@@ -6,32 +6,33 @@
|
||||
## TRAVIANZ ##
|
||||
############################################################
|
||||
$dataarray = explode(",",$message->readingNotice['data']);
|
||||
if(isset($dataarray[151]) and $dataarray[151]!=0){$colspan="11";}else{$colspan="10";}
|
||||
$colspan = (isset($dataarray[173]) && $dataarray[173] > 0) ? 11 : 10;
|
||||
$colspan2 = 10;
|
||||
//attacker
|
||||
if ($database->getUserField($dataarray[0],'username',0)!="??") {
|
||||
$user_url="<a href=\"spieler.php?uid=".$database->getUserField($dataarray[0],'id',0)."\">".$database->getUserField($dataarray[0],'username',0)."</a>";
|
||||
}else{
|
||||
$user_url="<font color=\"grey\"><b>??</b></font>";
|
||||
|
||||
//Attacker
|
||||
if ($database->getUserField($dataarray[0], 'username', 0) != "[?]") {
|
||||
$user_url="<a href=\"spieler.php?uid=".$database->getUserField($dataarray[0], 'id', 0)."\">".$database->getUserField($dataarray[0], 'username', 0)."</a>";
|
||||
}
|
||||
if($database->getVillageField($dataarray[1],'name')!="??") {
|
||||
$from_url="<a href=\"karte.php?d=".$dataarray[1]."&c=".$generator->getMapCheck($dataarray[1])."\">".$database->getVillageField($dataarray[1],'name')."</a>";
|
||||
}else{
|
||||
$from_url="<font color=\"grey\"><b>??</b></font>";
|
||||
else $user_url="<font color=\"grey\"><b>[?]</b></font>";
|
||||
|
||||
|
||||
if($database->getVillageField($dataarray[1],'name') != "[?]") {
|
||||
$from_url="<a href=\"karte.php?d=".$dataarray[1]."&c=".$generator->getMapCheck($dataarray[1])."\">".$database->getVillageField($dataarray[1], 'name')."</a>";
|
||||
}
|
||||
else $from_url="<font color=\"grey\"><b>[?]</b></font>";
|
||||
|
||||
//defender
|
||||
if ($database->getUserField($dataarray[28],'username',0)!="??") {
|
||||
$defuser_url="<a href=\"spieler.php?uid=".$database->getUserField($dataarray[28],'id',0)."\">".$database->getUserField($dataarray[28],'username',0)."</a>";
|
||||
}else{
|
||||
$defuser_url="<font color=\"grey\"><b>??</b></font>";
|
||||
if ($database->getUserField($dataarray[28], 'username', 0) != "[?]") {
|
||||
$defuser_url="<a href=\"spieler.php?uid=".$database->getUserField($dataarray[28], 'id', 0)."\">".$database->getUserField($dataarray[28], 'username', 0)."</a>";
|
||||
}
|
||||
else $defuser_url="<font color=\"grey\"><b>[?]</b></font>";
|
||||
|
||||
if($database->isVillageOases($dataarray[29])){
|
||||
$deffrom_url="<a href=\"karte.php?d=".$dataarray[29]."&c=".$generator->getMapCheck($dataarray[29])."\">".$dataarray[30]."</a>";
|
||||
}elseif($database->getVillageField($dataarray[29],'name')!="??") {
|
||||
$deffrom_url="<a href=\"karte.php?d=".$dataarray[29]."&c=".$generator->getMapCheck($dataarray[29])."\">".$database->getVillageField($dataarray[29],'name')."</a>";
|
||||
}else{
|
||||
$deffrom_url="<font color=\"grey\"><b>??</b></font>";
|
||||
}elseif($database->getVillageField($dataarray[29], 'name') != "[?]") {
|
||||
$deffrom_url="<a href=\"karte.php?d=".$dataarray[29]."&c=".$generator->getMapCheck($dataarray[29])."\">".$database->getVillageField($dataarray[29], 'name')."</a>";
|
||||
}
|
||||
else $deffrom_url="<font color=\"grey\"><b>[?]</b></font>";
|
||||
?>
|
||||
<table cellpadding="1" cellspacing="1" id="report_surround">
|
||||
<thead>
|
||||
@@ -44,7 +45,7 @@ if($database->isVillageOases($dataarray[29])){
|
||||
<?php
|
||||
$date = $generator->procMtime($message->readingNotice['time']); ?>
|
||||
<td class="sent">Sent:</td>
|
||||
<td>on <?php echo $date[0]."<span> at ".$date[1]; ?></span> <span>hour</span></td>
|
||||
<td>on <span><?php echo $date[0]." at ".$date[1]; ?></span> <span>hour</span></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -61,286 +62,107 @@ if($database->isVillageOases($dataarray[29])){
|
||||
<td> </td>
|
||||
<?php
|
||||
$tribe = $dataarray[2];
|
||||
$start = ($tribe-1)*10+1;
|
||||
for($i=$start;$i<=($start+9);$i++) {
|
||||
$start = ($tribe - 1) * 10 + 1;
|
||||
for($i = $start; $i <= ($start + 9); $i++) {
|
||||
echo "<td><img src=\"img/x.gif\" class=\"unit u$i\" title=\"".$technology->getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" /></td>";
|
||||
}
|
||||
if(isset($dataarray[151]) and $dataarray[151]!=0){
|
||||
if(isset($dataarray[173]) && $dataarray[173] > 0){
|
||||
echo "<td><img src=\"img/x.gif\" class=\"unit uhero\" title=\"Hero\" alt=\"Hero\" /></td>";
|
||||
}
|
||||
echo "</tr><tr><th>Troops</th>";
|
||||
for($i=3;$i<=12;$i++) {
|
||||
if($dataarray[$i] == 0) {
|
||||
echo "<td class=\"none\">0</td>";
|
||||
}
|
||||
else {
|
||||
echo "<td>".$dataarray[$i]."</td>";
|
||||
}
|
||||
|
||||
for($i = 3; $i <= 12; $i++) {
|
||||
if($dataarray[$i] == 0) echo "<td class=\"none\">0</td>";
|
||||
else echo "<td>".$dataarray[$i]."</td>";
|
||||
}
|
||||
if(isset($dataarray[151]) and $dataarray[151]!=0){
|
||||
echo "<td>$dataarray[151]</td>";
|
||||
|
||||
if(isset($dataarray[173]) && $dataarray[173] > 0){
|
||||
echo "<td>$dataarray[173]</td>";
|
||||
}
|
||||
echo "<tr><th>Casualties</th>";
|
||||
for($i=13;$i<=22;$i++) {
|
||||
if($dataarray[$i] == 0) {
|
||||
echo "<td class=\"none\">0</td>";
|
||||
}
|
||||
else {
|
||||
echo "<td>".$dataarray[$i]."</td>";
|
||||
}
|
||||
for($i = 13; $i <= 22; $i++) {
|
||||
if($dataarray[$i] == 0) echo "<td class=\"none\">0</td>";
|
||||
else echo "<td>".$dataarray[$i]."</td>";
|
||||
}
|
||||
if(isset($dataarray[151]) and $dataarray[151]!=0){
|
||||
if ($dataarray[152]==0) $tdclass='class="none"'; else $tdclass='';
|
||||
echo "<td $tdclass>$dataarray[152]</td>";
|
||||
if(isset($dataarray[173]) && $dataarray[173] > 0){
|
||||
if ($dataarray[174] == 0) $tdclass='class="none"'; else $tdclass='';
|
||||
echo "<td $tdclass>$dataarray[174]</td>";
|
||||
}
|
||||
if($dataarray[153] != 0 or $dataarray[154] != 0 or $dataarray[155] != 0 or $dataarray[156] != 0 or $dataarray[157] != 0 or $dataarray[158] != 0 or $dataarray[159] != 0 or $dataarray[160] != 0 or $dataarray[161] != 0 or $dataarray[162] != 0 or $dataarray[163] != 0){
|
||||
if($dataarray[175] > 0 || $dataarray[176] > 0 || $dataarray[177] > 0 || $dataarray[178] > 0 || $dataarray[179] > 0 || $dataarray[180] > 0 || $dataarray[181] > 0 || $dataarray[182] > 0 || $dataarray[183] > 0 || $dataarray[184] > 0 || $dataarray[185] > 0){
|
||||
echo "</tr><tr><th>Prisoners</th>";
|
||||
for($i=153;$i<=162;$i++) {
|
||||
if($dataarray[$i] == 0) {
|
||||
echo "<td class=\"none\">0</td>";
|
||||
}
|
||||
else {
|
||||
echo "<td>".$dataarray[$i]."</td>";
|
||||
}
|
||||
|
||||
for($i = 175; $i <= 184; $i++) {
|
||||
if($dataarray[$i] == 0) echo "<td class=\"none\">0</td>";
|
||||
else echo "<td>".$dataarray[$i]."</td>";
|
||||
}
|
||||
if(isset($dataarray[151]) and $dataarray[151]!=0){
|
||||
if ($dataarray[163]==0) $tdclass='class="none"'; else $tdclass='';
|
||||
echo "<td $tdclass>$dataarray[163]</td>";
|
||||
|
||||
if(isset($dataarray[173]) && $dataarray[173] > 0){
|
||||
if ($dataarray[185]==0) $tdclass='class="none"'; else $tdclass='';
|
||||
echo "<td $tdclass>$dataarray[185]</td>";
|
||||
}
|
||||
}
|
||||
if ($dataarray[165]!='' and $dataarray[166]!=''){ //ram
|
||||
if (!empty($dataarray[187]) && !empty($dataarray[188])){ //ram
|
||||
?>
|
||||
<tbody class="goods"><tr><th>Information</th><td colspan="<?php echo $colspan; ?>">
|
||||
<img class="unit u<?php echo $dataarray[165]; ?>" src="img/x.gif" alt="Ram" title="Ram" />
|
||||
<?php echo $dataarray[166]; ?>
|
||||
<img class="unit u<?php echo $dataarray[187]; ?>" src="img/x.gif" alt="Ram" title="Ram" />
|
||||
<?php echo $dataarray[188]; ?>
|
||||
</td></tr></tbody>
|
||||
<?php }
|
||||
if ($dataarray[167]!='' and $dataarray[168]!=''){ //cata
|
||||
if (!empty($dataarray[189]) && !empty($dataarray[190])){ //cata
|
||||
?>
|
||||
<tbody class="goods"><tr><th>Information</th><td colspan="<?php echo $colspan; ?>">
|
||||
<img class="unit u<?php echo $dataarray[167]; ?>" src="img/x.gif" alt="Catapult" title="Catapult" />
|
||||
<?php echo $dataarray[168]; ?>
|
||||
<img class="unit u<?php echo $dataarray[189]; ?>" src="img/x.gif" alt="Catapult" title="Catapult" />
|
||||
<?php echo $dataarray[190]; ?>
|
||||
</td></tr></tbody>
|
||||
<?php }
|
||||
if ($dataarray[169]!='' and $dataarray[170]!=''){ //chief
|
||||
if (!empty($dataarray[191]) && !empty($dataarray[192])){ //chief
|
||||
?>
|
||||
<tbody class="goods"><tr><th>Information</th><td colspan="<?php echo $colspan; ?>">
|
||||
<img class="unit u<?php echo $dataarray[169]; ?>" src="img/x.gif" alt="Chief" title="Chief" />
|
||||
<?php echo $dataarray[170]; ?>
|
||||
<img class="unit u<?php echo $dataarray[191]; ?>" src="img/x.gif" alt="Chief" title="Chief" />
|
||||
<?php echo $dataarray[192]; ?>
|
||||
</td></tr></tbody>
|
||||
<?php }
|
||||
if ($dataarray[172]!='' and $dataarray[173]!=''){ //hero
|
||||
if (!empty($dataarray[194]) && !empty($dataarray[195])){ //hero
|
||||
?>
|
||||
<tbody class="goods"><tr><th>Information</th><td colspan="<?php echo $colspan; ?>">
|
||||
<img class="unit u<?php echo $dataarray[172]; ?>" src="img/x.gif" alt="Hero" title="Hero" />
|
||||
<?php echo $dataarray[173]; ?>
|
||||
<img class="unit u<?php echo $dataarray[194]; ?>" src="img/x.gif" alt="Hero" title="Hero" />
|
||||
<?php echo $dataarray[195]; ?>
|
||||
</td></tr></tbody>
|
||||
<?php }
|
||||
if(isset($dataarray[171]) && $dataarray[171] !=''){ //troop not return
|
||||
if(isset($dataarray[193]) && !empty($dataarray[193])){ //No troops returned
|
||||
?>
|
||||
<tbody class="goods"><tr><th>Information</th><td colspan="<?php echo $colspan; ?>">
|
||||
<?php echo $dataarray[171]; ?>
|
||||
<?php echo $dataarray[193]; ?>
|
||||
</td></tr></tbody>
|
||||
<?php }?>
|
||||
</td></tr></tbody>
|
||||
</table>
|
||||
|
||||
<?php
|
||||
$targettribe=$dataarray['31'];
|
||||
|
||||
|
||||
if ($dataarray[31]=='1'){
|
||||
$start=1; ?>
|
||||
<table cellpadding="1" cellspacing="1" class="defender">
|
||||
<thead>
|
||||
<tr>
|
||||
<td class="role">Defender</th>
|
||||
<td colspan="<?php echo $colspan2; ?>"><?php if($targettribe=='1'){ echo $defuser_url." from the village ".$deffrom_url; } else { echo"Reinforcement"; } ?></td>
|
||||
</tr></thead>
|
||||
<tbody class="units">
|
||||
<tr>
|
||||
<td> </td>
|
||||
|
||||
|
||||
<?php
|
||||
for($i=$start;$i<=($start+9);$i++) {
|
||||
echo "<td><img src=\"img/x.gif\" class=\"unit u$i\" title=\"".$technology->getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" /></td>";
|
||||
}
|
||||
echo "</tr><tr><th>Troops</th>";
|
||||
for($i=35;$i<=44;$i++) {
|
||||
if($dataarray[$i] == "?") {
|
||||
echo "<td class=\"none\">?</td>";
|
||||
}
|
||||
else {
|
||||
echo "<td class=\"none\">?</td>";
|
||||
}
|
||||
}
|
||||
echo "<tr><th>Casualties</th>";
|
||||
for($i=45;$i<=54;$i++) {
|
||||
if($dataarray[$i] == "?") {
|
||||
echo "<td class=\"none\">?</td>";
|
||||
}
|
||||
else {
|
||||
echo "<td class=\"none\">?</td>";
|
||||
}
|
||||
}
|
||||
$target = $dataarray[33] - 1;
|
||||
$start = ($target * 10) + 1;
|
||||
$troopsStart = ($target * 21) + 35;
|
||||
?>
|
||||
</tr></tbody></table>
|
||||
<table cellpadding="1" cellspacing="1" class="defender">
|
||||
<thead>
|
||||
<tr>
|
||||
<td class="role">Defender</td>
|
||||
<td colspan="<?php echo $colspan2; ?>"><?php echo $defuser_url." from the village ".$deffrom_url; ?></td>
|
||||
</tr></thead>
|
||||
<tbody class="units">
|
||||
<tr>
|
||||
<td> </td>
|
||||
|
||||
<?php }
|
||||
if ($dataarray[31]=='2'){
|
||||
$start=11;?>
|
||||
<table cellpadding="1" cellspacing="1" class="defender">
|
||||
<thead>
|
||||
<tr>
|
||||
<td class="role">Defender</th>
|
||||
<td colspan="<?php echo $colspan2; ?>"><?php if($targettribe=='2'){ echo $defuser_url." from the village ".$deffrom_url; } else { echo"Reinforcement"; } ?></td>
|
||||
</tr></thead>
|
||||
<tbody class="units">
|
||||
<tr>
|
||||
<td> </td>
|
||||
|
||||
|
||||
<?php
|
||||
for($i=$start;$i<=($start+9);$i++) {
|
||||
for($i = $start; $i <= ($start + 9); $i++)
|
||||
{
|
||||
echo "<td><img src=\"img/x.gif\" class=\"unit u$i\" title=\"".$technology->getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" /></td>";
|
||||
}
|
||||
echo "</tr><tr><th>Troops</th>";
|
||||
for($i=56;$i<=65;$i++) {
|
||||
if($dataarray[$i] == "?") {
|
||||
echo "<td class=\"none\">?</td>";
|
||||
}
|
||||
else {
|
||||
echo "<td class=\"none\">?</td>";
|
||||
}
|
||||
}
|
||||
echo "<tr><th>Casualties</th>";
|
||||
for($i=66;$i<=75;$i++) {
|
||||
if($dataarray[$i] == "?") {
|
||||
echo "<td class=\"none\">?</td>";
|
||||
}
|
||||
else {
|
||||
echo "<td class=\"none\">?</td>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tr></tbody></table>
|
||||
<?php } ?>
|
||||
<?php if ($dataarray[31]=='3'){
|
||||
$start=21; ?>
|
||||
<table cellpadding="1" cellspacing="1" class="defender">
|
||||
<thead>
|
||||
<tr>
|
||||
<td class="role">Defender</th>
|
||||
<td colspan="<?php echo $colspan2; ?>"><?php if($targettribe=='3'){ echo $defuser_url." from the village ".$deffrom_url; } else { echo"Reinforcement"; } ?></td>
|
||||
</tr></thead>
|
||||
<tbody class="units">
|
||||
<tr>
|
||||
<td> </td>
|
||||
|
||||
|
||||
<?php
|
||||
for($i=$start;$i<=($start+9);$i++) {
|
||||
echo "<td><img src=\"img/x.gif\" class=\"unit u$i\" title=\"".$technology->getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" /></td>";
|
||||
}
|
||||
echo "</tr><tr><th>Troops</th>";
|
||||
for($i=77;$i<=86;$i++) {
|
||||
if($dataarray[$i] == "?") {
|
||||
echo "<td class=\"none\">?</td>";
|
||||
}
|
||||
else {
|
||||
echo "<td class=\"none\">?</td>";
|
||||
}
|
||||
}
|
||||
echo "<tr><th>Casualties</th>";
|
||||
for($i=87;$i<=96;$i++) {
|
||||
if($dataarray[$i] == "?") {
|
||||
echo "<td class=\"none\">?</td>";
|
||||
}
|
||||
else {
|
||||
echo "<td class=\"none\">?</td>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tr></tbody></table>
|
||||
for($i = $troopsStart; $i <= $troopsStart + 9; $i++) echo "<td class=\"none\">?</td>";
|
||||
|
||||
<?php } ?>
|
||||
<?php if ($dataarray[31]=='4'){
|
||||
$start=31; ?>
|
||||
<table cellpadding="1" cellspacing="1" class="defender">
|
||||
<thead>
|
||||
<tr>
|
||||
<td class="role">Defender</th>
|
||||
<td colspan="10"><?php if($targettribe=='4'){ echo'<a href="spieler.php?uid=">'.$database->getUserField($dataarray[28],"username",0).'</a> from the village <a href="karte.php?d='.$dataarray[29].'&c='.$generator->getMapCheck($dataarray[29]).'">'.stripslashes($dataarray[30]).'</a>'; } else { echo"Reinforcement"; } ?></td>
|
||||
</tr></thead>
|
||||
<tbody class="units">
|
||||
<tr>
|
||||
<td> </td>
|
||||
|
||||
|
||||
<?php
|
||||
for($i=$start;$i<=($start+9);$i++) {
|
||||
echo "<td><img src=\"img/x.gif\" class=\"unit u$i\" title=\"".$technology->getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" /></td>";
|
||||
}
|
||||
echo "</tr><tr><th>Troops</th>";
|
||||
for($i=98;$i<=107;$i++) {
|
||||
if($dataarray[$i] == "?") {
|
||||
echo "<td class=\"none\">?</td>";
|
||||
}
|
||||
else {
|
||||
echo "<td class=\"none\">?</td>";
|
||||
}
|
||||
}
|
||||
echo "<tr><th>Casualties</th>";
|
||||
for($i=108;$i<=117;$i++) {
|
||||
if($dataarray[$i] == "?") {
|
||||
echo "<td class=\"none\">?</td>";
|
||||
}
|
||||
else {
|
||||
echo "<td class=\"none\">?</td>";
|
||||
}
|
||||
}
|
||||
for($i = $troopsStart + 10; $i <= $troopsStart + 19; $i++) echo "<td class=\"none\">?</td>";
|
||||
?>
|
||||
</tr></tbody></table>
|
||||
|
||||
<?php } ?>
|
||||
<?php if ($dataarray[31]=='5'){
|
||||
$start=41; ?>
|
||||
<table cellpadding="1" cellspacing="1" class="defender">
|
||||
<thead>
|
||||
<tr>
|
||||
<td class="role">Defender</th>
|
||||
<td colspan="10"><?php if($targettribe=='5'){ echo $defuser_url." from the village ".$deffrom_url; } else { echo"Reinforcement"; } ?></td>
|
||||
</tr></thead>
|
||||
<tbody class="units">
|
||||
<tr>
|
||||
<td> </td>
|
||||
|
||||
|
||||
<?php
|
||||
for($i=$start;$i<=($start+9);$i++) {
|
||||
echo "<td><img src=\"img/x.gif\" class=\"unit u$i\" title=\"".$technology->getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" /></td>";
|
||||
}
|
||||
echo "</tr><tr><th>Troops</th>";
|
||||
for($i=119;$i<=128;$i++) {
|
||||
if($dataarray[$i] == "?") {
|
||||
echo "<td class=\"none\">?</td>";
|
||||
}
|
||||
else {
|
||||
echo "<td class=\"none\">?</td>";
|
||||
}
|
||||
}
|
||||
echo "<tr><th>Casualties</th>";
|
||||
for($i=129;$i<=138;$i++) {
|
||||
if($dataarray[$i] == "?") {
|
||||
echo "<td class=\"none\">?</td>";
|
||||
}
|
||||
else {
|
||||
echo "<td class=\"none\">?</td>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tr></tbody></table>
|
||||
|
||||
<?php } ?>
|
||||
</td></tr></tbody></table>
|
||||
</td></tr></tbody></table>
|
||||
Reference in New Issue
Block a user