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

Avaliable buldings to construct #512

Closed eliopinho closed 5 years ago

eliopinho commented 6 years ago

@iopietro for example i already have a market and no granary (destroyed by catapults) in construction list shows the market..

captura de ecra 2018-04-05 as 00 14 33 captura de ecra 2018-04-05 as 00 14 44

iopietro commented 6 years ago

That's another bug, i'll look into it.

iopietro commented 6 years ago

It should be fixed, shouldn't it?

velhbxtyrj commented 6 years ago

I noticed one problem. I have not built Grain Mill although all the conditions for this have been met and it is displayed in "avaliable". Accordingly, all conditions are met for the construction of Bakery. And now the Bakery are displayed in "more", maybe Bakery should be displayed in "soon"? It turns out that I had to fulfill only one condition for the construction of Bakery, this is to build Grain Mill. This is certainly not critical :) default

iopietro commented 6 years ago

@velhbxtyrj It should be fixed in a067344e03fd426a04ce58ff622f704b16af36ea.

velhbxtyrj commented 6 years ago

If build Grain Mill on level 1, then the bakery is displayed in "soon". By code, this works correctly. But if we not built Grain Mill then bakery is displayed in "more".

This is displayed in the "soon" if set $grainmill >= 0. I'm not sure if it will be right :)

iopietro commented 6 years ago

I forgotten a little thing, it should be fixed in 00d5021.

Now, if you meet at least one prerequisite, the Bakery will show in the "Soon" building list.

The three prerequisites are: Grain Mill from level 1 to level 5, Cropland from level 5 to level 10, Main Building from level 2 to level 5.

velhbxtyrj commented 6 years ago

This needs to be reviewed carefully. Tomorrow I will study it. I just noticed another oddity. If the residence is established in the village and I am removing the main building on level 3 from level 20, then the palace appears in the "soon". I think it is necessary to relate two different conditions. For example, that the building would appear "soon" if we have 3 conditions and two of them are fulfilled. In this case, the main building should go from level 2 to level 20. It should be the same with cropland.

iopietro commented 6 years ago

Yeah, you're right, the problem is related to nearly all buildings in the "Soon" and "Show more" list.

velhbxtyrj commented 6 years ago

Maybe it should be done in this form:

if($bakery == 0 && $grainmill >= 1 && $cropland >= 5 || $bakery == 0 && $cropland >= 5 && $mainbuilding >= 2 || $bakery == 0 && $mainbuilding >= 2 && $grainmill >= 1) {
     include("soon/bakery.tpl");
 }
TerraSkye commented 6 years ago

I thinl it should be refactored and taken these conditions in account.

The amount of different buildings thst have to been build before. And the total of levels that other buildings need. And then sort all the buildings accordingly. That way you always have the correct displayment

iopietro commented 6 years ago

@velhbxtyrj, Ok, i'll code it in the game. @TerraSkye, This can be an idea, but someone should do a complete list with all the conditions.

velhbxtyrj commented 6 years ago

I could try it if you say in what form it should be.

iopietro commented 6 years ago

A building is shown in "Sho soon" if the sum of the actual required buildings level is greater than 45/50% of the total sum of required buildings level for building that building.

A building is shown in "Show more" if the sum of the actual required buildings level is greater than 45/50% of the total sum of required buildings level for building that building.

For example:

I've a level 2 Barracks and a level 1 Main Building, to build the Academy i need a level 3 Barracks and a level 3 Main Building, so it will be shown in "Show Soon" because the sum of the needed levels is 6, but the sum of the actual levels is 3 --> I've exactly 50% of the required levels.

Let me know if you like it.

velhbxtyrj commented 6 years ago

I think it requires a deeper logic.

For example:

I have the Main Building of the 3rd level to build the Academy, I need the 3rd level barracks and the Main building of the 3rd level, so it will be shown in the "soon" because the sum of the required levels is 6, but the sum of the actual levels - 3 -> I have exactly 50% of the required levels.

We can build 50% of the total amount of two buildings to fulfill this condition. In the same way, we can build one single building requirement completely and this will also be 50% of the two buildings.

Sorry for paraphrasing your expression :)

iopietro commented 6 years ago

Ok, i agree with you, i like your algorithm :)!