iopietro / Travianz-Legacy

Join our Discord Server: https://discordapp.com/invite/9fbJKP9 | New repo: https://github.com/iopietro/Travianz
GNU General Public License v3.0
160 stars 94 forks source link

Implementation of Newsbox 2 with new information #541

Closed velhbxtyrj closed 6 years ago

velhbxtyrj commented 6 years ago

I do not know how true this is, but I tried to make it real.

The code itself:

<h5><img src="img/en/t2/newsbox2.gif" alt="newsbox 2"></h5>
<div class="news">
<table width="100%">
<tr>
<td><b>Natars spawn</b></td>
<td><b>: <font color="Red"><?php
    $time = strtotime(START_DATE); // Date of server installation (the countdown for the appearance of Natars begins)
    $interval = NATARS_SPAWN_TIME * 24 * 3600; // The number of seconds in the number of days that is set for the appearance of Natars
    $time += $interval;
    echo date('m/d/Y', $time); ?></font></b></td>
</tr>
<tr>
<td><b>WW spawn</b></td>
<td><b>: <font color="Red"><?php
    $time = strtotime(START_DATE); // Date of server installation (the countdown for the appearance of Natars begins)
    $interval = NATARS_WW_SPAWN_TIME * 24 * 3600; // The number of seconds in the number of days that is set for the appearance of WW village
    $time += $interval;
    echo date('m/d/Y', $time); ?></font></b></td>
</tr>
<tr>
<td><b>WW Plan spawn</b></td>
<td><b>: <font color="Red"><?php
    $time = strtotime(START_DATE); // Date of server installation (the countdown for the appearance of Natars begins)
    $interval = NATARS_WW_BUILDING_PLAN_SPAWN_TIME * 24 * 3600; // The number of seconds in the number of days that is set for the appearance of Ancient Construction Plan
    $time += $interval;
    echo date('m/d/Y', $time); ?></font></b></td>
</tr>
</table>
</div>

If it looks good then I'll be happy :) Actually, as always, express their thoughts :)

default

ZZJHONS commented 6 years ago

Isn't it better D, M, Y? It's more international I think

El lun., 14 may. 2018 19:47, Vladyslav notifications@github.com escribió:

I do not know how true this is, but I tried to make it real.

The code itself:

newsbox 2
Natars spawn :
WW spawn :
WW Plan spawn :

If it looks good then I'll be happy :) Actually, as always, express their thoughts :)

[image: default] https://user-images.githubusercontent.com/21306412/40013892-95618436-57b7-11e8-8114-aa10c2fba1c7.jpg

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Shadowss/TravianZ/issues/541, or mute the thread https://github.com/notifications/unsubscribe-auth/ABA5yKf2Ng66h2yDcmSaBC9sTF3d-ZhEks5tycNHgaJpZM4T-Os7 .

velhbxtyrj commented 6 years ago

I adjusted this data to the output that is used in the game. You can see it in Newbox 1 - Server Start. But I completely agree with you.

Shadowss commented 6 years ago

Looks awsome you can implement in code

iopietro commented 6 years ago

I agree with Shadowss, you can implement it!

velhbxtyrj commented 6 years ago

Implemented in https://github.com/Shadowss/TravianZ/commit/fde8bb1371137c47a066a5f16d62d704c6135399

velhbxtyrj commented 6 years ago

@iopietro Please check this code. It works but I'm not sure if it's done correctly. Slightly modified to output information. If something appeared in the world, then instead of the date information is displayed: In World.

<h5><img src="img/en/t2/newsbox2.gif" alt="newsbox 2"></h5>
<div class="news">
<table width="100%">
<tr>
<td><b>Natars spawn</b></td>
<td><b>: <font color="Red"><?php
    if($database->areArtifactsSpawned()) {
        echo 'In World';
    } else {
        $time = strtotime(START_DATE); // Date of server installation (the countdown for the appearance of Natars begins)
        $interval = NATARS_SPAWN_TIME * 86400; // The number of seconds in the number of days that is set for the appearance of Natars
        $time += $interval;
        echo date('m/d/Y', $time);
    }
    ?></font></b></td>
</tr>
<tr>
<td><b>WW spawn</b></td>
<td><b>: <font color="Red"><?php
    if($database->areWWVillagesSpawned()) {
        echo 'In World';
    } else {
        $time = strtotime(START_DATE); // Date of server installation (the countdown for the appearance of Natars begins)
        $interval = NATARS_WW_SPAWN_TIME * 86400; // The number of seconds in the number of days that is set for the appearance of WW village
        $time += $interval;
        echo date('m/d/Y', $time);
    }
    ?></font></b></td>
</tr>
<tr>
<td><b>WW Plan spawn</b></td>
<td><b>: <font color="Red"><?php
    if($database->areArtifactsSpawned(true)) {
        echo 'In World';
    } else {
        $time = strtotime(START_DATE); // Date of server installation (the countdown for the appearance of Natars begins)
        $interval = NATARS_WW_BUILDING_PLAN_SPAWN_TIME * 86400; // The number of seconds in the number of days that is set for the appearance of Ancient Construction Plan
        $time += $interval;
        echo date('m/d/Y', $time);
    }
    ?></font></b></td>
</tr>
</table>
</div>

default

Shadowss commented 6 years ago

Maybe is better to put Already in Game or In Game or Already released

It`s just a suggestion

velhbxtyrj commented 6 years ago

Yes you are right. But rewriting two words is not such a big problem. And most importantly, that it would not be a long expression, or then the tex will go beyond the frame.

default 1 2 3

velhbxtyrj commented 6 years ago

Another display of this list:

default 1 2 3

And the code itself:

<h5><img src="img/en/t2/newsbox2.gif" alt="newsbox 2"></h5>
<div class="news">
<table width="100%">
<tr>
<td><b><?php
    if($database->areArtifactsSpawned()) {
        echo 'Natars Tribe';
    } else {
        echo 'Natars spawn';
    }
    ?></b></td>
<td><b>: <font color="Red"><?php
    if($database->areArtifactsSpawned()) {
        echo 'Released';
    } else {
        $time = strtotime(START_DATE); // Date of server installation (the countdown for the appearance of Natars begins)
        $interval = NATARS_SPAWN_TIME * 86400; // The number of seconds in the number of days that is set for the appearance of Natars
        $time += $interval;
        echo date('m/d/Y', $time);
    }
    ?></font></b></td>
</tr>
<tr>
<td><b><?php
    if($database->areWWVillagesSpawned()) {
        echo 'WW Village';
    } else {
        echo 'WW spawn';
    }
    ?></b></td>
<td><b>: <font color="Red"><?php
    if($database->areWWVillagesSpawned()) {
        echo 'Released';
    } else {
        $time = strtotime(START_DATE); // Date of server installation (the countdown for the appearance of Natars begins)
        $interval = NATARS_WW_SPAWN_TIME * 86400; // The number of seconds in the number of days that is set for the appearance of WW village
        $time += $interval;
        echo date('m/d/Y', $time);
    }
    ?></font></b></td>
</tr>
<tr>
<td><b><?php
    if($database->areArtifactsSpawned(true)) {
        echo 'Construction plan';
    } else {
        echo 'WW Plan spawn';
    }
    ?></b></td>
<td><b>: <font color="Red"><?php
    if($database->areArtifactsSpawned(true)) {
        echo 'Released';
    } else {
        $time = strtotime(START_DATE); // Date of server installation (the countdown for the appearance of Natars begins)
        $interval = NATARS_WW_BUILDING_PLAN_SPAWN_TIME * 86400; // The number of seconds in the number of days that is set for the appearance of Ancient Construction Plan
        $time += $interval;
        echo date('m/d/Y', $time);
    }
    ?></font></b></td>
</tr>
</table>
</div>
iopietro commented 6 years ago

Your code is good, I reduced it a little bit:

<?php 
$textArray = ["Natars Spawn", "WW Spawn", "WW Plan Spawn"];
$spawnTimeArray = [NATARS_SPAWN_TIME, NATARS_WW_SPAWN_TIME, NATARS_WW_BUILDING_PLAN_SPAWN_TIME];
$areSpawned = [$database->areArtifactsSpawned(), $database->areWWVillagesSpawned(), $database->areArtifactsSpawned(true)];

?>
<h5><img src="img/en/t2/newsbox2.gif" alt="newsbox 2"></h5>
<div class="news">
<table width="100%">
<?php for($i = 0; $i < count($spawnTimeArray); $i++){ ?>
<tr>
<td><b><?php echo $textArray[$i]; ?></b></td>
<td><b>: <font color="Red"><?php
    if($areSpawned[$i]) echo "Released";     
    else 
    {
        $time = strtotime(START_DATE); // Date of server installation (the countdown for the appearance of Natars begins)
        $interval = $spawnTimeArray[$i] * 86400; // The number of seconds in the number of days that is set for the appearance of Natars
        echo date('m/d/Y', $time + $interval);
    }
    ?></font></b></td>
</tr>
<?php } ?>
</table>
</div>
Shadowss commented 6 years ago

@velhbxtyrj : you can implement it !

velhbxtyrj commented 6 years ago

I'll do it in the evening, I want to work with this code a little. And now I'm already at work (

velhbxtyrj commented 6 years ago

And if there is such a conclusion? I added another array and made a definition of its output. It will not be cumbersome and superfluous in this code?

<?php
$textArray = ["Natars Spawn", "WW Spawn", "WW Plan Spawn"];
$newTextArray = ["Natars Tribe", "WW Village", "Construction Plan"];
$spawnTimeArray = [NATARS_SPAWN_TIME, NATARS_WW_SPAWN_TIME, NATARS_WW_BUILDING_PLAN_SPAWN_TIME];
$areSpawned = [$database->areArtifactsSpawned(), $database->areWWVillagesSpawned(), $database->areArtifactsSpawned(true)];

?>
<h5><img src="img/en/t2/newsbox2.gif" alt="newsbox 2"></h5>
<div class="news">
<table width="100%">
<?php for($i = 0; $i < count($spawnTimeArray); $i++){ ?>
<tr>
<td><b>
<?php
    if($areSpawned[$i]) echo $newTextArray[$i];
    else echo $textArray[$i];
    ?></b></td>
<td><b>: <font color="Red"><?php
    if($areSpawned[$i]) echo "Released";
    else
    {
        $time = strtotime(START_DATE); // Date of server started (the countdown for the appearance of Natars begins)
        $interval = $spawnTimeArray[$i] * 86400; // The number of seconds in the number of days that is set for the appearance of Natars
        echo date('d.m.Y', $time + $interval);
    }
    ?></font></b></td>
</tr>
<?php } ?>
</table>
</div>
iopietro commented 6 years ago

I think that the code is pretty clean and clear, also it's very easy to edit/maintain (I edited just two little things), for me, you can implement it.

velhbxtyrj commented 6 years ago

I saw what it was changed. Implemented in https://github.com/Shadowss/TravianZ/commit/25b52f6b1ad6f9b63813085ac47844803132b63b I decided to make dates more international. And I think that it needs to be changed throughout the code, where they will meet.

iopietro commented 6 years ago

Yeah, D/M/Y is more understandable than M/D/Y.

eliopinho commented 6 years ago

@iopietro can you implement automatic add X amount of gold weekly at same time of the medals!? @velhbxtyrj if @iopietro implement that function can you add to newsbox 2 if that function are active!?

porpose of that is, if you want play with friends a fair game no one have acess to admin panel.. :+1:

iopietro commented 6 years ago

Yes, but you should propose it as an enhancement (by creating a new issue), so I'll do it after the refactor of the game.

velhbxtyrj commented 6 years ago

@eliopinho You already made such an offer right here #511

velhbxtyrj commented 6 years ago

In general, it would be great to make these newsboxes customizable during installation and from the admin panel. What would every administrator look at the output of the information he needed. Do this either by writing certain tags or by checkbox.

iopietro commented 6 years ago

@eliopinho I forgot that you already opened an issue about that enhancement, lol. @velhbxtyrj Yeah, that's a nice feature too.

eliopinho commented 6 years ago

@velhbxtyrj love your idea!! @iopietro yes i know i already propose that, i spoke again because the "notification on a newsbox" :+1:

velhbxtyrj commented 6 years ago

@iopietro Since I mentioned here about changing the display of dates, for example, changing this: https://github.com/Shadowss/TravianZ/blob/37e70a165b78afe283ce015c9a593032cfb33097/GameEngine/Automation.php#L4577 on here such code:

$stime = strtotime(START_DATE) - strtotime(date('d.m.Y')) + strtotime(START_TIME);

Will this change affect the operation of the code or, for example, on the counting of something in the code. Or is it safe to change the entire code, since it answers only for how the output of dates is displayed?

iopietro commented 6 years ago

I think that if you change strtotime(date('m/d/Y')) to strtotime(date('d.m.Y')) you have to change the date format of "START_DATE" too (to d.m.y).

velhbxtyrj commented 6 years ago

I understand that the start date is here? https://github.com/Shadowss/TravianZ/blob/5ef8a1d8d9664eb0c74d4e978bf8656fd8cd7c04/install/templates/config.tpl#L621

iopietro commented 6 years ago

Yep.

velhbxtyrj commented 6 years ago

@iopietro I like the PHP code and I'm studying it a bit. So I again changed the code of the output of the announcement of the natars. I made the code one line shorter. I made an array in an array and output these arrays when we need it. It works and I hope that this is properly changed.

Here is the slightly modified code:

<?php
$textArray = [["Natars Spawn", "WW Spawn", "WW Plan Spawn"], ["Natars Tribe", "WW Village", "Construction Plan"]];
$spawnTimeArray = [NATARS_SPAWN_TIME, NATARS_WW_SPAWN_TIME, NATARS_WW_BUILDING_PLAN_SPAWN_TIME];
$areSpawned = [$database->areArtifactsSpawned(), $database->areWWVillagesSpawned(), $database->areArtifactsSpawned(true)];

?>
<h5><img src="img/en/t2/newsbox2.gif" alt="newsbox 2"></h5>
<div class="news">
<table width="100%">
<?php for($i = 0; $i < count($spawnTimeArray); $i++){ ?>
<tr>
<td><b>
<?php
    if($areSpawned[$i]) echo $textArray[1][$i];
    else echo $textArray[0][$i];
    ?></b></td>
<td><b>: <font color="Red"><?php
    if($areSpawned[$i]) echo "Released";
    else
    {
        $time = strtotime(START_DATE); // Date of server started (the countdown for the appearance of Natars begins)
        $interval = $spawnTimeArray[$i] * 86400; // The number of seconds in the number of days that is set for the appearance of Natars
        echo date('d.m.Y', $time + $interval);
    }
    ?></font></b></td>
</tr>
<?php } ?>
</table>
</div>
iopietro commented 6 years ago

I love and hate the PHP at the same time, lol. The code is good, so you can implement it.