[TUTO] List of Buildings, research, ... - visible prerequisite

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • [TUTO] List of Buildings, research, ... - visible prerequisite

    Bonjour à tous suite à une demande en mp par zeus je vous mes ici même le code qui vas vous permettre d'avoir vos listes bâtiments, recherches, flottes, défenses et officier totalement visible avec les pré-requis pour les dévérouiller ce qui permet donc de supprimer une page du jeu.

    -------------------------------------------------

    hello to all following a request in pm by zeus I give you here the code which will allow you to have your lists of buildings, research, fleets, defenses and officer totally visible with the prerequisites to unlock them which therefore allows to delete a page from the game.



    Recherche - Search

    PHP Source Code: ShowBuildingPage.class.php

    1. if (!BuildFunctions::isTechnologieAccessible($USER, $PLANET, $Element)) continue;
    suprimer le code - delete the code

    Recherche - Search

    PHP Source Code: ShowBuildingPage.class.php

    1. $costResources = BuildFunctions::getElementPrice($USER, $PLANET, $Element, false, $levelToBuild+1);
    Ajouter avant - Addon after

    PHP Source Code: ShowBuildingPage.class.php

    1. $techListRequiere = BuildFunctions::requirementsList($USER, $PLANET, $Element);
    Recherche - Search

    PHP Source Code: ShowBuildingPage.class.php

    1. 'levelToBuild' => $levelToBuild,
    Ajouter après - Addon brfore

    PHP Source Code: ShowBuildingPage.class.php

    1. 'AllTechList' => $techListRequiere,
    2. 'techacc' => BuildFunctions::isTechnologieAccessible($USER, $PLANET, $Element),
    Recherche - Search

    PHP Source Code: class.BuildFunctions.php

    1. public static function isTechnologieAccessible($USER, $PLANET, $Element)
    2. {
    3. global $requeriments, $resource;
    4. if(!isset($requeriments[$Element]))
    5. return true;
    6. foreach($requeriments[$Element] as $ReqElement => $EleLevel)
    7. {
    8. if (
    9. (isset($USER[$resource[$ReqElement]]) && $USER[$resource[$ReqElement]] < $EleLevel) ||
    10. (isset($PLANET[$resource[$ReqElement]]) && $PLANET[$resource[$ReqElement]] < $EleLevel)
    11. ) {
    12. return false;
    13. }
    14. }
    15. return true;
    16. }
    Display All
    Ajouter après - Addon brfor

    PHP Source Code: class.BuildFunctions.php

    1. /** Ajout pour le [TUTO] Requierements construction */
    2. public static function requirementsList($USER, $PLANET, $Element)
    3. {
    4. global $resource, $requeriments;
    5. $requirementsList = [];
    6. if(isset($requeriments[$Element]))
    7. {
    8. foreach($requeriments[$Element] as $requireID => $RedCount)
    9. {
    10. $requirementsList[$requireID] = [
    11. 'count_level' => (isset($PLANET[$resource[$requireID]]) ? $PLANET[$resource[$requireID]] : $USER[$resource[$requireID]]),
    12. 'count_requiere' => $RedCount
    13. ];
    14. }
    15. }
    16. $techTreeList[$Element] = $requirementsList;
    17. return $techTreeList;
    18. }
    Display All
    Rechercher - Search

    Smarty-Template: page.building.page.tpl

    1. <div class="block_construct_desc">
    2. <div class="block_construct_desc_list">
    3. {foreach $Element.costResources as $RessID => $RessAmount}
    4. <div style="margin-bottom: 10px;" >
    5. <img src="{$dpath}images/{$RessID}.gif" alt=""> <b><span {if $Element.costOverflow[$RessID] == 0}class="res_{$RessID}_text"{/if} style="color:{if $Element.costOverflow[$RessID] == 0}{else}red{/if}">{$RessAmount|number}</span></b>
    6. </div>
    7. {/foreach}
    8. {if !empty($Element.infoEnergy)}
    9. {$LNG.bd_next_level}<br>
    10. {$Element.infoEnergy}<br>
    11. <br>
    12. {/if}
    13. <span style="font-weight: bold;"><i class="fas fa-tachometer-alt" style="font-size: 13px;"></i> {$Element.elementTime|time}</span>
    14. </div>
    15. <div>
    16. {if $Element.maxLevel == $Element.levelToBuild}
    17. <div class="construct_button_lost">
    18. <span style="color:red">{$LNG.bd_maxlevel}</span>
    19. </div>
    20. {elseif ($isBusy.research && ($ID == 6 || $ID == 31)) || ($isBusy.shipyard && ($ID == 15 || $ID == 21))}
    21. <div class="construct_button_lost">
    22. <span style="color:red">{$LNG.bd_working}</span>
    23. </div>
    24. {else}
    25. {if $RoomIsOk}
    26. {if $CanBuildElement && $Element.buyable}
    27. <form action="game.php?page=buildings" method="post" class="build_form">
    28. <input type="hidden" name="cmd" value="insert">
    29. <input type="hidden" name="building" value="{$ID}">
    30. <button type="submit" class="build_submit construct_button">{if $Element.level == 0}{$LNG.bd_build}{else}{$LNG.bd_build_next_level}{$Element.levelToBuild + 1}{/if}</button>
    31. </form>
    32. {else}
    33. <div class="construct_button_lost">
    34. <span style="color:red">{if $Element.level == 0}{$LNG.bd_build}{else}{$LNG.bd_build_next_level}{$Element.levelToBuild + 1}{/if}</span>
    35. </div>
    36. {/if}
    37. {else}
    38. <div class="construct_button_lost">
    39. <span style="color:red">{$LNG.bd_no_more_fields}</span>
    40. </div>
    41. {/if}
    42. {/if}
    43. </div>
    44. </div>
    Display All
    Remplacer par - Replace By

    Smarty-Template: page.building.page.tpl

    1. <!-- Ajout pour le [TUTO] Requierements construction -->
    2. {if !$Element.techacc}
    3. <div class="block_construct_desc">
    4. <div class="block_construct_desc_list" style="min-height: 190px;">
    5. <div class="necccos">Pré-requis :</div>
    6. <div class="require_tech" style="display: flex; flex-direction: row; flex-wrap: warp; justify-content: space-evenly; align-items: center;">
    7. {foreach $Element.AllTechList as $elementID => $requireList}
    8. {foreach $requireList as $requireID => $NeedLevel}
    9. <div class="required_block required_smal_text">
    10. <a href="#" onclick="return Dialog.info({$requireID})" class="tooltip" data-tooltip-content="<span style='color:{if $NeedLevel.count_level < $NeedLevel.count_requiere}red{else}lime{/if};'>{$LNG.tech.$requireID} {$LNG.tt_lvl} {$NeedLevel.count_requiere} ({$NeedLevel.count_level}/{$NeedLevel.count_requiere})</span>">
    11. <img width="50" src="{$dpath}gebaeude/{$requireID}{if $requireID > 600 && $requireID < 700}.jpg{else}.gif{/if}" alt="{$LNG.tech.$requireID}" />
    12. <div class="text" style="color:{if $NeedLevel.count_level < $NeedLevel.count_requiere}red{else}lime{/if}; position: relative; top: -13px; background: #362e2ecc; text-align: center;"><span>{$NeedLevel.count_level}/{$NeedLevel.count_requiere}</span></div></a>
    13. </div>
    14. {/foreach}
    15. {/foreach}
    16. </div>
    17. </div>
    18. </div>
    19. {else}
    20. <div class="block_construct_desc">
    21. <div class="block_construct_desc_list">
    22. {foreach $Element.costResources as $RessID => $RessAmount}
    23. <div style="margin-bottom: 10px;">
    24. <img src="{$dpath}images/{$RessID}.gif" alt=""> <b><span {if $Element.costOverflow[$RessID] == 0}class="res_{$RessID}_text"{/if} style="color:{if $Element.costOverflow[$RessID] == 0}{else}red{/if}">{$RessAmount|number}</span></b>
    25. </div>
    26. {/foreach}
    27. {if !empty($Element.infoEnergy)}
    28. {$LNG.bd_next_level}<br>
    29. {$Element.infoEnergy}<br>
    30. <br>
    31. {/if}
    32. <span style="font-weight: bold;"><i class="fas fa-tachometer-alt" style="font-size: 13px;"></i> {$Element.elementTime|time}</span>
    33. </div>
    34. <div>
    35. {if $Element.maxLevel == $Element.levelToBuild}
    36. <div class="construct_button_lost">
    37. <span style="color:red">{$LNG.bd_maxlevel}</span>
    38. </div>
    39. {elseif ($isBusy.research && ($ID == 6 || $ID == 31)) || ($isBusy.shipyard && ($ID == 15 || $ID == 21))}
    40. <div class="construct_button_lost">
    41. <span style="color:red">{$LNG.bd_working}</span>
    42. </div>
    43. {else}
    44. {if $RoomIsOk}
    45. {if $CanBuildElement && $Element.buyable}
    46. <form action="game.php?page=buildings" method="post" class="build_form">
    47. <input type="hidden" name="cmd" value="insert">
    48. <input type="hidden" name="building" value="{$ID}">
    49. <button type="submit" class="build_submit construct_button">{if $Element.level == 0}{$LNG.bd_build}{else}{$LNG.bd_build_next_level}{$Element.levelToBuild + 1}{/if}</button>
    50. </form>
    51. {else}
    52. <div class="construct_button_lost">
    53. <span style="color:red">{if $Element.level == 0}{$LNG.bd_build}{else}{$LNG.bd_build_next_level}{$Element.levelToBuild + 1}{/if}</span>
    54. </div>
    55. {/if}
    56. {else}
    57. <div class="construct_button_lost">
    58. <span style="color:red">{$LNG.bd_no_more_fields}</span>
    59. </div>
    60. {/if}
    61. {/if}
    62. </div>
    63. </div>
    64. {/if}
    Display All
    Vous devez faire cette opération sur toute vos page faite juste attention au différente variable de la liste

    You must do this operation on all your pages, just pay attention to the different variables in the list

    The post was edited 3 times, last by Danter14 ().

  • Bonjour petite correction niveau design car quand j'ai fait la page flotte et défense les pré-requis dépasser la page, j'ai donc ajouter un flex-wrap: warp; dans le style de la div qui a la class="require_tech".
    Une image était également non afficher les officiers j'ai donc corriger l'extention de l'image : {if $requireID > 600 && $requireID < 700}.jpg{else}.gif{/if}

    Correctif ajouter dans le code disponible.

    Hello, small design level correction because when I made the float and defense page, the prerequisites exceeded the page, so I added a flex-wrap: warp; in the style of the div that has the class="require_tech".
    An image was also not displaying the officers so I corrected the extension of the image: {if $requireID > 600 && $requireID < 700}.jpg{else}.gif{/if}

    Fix add in code available.

    The post was edited 2 times, last by Danter14 ().

  • Zeus wrote:

    So, do these same codes apply to the hangar or do we need to fix the codes?
    They are the same code for all the pages, just a small variable modification for the technology page in php

    Replace $Element by $elementId
  • Zeus wrote:

    your code did not have a picture of the building or the structure, I added it there with a few additions, I edited it with a few touches from the style file
    It all depends on your images if they are in .jpg, .gif, .png ect...
    I did it with the original images, yes a css adjustment is always good to do because some things are different from my code
  • I just want to learn that attack and defense also there are some codes in the research as in build and it gives an error, so I am trying to integrate the codes you gave and all units come out but there are no predictions for production
  • Good for me

    Smarty-Template: page.shipyard.default.tpl

    1. {if !$Element.techacc}
    2. <div class="block_construct_desc">
    3. <div class="block_construct_desc_list" style="min-height: 221px;">
    4. <div class="necccos">Pré-requis :</div>
    5. <div class="require_tech" style="display: flex; flex-direction: row; flex-wrap: wrap; justify-content: space-evenly; align-items: center;">
    6. {foreach $Element.AllTechList as $elementID => $requireList}
    7. {foreach $requireList as $requireID => $NeedLevel}
    8. <div class="required_block required_smal_text">
    9. <a href="#" onclick="return Dialog.info({$requireID})" class="tooltip" data-tooltip-content="<span style='color:{if $NeedLevel.count_level < $NeedLevel.count_requiere}red{else}lime{/if};'>{$LNG.tech.$requireID} {$LNG.tt_lvl} {$NeedLevel.count_requiere} ({$NeedLevel.count_level}/{$NeedLevel.count_requiere})</span>">
    10. <img width="50" src="{$dpath}gebaeude/{$requireID}{if $requireID > 600 && $requireID < 700}.jpg{else}.gif{/if}" alt="{$LNG.tech.$requireID}" />
    11. <div class="text" style="color:{if $NeedLevel.count_level < $NeedLevel.count_requiere}red{else}lime{/if}; position: relative; top: -13px; background: #362e2ecc; text-align: center;"><span>{$NeedLevel.count_level}/{$NeedLevel.count_requiere}</span></div></a>
    12. </div>
    13. {/foreach}
    14. {/foreach}
    15. </div>
    16. </div>
    17. </div>
    18. {else}
    19. <div class="block_construct_desc">
    20. <div class="block_construct_desc_list">
    21. {foreach $Element.costResources as $RessID => $RessAmount}
    22. <div style="margin-bottom: 10px;">
    23. <img src="{$dpath}images/{$RessID}.gif" alt=""> <b><span {if $Element.costOverflow[$RessID] == 0}class="res_{$RessID}_text"{/if} style="color:{if $Element.costOverflow[$RessID] == 0}{else}red{/if}">{$RessAmount|number}</span></b>
    24. </div>
    25. {/foreach}
    26. <div style="margin-bottom: 5px;">
    27. {$LNG.bd_max_ships_long}: <span style="font-weight:700">{$Element.maxBuildable|number}</span>
    28. </div>
    29. <span style="font-weight: bold;"><i class="fas fa-tachometer-alt" style="font-size: 13px;"></i> {$Element.elementTime|time}</span>
    30. </div>
    31. <div>
    32. {if $Element.AlreadyBuild}<span style="color:red">{$LNG.bd_protection_shield_only_one}</span>{elseif $NotBuilding && $Element.buyable}<input style="width: 85%;" type="text" name="fmenge[{$ID}]" id="input_{$ID}" value="0" tabindex="{$smarty.foreach.FleetList.iteration}">
    33. <input style="padding: 8px; margin-left: -10px; border-left: none;" type="button" value="{$LNG.bd_max_ships}" onclick="$('#input_{$ID}').val('{$Element.maxBuildable}')"></p>
    34. {/if}
    35. </div>
    36. {if $NotBuilding}<div style="text-align:center"><input type="submit" value="{$LNG.bd_build_ships}"></div>{/if}
    37. </div>
    38. {/if}
    Display All
  • it is put only on the dwt fleet and defense page

    you changed this line there in the php then which was not necessary

    PHP Source Code

    1. $costResources = BuildFunctions::getElementPrice($USER, $PLANET, $Element);
  • Zeus wrote:

    Hello @Danter14

    I made the predictions for the research and buildings section, but I couldn't make it to the fleet centre, can you help me which code should I change from php?

    techacc code header available
    you speak for the fleet and defense in addition to collum