Skip to content

Commit

Permalink
Ajout carte action joueur anniversaire
Browse files Browse the repository at this point in the history
  • Loading branch information
jotitan committed Oct 17, 2014
1 parent c11747a commit bb210d5
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 10 deletions.
37 changes: 31 additions & 6 deletions js/GestionTerrains.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ var GestionTerrains = {
if (!this.verify()) {
return;
}
this.Constructions.vendre();
this.Hypotheque.valider();
this.LeverHypotheque.valider();
this.Constructions.acheter();

this.Constructions.vendre();
this.Hypotheque.valider();
this.LeverHypotheque.valider();
this.Constructions.acheter();

this.closePanel();
},
Expand Down Expand Up @@ -271,9 +271,34 @@ var GestionTerrains = {
joueur: GestionJoueur.getJoueurCourant(),
achats: this.simulation.achat
});
}
},
acheter: function () {
for (var achat in this.table) {
var data = this.table[achat];
if(data.propriete.nbMaison < data.nbMaison){
data.propriete.setNbMaison(data.nbMaison);
GestionJoueur.getJoueurCourant().payer(data.cout);
}
}


// On modifie les quantites de maisons / hotels
if (this.simulation != null && (this.simulation.achat.maison!=0 || this.simulation.achat.hotel!=0)) {
GestionConstructions.buyHouses(this.simulation.achat.maison);
GestionConstructions.buyHotels(this.simulation.achat.hotel);
$.trigger('monopoly.acheteConstructions', {
joueur: GestionJoueur.getJoueurCourant(),
achats: this.simulation.achat
});
}
},
vendre: function () {
for (var achat in this.table) {
var data = this.table[achat];
if(data.propriete.nbMaison > data.nbMaison){
data.propriete.setNbMaison(data.nbMaison);
GestionJoueur.getJoueurCourant().payer(data.cout);
}
}
},
acheter: function () {
for (var achat in this.table) {
Expand Down
13 changes: 13 additions & 0 deletions js/entity/CartesAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@ function CarteAction(type,action){

}

/* Carte chance : chaque joueur vous donne 1000 francs */
function BirthdayCarte(montant){
CarteAction.call(this,"birthday");
this.action = function(joueur){
GestionJoueur.joueurs.forEach(function(j){
if(!joueur.equals(j)){
j.payerTo(montant,joueur,true);
}
})
GestionJoueur.change()
}
}

/* Action de déplacement vers une case */
/* @param direct : si renseigné a vrai, le pion est deplacé directement vers la case, sans passer par la case depart */
function GotoCarte(axe, pos, direct) {
Expand Down
5 changes: 4 additions & 1 deletion js/entity/Joueur.js
Original file line number Diff line number Diff line change
Expand Up @@ -1599,10 +1599,13 @@ function Joueur(numero, nom, color) {
/* Paye une somme a un joueur */
/* Si le joueur ne peut pas payer, une exception est lancee (il a perdu). On recupere le peut d'argent a prendre */
/* Payer est potentiellement asynchrone (resolve manuel), on indique l'etape suivante en cas de reussite */
this.payerTo = function (montant, joueur) {
this.payerTo = function (montant, joueur,noChange) {
try {
this.payer(montant, function () {
joueur.gagner(montant);
if(noChange){
return;
}
GestionJoueur.change();
});
} catch (insolvable) {
Expand Down
6 changes: 3 additions & 3 deletions monopoly.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ var VARIANTES = {

/* Preconfiguration des variantes */
var configJeu = [
{nom:"Classique strict",config:[false,false,true,true]},
{nom:"Classique",config:[false,false,false,false]},
{nom:"Variante 1",config:[true,true,false,false]}
{nom:"Classique strict",config:[false,false,true,true,false]},
{nom:"Classique",config:[false,false,false,false,false]},
{nom:"Variante 1",config:[true,true,false,false,false]}
];

var stats = { // Statistiques
Expand Down

0 comments on commit bb210d5

Please sign in to comment.