forked from MAYANK25402/Hactober-2023-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkabaddi.c
389 lines (357 loc) · 9.2 KB
/
kabaddi.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
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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
int raider(int k) {
srand(time(NULL));
return rand() % k;
}
int skills(int l) {
srand(time(NULL));
return rand() % l;
}
int creacts(int y) {
srand(time(NULL));
return rand() % y;
}
int raidresult(int r) {
srand(time(NULL));
return rand() % r;
}
int toss(int n) {
srand(time(NULL));
return rand() % n;
}
char player1Name[10], player2Name[10], player3Name[10], player4Name[10],
player5Name[10], player6Name[10], player7Name[10];
int Toss, choice, playerSkill1,
played = 0, won = 0, lost = 0, playAgain, Raider, compReaction, urReaction,
result_1, result_2, score1 = 0, score2 = 0, raidNum = 1, playerSkill2;
int main() {
printf("\n\n\t\t\t\tWELCOME TO THE WORLD OF KABADDI \n");
printf("\n");
for (int j = 0; j < 89; j++) {
printf("_");
}
printf("\n");
for (int i = 0; i < 25; i++) {
printf("| | | | "
" | | |\n");
}
for (int j = 0; j < 89; j++) {
printf("-");
}
printf("\n");
playagain:
if (playAgain == 1) {
score1 = 0;
score2 = 0;
raidNum = 1;
}
printf("\nEnter your Playing-7\n");
printf("Player-1: ");
scanf("%s", player1Name);
printf("Player-2: ");
scanf("%s", player2Name);
printf("Player-3: ");
scanf("%s", player3Name);
printf("Player-4: ");
scanf("%s", player4Name);
printf("Player-5: ");
scanf("%s", player5Name);
printf("Player-6: ");
scanf("%s", player6Name);
printf("Player-7: ");
scanf("%s", player7Name);
printf("TIME FOR TOSS..!!\n\nPRESS 0 FOR 'HEADS' & 1 FOR 'TAILS'\n");
scanf("%d", &Toss);
if (Toss == toss(2)) {
printf("PRESS 1 FOR 'COURT' & 0 FOR 'RAID'\n");
scanf("%d", &choice);
if (choice == 0) {
printf("You will RAID first.!\n");
} else if (choice == 1) {
printf("COMPUTER will RAID first.!\n");
goto cmpraid;
}
} else {
printf("You will RAID first.!\n");
}
// raid first
matchOn:
printf("\ncomputer %d - %d you\n",score2,score1);
printf("\nIt is raid number %d \n", raidNum);
raidNum = raidNum + 1;
// Raider = raider(7);
printf("Select player's number to send him as raider.\n");
scanf("%d", &Raider);
// you
switch (Raider - 1) {
case 0:
printf("\n%s is going for the raid..! ", player1Name);
goto skill;
break;
case 1:
printf("\n%s is going for the raid..! ", player2Name);
goto skill;
break;
case 2:
printf("\n%s is going for the raid..! ", player3Name);
goto skill;
break;
case 3:
printf("\n%s is going for the raid..! ", player4Name);
goto skill;
break;
case 4:
printf("\n%s is going for the raid..! ", player5Name);
goto skill;
break;
case 5:
printf("\n%s is going for the raid..! ", player6Name);
goto skill;
break;
case 6:
printf("\n%s is going for the raid..! ", player7Name);
goto skill;
break;
}
skill:
playerSkill1 = skills(5);
// for skill
switch (playerSkill1) {
case 0:
printf("and tries for 'TURNING HAND TOUCH', and ");
goto reaction;
break;
case 1:
printf("and attempts a 'RUNNING HAND TOUCH', and ");
goto reaction;
break;
case 2:
printf("and goes for the 'TOE TOUCH', and ");
goto reaction;
break;
case 3:
printf("and here he tries the 'SCORPION KICK', and ");
goto reaction;
break;
case 4:
printf("and surprisingly attempts 'RUNNING KICK' in the middle of the "
"COURT, and ");
goto reaction;
break;
}
reaction:
compReaction = creacts(6);
switch (compReaction) {
case 0:
printf(" the defender goes for 'DOUBLE THIGH HOLD'. ");
goto result1;
break;
case 1:
printf(" defender tries 'ANKLE HOLD' here. ");
goto result1;
break;
case 2:
printf(" the defenders came in with a 'CHAIN' to block the raider, ");
goto result1;
break;
case 3:
printf(" the defence goes for a 'DASH' ");
goto result1;
break;
case 4:
printf(" here defender tries the 'BACK HOLD' ");
goto result1;
break;
}
result1:
result_1 = raidresult(8);
// for result1
switch (result_1) {
case 0:
printf(" the raider escapes easily and got 1 point.\n");
score1 = score1 + 1;
goto cmpraid;
break;
case 1:
printf(" the defender don't let the raider escape and earns one point for "
"his team..!\n");
score2 = score2 + 1;
goto cmpraid;
break;
case 2:
printf(" the raider get rid of the two defenders and added 2 more points "
"to the total.\n");
score1 = score1 + 2;
goto cmpraid;
break;
case 3:
printf(" JUST AMAZINGGG..!!, the defence is 'ROARING', 1 point to the "
"defence.\n");
score2 = score2 + 1;
goto cmpraid;
break;
case 4:
printf(" a good effort from raider and the defence, 'AN EMPTY RAID' this "
"time.\n");
goto cmpraid;
break;
case 5:
printf(" 'ONE POINT EACH', raider got the 'BONUS' but can not escape the "
"'SOLID DEFENCE'.\n");
score1 = score1 + 1;
score2 = score2 + 1;
goto cmpraid;
break;
case 6:
printf(" this is a 'SUUUUUPPPEEERRRRRRR RAAAIIIIIID..!!' the RAIDER "
"manages to escape all the '3 DEFENDERS'; got 3 POINTS.\n");
score1 = score1 + 3;
goto cmpraid;
break;
case 7:
printf(
" the defence got him, raider was just about to cross the midline but "
"the support comes at very right time, 1 POINT to the defence.\n");
score2 = score2 + 1;
goto cmpraid;
break;
}
cmpraid:
printf("\ncomputer %d - %d you\n",score2,score1);
printf("\nIt is raid number %d\n", raidNum);
raidNum = raidNum + 1;
playerSkill2 = skills(4);
switch (playerSkill2) {
case 0:
printf(" It's time for computer to raid and computer tries for 'TURNING "
"HAND TOUCH', and ");
goto reaction2;
break;
case 1:
printf(" It's time for computer to raid and computer attempts a 'RUNNING "
"HAND TOUCH', and ");
goto reaction2;
break;
case 2:
printf(" It's time for computer to raid and computer goes for the 'TOE "
"TOUCH', and ");
goto reaction2;
break;
case 3:
printf(" It's time for computer to raid and computer here he tries the "
"'SCORPION KICK', and ");
goto reaction2;
break;
}
reaction2:
urReaction = creacts(5);
// for reactions
switch (urReaction) {
case 0:
printf(" the defender goes for 'DOUBLE THIGH HOLD'. ");
goto result2;
break;
case 1:
printf(" defender tries 'ANKLE HOLD' here. ");
goto result2;
break;
case 2:
printf(" the defenders came in with a 'CHAIN' to block the raider, ");
goto result2;
break;
case 3:
printf(" the defence goes for a 'DASH' ");
goto result2;
break;
case 4:
printf(" here defender tries the 'BACK HOLD' ");
goto result2;
break;
case 5:
printf(" defender tries to trap the raider in 'THIGH HOLD' ");
goto result2;
break;
}
result2:
result_2 = raidresult(7);
switch (result_2) {
case 0:
printf(" JUST AMAZINGGG..!!, the defence is 'ROARING', 1 point to the "
"defence.\n");
score1 = score1 + 1;
break;
case 1:
printf(" the raider get rid of the two defenders and added 2 more points "
"to the total.\n");
score2 = score2 + 2;
break;
case 2:
printf(" the defender don't let the raider escape and earns one point for "
"his team..!\n");
score1 = score1 + 1;
break;
case 3:
printf(" the raider escapes easily and got 1 point.\n");
score2 = score2 + 1;
break;
case 4:
printf(" this is a 'SUUUUUPPPEEERRRRRRR RAAAIIIIIID..!!' the RAIDER "
"manages to escape all the '3 DEFENDERS'; got 3 POINTS.\n");
score2 = score2 + 3;
break;
case 5:
printf(
" the defence got him, raider was just about to cross the midline but "
"the support comes at very right time, 1 POINT to the defence.\n");
score1 = score1 + 1;
break;
case 6:
printf(" 'ONE POINT EACH', raider got the 'BONUS' but can not escape the "
"'SOLID DEFENCE'.\n");
score2 = score2 + 1;
score1 = score1 + 1;
break;
}
if (raidNum > 31) {
goto matchOver;
} else {
goto matchOn;
}
matchOver:
for (int i = 0; i < 90; i++) {
printf("_");
}
// final result
if (score1 > score2) {
won = won + 1;
played = played + 1;
printf("\n\n\t\t\t 'CONGRATULATIONS..!!' YOU WON THE MATCH.\n");
} else if (score2 > score1) {
lost = lost + 1;
played = played + 1;
printf("\n\n\t\t\t 'WELL TRIED..!' YOU LOST THE MATCH.\n");
} else {
played = played + 1;
printf("\n\n\t\t\t 'THIS MATCH ENDS ON A TIE..! CONGRATULATIONS TO "
"BOTH THE TEAMS.'\n");
}
printf("\t\t\t\t\tTHE FINAL SCORE\n\t\t\t\t COMPUTER %d - %d "
"YOU\n\t\t\t\tPLAYED %d \tWON %d \tLOST %d\n\n",
score2, score1, played, won, lost);
for (int i = 0; i < 90; i++) {
printf("_");
}
printf("\n\t\t\tPress\t\t 0 to QUIT\t\t1 to PLAY AGAIN\n");
scanf("%d", &playAgain);
if (playAgain == 1) {
goto playagain;
} else {
goto quit;
}
quit:
printf("\n\t\t\tSEE YOU AGAIN.... KABADDI LOVER..!\n\n\n");
return 0;
}