Explorar el Código

Ajout du code pour le canvas et logique des évènements

Nathanael Klapczynski hace 6 años
padre
commit
7283429a32

+ 2 - 0
README.md

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

+ 12 - 0
TODO.md

@@ -0,0 +1,12 @@
+# 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)

+ 57 - 0
src/control/ctrlEvents.js

@@ -0,0 +1,57 @@
+/*
+possibleEvents : liste des evenements possibles avec leurs ponderations
+      - event : evenement
+      - weight : ponderations
+*/
+
+let possibleEvents = [];
+
+
+function resetPossibleEvents() {
+  possibleEvents = [];
+}
+
+
+function addPossibleEvent(pEvent) {
+  possibleEvents.push(
+    {
+      pEvent : pEvent,
+      weight : getEventWeight(pEvent)
+    }
+  );
+}
+
+// à faire
+function getEventWeight(pEvent) {
+  let weight = 1;
+  return weight;
+}
+
+
+function testPossibleEvent(pEvent) {
+  if (
+    (clergy.wealth <= pEvent.clergy.wealth) &&
+    (clergy.influence <= pEvent.clergy.influence) &&
+    (nobility.wealth <= pEvent.nobility.wealth) &&
+    (nobility.influence <= pEvent.nobility.influence) &&
+    (nobility.army <= pEvent.nobility.army) &&
+    (people.wealth <= pEvent.people.wealth) &&
+    (people.wellBeing <= pEvent.people.wellBeing)
+  ) {
+    return true;
+  }
+  return false;
+}
+
+
+function allPossibleEvents() {
+
+  resetPossibleEvents();
+
+  for (let i = 0; i < events.length; i++) {
+    let currentEvents = events[i];
+    if (testPossibleEvent(currentEvents)) {
+      addPossibleEvents(currentEvents);
+    }
+  }
+}

+ 22 - 0
src/control/ctrlGameLaws.js

@@ -0,0 +1,22 @@
+function addPlayerLaw(pLaw) {
+  playerLaws.push(pLaw);
+}
+
+function removePlayerLaw(pLaw) {
+  for (var i = 0; i < playerLaws.length; i++) {
+    if (playerLaws[i] == pLaw) {
+      playerLaws.splice(i, 1);
+      break;
+    }
+  }
+}
+
+function getPlayerLawsByType(pPlayerLawType) {
+  let playerLawsOfTheType = [];
+  for (var i = 0; i < playerLaws.length; i++) {
+    if (playerLaws[i].type == pPlayerLawType) {
+      playerLawsOfTheType.push(playerLaws[i]);
+    }
+  }
+  return playerLawsOfTheType;
+}

+ 0 - 0
src/control/ctrlIndicators.js


+ 9 - 0
src/control/ctrlLaws.js

@@ -0,0 +1,9 @@
+function getLawsByType(pLawType) {
+  let lawsOfTheType = [];
+  for (var i = 0; i < laws.length; i++) {
+    if (laws[i].type == pLawType) {
+      lawsOfTheType.push(laws[i]);
+    }
+  }
+  return lawsOfTheType;
+}

+ 3 - 0
src/control/round.js

@@ -0,0 +1,3 @@
+function newRound(){
+  
+}

+ 3 - 0
src/control/utils.js

@@ -0,0 +1,3 @@
+function randInt(min, max) {
+  return Math.floor(Math.random() * (max - min + 1) ) + min;
+}

+ 15 - 0
src/model/events.js

@@ -0,0 +1,15 @@
+let events = [
+  {
+    name : "Nom de l'evenement",
+    threshold : {
+      clergy : { wealth : 0, influence : 0 },
+      nobility : { wealth : 0 , influence : 0 , army : 0 },
+      people : { wealth : 0 , wellBeing : 0 }
+    },
+    coefficient : {
+      clergy : { wealth : 0, influence : 0 },
+      nobility : { wealth : 0 , influence : 0 , army : 0 },
+      people : { wealth : 0 , wellBeing : 0 }
+    }
+  },
+]

+ 6 - 0
src/model/game.js

@@ -0,0 +1,6 @@
+let playerTaxes = {
+  clergy : 15,
+  nobility : 25
+}
+
+let playerLaws = [];

+ 39 - 0
src/model/indicators.js

@@ -0,0 +1,39 @@
+// INDICATEURS
+
+/*
+CLERGE :
+  - richesse : relatif a la noblesse et au peuple
+  - influence : relatif a la noblesse
+
+OBJET : { INT: wealth | INT: influence }
+*/
+let clergy = { wealth : 0 , influence : 0 };
+
+
+/*
+NOBLESSE :
+  - richesse : relatif au clerge et au peuple
+  - influence : relatif au clerge
+  - armee : individuel
+
+OBJET : { INT: wealth | INT: influence | INT: army }
+*/
+let nobility = { wealth : 0 , influence : 0 , army : 0 };
+
+
+/*
+PEUPLE :
+  - richesse : relatif a la noblesse et au clerge
+  - bien etre : individuel
+
+OBJET : { INT: wealth | INT: wellBeing }
+*/
+let people = { wealth : 0 , wellBeing : 0 };
+
+
+// Tour de jeu actuel
+let round = 0;
+
+
+// Score actuel
+let score = 0;

+ 14 - 0
src/model/laws.js

@@ -0,0 +1,14 @@
+let lawsTypes = ["nom du type 1","nom du type 2"];
+
+let laws = [
+  {
+    name : "Nom de la loie",
+    type : "nom du type",
+    effect : {
+      clergy : { wealth : 50, influence : 60 },
+      nobility : { wealth : -10 , influence : 33 , army : 69 },
+      people : { wealth : -420 , wellBeing : 1337 }
+    },
+    description : "Description de la loi précise est pédagogique"
+  },
+];

+ 12 - 0
src/view/game.html

@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="fr">
+  <head>
+    <meta charset="utf-8">
+    <title>Tompeur</title>
+  </head>
+  <body>
+    <canvas id="main" width="300" height="300"></canvas>
+  </body>
+  <!-- script load -->
+  <script type="text/javascript" src="../model/javascript.js"></script>
+</html>

+ 14 - 0
src/view/index.html

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