|
|
@@ -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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|