-
Notifications
You must be signed in to change notification settings - Fork 0
/
rpg_function.c
221 lines (178 loc) · 5.5 KB
/
rpg_function.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
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
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <time.h>
#include <sys/stat.h>
#include <conio.h>
#include <wchar.h>
#include "rpg.h"
//badstatus表示
void display_condition(Player ***st){
if ( (**st) -> badstatus == GOOD ){
printf("STATUS:GOOD\n");
}
else if ( (**st) -> badstatus == DEAD ){
printf("STATUS:DEAD\n");
}
else if ( (**st) -> badstatus == POISON ){
printf("STATUS:POISON\n");
}
}
void display_status(Player **st, Player **st2, Player **st3){
printf("パーティの能力を表示します\n");
printf("\n");
//主人公
printf("%sの能力は・・・\n", (*st) -> name);
printf("%s LV:%d EXP:%d NEXT EXP:%d\n", (*st) -> name, (*st) -> lv, (*st) -> sumexp, (*st) -> nextexp);
printf("HP:%d/%d MP:%d/%d\n", (*st) -> hp, (*st) -> maxhp, (*st) -> mp, (*st) -> maxmp);
display_condition(&st);
printf("力:%d\n", (*st) -> atk);
printf("魔:%d\n", (*st) -> magic);
printf("体:%d\n", (*st) -> str);
printf("速:%d\n", (*st) -> agi);
printf("運:%d\n", (*st) -> luk);
printf("GOLD:%d\n", (*st) -> gold);
//2人目
printf("%sの能力は・・・\n", (*st2) -> name);
printf("%s LV:%d EXP:%d NEXT EXP:%d\n", (*st2) -> name, (*st2) -> lv, (*st2) -> sumexp, (*st2) -> nextexp);
printf("HP:%d/%d MP:%d/%d\n", (*st2) -> hp, (*st2) -> maxhp, (*st2) -> mp, (*st2) -> maxmp);
display_condition(&st2);
printf("力:%d\n", (*st2) -> atk);
printf("魔:%d\n", (*st2) -> magic);
printf("体:%d\n", (*st2) -> str);
printf("速:%d\n", (*st2) -> agi);
printf("運:%d\n", (*st2) -> luk);
//3人目
printf("%sの能力は・・・\n", (*st3) -> name);
printf("%s LV:%d EXP:%d NEXT EXP:%d\n", (*st3) -> name, (*st3) -> lv, (*st3) -> sumexp, (*st3) -> nextexp);
printf("HP:%d/%d MP:%d/%d\n", (*st3) -> hp, (*st3) -> maxhp, (*st3) -> mp, (*st3) -> maxmp);
display_condition(&st3);
printf("力:%d\n", (*st3) -> atk);
printf("魔:%d\n", (*st3) -> magic);
printf("体:%d\n", (*st3) -> str);
printf("速:%d\n", (*st3) -> agi);
printf("運:%d\n", (*st3) -> luk);
printf("\n");
}
int school_command(){
int input;
printf("1.保健室へ行く\n");
printf("2.美術室へ行く\n");
printf("3.化学実験室へ行く\n");
printf("4.ダンジョンへ行く\n");
printf("5.ゲームをセーブせずに止める\n");
printf("6.セーブする\n");
input = _getch();
return input;
}
void buy_goods(Player ***st, Items ***items, int goods_number, int price){
int sum, count;
int input;
printf("何個購入しますか?(1~99個まで,入力が完了したらエンターキーを押してください)\n");
scanf("%d", &count);
if ( count < 1 || count > 99 ){
printf("個数を入力し直してください\n");
return;
}
sum = 0;
for ( int i = 1; i <= count; i++ ){
sum += price;
if ( (**st) -> gold < sum ){
printf("\n");
printf("所持金が足りません...\n");
return;
}
}
printf("\n");
printf("%d個購入しました\n", count);
printf("\n");
(**st) -> gold -= sum;
if ( goods_number == 1 ){
(**items) -> medicine += count;
}
else if ( goods_number == 2 ){
(**items) -> antipoison += count;
}
}
void goods_shop(Player **st, Items **items){
int input;
int goods_number, price;
do{
goods_number = 0;
printf("\n");
printf("---SHOP---\n");
printf("何を買いますか?(所持金: %dG)\n", (*st) -> gold);
printf("1.傷薬:100G(味方1人のHPを50回復)\n");
printf("2.アンタイポイズン:150G(味方1人のPOISONを回復)\n");
printf("c.購入を止める\n");
input = _getch();
if ( input == '1' ){
goods_number = 1;
price = 100;
buy_goods(&st,&items,goods_number, price);
}
else if ( input == '2' ){
goods_number = 2;
price = 150;
buy_goods(&st,&items,goods_number, price);
}
printf("\n");
} while ( input != 'c' );
}
void buy_equips(Player ***st, Equip ***equip, int equip_number, int price){
int sum, count;
int input;
printf("何個購入しますか?(1~99個まで,入力が完了したらエンターキーを押してください)\n");
scanf("%d", &count);
if ( count < 1 || count > 99 ){
printf("個数を入力し直してください\n");
return;
}
sum = 0;
for ( int i = 1; i <= count; i++ ){
sum += price;
if ( (**st) -> gold < sum ){
printf("\n");
printf("所持金が足りません...\n");
return;
}
}
printf("\n");
printf("%d個購入しました\n", count);
printf("\n");
(**st) -> gold -= sum;
if ( equip_number == 1 ){
(**equip) -> HpRing1 += count;
}
else if ( equip_number == 2 ){
(**equip) -> MpRing1 += count;
}
}
void equip_shop(Player **st, Player **st2, Player **st3, Equip **equip){
int input;
int equip_number, price;
do {
equip_number = 0;
printf("\n");
printf("---SHOP---\n");
printf("何を購入しますか?(所持金: %dG)\n", (*st) -> gold);
printf("1.HPリング1: 500G(味方1人の最大HPを5%増加)\n");
if ( (*st) -> stage_clear >= 2 ){
printf("2.MPリング1: 800G(味方1人の最大MPを5%増加)\n");
}
printf("c.購入を止める\n");
input = _getch();
if ( input == '1' ){
equip_number = 1;
price = 500;
buy_equips(&st,&equip,equip_number,price);
}
else if ( input == '2' && (*st) -> stage_clear >= 2 ){
equip_number = 2;
price = 800;
buy_equips(&st,&equip,equip_number,price);
}
printf("\n");
} while ( input != 'c' );
}