-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStore.pas
757 lines (590 loc) · 22.5 KB
/
Store.pas
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
(*
Copyright (C) 2024 Jeffrey Getzin.
Licensed under the GNU General Public License v3.0 with additional terms.
See the LICENSE file in the repository root for details.
*)
[Inherit ('Types','SYS$LIBRARY:STARLET','SMGRTL')]Module Trading_Post;
Type
Choice_List = Array [1..10] of Item_Record;
Var
BottomDisplay: [External]Unsigned;
Item_List: [External]List_of_Items;
(******************************************************************************)
[External]Function Roll_Die (Die_Type: Integer): [Volatile]Integer;External;
[External]Function Make_Choice (Choices: Char_Set; Time_Out: Integer:=-1; Time_Out_Char: Char:=' '):Char;External;
[External]Function Yes_or_No (Time_Out: Integer:=-1; Time_Out_Char: Char:=' '): [Volatile]Char;External;
[External]Function Can_Play: [Volatile]Boolean;External;
[External]Procedure Delay (Seconds: Real);External;
[External]Procedure Ring_Bell (Display_Id: Unsigned; Number_of_Times: Integer:=1);External;
[External]Function String(Num: Integer; Len: Integer:=0):Line;External;
[External]Procedure increment_item_quantity(slot: integer);External;
[External]Procedure Close_Quantity_File;External;
(******************************************************************************)
Function Item_Has_Value (Item: Item_Record): Boolean;
Var
Temp: Boolean;
Begin
Temp:=False;
Temp:=Temp or (Item.Special_Occurance_No<>0);
Temp:=Temp or (Item.Spell_Cast<>NoSp);
Temp:=Temp or (Item.Regenerates>0);
Temp:=Temp or (Item.Protects_Against<>[]);
Temp:=Temp or (Item.Resists<>[]);
Temp:=Temp or (Item.Versus<>[]);
Temp:=Temp or (Item.Damage.X + Item.Damage.Z>0);
Temp:=Temp or (Item.Additional_Attacks>0);
Temp:=Temp or (Item.Plus_to_Hit>0);
Temp:=Temp or (Item.AC_plus<0);
Temp:=Temp or (Item.autoKill);
Temp:=Temp AND (Item.Usable_By<>[]);
Item_Has_Value:=Temp;
End;
(******************************************************************************)
Procedure Print_Message (Message_Text: Line);
Begin
SMG$Begin_Display_Update (BottomDisplay);
SMG$Erase_Display (BottomDisplay,,1);
SMG$Set_Cursor_ABS (BottomDisplay,,40-(Message_Text.length div 2));
SMG$Put_Line (BottomDisplay,Message_Text,0);
SMG$End_Display_Update (BottomDisplay);
End;
(******************************************************************************)
Procedure Attach_Item_to_Character (Item: Item_Record; Var Character: Character_Type);
Begin
Character.No_of_Items:=Character.No_of_Items + 1;
Character.Item[Character.No_of_Items].Item_Num:=Item.Item_Number;
Character.Item[Character.No_of_Items].Ident:=True;
Character.Item[Character.No_of_Items].Usable:=(Character.Class in Item.Usable_By) or (Character.PreviousClass in Item.Usable_By);
Character.Item[Character.No_of_Items].Cursed:=False;
Character.Item[Character.No_of_Items].isEquipped:=False;
Character.Items_Seen[Character.No_of_Items]:=True;
End;
(******************************************************************************)
Procedure Its_Been_a_Pleasure;
Begin
Print_Message ('* * * It''s a pleasure doing business with thee * * *');
Delay (2);
End;
(******************************************************************************)
[External]Procedure Access_Item_Quantity_Record (N: Integer);External;
[External]Function Item_Count (Item_Number: Integer): [Volatile]Integer;External;
[External]Procedure Decrement_Quantity (slot: Integer);External;
[External]Function Get_Store_Quantity(slot: Integer): Integer;External;
[External]Procedure Open_Quantity_File_For_Write;External;
(******************************************************************************)
Procedure Get_Item (Var Character: Character_Type; Item: Item_Record);
{ Gives an item to a character. It is assumed he/she can afford it and has room. }
Begin
Character.Gold:=Max(Character.Gold-Item.Current_Value,0);
Attach_Item_to_Character (Item,Character);
If Get_Store_Quantity(Item.Item_Number) = 1 then
Begin
Print_Message ('* * * That was the last one we had in stock * * *');
Delay(1);
End
Else if Not(Character.Item[Character.No_of_Items].Usable) then
Begin
Print_Message ('* * * It''s thy money... * * *');
Delay(1);
End
Else
Its_Been_a_Pleasure;
{ If the item is not in unlimited supply, decrement the amount available }
Decrement_Quantity(item.Item_Number);
End;
(******************************************************************************)
Procedure Too_Expensive;
Begin { Too Expensive }
Print_Message ('* * * Thou canst not afford it! * * *');
Ring_Bell (BottomDisplay);
Delay (2);
End;
(******************************************************************************)
Procedure Sold_Out;
Begin
Print_Message ('* * * Sorry, we just sold our last one! * * *');
Delay(2);
End;
(******************************************************************************)
Procedure No_Room;
Begin
Print_Message ('* * * Thou canst not carry any more! * * *');
Delay(2);
End;
(******************************************************************************)
Procedure Add_Item (Item: Item_Record; Var Character: Character_Type);
{ This procedure assumes AMOUNTFILE has been oppened for DIRECT access. TODO: Move to Files.pas }
Begin
If Get_Store_Quantity(Item.Item_Number) = 0 then
Sold_Out
Else if Character.Gold<Item.Current_Value then
Too_Expensive
Else If Character.No_of_Items=8 then
No_Room
Else
Get_Item (Character,Item);
End;
(******************************************************************************)
Procedure Page_Backwards (Var First: Integer; Amount: Integer:=10);
Var
Temp: Integer;
Begin
Temp:=0;
Repeat
Begin
First:=First-1;
If First<1 then
First:=249;
If Item_Count(First)<>0
then Temp:=Temp + 1;
End;
Until Temp=Amount; { TODO: If there aren't ten items in the store, this will loop forever. }
End;
(******************************************************************************)
Procedure Purchase_Item (Choices: Choice_List; Var Buyer: Character_Type);
Var
Answer: Char;
INum: Integer;
Begin
SMG$Put_Line (BottomDisplay,'Purchase which item?',0);
Answer:=Make_Choice (['A'..'J',' ',CHR(13)]);
If Buyer.Status=Insane then
Answer:=CHR(Roll_Die(10)+64);
If Not (Answer in [' ',CHR(13)]) then
Begin
INum:=Ord(Answer)-64;
Access_Item_Quantity_Record (Choices[INum].Item_Number);
If Not ((Buyer.Class in Choices[INum].Usable_By) or (Buyer.PreviousClass in Choices[INum].Usable_By)) then
Begin
SMG$Put_Line (BottomDisplay,'Unusable item. Confirm purchase? (Y/N)',0);
If Yes_or_No='Y' then
Add_Item(Choices[INum],Buyer);
End
Else
Add_Item (Choices[INum],Buyer);
End;
End;
(******************************************************************************)
Procedure Print_List (Choices: Choice_List; Buyer: Character_Type);
Var
Loop: Integer;
Begin
For Loop:=1 to 10 do { TODO: Use a constant }
Begin
SMG$Put_Chars (BottomDisplay,'['+CHR(Loop + 64)+'] '+Pad(Choices[Loop].True_Name,' ',20)+' ');
SMG$Put_Chars (BottomDisplay,String(Choices[Loop].Current_Value,12)+' GP');
If Not ((Buyer.Class in Choices[Loop].Usable_By) or (Buyer.PreviousClass in Choices[Loop].Usable_By)) then
SMG$Put_Chars (BottomDisplay,' (Unusable)');
SMG$Put_Line (BottomDisplay,'');
End;
SMG$Put_Line (BottomDisplay,'Thou hast '+String(Buyer.Gold)+' GP');
SMG$Put_Line (BottomDisplay,'F)orward, B)ack, P)urchase, E)xit',0);
End;
(******************************************************************************)
Function Compute_Items_on_Page (First: Integer; Var Choices: Choice_List): Integer;
Var
Last,Loop: Integer;
Begin
Last:=First;
For Loop:=1 to 10 do
Begin
While (Item_Count(Last)=0) or Not(Item_Has_Value(Item_List[Last])) do
Begin
Last:=Last + 1;
If Last=450 then Last:=1; { TODO: This may be a bug. I think 450 is a valid index }
End;
Choices[Loop]:=Item_List[Last];
Last:=Last + 1;
If Last>249 then { TODO: These two constants---450 and 249---seem confusing to me. Is 450 the maximum item in the item list and 249 is the maximum number of items *in the store*? }
Last:=1;
End;
Compute_Items_On_Page:=Last;
End;
(******************************************************************************)
Procedure Buy_Item (Var Buyer: Character_Type);
Var
First,Last: Integer;
Answer: Char;
Choices: Choice_List;
Begin
First:=1; Choices:=Zero;
Open_Quantity_File_For_Write;
Repeat
Begin
{ For a list of 10 items in the store for sale }
Last:=Compute_Items_on_Page (First,Choices);
SMG$Begin_Display_Update (BottomDisplay);
SMG$Erase_Display (BottomDisplay);
Print_List (Choices,Buyer);
SMG$End_Display_Update (BottomDisplay);
Answer:=Make_Choice (['B','F','P','E']);
Case Answer of
'B': Page_Backwards (First);
'F': First:=Item_List[Last].Item_Number; { TODO: Is this correct? Shouldn't first = last? }
'P': Purchase_Item (Choices,Buyer);
'E': ;
End;
End;
Until (Answer='E');
Close_Quantity_File;
End;
(******************************************************************************)
Procedure Print_Sale_Items (Seller: Character_Type; NumItems: Integer; Var Options,Dont_Want: Char_Set);
Var
TempItem1: Item_Record;
Current_Value,Loop: Integer;
T: Line;
Begin
For Loop:=1 to NumItems do
Begin
Options:=Options+[CHR(Loop + 64)];
T:=T+'['+CHR(Loop + 64)+'] ';
If Seller.Item[Loop].Cursed then
T:=T+'-'
Else if Seller.Item[Loop].isEquipped then
T:=T+'*'
Else if Not Seller.Item[Loop].Ident then
T:=T+'?'
Else
T:=T+' ';
TempItem1:=Item_List[Seller.Item[Loop].Item_Num];
Current_Value:=TempItem1.Current_Value;
If (Seller.Item[Loop].Ident) and not (TempItem1.Cursed) and Item_Has_Value(TempItem1) then
Begin
T:=T + Pad(TempItem1.True_Name,' ',20)+' '+String (Current_Value div 2,12)+' GP';
SMG$Put_Line (BottomDisplay, T);
End
Else
Begin
Dont_Want:=Dont_Want+[CHR(Loop + 64)];
If (Not(Seller.Item[Loop].Ident)) then
T:=T + Pad(TempItem1.Name,' ',20)
Else
T:=T + Pad(TempItem1.True_Name,' ',20);
T:=T+' '+String(0,7)+' GP';
SMG$Put_Line (BottomDisplay,T);
End;
End;
SMG$Set_Cursor_ABS (BottomDisplay,11,1);
SMG$Put_Line (BottomDisplay,'Thou has '+String(Seller.Gold)+' GP');
SMG$Put_Line (BottomDisplay,'Sell which item?');
SMG$End_Display_Update (BottomDisplay);
End;
(******************************************************************************)
Procedure Sell_Items (Var Seller: Character_Type; Var NumItems: Integer; Var Answer: Char);
Var
Current_Value,Num,Loop: Integer;
Options,Dont_Want: Char_Set;
TempItem: Item_Record;
Begin
Options:=[CHR(13),CHR(32)]; Dont_Want:=[];
Print_Sale_Items (Seller,NumItems,Options,Dont_Want);
Answer:=Make_Choice (Options);
If Not (Answer in [CHR(13),CHR(32)]) then { TODO: This code seems suspect. Double-check source in printout. }
Begin
Num:=ORD(Answer)-64;
TempItem:=Item_List[Seller.Item[Num].Item_Num];
Current_Value:=TempItem.Current_Value;
If Num=NumItems then
NumItems:=NumItems-1
Else
Begin
For Loop:=Num to NumItems-1 do
Seller.Item[Loop]:=Seller.Item[Loop + 1];
NumItems:=NumItems-1;
End;
increment_item_quantity(TempItem.Item_Number);
Seller.Gold:=Min(Seller.Gold+(Current_Value div 2),MaxInt);
Its_Been_A_Pleasure;
End
Else
Begin
Print_Message ('* * * We''re not interested in that! * * *');
Delay (2);
End;
End;
(******************************************************************************)
Procedure Sell_Item (Var Seller: Character_Type);
Var
NumItems: Integer;
Answer: Char;
Begin
Open_Quantity_File_For_Write;
Repeat
Begin
SMG$Begin_Display_Update (BottomDisplay);
SMG$Erase_Display (BottomDisplay);
SMG$Set_Cursor_ABS (BottomDisplay,2,1);
NumItems:=Seller.No_of_Items;
If NumItems<>0 then
Begin
Sell_Items (Seller,NumItems,Answer);
Seller.No_of_Items:=NumItems;
End
Else
Begin
Answer:=CHR(13);
SMG$End_Display_Update (BottomDisplay);
End;
End;
Until Answer in [CHR(13),CHR(32)];
Close_Quantity_File;
End;
(******************************************************************************)
Procedure Print_Uncurse_Items (Customer: Character_Type; NumItems: Integer; Var Options: Char_Set);
Var
Current_Value,Loop: Integer;
T: Line;
Begin
For Loop:=1 to NumItems do
Begin
Options:=Options+[CHR(Loop + 64)];
T:='['+CHR(Loop + 64)+'] ';
If Customer.Item[Loop].Cursed then
T:=T+'-'
Else
T:=T+' ';
If (Customer.Item[Loop].Ident) then
T:=T + Pad(Item_List[Customer.Item[Loop].Item_Num].True_Name,' ',20)+' '
Else
T:=T + Pad(Item_List[Customer.Item[Loop].Item_Num].Name,' ',20)+' ';
Current_Value:=Item_List[Customer.Item[Loop].Item_Num].Current_Value;
If Not Customer.Item[Loop].Cursed then
Current_Value:=0;
T:=T + String(Current_Value)+' GP';
SMG$Put_Line (BottomDisplay,T);
End;
SMG$Set_Cursor_ABS (BottomDisplay,11,1);
SMG$Put_Line (BottomDisplay,'Thou hast '+String(Customer.Gold)+' GP');
SMG$Put_Line (BottomDisplay,'Uncurse which item?',0);
SMG$End_Display_Update (BottomDisplay);
End;
(******************************************************************************)
Procedure Uncurse_Items (Var Customer: Character_Type; Var NumItems: Integer; Var Answer: Char);
Var
Options: Char_Set;
Current_Value,Loop,Num: Integer;
TempItem: Item_Record;
Begin
Options:=[CHR(13),CHR(33)];
Print_Uncurse_Items (Customer,NumItems,Options);
Answer:=Make_Choice (Options);
If Not(Answer in [CHR(13),CHR(32)]) then
Begin
Num:=ORD(Answer)-64;
TempItem:=Item_List[Customer.Item[Num].Item_Num];
Current_Value:=TempItem.Current_Value;
If Customer.Gold>=Current_Value then
Begin
If Num<>NumItems then
For Loop:=Num to NumItems-1 do
Customer.Item[Loop]:=Customer.Item[Loop + 1];
NumItems:=NumItems-1;
Customer.Gold:=Max(Customer.Gold-Current_Value,0);
Its_Been_a_Pleasure;
End
Else
Too_Expensive;
End;
End;
(******************************************************************************)
Procedure Uncurse_Item (Var Customer: Character_Type);
Var
NumItems: Integer;
Answer: Char;
Begin
Repeat
Begin
SMG$Begin_Display_Update (BottomDisplay);
SMG$Erase_Display (BottomDisplay,1,1,12,80);
SMG$Set_Cursor_ABS (BottomDisplay,2,1);
NumItems:=Customer.No_of_Items;
If NumItems<>0 then
Begin
Uncurse_Items (Customer,NumItems,Answer);
Customer.No_of_Items:=NumItems;
End
Else
Begin
Answer:=CHR(13);
SMG$End_Display_Update (BottomDisplay);
End;
End;
Until Answer in [CHR(13),CHR(32)];
End;
(******************************************************************************)
Procedure Print_ID_Items (Customer: Character_Type);
Var
Current_Value,NumItems,Loop: Integer;
T: Line;
Begin
NumItems:=Customer.No_of_Items;
For Loop:=1 to NumItems do
Begin
T:='['+CHR(Loop + 64)+'] ';
If Customer.Item[Loop].Cursed then
T:=T+'-'
Else if Customer.Item[Loop].Ident then
T:=T+' '
Else
T:=T+'?';
If (Customer.Item[Loop].Ident) then
T:=T + Pad(Item_List[Customer.Item[Loop].Item_Num].True_Name,' ',21)
Else
T:=T + Pad(Item_List[Customer.Item[Loop].Item_Num].Name,' ',21);
Current_Value:=Item_List[Customer.Item[Loop].Item_Num].Current_Value;
If Customer.Item[Loop].Ident then
Current_Value:=0;
T:=T+' '+String(Current_Value)+' GP';
SMG$Put_Line (BottomDisplay,T);
End;
SMG$Set_Cursor_ABS (BottomDisplay,11,1);
SMG$Put_Line (BottomDisplay,'Thou hast '+String(Customer.Gold)+' GP');
SMG$Put_Line (BottomDisplay,'Identify which item?',0);
SMG$End_Display_Update (BottomDisplay);
End;
(******************************************************************************)
Procedure Identify_Items (Var Customer: Character_Type; Var Answer: Char);
Var
Num,Current_Value,NumItems: Integer;
Options: Char_Set;
TempItem: Item_Record;
Begin
NumItems:=Customer.No_of_Items;
Print_ID_Items (Customer);
Options:=['A'..CHR(NumItems + 64),CHR(13),CHR(32)];
Answer:=Make_Choice (Options);
If Not(Answer in [CHR(13),CHR(32)]) then
Begin
Num:=ORD(Answer)-64;
TempItem:=Item_List[Customer.Item[Num].Item_Num];
Current_Value:=TempItem.Current_Value;
If Customer.Item[Num].Ident then
Current_Value:=0;
If Customer.Gold>=Current_Value then
Begin
Num:=Ord(Answer)-64;
Customer.Item[Num].Ident:=True;
Customer.Gold:=Max(Customer.Gold-Current_Value,0);
If TempItem.Item_Number<251 then
Customer.Items_Seen[TempItem.Item_Number]:=True;
Its_Been_a_Pleasure;
End
Else
Too_Expensive;
End;
End;
(******************************************************************************)
Procedure Identify_Item (Var Customer: Character_Type);
Var
NumItems: Integer;
Answer: Char;
Begin
Repeat
Begin
SMG$Begin_Display_Update (BottomDisplay);
SMG$Erase_Display (BottomDisplay, 1,1,12,80);
SMG$Set_Cursor_ABS (BottomDisplay,2,1);
NumItems:=Customer.No_of_Items;
If NumItems<>0 then
Identify_Items (Customer,Answer)
Else
Begin
Answer:=CHR(13);
SMG$End_Display_Update (BottomDisplay);
End
End
Until Answer in [CHR(13),CHR(32)];
End;
(******************************************************************************)
Function Pool_Gold (Var Party: Party_Type; Party_Size: Integer): Integer;
{ The function returns the total amount of gold the party has, and then clears each member's purse. For this reason, it is only
to be used in an assignment statement and never like the following:
If Pool_Gold(Party,Party_Size)>0 then ...
because this will clear the party's wealth, and not store it anywhere ... }
Var
N,Sum: Integer;
Begin
Sum:=0;
For N:=1 to Party_Size do
Begin
Sum:=Sum + Party[N].Gold;
Party[N].Gold:=0;
End;
If Sum<0 then Sum:=MaxInt; { If overflow }
Pool_Gold:=Sum;
End;
(******************************************************************************)
Procedure Print_Menu (Character: Character_Type);
Begin
SMG$Begin_Display_Update (BottomDisplay);
SMG$Erase_Display (BottomDisplay);
SMG$Set_Cursor_ABS (BottomDisplay,2,1);
SMG$Put_Line (BottomDisplay,'Welcome ',2);
SMG$Put_Chars (BottomDisplay,Character.Name+'',2,9,0,1);
SMG$Put_Line (BottomDisplay,', thou hast '+ String(Character.Gold)+' Gold Pieces.');
SMG$Put_Line (BottomDisplay,'What wouldst thou like to do?',2);
SMG$Put_Line (BottomDisplay,'[B] Buy an item');
SMG$Put_Line (BottomDisplay,'[S] Sell an item');
SMG$Put_Line (BottomDisplay,'[U] Have an item uncursed');
SMG$Put_Line (BottomDisplay,'[I] Have an item identified');
SMG$Put_Line (BottomDisplay,'[P] Pool thine party''s gold');
SMG$Put_Line (BottomDisplay,'[E] Exit my shop',2);
SMG$Put_Line (BottomDisplay,'Which?',0);
SMG$End_Display_Update (BottomDisplay);
End;
(******************************************************************************)
Procedure Enter_Store (Var Character: Character_Type; Var Party: Party_Type; Party_Size: Integer);
Var
Answer: Char;
Begin
Repeat
Begin
{ Print a menu of available options }
Print_Menu (Character);
{ Get Sophie's choice }
Answer:=Make_Choice(['B','S','U','I','P','E']);
{ Handle it }
Case Answer of
'B': Buy_Item (Character);
'S': Sell_Item (Character);
'U': Uncurse_Item (Character);
'I': Identify_Item (Character);
'P': Character.Gold:=Pool_Gold (Party,Party_Size);
'E': ;
End;
End;
Until Answer='E';
End;
(******************************************************************************)
Procedure Print_Store_Heading (Party_Size: Integer);
Begin
SMG$Begin_Display_Update (BottomDisplay);
SMG$Erase_Display (BottomDisplay);
SMG$Set_Cursor_ABS (BottomDisplay,2,1);
SMG$Put_Line (BottomDisplay,'Welcome to Gisele''s Trading Post! Who will enter and try my wares?');
SMG$Put_Line (BottomDisplay,'(1-'+String(Party_Size,1)+', [RETURN] exists)',0);
SMG$End_Display_Update (BottomDisplay);
End;
(******************************************************************************)
[Global]Procedure Run_Trading_Post (Var Party: Party_Type; Party_Size: Integer);
Var
Person: Integer;
Location: [External]Place_Type;
[External]Function Pick_Character_Number (Party_Size: Integer; Current_Party_Size: Integer:=0;
Time_Out: Integer:=-1; Time_Out_Char: Char:='0'): [Volatile]Integer;External;
Begin { Run Trading Post }
Person:=0;
Repeat
Begin
Print_Store_Heading (Party_Size);
If Not Can_Play then Person:=0
Else Person:=Pick_Character_Number (Party_Size);
If Person<>0 then
If (Party[Person].Status in [Healthy,Poisoned,Insane]) then
Enter_Store (Party[Person],Party,Party_Size);
End;
Until Person=0;
Location:=InKyrn;
End; { Run Trading Post }
End. { Trading Post }