-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestWarrior.java
More file actions
195 lines (191 loc) · 6.1 KB
/
TestWarrior.java
File metadata and controls
195 lines (191 loc) · 6.1 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
import java.util.Scanner;
public class TestWarrior implements ObjetcInGame {
public static void main( String [ ] args ) {
int play = 0;
int lig = 30;
int col = 20;
int jok;
int x = 0;
int val = 0;
int bla = 0;
int PA = 100;
boolean t = false;
boolean stop = false;
boolean off = false;
Scanner sc = new Scanner(System.in);
Scanner pc = new Scanner(System.in);
Scanner pla = new Scanner(System.in);
String tab[][] = new String [lig][col];
Map p = new Map (tab,lig,col);
String j = "Test";
String m = "Poporing";
Player j1 = new Player(j);
Monster m1 = new Monster(m);
Inventory i = new Inventory();
PotionPV i1 = new PotionPV("Potion de vie");
PotionPA i2 = new PotionPA("Potion d'action");
Equipement eq = new Sword("Epee d'argent ");
Equipement eq2 = new Armor ("Armure de cuivre");
int a = 0;
int b = 0;
int co = 0;
int rok = 0;
System.out.println("#################################################################################################\r\n" +
" \r\n" +
"## ## # ################# ################# ## ################# ################# \r\n" +
"### ### ### ## ## ## ## ## ################# ## ## \r\n" +
"#### #### ##### ## ## ## ## ## ## ## ## ## \r\n" +
"##### ##### ####### ## ## ## ## ## ## ## ## ## \r\n" +
"##### ##### ######### ## ## ## ## ## ## ## ## ## \r\n" +
"############## ########### ## ## ## ## ## ## ## ## ## \r\n" +
"############## ############# ################# ################# ## ## ## ################# \r\n" +
"############## ############### ################ ################ ## ## ## ################ \r\n" +
"#### #### ################# ## ## ## ## ## ################# ## ## \r\n" +
"#### ######################### ## ## ## ## ################# ## ## \r\n" +
" \r\n" +
"########################################################################################################### \n"
+ "1.Commencer le jeu ?");
play = pla.nextInt();
System.out.println("");
System.out.println("");
System.out.println("");
System.out.println("");
System.out.println("");
System.out.println("");
System.out.println("");
System.out.println("");
System.out.println("");
System.out.println("");
if ( play == 1) {
p.CreateMap();
p.Spawn();
p.ShowMap();
while (p.DetectMonster()==false ) {
System.out.println(" Action de "+ j +" : ");
System.out.println(" 1. Se deplacer (2PA) 2. Attaquer (3PA) ");
System.out.println(" 3. Utiliser objet 4. Ramasser/Deposer objet(2PA) ");
System.out.println(" 5. Finir son tour ");
System.out.println(""+PA);
x =sc.nextInt();
if (x == 1 && PA >= 2) {
j1.Check(PA);
val = j1.Deplacer();
p.SetPosition(val);
PA = PA -2;
}
else if (x == 1 && PA < 2)
System.out.println(" Plus de PA !");
if (x == 2 && PA >= 3) {
j1.Check(PA);
t = p.DetectFight();
if (t == true) {
b = j1.CombatP(10);
if (b == 0) {
stop = true;
}
System.out.println(" Vous avez recu 10 pts de degats !");
a = m1.CombatM(50);
if (a == 0) {
p.Kill();
m1 = new Monster(m);
}
System.out.println(" Vous avez infligez 50 pts de degats !");
System.out.println(" Life :"+j1.getlife()+"");
}
else if (t == false)
System.out.println(" Pas de monstre a proximite !");
else if (x == 2 && PA < 3) {
System.out.println(" Plus de PA !");
}
PA = PA -3;
}
if (stop == true) {
System.out.println("Game Over");
break;
}
if (x == 3) {
System.out.println(" 1.Utiliser objet 2.S'equiper ");
bla = pc.nextInt();
if (bla == 1) {
if (i.ShowInventory() == true ) {
j1.setlife(i1.getHeal());
}
}
else if (bla == 2) {
if (i.ShowEquipement() == false ) {
j1.setForce(eq.getForce());
j1.setAdresse(eq.getadresse());
}
else {
j1.setResistance(eq.getResistance());
}
}
/*else if (bla == 3) {
if(equip.get(i.ShowGear()) instanceof Sword) {
j1.RemoveForce(eq.getForce());
j1.RemoveAdresse(eq.getadresse());
}
else if(equip.get(i.ShowEquipement()) instanceof Armor) {
j1.RemoveResistance(eq.getResistance());
}
}*/
}
if (x == 4 && PA >= 2) {
System.out.println("1.Ramasser 2.Deposer ? 3.Deposer equipement ?");
co =sc.nextInt();
if (p.DetectObject() == true && co == 1) {
p.TakeObject();
jok = (int)( Math.random());
if (jok == 0) {
i.addInventory(i1);
}
else if (jok == 1) {
i.addInventory(i2);
}
}
else if (p.DetectWeapon() == true && co == 1) {
p.TakeWeapon();
i.addEquipement(eq);
for (int i11 = 0 ; i11 < equip.size() ; i11++) {
System.out.println(i11+" "+equip.get(i11)+"\n");
}
}
else if (p.DetectArmor() == true && co == 1) {
p.TakeArmor();
i.addEquipement(eq2);
}
else if (co == 2){
if (i.Check() == false) {
i.CancelInventory();
p.DropObject();
}
else
System.out.println(" Inventaire vide !");
}
else if (co == 3){
if (i.Check() == false) {
if ( i.CancelEquipement() == 1)
p.DropArmor();
}
else if ( i.CancelEquipement() == 2)
p.DropWeapon();
}
else if (p.DetectObject() == false && p.DetectWeapon() == false && co == 1 )
System.out.println(" Pas d'objet a proximite !");
else if (x == 4 && PA < 2) {
System.out.println(" Plus de PA");
}
}
if (x == 5) {
if ( PA == 5) {
System.out.println(" PA au max !");
}
else
PA = PA +1;
}
p.ShowMap();
}
}
System.out.println(" Niveau termine !");
}
}