-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathularn_ask.c
138 lines (114 loc) · 3.13 KB
/
ularn_ask.c
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
/* =============================================================================
* PROGRAM: ularn
* FILENAME: ularn_ask.c
*
* DESCRIPTION:
* This module provides functions for getting answers to common questions
* in the game from teh player.
*
* =============================================================================
* EXPORTED VARIABLES
*
* None
*
* =============================================================================
* EXPORTED FUNCTIONS
*
* more - Asks press space to continue
* clearpager - resets pagination calculations for paged text output
* pager - Call to perform pagination ofter each line of text is output
* getyn - ASks for a yess no answer
* getpassword - Get the password for wizard
* dirsub - Asks for a direction
*
* =============================================================================
*/
#include "ularn_ask.h"
#include "dungeon.h"
#include "header.h"
#include "player.h"
#include "ularn_game.h"
#include "ularn_win.h"
/* =============================================================================
* Local variables
*/
/* the current line number for paginating text */
static int srcount = 0;
/* =============================================================================
* Exported functions
*/
/* =============================================================================
* FUNCTION: more
*/
void more(void) {
Print("\n --- press ");
Standout("space");
Print(" to continue --- ");
get_prompt_input("", " ", 0);
}
/* =============================================================================
* FUNCTION: clearpager
*/
void clearpager(void) { srcount = 0; }
/* =============================================================================
* FUNCTION: pager
*/
void pager(void) {
if (++srcount >= 22) {
srcount = 0;
more();
ClearText();
}
}
/* =============================================================================
* FUNCTION: getyn
*/
int getyn(void) {
int i;
i = get_prompt_input("", "yYnN\033 ", 1);
if (isspace(i))
i = ESC;
return i;
}
/* =============================================================================
* FUNCTION: getpassword
*/
int getpassword(void) {
char gpwbuf[9];
Print("\nEnter Password: ");
get_password_input(gpwbuf, 8);
if (strcmp(gpwbuf, password) != 0) {
Print("\nSorry.\n");
return 0;
} else
return 1;
}
/* =============================================================================
* FUNCTION: dirsub
*/
int dirsub(int *x, int *y) {
ActionType ans;
int d;
ActionType dir_order[9];
/*
* Direction keys. Order must match diroff
*/
dir_order[0] = ACTION_MOVE_SOUTH;
dir_order[1] = ACTION_MOVE_EAST;
dir_order[2] = ACTION_MOVE_NORTH;
dir_order[3] = ACTION_MOVE_WEST;
dir_order[4] = ACTION_MOVE_NORTHEAST;
dir_order[5] = ACTION_MOVE_NORTHWEST;
dir_order[6] = ACTION_MOVE_SOUTHEAST;
dir_order[7] = ACTION_MOVE_SOUTHWEST;
dir_order[8] = 0;
ans = get_dir_input("\nIn What Direction? ", 1);
d = 0;
while (dir_order[d] != ans)
d++;
d++;
Print(dirname[d]);
*x = playerx + diroffx[d];
*y = playery + diroffy[d];
return d;
}