-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunitaffichage.pas
More file actions
386 lines (287 loc) · 16.4 KB
/
unitaffichage.pas
File metadata and controls
386 lines (287 loc) · 16.4 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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
unit unitAffichage;
{$codepage utf8}
interface
(*#########################################################*)
(* *)
(* ### # # ##### #### ### #### ### ## #### *)
(* # ## # # # # # # # # # # # *)
(* # # ## # ## # # ## # # # ## *)
(* # # # # # ### # #### # # # *)
(* ### # # # #### # # # # # ## #### *)
(* *)
(*#########################################################*)
uses unitEcran, unitMenuInitiale, unitMenuCreationPersonnage, unitMenuJeu, unitMenuQuete, unitMenuInventaire, typesDuJeu, sysutils;
(*#################################################################*)
(* *)
(* #### # # # # ## ##### # #### ### ### ## *)
(* # # # ## # # # # # # # # # # # # # *)
(* ### # # # ## # # # ### # # # # # *)
(* # # # # # # # # # # ### # # # # *)
(* # ## # # ## # # # # # ## ## *)
(* *)
(*#################################################################*)
{Initialise la taille et le cadre de la console}
procedure initConsole();
(*Attend une réponse de la part de l'utilisateur.*)
function jeVeuxUneReponse() : String;
(*Vérifie si la masse d'ébonite est dans l'inventaire. Retourne TRUE si oui.*)
function presenceMasseEbo(p:personnage):Boolean;
(*Procedure qui modifie qF en fonction du choix de l'utilisateur, soit il ferme le jeu, soit il démare une nouvelle partie.*)
procedure affMenuInitiale(var qF : String);
(*Procedure qui modifie qF en fonction du choix de l'utilisateur, soit il ferme le jeu, soit il démare une nouvelle partie.*)
procedure affMenuCreationPersonnage(var joueur : Personnage);
(*Procedure qui affiche la fenetre de jeu principale.*)
procedure affMenuJeu(var p : Personnage; var rep : String);
(*Procedure qui affiche la quête actuelle*)
procedure affMenuQuete(var p : Personnage; var rep : String);
(*Procedure qui affiche le menu de inventaire.*)
procedure affMenuInv(var pe : Personnage; var rep : String);
(*Procedure qui affiche le magasin du jeu.*)
procedure affMenuMag(var p : Personnage; rep : String);
implementation
(*#########################################################################################*)
(* *)
(* ### # # #### # #### # # #### # # ##### ### ##### ### ### # # *)
(* # ## ## # # # # ## ## # ## # # # # # # # # ## # *)
(* # # # # ### # ## # # # ## # ## # # # # # # # # ## *)
(* # # # # # # # # # # # # #### # # # # # # *)
(* ### # # # #### #### # # #### # # # # # # ### ## # # *)
(* *)
(*#########################################################################################*)
{Initialise la taille et le cadre de la console}
procedure initConsole();
begin
changerTailleConsole(200, 60);
effacerEcran;
dessinerCadreXY(2,1,196,58,double,15,0);
end;
(*Attend une réponse de la part de l'utilisateur.*)
function jeVeuxUneReponse() : String;
var
rep : String;
begin
ReadLn(rep);
jeVeuxUneReponse:=rep;
end;
(*Vérifie si la masse d'ébonite est dans l'inventaire. Retourne TRUE si oui.*)
function presenceMasseEbo(p:personnage):Boolean;
var
i:Integer;
rep : Boolean;
begin
rep:=FALSE;
for i:=1 to 12 do
begin
if p.inv[i]='Masse d''ebonite' then
begin
rep:=TRUE;
end;
end;
presenceMasseEbo:=rep;
end;
(*Procedure qui modifie qF en fonction du choix de l'utilisateur, soit il ferme le jeu, soit il démare une nouvelle partie.*)
procedure affMenuInitiale(var qF : String);
var
rep : String; // Variable qui vaut n ou k pour respectivement créer une nouvelle partie ou killer le jeu.
begin
initConsole();
affichageTextesMI();
repeat
centrerTexte(' ', 49, 100);
centrerTexte('', 49, 100);
rep := jeVeuxUneReponse();
until (rep = '1') OR (rep = '2');
if rep = '1' then rep := 'n';
if rep = '2' then rep := 'exit';
qF := rep;
end;
(*Procedure qui modifie qF en fonction du choix de l'utilisateur, soit il ferme le jeu, soit il démare une nouvelle partie.*)
procedure affMenuCreationPersonnage(var joueur : Personnage);
var
ctn : Boolean;
nom : String;
race : Integer;
begin
ctn := True;
while ctn do
begin
initConsole();
// Demande du nom du joueur
affTexteDemandeNomPersMCP;
nom :=jeVeuxUneReponse();
centrerPseudoMCP(nom);
// Affiche les races
affRacesMCP;
// Vérifie et donne la race que l'utilisateur désire.
race := choixRaceMCP();
ctn := confirmationMCP();
end;
creerPersonnage(joueur, nom, race);
end;
(*Procedure qui affiche la fenetre de jeu principale.*)
procedure affMenuJeu(var p : Personnage; var rep : String);
begin
initConsole();
initCadreHautMJ(p);
initCadreBasMJ();
//affTexte('abc abc abc');
rep := '';
//p.lieu:='m';
//p.quete:=5;
//p.inv[1] := 'Masse d''ebonite';
if ((rep <> 'OK') AND (rep<>'exit') AND (rep<>'Mourrir') AND (rep<>'Magasin') AND (rep<>'Quete') AND (rep<>'Inventaire')) AND (p.lieu = 'a') AND (p.quete = 1) then scenario1MJ(p, rep);
if ((rep <> 'OK') AND (rep<>'exit') AND (rep<>'Mourrir') AND (rep<>'Magasin') AND (rep<>'Quete') AND (rep<>'Inventaire')) AND (p.lieu = 'a') AND (p.quete = 5) then scenario19MJ(p, rep);
if ((rep <> 'OK') AND (rep<>'exit') AND (rep<>'Mourrir') AND (rep<>'Magasin') AND (rep<>'Quete') AND (rep<>'Inventaire')) AND (p.lieu = 'a') AND (p.quete <> 1) AND (p.quete <> 5) then scenario26MJ(p, rep);
if ((rep <> 'OK') AND (rep<>'exit') AND (rep<>'Mourrir') AND (rep<>'Magasin') AND (rep<>'Quete') AND (rep<>'Inventaire')) AND (p.lieu = 'b') AND (p.quete = 1) then scenario2MJ(p, rep);
if ((rep <> 'OK') AND (rep<>'exit') AND (rep<>'Mourrir') AND (rep<>'Magasin') AND (rep<>'Quete') AND (rep<>'Inventaire')) AND (p.lieu = 'b') AND (p.quete <> 1) then scenario25MJ(p, rep);
if ((rep <> 'OK') AND (rep<>'exit') AND (rep<>'Mourrir') AND (rep<>'Magasin') AND (rep<>'Quete') AND (rep<>'Inventaire')) AND (p.lieu = 'c') AND (p.quete = 1) then scenario5MJ(p, rep);
if ((rep <> 'OK') AND (rep<>'exit') AND (rep<>'Mourrir') AND (rep<>'Magasin') AND (rep<>'Quete') AND (rep<>'Inventaire')) AND (p.lieu = 'c') AND (p.quete = 2) then scenario6MJ(p, rep);
if ((rep <> 'OK') AND (rep<>'exit') AND (rep<>'Mourrir') AND (rep<>'Magasin') AND (rep<>'Quete') AND (rep<>'Inventaire')) AND (p.lieu = 'c') AND (p.quete > 2) then scenario9MJ(p, rep);
if ((rep <> 'OK') AND (rep<>'exit') AND (rep<>'Mourrir') AND (rep<>'Magasin') AND (rep<>'Quete') AND (rep<>'Inventaire')) AND (p.lieu = 'd') AND (p.quete = 1) then scenario7MJ(p, rep);
if ((rep <> 'OK') AND (rep<>'exit') AND (rep<>'Mourrir') AND (rep<>'Magasin') AND (rep<>'Quete') AND (rep<>'Inventaire')) AND (p.lieu = 'd') AND (p.quete = 5) AND (p.gold < 1100) then scenario27MJ(p, rep);
if ((rep <> 'OK') AND (rep<>'exit') AND (rep<>'Mourrir') AND (rep<>'Magasin') AND (rep<>'Quete') AND (rep<>'Inventaire')) AND (p.lieu = 'd') AND (((p.quete <> 1) AND ((p.quete = 5) AND (p.gold >= 1100)) OR ((p.quete <> 1) AND ((p.quete <> 5))))) then scenario8MJ(p, rep);
if ((rep <> 'OK') AND (rep<>'exit') AND (rep<>'Mourrir') AND (rep<>'Magasin') AND (rep<>'Quete') AND (rep<>'Inventaire')) AND (p.lieu = 'e') then scenario3MJ(p, rep);
if ((rep <> 'OK') AND (rep<>'exit') AND (rep<>'Mourrir') AND (rep<>'Magasin') AND (rep<>'Quete') AND (rep<>'Inventaire')) AND (p.lieu = 'f') AND (p.quete < 3) then scenario10MJ(p, rep);
if ((rep <> 'OK') AND (rep<>'exit') AND (rep<>'Mourrir') AND (rep<>'Magasin') AND (rep<>'Quete') AND (rep<>'Inventaire')) AND (p.lieu = 'f') AND (p.quete > 2) then scenario11MJ(p, rep);
if ((rep <> 'OK') AND (rep<>'exit') AND (rep<>'Mourrir') AND (rep<>'Magasin') AND (rep<>'Quete') AND (rep<>'Inventaire')) AND (p.lieu = 'g') then scenario12MJ(p, rep);
if ((rep <> 'OK') AND (rep<>'exit') AND (rep<>'Mourrir') AND (rep<>'Magasin') AND (rep<>'Quete') AND (rep<>'Inventaire')) AND (p.lieu = 'h') then scenario13MJ(p, rep);
if ((rep <> 'OK') AND (rep<>'exit') AND (rep<>'Mourrir') AND (rep<>'Magasin') AND (rep<>'Quete') AND (rep<>'Inventaire')) AND (p.lieu = 'i') then scenario14MJ(p, rep);
if ((rep <> 'OK') AND (rep<>'exit') AND (rep<>'Mourrir') AND (rep<>'Magasin') AND (rep<>'Quete') AND (rep<>'Inventaire')) AND (p.lieu = 'j') AND ( (p.quete = 5) OR (p.quete = 6) ) AND presenceMasseEbo(p) then scenario21MJ(p, rep);
if ((rep <> 'OK') AND (rep<>'exit') AND (rep<>'Mourrir') AND (rep<>'Magasin') AND (rep<>'Quete') AND (rep<>'Inventaire')) AND (p.lieu = 'j') AND (p.quete = 5) AND not presenceMasseEbo(p) then scenario20MJ(p, rep);
if ((rep <> 'OK') AND (rep<>'exit') AND (rep<>'Mourrir') AND (rep<>'Magasin') AND (rep<>'Quete') AND (rep<>'Inventaire')) AND (p.lieu = 'j') AND (p.quete <> 5) then scenario20MJ(p, rep);
if ((rep <> 'OK') AND (rep<>'exit') AND (rep<>'Mourrir') AND (rep<>'Magasin') AND (rep<>'Quete') AND (rep<>'Inventaire')) AND (p.lieu = 'k') then scenario16MJ(p, rep);
if ((rep <> 'OK') AND (rep<>'exit') AND (rep<>'Mourrir') AND (rep<>'Magasin') AND (rep<>'Quete') AND (rep<>'Inventaire')) AND (p.lieu = 'l') then scenario17MJ(p, rep);
if ((rep <> 'OK') AND (rep<>'exit') AND (rep<>'Mourrir') AND (rep<>'Magasin') AND (rep<>'Quete') AND (rep<>'Inventaire')) AND (p.lieu = 'm') then scenario24MJ(p, rep);
if ((rep <> 'OK') AND (rep<>'exit') AND (rep<>'Mourrir') AND (rep<>'Magasin') AND (rep<>'Quete') AND (rep<>'Inventaire')) AND (p.lieu = 'n') then scenario23MJ(p, rep);
if ((rep <> 'OK') AND (rep<>'exit') AND (rep<>'Mourrir') AND (rep<>'Magasin') AND (rep<>'Quete') AND (rep<>'Inventaire')) AND ( (p.lieu = 'o')) then p.lieu:='i';
if ((rep <> 'OK') AND (rep<>'exit') AND (rep<>'Mourrir') AND (rep<>'Magasin') AND (rep<>'Quete') AND (rep<>'Inventaire')) AND ( (p.lieu = 'p') ) then p.lieu:='l';
if ((rep <> 'OK') AND (rep<>'exit') AND (rep<>'Mourrir') AND (rep<>'Magasin') AND (rep<>'Quete') AND (rep<>'Inventaire')) AND ( (p.lieu = 'q') ) then p.lieu:='m';
// ReadLn;
//affTexte('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam scelerisque risus eget enim porttitor, quis mattis tellus luctus. Mauris a justo sed sem congue pretium vitae quis elit. Curabitur tincidunt ultricies mattis. Ut lectus dui, accumsan at commodo sed, finibus quis erat. Pellentesque volutpat nibh orci, non ultrices turpis finibus lobortis. Praesent eget justo vel erat finibus maximus et et elit. Interdum et malesuada fames ac ante ipsum primis in faucibus. Nulla malesuada fringilla efficitur. ');
end;
(*Procedure qui affiche la quête actuelle*)
procedure affMenuQuete(var p : Personnage; var rep : String);
var
pos : coordonnees;
//rep : String;
begin
initConsole();
initCadreHautMQ(p);
if p.quete = 1 then centrerTexte('Retrouver le Jarl de Blancherive dans le Fort Dragon', 30, 100);
if p.quete = 2 then centrerTexte('Retrouver le Chambellan : Cavovius Dargogne', 30, 100);
if p.quete = 3 then centrerTexte('Rejoindre la porte principale de Blancherive', 30, 100);
if p.quete = 4 then centrerTexte('Retrouver les soldats à la Tour de Guet', 30, 100);
if p.quete = 5 then centrerTexte('Aller a l’armurerie de Blancherive pour s’équiper de la Masse d’Ebonite', 30, 100);
if p.quete = 6 then centrerTexte('Retourner à la Tour de Guet combattre le Dragon', 30, 100);
if p.quete = 7 then centrerTexte('Vaincre le Dragon', 30, 100);
initCadreBasMQ();
repeat
changerLigneCurseur(56);
changerColonneCurseur(10);
Write('>>> ');
changerColonneCurseur(14);
rep := jeVeuxUneReponse();
until (rep = 'a') OR (rep = 'exit');
if rep = 'a' then rep := 'OK';
end;
(*Procedure qui affiche le menu de inventaire.*)
procedure affMenuInv(var pe : Personnage; var rep : String);
var
pos : coordonnees;
//rep : String;
A, B, C, D, E, F, G, H, I, J, K, P, Q : Boolean;
begin
initAffMInv(pe);
repeat
repeat
changerLigneCurseur(56);
changerColonneCurseur(10);
Write('>>> ');
changerColonneCurseur(14);
rep := jeVeuxUneReponse();
centrerTexte(' ', 48, 100);
P := Length(rep)=3;
Q := Length(rep)=4;
A := rep = 'exit';
B := rep = 'a';
C := rep = 'b';
if rep <> '' then
begin
E := rep[1] = 'e';
F := rep[2] = '-';
G := Ord(rep[3]) <= Ord('9');
H := Ord(rep[3]) > Ord('0');
I := Ord(rep[3]) = Ord('1');
J := Ord(rep[4]) >= Ord('0');
K := Ord(rep[4]) < Ord('3');
end;
until A OR B OR C OR ( E AND F AND ( (P AND G AND H) OR (Q AND I AND J AND K) ) );
if rep='a' then utiliserUnePotion(pe);
if ( E AND F AND ( (P AND G AND H) OR (Q AND I AND J AND K) ) ) then tenterDEquiperLeJoueur(pe, rep);
until A OR C;
if rep = 'b' then rep := 'OK';
end;
(*Procedure qui affiche le magasin du jeu.*)
procedure affMenuMag(var p : Personnage; rep : String);
var
pos : coordonnees;
//rep : String;
armur : Armurerie;
len, cb : Integer;
begin
initAffMag(p);
initArmurerie(armur);
repeat
rep:='';
repeat
changerLigneCurseur(56);
changerColonneCurseur(10);
Write('>>> ');
changerColonneCurseur(14);
rep := jeVeuxUneReponse();
centrerTexte(' ', 48, 100);
// R AND ( ( A AND B AND ( S OR T ) ) OR ( C AND D AND ( (S AND E) OR ( T AND F ) ) ) )
until (rep='a') OR ( rep='exit' ) OR ( ( rep[2] = '-' ) AND ( ( (Length(rep) = 3) AND ( Ord(rep[3]) < 58 ) AND ( Ord(rep[3]) > 48 ) AND ( ( rep[1] = 'a' ) OR ( rep[1] = 'v' ) ) ) OR ( (Length(rep) = 4) AND ( rep[3] = '1' ) AND ( Ord(rep[4]) > 47 ) AND ( ( ( rep[1] = 'a' ) AND ( Ord(rep[4]) < 58 ) ) OR ( ( rep[1] = 'v' ) AND ( Ord(rep[4]) < 51 ) ) ) ) ) );
if (rep <> 'a') AND (rep <> 'exit') then
begin
len := Length(rep);
case len of
3: cb:=StrToInt(rep[3]);
4: cb:=StrToInt(rep[4])+10;
end;
if (rep[1] = 'a') then
begin
if p.gold >= armur[cb-1].prix then
begin
if placeInventaire(p) then
begin
p.gold := p.gold - armur[cb-1].prix;
ajouterObjet(p, armur[cb-1].nom);
if (cb = 10) AND (p.quete=5) then p.quete:=6;
initAffMag(p);
centrerTexte(' Tu viens d''acheter un nouvel item, bravo !! ', 48, 100);
end
else
centrerTexte(' T''as plus de place, je peux rien faire pour toi ... ', 48, 100);
end
else
centrerTexte(' T''es pauvre déso ... ', 48, 100);
end
else
begin
if p.inv[cb] <> '' then
begin
p.gold := p.gold + Round(trouverPrixObj(p, cb)*0.5);
enleverObjet(p, p.inv[cb]);
enleverEquipement(p);
initAffMag(p);
centrerTexte(' Tu viens de vendre un item, bravo !! ', 48, 100);
end
else
centrerTexte(' Heuuu tu peux vendre le vide toi ?! ', 48, 100);
end;
end;
until (rep='a') OR (rep='exit');
if rep = 'a' then rep := 'OK';
end;
end.