Bladeren bron

Suppression avant restructuration

klapczynski 6 jaren geleden
bovenliggende
commit
dfa5f4d53c
16 gewijzigde bestanden met toevoegingen van 0 en 629 verwijderingen
  1. 0 2
      README.md
  2. 0 12
      TODO.md
  3. 0 16
      css/style.css
  4. 0 31
      css/styleacc.css
  5. 0 14
      html/index.html
  6. 0 41
      html/jeu.html
  7. 0 11
      html/tuto.html
  8. 0 37
      js/eventCTRL.js
  9. 0 107
      js/events.js
  10. 0 56
      js/indicatorCTRL.js
  11. 0 58
      js/laws.js
  12. 0 131
      js/lawsCTRL.js
  13. 0 20
      js/main.js
  14. 0 59
      js/optionsCTRL.js
  15. 0 6
      js/start.js
  16. 0 28
      js/turn.js

+ 0 - 2
README.md

@@ -1,2 +0,0 @@
-# ECR19-T3-E
-

+ 0 - 12
TODO.md

@@ -1,12 +0,0 @@
-# Decomposition des fichiers js
-+ main.js : lancement du jeu
-+ utils.js : fonctions utilitaires
-+ laws.js : lois
-+ events.js : evenements
-+ interface.js : mises a jour de l'interface
-
-# Creation de dossiers 
-+ HTML
-+ JS
-+ CSS
-+ Ressources (images, etc)

+ 0 - 16
css/style.css

@@ -1,16 +0,0 @@
-body {
-	display: flex;
-}
-
-.flexRow {
-	display: flex;
-	flex-direction: row;
-}
-
-div {
-	border: solid 1px red;
-}
-
-.indicator {
-	margin-right: 5rem;
-}

+ 0 - 31
css/styleacc.css

@@ -1,31 +0,0 @@
-*{
-    margin: 0;
-    padding: 0;
-}
-
-div
-{
-    display: flex;
-    flex-direction: column;
-    border: solid;
-    width: 50%;
-    height: 200px;
-    border-width: thin;
-    box-sizing: border-box;
-    justify-content: center;
-    align-items: center;
-
-    position: absolute;
-    top: 0;
-    bottom: 0;
-    left: 0;
-    right: 0;
-    margin: auto;
-}
-button
-{
-    width: 8em;
-    margin: 2em;
-    background-color: aquamarine;
-    border-color: black;
-}

+ 0 - 14
html/index.html

@@ -1,14 +0,0 @@
-<!DOCTYPE html>
-<html>
-    <head>
-        <title>Accueil</title>
-        <link rel="stylesheet" type="text/css" href="../css/styleacc.css">
-    </head>
-
-    <body>
-        <div>
-             <button onclick="location.href = 'jeu.html';">Nouvelle partie</button>
-             <button onclick="location.href = 'tuto.html';">Tutoriel</button>
-        </div>
-    </body>
-</html>

+ 0 - 41
html/jeu.html

@@ -1,41 +0,0 @@
-<!DOCTYPE html>
-<html lang="fr">
-  <head>
-    <meta charset="utf-8">
-    <title>Home</title>
-    <link rel="stylesheet" type="text/css" href="../css/style.css">
-  </head>
-  <body>
-
-    <div id="indicator">
-
-    </div>
-
-    <div id="main">
-
-      <div id="event">
-
-      </div>
-
-      <div id="options">
-
-      </div>
-
-    </div>
-
-    <div id="listLaws">
-
-    </div>
-
-  </body>
-</html>
-
-<script type="text/javascript" src="../js/main.js"></script>
-<script type="text/javascript" src="../js/laws.js"></script>
-<script type="text/javascript" src="../js/lawsCTRL.js"></script>
-<script type="text/javascript" src="../js/optionsCTRL.js"></script>
-<script type="text/javascript" src="../js/indicatorCTRL.js"></script>
-<script type="text/javascript" src="../js/events.js"></script>
-<script type="text/javascript" src="../js/eventCTRL.js"></script>
-<script type="text/javascript" src="../js/turn.js"></script>
-<script type="text/javascript" src="../js/start.js"></script>

+ 0 - 11
html/tuto.html

@@ -1,11 +0,0 @@
-<!DOCTYPE html>
-    <html>
-        <head>
-            <title>Tutoriel</title>
-            <link rel="stylesheet" type="text/css" href="styletuto.css">
-        </head>
-
-        <body>
-            <h1>A faire...</h1>
-        </body>
-    </html>

+ 0 - 37
js/eventCTRL.js

@@ -1,37 +0,0 @@
-
-
-/* Fonction qui prend un event au hazard */
-function randEvent(){
-  let found = false;
-  let id = -1;
-  if (randInt(0, 1) == 0) {
-    while (!found) {
-      if (usedEvents.length >= events.length) {
-        break;
-      }
-      id = randInt(0, events.length - 1);
-      found = true;
-      for (var i = 0; i < usedEvents.length; i++) {
-        if (usedEvents[i] == id) {
-            found = false;
-        }
-      }
-    }
-  }
-  console.log(id);
-  return id;
-}
-
-/* fonction qui génère l'HTML pour un evenement */
-
-function displayEvent(eventID) {
-  document.querySelector("#event").innerHTML = genEvent(eventID);
-}
-
-function genNoEvent() {
-  document.querySelector("#event").innerHTML = "Pas d'evenement";
-}
-
-function genEvent(eventID) {
-  return '<p>' + events[eventID].nom + '</p><p>' + events[eventID].description + "</p>";
-}

+ 0 - 107
js/events.js

@@ -1,107 +0,0 @@
-const events = [
-    {
-        nom : "Tremblement de terre",
-        description : "Un tremblement de terre vient de surgir, et beacoup des paysans se retrouvent sans toit sur leur têtes.",
-        lois : [
-            {
-                nom: "Recueil par les nobles",
-                descriptions: [
-                    "Les seigneurs ont pour obligation de recueillir dans leur château au moins le tiers le plus touché",
-                    "Les seigneurs ont pour obligation de recueillir dans leur château au moins la moitiée  la plus touchée",
-                    "Les seigneurs doivent recueillir l'ensemble de leurs paysans affectés"
-                ],
-                effets: {cri: 0, rel: 0, eco: 0, nob: -5, peu: 8},
-                niveau: 0
-            },
-            {
-                nom: "Recueil par l'église",
-                descriptions: [
-                    "L'église a pour obligation de recueillir au moins le tiers des fidèles les plus touché",
-                    "L'église a pour obligation de recueillir au moins la moitié des fidèles les plus touché",
-                    "L'église a pour obligation de recueillir la totalité des fidèles "
-                ],
-                effets: {cri: 0, rel: -3, eco: 0, nob: 0, peu: 4},
-                niveau: 0
-            }
-        ]
-    },
-    {
-        nom : "Annonce du pape",
-        description : "Le pape vient de déclarer que les criminels devaient être punis moins fortemment, en tant qu'enfants du seigneur.",
-        lois : [
-            {
-                nom: "Baisse des sentences criminelles",
-                descriptions: [
-                    "La peine de mort est réservée aux assassins.",
-                    "Les prisons sont financés par un nouvel impôt.",
-                    "Plus aucun criminel n'est puni, ils doivent seulement se repentir devant dieu."
-                ],
-                effets: {cri: 10, rel: 5, eco: -5, nob: -5, peu: -3},
-                niveau: 0
-            },
-            {
-                nom: "Transfert des criminels au vatican",
-                descriptions: [
-                    "Un centième des criminels sont désormais evoyés directement au pape.",
-                    "Un dixieme des criminels sont désormais evoyés directement au pape.",
-                    "La moitié des criminels sont désormais evoyés directement au pape.",
-                ],
-                effets: {cri: -10, rel: -3, eco: -3, nob: 2, peu: 4},
-                niveau: 0
-            }
-        ]
-    },
-    {
-        nom : "Famine",
-        description : "Les récoltes ont été pitoyables. Votre peuple se meurt de faim.",
-        lois : [
-            {
-                nom: "Baisse de la dime du clergé",
-                descriptions: [
-                    "La part de la dime réservée au clergé baisse d'un tiers.",
-                    "La part de la dime réservée au clergé baisse d'un quart.",
-                    "La part de la dime réservée au clergé baisse de moitié.",
-                ],
-                effets: {cri: 0, rel: -5, eco: 5, nob: 3, peu: 13},
-                niveau: 0
-            },
-            {
-                nom: "Baisse de la dime de la noblesse",
-                descriptions: [
-                    "La part de la dime réservée à la noblesse baisse d'un tiers.",
-                    "La part de la dime réservée à la noblesse baisse d'un quart.",
-                    "La part de la dime réservée à la noblesse baisse de moitié.",
-                ],
-                effets: {cri: 0, rel: 3, eco: 5, nob: -5, peu: 13},
-                niveau: 0
-            }
-        ]
-    },
-    {
-        nom : "Epidemie",
-        description : "Une épidémie d'une maladie inconnue s'est déclarée. Les victimes se font déjà nombreuses.",
-        lois : [
-            {
-                nom: "Loi anti importations",
-                descriptions: [
-                    "Les impots sur les importations sont augmentés de 10%",
-                    "Les impots sur les importations sont augmentés de 20%",
-                    "Les impots sur les importations sont augmentés de 30%"
-                ],
-                effets: {cri: 0, rel: -5, eco: 5, nob: 3, peu: 13},
-                niveau: 0
-            },
-            {
-                nom: "Lois sur l'hygiène",
-                descriptions: [
-                    "Contrôles sanitaires recommandés",
-                    "Contrôles sanitaires renforcés",
-                    "Contrôles sanitaires obligatoires"
-
-                ],
-                effets: {cri: 0, rel: 3, eco: 5, nob: -5, peu: 13},
-                niveau: 0
-            }
-        ]
-    }
-]

+ 0 - 56
js/indicatorCTRL.js

@@ -1,56 +0,0 @@
-/* indicator table */
-
-var tableIndicators = [["Criminalité",0],["Religion",0],["Economie",0],["Noblesse",0],["Peuple",0]];
-
-var currentTurn = 0;
-
-/*  */
-
-function genAllIndicators() {
-  let element = document.querySelector("#indicator");
-  element.innerHTML = genTurn() + "<div>" + genListeIndicators() + "</div>";
-  }
-
-/* tour de jeu actuel */
-
-function genTurn() {
-  return '<div><p>Tour : </p><p>' + currentTurn + "</p></div>";
-  }
-
-/* indicator */
-
-function genListeIndicators() {
-  let res = "";
-  for (var i = 0; i < tableIndicators.length; i++) {
-      res = res + genIndicator(i);
-    }
-  return res;
-  }
-
-function genIndicator(i) {
-  return '<div><p>' + tableIndicators[i][0] + ' : </p><p>' + tableIndicators[i][1] + "</p></div>";
-  }
-
-function updateIndicatorsAddLaws(law) {
-  tableIndicators[0][1] = tableIndicators[0][1] + law.effets.cri;
-  tableIndicators[1][1] = tableIndicators[1][1] + law.effets.rel;
-  tableIndicators[2][1] = tableIndicators[2][1] + law.effets.eco;
-  tableIndicators[3][1] = tableIndicators[3][1] + law.effets.nob;
-  tableIndicators[4][1] = tableIndicators[4][1] + law.effets.peu;
-}
-
-function updateIndicatorsRemoveLaws(law) {
-  tableIndicators[0][1] = tableIndicators[0][1] - law.effets.cri;
-  tableIndicators[1][1] = tableIndicators[1][1] - law.effets.rel;
-  tableIndicators[2][1] = tableIndicators[2][1] - law.effets.eco;
-  tableIndicators[3][1] = tableIndicators[3][1] - law.effets.nob;
-  tableIndicators[4][1] = tableIndicators[4][1] - law.effets.peu;
-}
-
-function updateIndicatorsUpgradeLaws(law) {
-  tableIndicators[0][1] = tableIndicators[0][1] + law.effets.cri;
-  tableIndicators[1][1] = tableIndicators[1][1] + law.effets.rel;
-  tableIndicators[2][1] = tableIndicators[2][1] + law.effets.eco;
-  tableIndicators[3][1] = tableIndicators[3][1] + law.effets.nob;
-  tableIndicators[4][1] = tableIndicators[4][1] + law.effets.peu;
-}

+ 0 - 58
js/laws.js

@@ -1,58 +0,0 @@
-const laws = [
-    {
-        "id": 0,
-        "nom": "Loi financement culte",
-        "descriptions": [
-            "Les lieux de culte sont financés à 1/3 par l'Etat",
-            "Les lieux de culte sont financés à moitié par l'Etat",
-            "Les lieux de culte sont entièrement financés par l'Etat"
-        ],
-        "effets": {"cri": 0, "rel": 5, "eco": -5, "nob": 0, "peu": 0},
-        "niveau": 0
-    },
-    {
-        "id": 1,
-        "nom": "Impôt sur le blé",
-        "descriptions": [
-            "Taxe de 3%",
-            "Taxe de 6%",
-            "Taxe de 9%"
-        ],
-        "effets": {"cri": 1, "rel": 0, "eco": 3, "nob": 1, "peu": -2},
-        "niveau": 0
-    },
-    {
-        "id": 2,
-        "nom": "Impôt sur le titre",
-        "descriptions": [
-            "Les nobles paient 3% d'impôts",
-            "Les nobles paient 6% d'impôts",
-            "Les nobles paient 9% d'impôts"
-
-        ],
-        "effets": {"cri":0, "rel": 0, "eco": 3, "nob": -2, "peu": 1},
-        "niveau": 0
-    },
-    {
-        "id": 3,
-        "nom": "Liberté d'expression",
-        "descriptions": [
-            "Abolition peine de mort pour les dissidents",
-            "Plus de prison pour les dissidents",
-            "Les gens peuvent dire ce qu'ils veulent"
-        ],
-        "effets": {"cri": -1, "rel": -5, "eco": 0, "nob": 1, "peu": 3},
-        "niveau": 0
-    },
-    {
-        "id": 4,
-        "nom": "Légalisation de la mandragore",
-        "descriptions": [
-            "Dépénalisation de la consommation",
-            "Légalisation de la consommation",
-            "Organisation de la consommation par l'Etat"
-        ],
-        "effets": {"cri": -2, "rel": -2, "eco": 1, "nob": 0, "peu": 1},
-        "niveau": 0
-    }
-]

+ 0 - 131
js/lawsCTRL.js

@@ -1,131 +0,0 @@
-/* c'est la table qui contient toutes les lois choisi par le joueur */
-
-var tableLaws = [];
-
-var tableEventsLaws = [];
-
-
-/* Lister les lois votee */
-
-function genListeTableLaws() {
-  let res = "";
-  for (var i = 0; i < tableLaws.length; i++) {
-    res = res + genTableLaw(tableLaws[i][0].id, tableLaws[i][1]);
-  }
-  return res;
-}
-
-function genTableLaw(lawID, lawLevel) {
-  return '<div><p>' + laws[lawID].nom + '</p><p>' + laws[lawID].descriptions[lawLevel] + "</p></div>";
-}
-
-function  genTableEventsLaw(eventID, id) {
-  return '<div><p>' + events[eventID].lois[id].nom + '</p><p>' + events[eventID].lois[id].descriptions[0] + "</p></div>";
-}
-
-/* id d'une loi non evenementiel au hazard */
-
-function randLaw(selectedLaws){
-  let found = false;
-  let id;
-  while (!found) {
-    if ((tableLaws.length + selectedLaws.length) >= laws.length) {
-      id = -1;
-      break;
-    }
-    id = randInt(0, laws.length - 1);
-    found = true;
-    for (var i = 0; i < selectedLaws.length; i++) {
-      if (selectedLaws[i].id == id) {
-          found = false;
-      }
-    }
-    for (var i = 0; i < tableLaws.length; i++) {
-      if (tableLaws[i][0].id == id) {
-          found = false;
-      }
-    }
-  }
-  return id;
-}
-
-const numberAddLaws = 3;
-
-function genListeAddLaws() {
-  console.log("genListeAddLaws");
-  let selectedLaws = [];
-  let res = "";
-  for (var i = 0; i < numberAddLaws; i++) {
-    let newLaw = randLaw(selectedLaws);
-    selectedLaws.push(laws[newLaw]);
-    if (newLaw > -1) {
-      res = res + genAddLaw(newLaw);
-    }
-  }
-  return res;
-}
-
-function genAddLaw(id){
-  return "<div onClick=\"addLaw(" + id + ")\"><p>" + laws[id].nom + '</p><p>' + laws[id].descriptions[0] + "</p></div>";
-}
-
-function addLaw(id){
-  tableLaws.unshift([laws[id], 0]);
-  updateIndicatorsAddLaws(laws[id]);
-  turnForward();
-}
-
-/* Ajouter une loi evenementiel */
-
-function genAddEventLaw(eventID, id){
-  return "<div onClick=\"addEventLaw(" + eventID + "," + id + ")\"><p>" + events[eventID].lois[id].nom + '</p><p>' + events[eventID].lois[id].descriptions[0] + "</p></div>";
-}
-
-function addEventLaw(eventID, id){
-  tableEventsLaws.unshift([eventID, id]);
-  updateIndicatorsAddLaws(events[eventID].lois[id]);
-  turnForward();
-}
-/* Supprimer une loi */
-
-function genListeRemoveLaws() {
-  let res = "";
-  for (var i = 0; i < tableLaws.length; i++) {
-    res = res + genRemoveLaw(tableLaws[i][0].id, tableLaws[i][1], i);
-  }
-  return res;
-}
-
-function genRemoveLaw(lawID, lawLevel, num) {
-  return '<div onClick=\"removeLaw('+ num + "," + lawID + ')\"><p>' + laws[lawID].nom + '</p><p>' + laws[lawID].descriptions[lawLevel] + "</p></div>";
-}
-
-function removeLaw(pos, lawID){
-  tableLaws.splice(pos, 1);
-  updateIndicatorsRemoveLaws(laws[lawID]);
-  turnForward()
-}
-
-/* Ameliorer une loi */
-
-function genListeUpgradeLaws() {
-  let res = "";
-  let num = 0;
-  for (var i = 0; i < tableLaws.length; i++) {
-    if (tableLaws[i][1] < 2) {
-      res = res + genUpgradeLaw(tableLaws[i][0].id, tableLaws[i][1], num);
-      num++;
-    }
-  }
-  return res;
-}
-
-function genUpgradeLaw(lawID, lawLevel, num) {
-  return "<div onClick=\"upgradeLaw(" + num + "," + lawID + ")\"><p>" + laws[lawID].nom + '</p><p>' + laws[lawID].descriptions[lawLevel] + "</p></div>";
-}
-
-function upgradeLaw(pos, lawID){
-  tableLaws[pos][1] = tableLaws[pos][1] + 1;
-  updateIndicatorsUpgradeLaws(laws[lawID]);
-  turnForward()
-}

+ 0 - 20
js/main.js

@@ -1,20 +0,0 @@
-/*
- * randInt : obtient un entier aleatoire entre min et max
- */
-function randInt(min, max) {
-    return Math.round(Math.random() * (max - min) ) + min;
-}
-
-function fin(tableIndicators, currentTurn) {
-  if (currentTurn > 10 ) {
-    document.body.innerHTML = '<p>Fin</p><p>Vous avez gagnez</p><a href="jeu.html">Rejouer</a>';
-    return true;
-  }
-  for (var i = 0; i < tableIndicators.length; i++) {
-    if (tableIndicators[i][1] > 100 | tableIndicators[i][1] <= 0) {
-      document.body.innerHTML = '<p>Fin</p><p>Vous avez Perdu</p><a href="jeu.html">Rejouer</a>';
-      return true;
-    }
-  }
-  return false;
-}

+ 0 - 59
js/optionsCTRL.js

@@ -1,59 +0,0 @@
-var tableOptions = [["Ajouter une nouvelle loi", false],["Améliorer une loi", false],["Supprimer une loi", false]];
-
-function chooseOption(id) {
-  let listLaws = document.querySelector("#listLaws");
-  listLaws.innerHTML = genListeTableLaws();
-  switch (id) {
-    case 0:
-      listLaws.innerHTML = genListeAddLaws();
-      break;
-    case 1:
-      listLaws.innerHTML = genListeUpgradeLaws();
-      break;
-    case 2:
-      listLaws.innerHTML = genListeRemoveLaws();
-      break;
-    default:
-      listLaws.innerHTML = genListeTableLaws();
-  }
-  enableOption(id);
-}
-
-function genListeOptions(newEventId) {
-  console.log(newEventId);
-  let element = document.querySelector("#options");
-  let res = "";
-  if (newEventId == -1) {
-    for (var i = 0; i < tableOptions.length; i++) {
-        res = res + genOption(i);
-      }
-    element.innerHTML = res;
-    console.log(newEventId);
-  }
-  else {
-    console.log("ca marche2");
-    element.innerHTML = genAddEventLaw(newEventId, 0) + genAddEventLaw(newEventId, 1);
-  }
-}
-
-function enableOption(id) {
-  for (var i = 0; i < tableOptions.length; i++) {
-    if (i == id) {
-      tableOptions[i][1] = true;
-    }
-    else {
-      tableOptions[i][1] = false;
-    }
-  }
-  genListeOptions();
-}
-
-function resetOptions() {
-  for (var i = 0; i < tableOptions.length; i++) {
-    tableOptions[i][1] = false;
-  }
-}
-
-function genOption(id, newEventId) {
-  return "<p onClick=\"chooseOption(" + id + ")\">" + tableOptions[id][0] + "</p>";
-}

+ 0 - 6
js/start.js

@@ -1,6 +0,0 @@
-tableIndicators[0][1] = 30;
-tableIndicators[1][1] = 30;
-tableIndicators[2][1] = 30;
-tableIndicators[3][1] = 30;
-tableIndicators[4][1] = 30;
-turnForward();

+ 0 - 28
js/turn.js

@@ -1,28 +0,0 @@
-/* liste des evenement deja produits */
-
-var usedEvents = [];
-
-/* fonction qui lance un tour */
-
-function turnForward() {
-  let isFin = fin(tableIndicators, currentTurn);
-  if (!isFin) {
-    let newEventId = randEvent();
-    if (newEventId == -1) {
-        genNoEvent();
-        // generation d'une simple liste des lois
-        document.querySelector("#listLaws").innerHTML = genListeTableLaws();
-    }
-    else {
-        console.log("test");
-        document.querySelector("#listLaws").innerHTML = "";
-        displayEvent(newEventId);
-        usedEvents.unshift(newEventId);
-    }
-    genAllIndicators();
-    resetOptions();
-    genListeOptions(newEventId);
-    currentTurn = currentTurn + 1;
-
-  }
-}