indicatorCTRL.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* indicator table */
  2. var tableIndicators = [["Criminalité",0],["Religion",0],["Economie",0],["Noblesse",0],["Peuple",0]];
  3. var currentTurn = 0;
  4. /* */
  5. function genAllIndicators() {
  6. let element = document.querySelector("#indicator");
  7. element.innerHTML = genTurn() + "<div>" + genListeIndicators() + "</div>";
  8. }
  9. /* tour de jeu actuel */
  10. function genTurn() {
  11. return '<div><p>Tour : </p><p>' + currentTurn + "</p></div>";
  12. }
  13. /* indicator */
  14. function genListeIndicators() {
  15. let res = "";
  16. for (var i = 0; i < tableIndicators.length; i++) {
  17. res = res + genIndicator(i);
  18. }
  19. return res;
  20. }
  21. function genIndicator(i) {
  22. return '<div><p>' + tableIndicators[i][0] + ' : </p><p>' + tableIndicators[i][1] + "</p></div>";
  23. }
  24. function updateIndicatorsAddLaws(law) {
  25. tableIndicators[0][1] = tableIndicators[0][1] + law.effets.cri;
  26. tableIndicators[1][1] = tableIndicators[1][1] + law.effets.rel;
  27. tableIndicators[2][1] = tableIndicators[2][1] + law.effets.eco;
  28. tableIndicators[3][1] = tableIndicators[3][1] + law.effets.nob;
  29. tableIndicators[4][1] = tableIndicators[4][1] + law.effets.peu;
  30. }
  31. function updateIndicatorsRemoveLaws(law) {
  32. tableIndicators[0][1] = tableIndicators[0][1] - law.effets.cri;
  33. tableIndicators[1][1] = tableIndicators[1][1] - law.effets.rel;
  34. tableIndicators[2][1] = tableIndicators[2][1] - law.effets.eco;
  35. tableIndicators[3][1] = tableIndicators[3][1] - law.effets.nob;
  36. tableIndicators[4][1] = tableIndicators[4][1] - law.effets.peu;
  37. }
  38. function updateIndicatorsUpgradeLaws(law) {
  39. tableIndicators[0][1] = tableIndicators[0][1] + law.effets.cri;
  40. tableIndicators[1][1] = tableIndicators[1][1] + law.effets.rel;
  41. tableIndicators[2][1] = tableIndicators[2][1] + law.effets.eco;
  42. tableIndicators[3][1] = tableIndicators[3][1] + law.effets.nob;
  43. tableIndicators[4][1] = tableIndicators[4][1] + law.effets.peu;
  44. }