Ajout des capacités spéciales
This commit is contained in:
@ -23,16 +23,27 @@ import main.GestionnaireJeu;
|
||||
public class LancerDes {
|
||||
private int resultat;
|
||||
private Contexte contexte;
|
||||
public LancerDes(Contexte c){
|
||||
contexte = c;
|
||||
private int typeDe;
|
||||
private int[] rolls;
|
||||
|
||||
private final static int LANCER_DE_4 = 0;
|
||||
private final static int LANCER_DE_6 = 1;
|
||||
private final static int LANCER_DES = 2;
|
||||
|
||||
public LancerDes(int typeDe, int[] rolls, Contexte c){
|
||||
this.typeDe = typeDe;
|
||||
this.rolls = rolls;
|
||||
this.contexte = c;
|
||||
}
|
||||
|
||||
public VBox initLancer() {
|
||||
switch (contexte) {
|
||||
case LANCER_DES_4:
|
||||
switch (typeDe) {
|
||||
case LANCER_DE_4:
|
||||
return initLancerD4();
|
||||
case LANCER_DES_6:
|
||||
case LANCER_DE_6:
|
||||
return initLancerD6();
|
||||
case LANCER_DES:
|
||||
return initLancerBoth();
|
||||
default :
|
||||
return null;
|
||||
}
|
||||
@ -53,19 +64,26 @@ public class LancerDes {
|
||||
btn.setOnAction((ActionEvent event) -> {
|
||||
btn.setDisable(true);// Disable Button
|
||||
Random random = new Random();
|
||||
Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(.3), (actionEvent) -> {
|
||||
int tempRandom = random.nextInt(4) + 1;
|
||||
Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(0.1), (actionEvent) -> {
|
||||
int tempRandom = random.nextInt(4)+1;
|
||||
die.setDieFace(tempRandom);
|
||||
}));
|
||||
|
||||
timeline.setCycleCount(random.nextInt(20) + 1);
|
||||
timeline.setCycleCount(20);
|
||||
timeline.play();
|
||||
timeline.setOnFinished(actionEvent -> {
|
||||
int res = die.getCurrentFace();
|
||||
txt.setText("Vous avez obtenu "+res+"!");
|
||||
resultat = res;
|
||||
GestionnaireJeu.notifyPlateau();
|
||||
});
|
||||
|
||||
die.setDieFace(rolls[0]);
|
||||
txt.setText("Vous avez obtenu "+rolls[0]);
|
||||
Timeline timeline2 = new Timeline(new KeyFrame(
|
||||
Duration.millis(2000),
|
||||
ae -> {
|
||||
|
||||
|
||||
GestionnaireJeu.notifyPlateau();
|
||||
}));
|
||||
timeline2.play();
|
||||
});
|
||||
});
|
||||
|
||||
HBox des = new HBox(stackpane);
|
||||
@ -77,6 +95,50 @@ public class LancerDes {
|
||||
}
|
||||
|
||||
private VBox initLancerD6() {
|
||||
DieImages images = new DieImages();
|
||||
Die die = new Die(images.getImages());
|
||||
ImageView stackpane = die.getdieFace();
|
||||
stackpane.setFitHeight(100);
|
||||
stackpane.setFitWidth(100);
|
||||
Button btn = new Button();
|
||||
Text txt = new Text("Lancez le dés pour attaquer");
|
||||
txt.setFont(Font.font(null, null, null, 12));
|
||||
txt.setFill(Color.WHITE);
|
||||
btn.setText("Lancer dés");
|
||||
btn.setOnAction((ActionEvent event) -> {
|
||||
btn.setDisable(true);// Disable Button
|
||||
Random random = new Random();
|
||||
Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(.1), (actionEvent) -> {
|
||||
int tempRandom = random.nextInt(6)+1;
|
||||
die.setDieFace(tempRandom);
|
||||
}));
|
||||
|
||||
timeline.setCycleCount(20);
|
||||
timeline.play();
|
||||
timeline.setOnFinished(actionEvent -> {
|
||||
|
||||
die.setDieFace(rolls[0]);
|
||||
txt.setText("Vous avez obtenu "+rolls[0]);
|
||||
Timeline timeline2 = new Timeline(new KeyFrame(
|
||||
Duration.millis(2000),
|
||||
ae -> {
|
||||
|
||||
|
||||
GestionnaireJeu.notifyPlateau();
|
||||
}));
|
||||
timeline2.play();
|
||||
});
|
||||
});
|
||||
|
||||
HBox des = new HBox(stackpane);
|
||||
des.setAlignment(Pos.CENTER);
|
||||
VBox root = new VBox(txt,des, new StackPane(btn));
|
||||
root.setAlignment(Pos.CENTER);
|
||||
root.setSpacing(20);
|
||||
return root;
|
||||
}
|
||||
|
||||
private VBox initLancerBoth() {
|
||||
DieImages images = new DieImages();
|
||||
Die die = new Die(images.getImages());
|
||||
Die die2 = new Die(images.getImages());
|
||||
@ -94,21 +156,33 @@ public class LancerDes {
|
||||
btn.setOnAction((ActionEvent event) -> {
|
||||
btn.setDisable(true);// Disable Button
|
||||
Random random = new Random();
|
||||
Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(.3), (actionEvent) -> {
|
||||
int tempRandom = random.nextInt(6) + 1;
|
||||
int tempRandom2 = random.nextInt(6) + 1;
|
||||
|
||||
Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(.1), (actionEvent) -> {
|
||||
int tempRandom = random.nextInt(4)+1;
|
||||
int tempRandom2 = random.nextInt(6)+1;
|
||||
die.setDieFace(tempRandom);
|
||||
die2.setDieFace(tempRandom2);
|
||||
}));
|
||||
|
||||
timeline.setCycleCount(random.nextInt(20) + 1);
|
||||
timeline.setCycleCount(20);
|
||||
timeline.play();
|
||||
timeline.setOnFinished(actionEvent -> {
|
||||
int res = die.getCurrentFace()+die2.getCurrentFace();
|
||||
txt.setText("Vous avez obtenu "+res+"!");
|
||||
resultat = res;
|
||||
GestionnaireJeu.notifyPlateau();
|
||||
});
|
||||
|
||||
die.setDieFace(rolls[0]);
|
||||
die2.setDieFace(rolls[1]);
|
||||
|
||||
int result = rolls[0]+rolls[1];
|
||||
|
||||
txt.setText("Vous avez obtenu "+result);
|
||||
Timeline timeline2 = new Timeline(new KeyFrame(
|
||||
Duration.millis(2000),
|
||||
ae -> {
|
||||
GestionnaireJeu.notifyPlateau();
|
||||
|
||||
}));
|
||||
timeline2.play();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
HBox des = new HBox(stackpane, stackpane2);
|
||||
|
@ -65,9 +65,9 @@ public class PlateauController implements Initializable {
|
||||
private Map<Carte,BufferedImage> mapRessourcesCartes;
|
||||
private Map<String,BufferedImage> mapRessourcesDosCartes;
|
||||
|
||||
public static int DICE_SIX = 2;
|
||||
public static int DICE_QUATRE = 1;
|
||||
public static int DICE_BOTH = 0;
|
||||
public static int DICE_SIX = 1;
|
||||
public static int DICE_QUATRE = 0;
|
||||
public static int DICE_BOTH = 2;
|
||||
|
||||
/**
|
||||
* initialise les données du plateau
|
||||
@ -333,9 +333,11 @@ public class PlateauController implements Initializable {
|
||||
}
|
||||
}
|
||||
|
||||
public void rollDice(Joueur joueur, int typeDice, int[] rolls) {
|
||||
|
||||
public void rollDice(Joueur joueur, int typeDice, int[] rolls, Contexte c) {
|
||||
|
||||
this.ld=new LancerDes(typeDice,rolls,c);
|
||||
JoueurIHM jihm = getJoueurIHM(joueur);
|
||||
jihm.setZoneJoueur(ld.initLancer());
|
||||
}
|
||||
|
||||
public void afficherChoisir(Joueur j, Contexte contexte) throws IOException {
|
||||
@ -493,7 +495,7 @@ public class PlateauController implements Initializable {
|
||||
|
||||
}
|
||||
|
||||
public void close () throws IOException {
|
||||
public void close() throws IOException {
|
||||
final URL fxmlURL = PlateauController.class.getResource("/ihm/ressources/Menu.fxml");
|
||||
final ResourceBundle bundle = ResourceBundle.getBundle("domaine.properties.langue", Locale.FRANCE);
|
||||
final FXMLLoader fxmlLoader = new FXMLLoader(fxmlURL, bundle);
|
||||
@ -501,36 +503,17 @@ public class PlateauController implements Initializable {
|
||||
rootPane.getChildren().setAll(pane);
|
||||
}
|
||||
|
||||
|
||||
public Integer getChoixLancerDes(Joueur joueur) {
|
||||
JoueurIHM jihm = getJoueurIHM(joueur);
|
||||
int result = this.ld.getResult();
|
||||
this.ld = null;
|
||||
jihm.getZoneJoueur().getChildren().setAll();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public void afficherLancerDes(Joueur j, Contexte c) throws IOException {
|
||||
this.ld=new LancerDes(c);
|
||||
JoueurIHM jihm = getJoueurIHM(j);
|
||||
jihm.setZoneJoueur(ld.initLancer());
|
||||
}
|
||||
|
||||
|
||||
public void afficherLT(Joueur j, CartePiochable cartePiochable) throws IOException {
|
||||
|
||||
Image i = getImageCarte(cartePiochable);
|
||||
ImageView iv = new ImageView(i);
|
||||
Pane p = new Pane(iv);
|
||||
PopUp pu = new PopUp(p,"Image");
|
||||
pu.getStage().focusedProperty().addListener((obs,wasFocused,isNowFocused) -> {
|
||||
|
||||
pu.getStage().focusedProperty().addListener((obs,wasFocused,isNowFocused) -> {
|
||||
if(!isNowFocused) {
|
||||
GestionnaireJeu.notifyPlateau();
|
||||
pu.getStage().hide();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
pu.display();
|
||||
|
@ -10,6 +10,12 @@ import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.Background;
|
||||
import javafx.scene.layout.BackgroundImage;
|
||||
import javafx.scene.layout.BackgroundPosition;
|
||||
import javafx.scene.layout.BackgroundRepeat;
|
||||
import javafx.scene.layout.BackgroundSize;
|
||||
import main.GestionnaireJeu;
|
||||
|
||||
public class RecevoirCarte implements Initializable {
|
||||
@ -31,6 +37,11 @@ public class RecevoirCarte implements Initializable {
|
||||
}
|
||||
|
||||
public void setImageView(Image imageCarte) {
|
||||
this.imageView.setImage(imageCarte);
|
||||
AnchorPane ap = (AnchorPane) imageView.getParent();
|
||||
|
||||
BackgroundImage myBI= new BackgroundImage(imageCarte,
|
||||
BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.DEFAULT,
|
||||
new BackgroundSize(BackgroundSize.AUTO,1.0,true,true,false,false));
|
||||
ap.setBackground(new Background(myBI));
|
||||
}
|
||||
}
|
||||
|
@ -8,27 +8,27 @@
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
<AnchorPane xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ihm.controller.RecevoirCarte">
|
||||
<AnchorPane prefHeight="344.0" prefWidth="385.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ihm.controller.RecevoirCarte">
|
||||
<children>
|
||||
<SplitPane dividerPositions="0.6212121212121212" styleClass="background" stylesheets="@style/plateau.css" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<SplitPane dividerPositions="0.9921671018276762" styleClass="background" stylesheets="@style/plateau.css" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<items>
|
||||
<AnchorPane>
|
||||
<children>
|
||||
<VBox alignment="CENTER" spacing="30.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<children>
|
||||
<Label fx:id="label" styleClass="text" text="Vous arrivez sur cette Carte Lieu" textOverrun="CLIP" wrapText="true">
|
||||
<Label fx:id="label" minHeight="0.0" minWidth="0.0" styleClass="text" text="Glissez la barre" textOverrun="CLIP" wrapText="true">
|
||||
<font>
|
||||
<Font size="14.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Button fx:id="okButton" mnemonicParsing="false" styleClass="bouton" text="Ok" />
|
||||
<Button fx:id="okButton" minHeight="0.0" minWidth="0.0" mnemonicParsing="false" styleClass="bouton" text="Ok" />
|
||||
</children>
|
||||
</VBox>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
<AnchorPane>
|
||||
<children>
|
||||
<ImageView fx:id="imageView" fitHeight="158.0" fitWidth="132.0" pickOnBounds="true" preserveRatio="true" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
|
||||
<ImageView fx:id="imageView" pickOnBounds="true" preserveRatio="true" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</items>
|
||||
|
Reference in New Issue
Block a user