-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCasino.pas
121 lines (98 loc) · 4.21 KB
/
Casino.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
(*
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','SMGRTL')]Module Casino;
Var
BottomDisplay: [External]Unsigned;
Location: [External]Place_Type;
(*********************************************************************************************************************************)
[External]Function String(Num: Integer; Len: Integer:=0):Line;external;
[External]Function Can_Play: [Volatile]Boolean;External;
[External]Function Make_Choice (Choices: Char_Set; Time_Out: Integer:=-1; Time_Out_Char: Char:=' '): Char;External;
[External]Function Zero_Through_Six (Var Number: Integer; Time_Out: Integer:=-1; Time_Out_Char: Char:='0'): Char;External;
[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;
Procedure Play_Slots (Var Character: Character_Type);external;
(*********************************************************************************************************************************)
Function Pool_Gold (Var Character: Character_Type; 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:=Character.Gold; Character.Gold:=0;
For N:=1 to Party_Size do
Begin
If Party[N].Name<>Character.Name then Sum:=Sum + Party[N].Gold;
Party[N].Gold:=0;
End;
Pool_Gold:=Sum;
End;
(*********************************************************************************************************************************)
Procedure Character_Entered (Var Character: Character_Type; Var Party: Party_Type; Party_Size: Integer);
Var
Answer: Char;
Options: Char_Set;
Begin { Character Entered }
Repeat
Begin
SMG$Begin_Display_Update (BottomDisplay);
SMG$Erase_Display (BottomDisplay);
SMG$Set_Cursor_ABS (BottomDisplay, 2, 1);
SMG$Put_Chars (BottomDisplay, 'Welcome, ');
SMG$Put_Chars (BottomDisplay, Character.Name,,,,1);
SMG$Put_Line (BottomDisplay, ', thou have');
SMG$Put_Line (BottomDisplay,String(Character.Gold)
+' Gold Pieces. Thou may: ',2);
SMG$Put_Line (BottomDisplay, '[S] Play Slots');
SMG$Put_Line (BottomDisplay, '[P] Pool gold',2);
SMG$Put_Line (BottomDisplay, 'Which? [Return exits]');
SMG$End_Display_Update (BottomDisplay);
Options:=['S', 'P', CHR(13)];
Answer:=Make_Choice(Options);
Case Answer of
'P': Character.Gold:=Pool_Gold(Character,Party,Party_Size);
'S': Play_Slots (Character);
CHR(13): ;
End
End
Until Answer=CHR(13);
End;
(*****************************************************************************)
Function Get_Person (Party_Size: Integer): [Volatile]Integer;
Var
Person: Integer;
Begin
Person:=0;
If Can_Play then Repeat Zero_Through_Six (Person) Until (Person<=Party_Size);
Get_Person:=Person;
End;
(*********************************************************************************************************************************)
[Global]Procedure Run_Casino (Var Party: Party_Type; Party_Size: Integer);
Var
Character: Character_Type;
Person: Integer;
Begin
Person:=0;
Repeat
Begin
SMG$Erase_Display (BottomDisplay);
Smg$Set_Cursor_ABS (BottomDisplay,2,1);
Smg$Put_line (BottomDisplay,
'Welcome to the Five Aces Casino! Who will tempt the winds of fate?');
Person:=Get_Person (Party_Size);
If (Person<>0) Then
If (Party[Person].Status in [Healthy,Poisoned,Insane]) then
Begin
Character:=Party[Person];
Character_Entered (Character,Party,Party_Size);
End;
End;
Until Person=0;
Location:=InKyrn;
End;
End.