-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
114 lines (89 loc) · 3.01 KB
/
Copy pathMain.java
File metadata and controls
114 lines (89 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import java.util.Scanner;
/**
* Created by RenCh1732786 on 2018-02-01.
*/
public class Main {
public static void main(String[] args) {
//Variables
Scanner sc=new Scanner(System.in);
int choix;
boolean erreur=true;
Personnage perso1=null;
Personnage perso2=null;
int tour=0;
//Choix des personnages
while (erreur) {
System.out.println("Choisissez le type du premier combattant");
System.out.println("1-Barbare");
System.out.println("2-Paladin");
System.out.println("3-Magicien Rouge");
System.out.println("4-Magicien Noir");
choix = sc.nextInt();
switch (choix){
case 1: perso1=new Barbare();
erreur=false;
break;
case 2: perso1=new Paladin();
erreur=false;
break;
case 3: perso1=new MagicienRouge();
erreur=false;
break;
case 4: perso1=new MagicienNoir();
erreur=false;
break;
default:System.out.println("Entrez un nombre valide");
}
}
erreur=true;
while (erreur) {
System.out.println("Choisissez le type du deuxième combattant");
System.out.println("1-Barbare");
System.out.println("2-Paladin");
System.out.println("3-Magicien Rouge");
System.out.println("4-Magicien Noir");
choix = sc.nextInt();
switch (choix){
case 1: perso2=new Barbare();
erreur=false;
break;
case 2: perso2=new Paladin();
erreur=false;
break;
case 3: perso2=new MagicienRouge();
erreur=false;
break;
case 4: perso2=new MagicienNoir();
erreur=false;
break;
default:System.out.println("Entrez un nombre valide");
}
}
sc.close();
//Combat
while (perso1.getPv()>0 && perso2.getPv()>0 && !erreur){
tour++;
if (tour%2==1){
perso1.attaque(perso2);
}
else{
perso2.attaque(perso1);
}
if (perso1 instanceof Magicien && perso2 instanceof Magicien){
if (((Magicien) perso1).getPointMagie()<=2 || ((Magicien) perso2).getPointMagie()<=2){
erreur=true;
}
}
}
//Fin de la partie
if (perso1.getPv()<=0){
System.out.println("Le "+perso2.getNom()+" a gagné!");
}
else if (erreur){
System.out.println("Match nul");
}
else{
System.out.println("Le "+perso1.getNom()+" a gagné!");
}
}
}