diff --git a/data/data-monopoly-starwars.json b/data/data-monopoly-starwars.json index 7d2e599..4407064 100644 --- a/data/data-monopoly-starwars.json +++ b/data/data-monopoly-starwars.json @@ -8,7 +8,8 @@ "imgJoueurs":["img/starwars/r2_d2.png","img/starwars/darth_vader.png","img/starwars/jango_fett.png","img/starwars/stormtrooper.png","img/starwars/boba_fett.png","img/starwars/clone_2.png"], "rollColor":"#999999", "depart":200, - "argent":1500 + "argent":1500, + "prison":50 }, "currency":"7", "background-image":"", @@ -51,7 +52,7 @@ {"type": "gare","axe": 1,"pos": 5,"nom": "Super Star destroyer","colors": ["#000000", "#ABABAB"],"prix": 200,"loyers": [25, 50, 100, 200]}, {"type": "chance","axe": 1,"pos": 6}, {"type": "propriete","groupe": "Bleu","axe": 1,"pos": 7,"nom": "Coruscant Jedi Temple","colors": ["#132450", "#808EB0"],"prix": 350,"loyers": [35, 175, 500, 1100, 1300, 1500],"prixMaison": 200}, - {"type": "taxe","axe": 1,"pos": 8,"nom": "Taxe de luxe","prix": 10000}, + {"type": "taxe","axe": 1,"pos": 8,"nom": "Taxe de luxe","prix": 100}, {"type": "propriete","groupe": "Bleu","axe": 1,"pos": 9,"nom": "Coruscant Senate","colors": ["#132450", "#808EB0"],"prix": 400,"loyers": [50, 200, 600, 1400, 1700, 2000],"prixMaison": 200} ], "images":{ @@ -93,7 +94,7 @@ {"nom":"Payer le carburant du landspeeder 7 150","type":"taxe","montant":150}, {"nom":"Amande pour excès de vitesse : 7 15","type":"taxe","montant":15}, {"nom":"Vous avez gagné le prix de tir. Recevez 7 100","type":"prime","montant":100}, - {"nom":"La banque vous verse un dividende de 7 5.000","type":"prime","montant":50}, + {"nom":"La banque vous verse un dividende de 7 50","type":"prime","montant":50}, {"nom":"Votre immeuble et votre prêt rapportent. Vous devez toucher 7 150","type":"prime","montant":150}, {"nom":"Amande pour ivresse : 7 20","type":"taxe","montant":20}, {"nom":"Rendez vous à Ord Mantell. Si vous passez par la case Départ, recevez 7 200","type":"goto","axe":0,"pos":4}, diff --git a/js/Enchere.js b/js/Enchere.js index a3e8849..453269e 100644 --- a/js/Enchere.js +++ b/js/Enchere.js @@ -20,6 +20,7 @@ var GestionEnchere = { /* @param miseDepart : prix de depart */ /* @param ventePerte : si vrai, permet de baisser la mise de depart (cas d'une vente obligee pour payer une dette) */ init: function (terrain, miseDepart, ventePerte, callback) { + this.pasVente = InitMonopoly.plateau.infos.montantDepart / 10; this.terrain = terrain; this.callback = callback; this.miseDepart = miseDepart; diff --git a/js/display/Message.js b/js/display/Message.js index f86b180..62f156b 100644 --- a/js/display/Message.js +++ b/js/display/Message.js @@ -212,7 +212,7 @@ var InfoMessage = { var buttons = { "Payer": function () { - joueur.payer(5000); + joueur.payer(InitMonopoly.plateau.infos.montantPrison); // TODO : Ajouter message pour indiquer qu'il paye joueur.exitPrison(); InfoMessage.close(); diff --git a/js/entity/Comportement.js b/js/entity/Comportement.js index fcd4c95..f13a944 100644 --- a/js/entity/Comportement.js +++ b/js/entity/Comportement.js @@ -32,8 +32,8 @@ function Comportement(risque, name, id) { var marge = strategieValue / (risque / 100 + 1); // On ajoute un random sur 10% du prix => moins previsible var montant = this.findCoutFromFixMarge(joueur, marge); - montant+=Math.round((montant*0.1)*(((Math.random()*1000)%10 -5)/10)); - return Math.min(montant, joueur.montant - 5000); + montant+=Math.round((montant*0.1)*(((Math.random()* 1000)%10 -5)/10)); + return Math.min(montant, joueur.montant - (InitMonopoly.plateau.infos.montantDepart / 4)); } /* Appele lorsqu'une proposition a deja ete faite et qu'elle etait insuffisante */ @@ -122,7 +122,7 @@ function Comportement(risque, name, id) { // calcul le loyer le plus fort du joueur (et n'appartenant pas au joueur). Permet de connaitre la treso max que le joueur peut posseder sur lui this.plusFortLoyer = function (joueur) { - var max = 20000; // Prix de la taxe de luxe + var max = InitMonopoly.plateau.infos.montantDepart; // Prix de l'impot sur le revenu, comme le depart var it = GestionFiche.iteratorTerrains(); while (it.hasNext()) { var f = it.next(); @@ -135,7 +135,7 @@ function Comportement(risque, name, id) { // calcul le loyer moyen que peut rencontrer le joueur this.getLoyerMoyen = function (joueur) { - var montant = 20000; // Prix de la taxe de luxe + var montant = InitMonopoly.plateau.infos.montantDepart; // Prix de l'impot sur le revenu, comme le depart var nb = 1; var it = GestionFiche.iteratorTerrains(); while (it.hasNext()) { diff --git a/js/entity/Joueur.js b/js/entity/Joueur.js index 1847b66..17c835a 100644 --- a/js/entity/Joueur.js +++ b/js/entity/Joueur.js @@ -140,7 +140,7 @@ function JoueurOrdinateur(numero, nom, color, argent) { /* TODO : dans le cas d'enchere immediate, empecher de tomber sur un terrain qui interesse un autre ? */ this._analyseCase = function(fiche){ var interet = 0; - if(fiche.isTerrain() == true){ + if(fiche.isPropriete() == true){ interet = fiche.statut == ETAT_LIBRE ? this.strategie.interetGlobal(fiche,this,false).interet : fiche.getLoyerFor(this) / -1000; @@ -241,10 +241,10 @@ function JoueurOrdinateur(numero, nom, color, argent) { prop.compensation = 0; // Calcule les monnaies d'echange prop.deals = maison.joueurPossede.findOthersInterestProprietes(this,maison); - if (prop.deals.length == 0) { + if (prop.deals.length == 0) { // On ajoute les terrains non importants (gare seule, compagnie) var othersProprietes = this.findUnterestsProprietes(); - var montant = 0; + var montant = 0; if (othersProprietes != null && othersProprietes.proprietes != null && othersProprietes.proprietes.length > 0) { // On en ajoute. En fonction de la strategie, on n'ajoute que les terrains seuls dans le groupe (peu important) for (var i = 0; i < othersProprietes.proprietes.length && montant / maison.achat < 0.7; i++) { @@ -258,6 +258,7 @@ function JoueurOrdinateur(numero, nom, color, argent) { } } } + // Permettre calcul compensation quand traitement fournit des terrains < 80% du montant if (montant / maison.achat < 0.8) { prop.compensation = this.evalueCompensation(joueur, maison, interetEchange, last) - montant; @@ -273,17 +274,18 @@ function JoueurOrdinateur(numero, nom, color, argent) { prop.deals = monnaies; } } - // Si aucune proposition, on ajoute les autres terrains dont on se moque (terrains constructibles mais non intéressant) + // Si aucune proposition, on ajoute les autres terrains dont on se moque (terrains constructibles mais non intéressant) + // Potentiellement un terrain de la strategie peut tout de meme etre proposee (une gare par exemple) if ((prop.deals == null || prop.deals.length == 0) && prop.compensation == 0) { var terrains = this.findOthersProperties(proprietes); - var montant = 0; + var montant = 0; for (var i = 0; i < terrains.length && montant / maison.achat < 0.7; i++) { var terrain = terrains[i]; if (!this.strategie.interetPropriete(terrain)) { if (prop.deals == null) { prop.deals = []; } - // On le refourgue + // On le propose prop.deals.push(terrain); montant += terrain.achat; } @@ -555,7 +557,7 @@ function JoueurOrdinateur(numero, nom, color, argent) { // Critere 1, nombre de maison par terrain pouvant etre achete var nbMaison = (this.argent / groupe.maisons[0].prixMaison) / groupe.fiches.length; // compte les autres groupes - var criterePrix = (groupe.maisons[0].loyers[nbMaison]) / 100000; + var criterePrix = (groupe.maisons[0].loyers[nbMaison]) / (InitMonopoly.plateau.infos.montantDepart*5); // Ligne presente var groups = this.findGroupes(); var isLigne = false; @@ -931,7 +933,7 @@ function JoueurOrdinateur(numero, nom, color, argent) { this.buildConstructions = function () { var budget = this.comportement.getBudget(this); // Pas d'argent - if (budget < 5000) { + if (budget < InitMonopoly.plateau.infos.montantDepart / 4) { return; } var sortedGroups = []; @@ -1850,14 +1852,14 @@ function Joueur(numero, nom, color,argent) { * @param interestTerrains : terrains qui interessent, on filtre */ this.findOthersProperties = function (interestTerrains) { - var terrains = []; + var terrains = []; var mapInterests = []; for (var i in interestTerrains) { - mapInterests[interestTerrains[i].id] = 1; + mapInterests[interestTerrains[i].maison.color] = 1; } - for (var f in this.maisons) { + for (var f in this.maisons) { var maison = this.maisons[f]; - if (maison.isTerrain() && !maison.isGroupee() && mapInterests[maison.id] == null) { + if (maison.isTerrain() && !maison.isGroupee() && mapInterests[maison.color] == null) { terrains.push(maison); } } @@ -1911,8 +1913,10 @@ var GestionJoueur = { getJoueurCourant:function(){ return this.joueurCourant; }, + // renvoi le nombre de joueur dans la partie getNb:function(){ - return this.joueurs.length; + return this.joueurs.reduce(function(somme,j){return somme+=!j.defaite?1:0;},0); + //return this.joueurs.length; }, createAndLoad:function(isRobot,i,nom,data){ var joueur = this.create(isRobot,i,nom); diff --git a/monopoly.js b/monopoly.js index 516348f..ca0268a 100644 --- a/monopoly.js +++ b/monopoly.js @@ -162,9 +162,10 @@ function GestionDesImpl(){ return; } else { if (j.nbDouble == 2) { - MessageDisplayer.write(j, message + " et sort de prison en payant " + CURRENCY + " 5.000"); - var buttons = InfoMessage.create(j,"Libere de prison", "lightblue", "Vous etes liberes de prison, mais vous devez payer " + CURRENCY + " 5.000 !", function () { - j.payerParcGratuit(InitMonopoly.plateau.parcGratuit,5000, function () { + MessageDisplayer.write(j, message + " et sort de prison en payant " + CURRENCY + " " + InitMonopoly.plateau.infos.montantPrison); + var messagePrison = "Vous etes liberes de prison, mais vous devez payer " + CURRENCY + " " + InitMonopoly.plateau.infos.montantPrison+ " !"; + var buttons = InfoMessage.create(j,"Libere de prison", "lightblue", messagePrison, function () { + j.payerParcGratuit(InitMonopoly.plateau.parcGratuit,InitMonopoly.plateau.infos.montantPrison, function () { j.exitPrison(); gd.endLancer(); }); @@ -503,6 +504,7 @@ var InitMonopoly = { DrawerFactory.addInfo('backgroundColor',this.infos.backgroundColor || '#FFFFFF'); this.infos.argentJoueurDepart = this.infos.argent || 150000 this.infos.montantDepart = this.infos.depart || 20000; + this.infos.montantPrison = this.infos.prison || 5000; if(this.infos.colors){ GestionJoueur.colorsJoueurs = this.infos.colors; }