-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
1379 lines (1138 loc) · 39.9 KB
/
main.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
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
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <stdlib.h>
/*É NECESSARIO TROCAR O CAMINHO DO ARQUIVO NA FUNÇÃO GAME OVER E NA FUNÇÃO SCORE!!!*/
typedef struct Item
{
int id;
int type[2]; /*respectivamente, o tipo de item e o quanto ele recupera */
char name[25];
char description[200];
float chance;
int damage;
int throwable[2]; /*respectivamente, jogavel sim ou não. o quanto de dano causa */
int craftable[2]; /*respectivamente, craftavel sim ou não, id do craft */
int durability[2]; /*Se tem durabilidade sim ou não, quanto de durabilidade tem (max 10) */
} Item;
typedef struct Enemy
{
char name[25];
int status[2]; /*respectivamente, vida e força*/
int max_life;
int chance; /*chance de aparecer */
Item in_hand;
int body;
char parts[4][25];
int first_encounter[2]; /*respectivamente, se já encontrou ou não e quanto de sanidade irá perder no primeiro encontro */
} Enemy;
typedef struct Pool
{
Item drops[4];
Enemy encounter;
} Pool;
typedef struct Area
{
char name[25];
int risk;
Pool loot;
} Area;
typedef struct Shack
{
char name[25];
int bed_window[2]; /* respectivamente, barricada sim ou não, com com armadilha sim ou não */
int living_window[2]; /* respectivamente, barricada sim ou não, com com armadilha sim ou não */
int kitchen_window[2]; /* respectivamente, barricada sim ou não, com com armadilha sim ou não */
int living_door[3]; /* respectivamente, barricada sim ou não, com armadilha sim ou não, quebrada sim ou não */
int back_door[3]; /* respectivamente, barricada sim ou não, com armadilha sim ou não, quebrada sim ou não */
int lamp_1[2]; /*respectivamente, ligada sim ou não, quebrada sim ou não */
int lamp_2[2]; /*respectivamente, ligada sim ou não, quebrada sim ou não */
Item chest[25];
int hour;
int generator;
} Shack;
typedef struct Player
{
char name[25];
int status[6]; /*são respectivamente vida, força, energia, sanidade, notoriedade e fome */
int max_life, max_hunger, max_energy;
Item in_hand;
Item bag[6];
int days;
} Player;
/*função que retorna um número aletório baseado no range dado*/
int coin(int flips) {
return (rand() % (flips + 1));
}
/*Função que limpa a tela*/
void clear()
{
system("cls");
}
/*função que manda um print customizado.*/
void print(char text[1]) {
system("cls");
printf("\n %s \n", text);
getchar();
getchar();
system("cls");
}
/*função que procura item no inventáio e retorna o index*/
int search_item (Item item, Player player)
{
int i;
for (i = 0; i < 6; i++)
{
if (player.bag[i].id == item.id)
{
return i;
}
}
return -1;
}
/*função que dropa um item da mochila do jogador (talvez retornar o item)*/
int drop_item_from_bag (int index, Player * player, Item nada)
{
if (index < 0 || index > 4) {
print("É, não vai funcionar.");
return -1;
}
if (player->bag[index].id == nada.id)
{
return -1;
}
player->bag[index] = nada;
return 1;
}
/*função que dropa um item da mão do jogador*/
int drop_item_from_hand (Player * player, Item nada)
{
if (player->in_hand.id == nada.id)
{
return -1;
}
player->in_hand = nada;
return 1;
}
/*função que lista os itens do jogador*/
void items_list (Player player, Item nada)
{
int i;
printf ("MOCHILA DO(A) %s:\n", player.name);
for (i = 0; i < 5; i++)
{
if (player.bag[i].id == nada.id)
{
printf ("%d -> nada \n", i + 1);
}
else
{
printf ("%d -> %s \n", i + 1, player.bag[i].name);
}
}
printf ("NA MÃO: %s \n", player.in_hand.name);
}
/*função que guarda um item da mão no primeiro espaço vazio da mochila.*/
int hand_to_bag (Player* player, Item nada)
{
if (player->in_hand.id == nada.id)
{
print("Minhas mãos estam vazias...");
return -1;
}
int bagIndex = search_item (nada, *player);
if (bagIndex == -1)
{
print("Minha mochila está cheia, droga!");
return -1;
}
player->bag[bagIndex] = player->in_hand;
player->in_hand = nada;
print("Agora minhas mãos estão livres.");
return 1;
}
/*função que passa um item da mochila para mão.*/
int bag_to_hand (int index, Player* player, Item nada)
{
if (index < 0 || index > 4) {
print("Não vai funcionar..");
return -1;
}
if (player->bag[index].id == nada.id)
{
print("Acho que eu ainda preciso respeitar as regras da fisica...");
return -1;
}
if (player->in_hand.id != nada.id)
{
// mudar aqui (mudando)
Item aux = player->in_hand;
player->in_hand = player->bag[index];
player->bag[index] = aux;
return 1;
}
player->in_hand = player->bag[index];
player->bag[index] = nada;
return 1;
}
/*função que lista os itens do baú*/
void chest_list (Item chest[])
{
int i;
for (i = 0; i < 25; i++)
printf ("-%s \n", chest[i].name);
}
/*função que percorre o baú até achar um espaço vazio*/
int chest_free_space (Shack shack, Item nada) {
int a;
do {
if (shack.chest[a].id == nada.id) {
return a;
}
a++;
}while(0 == 0);
return -1;
}
/*função que passa um item pro bau diretamente da mão.*/
int hand_to_chest(Shack* shack, Player* player, Item nada) {
if (player->in_hand.id != nada.id) {
shack->chest[chest_free_space(*shack, nada)] = player->in_hand;
drop_item_from_hand(player, nada);
return 1;
}
print("Minhas mãos estão vazias...");
return -1;
}
/*função que passa um item da mochila para o baú*/
int bag_to_chest (int index, Shack* shack, Player* player, Item nada)
{
if (index < 0 || index > 4)
{
print("Isso não vai funcionar...");
return -1;
}
if (player->bag[index].id == nada.id)
{
print("Tá vazio!");
return -1;
}
int chestIndex = chest_free_space(*shack, nada);
/*Esse retorno C) mais voltado pro lado do dev */
if (chestIndex == -1)
{
print("Cacete, o baú ta cheio.");
return -1;
}
shack->chest[chestIndex] = player->bag[index];
/*função que dropa um item da mochila*/
if (drop_item_from_bag (index, player, nada) == -1)
{
printf ("Erro ao remover item da mochila!\n");
return -1;
}
return 1;
}
/*função que passa item do baú para mochila.*/
int chest_to_bag (int index, Shack* shack, Player* player, Item nada) {
if (index < 0 || index > 24) {
print("Esse baú não é tão grande quanto eu queria que fosse.");
return -1;
}
if (shack->chest[index].id == nada.id) {
print("Aqui não tem nada...");
return -1;
}
int bagIndex = search_item(nada, *player);
if (bagIndex == -1 && player->in_hand.id == nada.id) {
player->in_hand = shack->chest[index];
shack->chest[index] = nada;
return 1;
}
player->bag[bagIndex] = shack->chest[index];
shack->chest[index] = nada;
return 1;
}
/*função que quebra um item na mão caso a durabilidade chegue a zero*/
void durability(Player* player, Item nada) {
if (player->in_hand.durability[0] == 0) {
player->in_hand.durability[1] --;
}
if (player->in_hand.durability[1] <= 0 && player->in_hand.id != nada.id) {
print("Quebrou!");
drop_item_from_hand(player, nada);
}
}
/*função que controla alguns status do jogador.*/
void balance(Player* player) {
if (player->max_life < player->status[0]) {
player->status[0] = player->max_life;
}
if (player->max_energy < player->status[2]) {
player->status[2] = player->max_energy;
}
if (player->max_hunger < player->status[5]) {
player->status[5] = player->max_hunger;
}
}
/*função que usa um item da mão do jogador.*/
int use_item_in_hand(Player* player, Item nada) {
if (player->in_hand.type[0] == -1) {
print("Não vai dar pra usar isso.");
return -1;
}
Item item = player->in_hand;
player->status[item.type[0]] += item.type[1];
drop_item_from_hand(player, nada);
balance(player);
system("cls");
printf("\nAcho que %s vai prestar por agora.\n", item.name);
getchar();
getchar();
system("cls");
return 1;
}
/*função que usa um item da mochila do jogador.*/
int use_item(int index, Player* player, Item nada) {
if (index < 0 || index > 5) {
print("Eu não sei o que eu estou tentando fazer, mas provavelmente não vai funcionar...");
return -1;
}
if (player->bag[index].type[0] == -1) {
print("Não vai dar pra usar isso.");
return -1;
}
Item item = player->bag[index];
player->status[item.type[0]] += item.type[1];
drop_item_from_bag(index, player, nada);
balance(player);
system("cls");
printf("\nAcho que %s vai prestar por agora.\n", item.name);
getchar();
getchar();
system("cls");
return 1;
}
/*função que adciona gasolina ao gerador*/
int generator_fuel(Player* player, Shack* shack, Item nada, Item gasolina) {
int bagIndex = search_item(gasolina, *player);
if (bagIndex == -1 && player->in_hand.id == gasolina.id) {
shack->generator += 25;
drop_item_from_hand(player, nada);
return 1;
}
if (bagIndex == -1 && player->in_hand.id != gasolina.id) {
print("Eu não tenho gasolina.");
return -1;
}
shack->generator += 25;
player->bag[bagIndex] = nada;
}
/*função que controla e mostra a tela de game over, ela também salva o ultimo score (dias sobrevividos)*/
void game_over(Player* player) {
if (player->status[0] <= 0) {
FILE* f = fopen("C:\\Users\\Win\\CLionProjects\\demo_matagal\\score.txt", "w");
if (f == NULL) {
printf("Erro ao abrir o arquivo\n");
exit(1);
}
int resultado = fprintf(f, "%d \n", player->days);
if (resultado < 0) {
printf("Erro ao escrever no arquivo\n");
exit(1); // Encerra o programa em caso de erro
}
fclose(f);
print("Acabou, você escuta seu oração parar aos poucos enquanto sua visão fica turva, mas...\n");
exit(1);
}
}
/*função que printa o ultimo score do jogador*/
void score() {
FILE *f;
char linha[1024];
f = fopen("C:\\Users\\Win\\CLionProjects\\demo_matagal\\score.txt", "r");
if (f == NULL) {
printf("Erro ao abrir o arquivo.\n");
exit(1);
}
while (fgets(linha, sizeof(linha), f) != NULL) {
printf("O fortuna do seu ultimo ciclo durou %s dias", linha);
}
fclose(f);
}
/*função que define encontros*/ /*NÃO ESQUECER DE TRABALHAR A DURABILIDADE DO ITEM NA MÃO*/
int encounter(Player* player, Enemy enemy, Item nada) {
print("Merda, me acharam!");
if (coin(1) == 0) {
print("Você sente seu coração acelerar, suas pernas fraquejam enquanto sua mente se esvazia de pensamentos coerentes.");
player->status[3] --;
}
do {
int c;
clear();
printf(" MdJcczvzYYXJcj> \n"
" @@W#ahpk0zQzvc00Qx) \n"
" @@@Bb##azkdQYkJzndJCp \n"
" WW@@@$BaWahpphbZYvYbXtW \n"
" @$@@@@@@$$*aaadapZJYcrpm# \n"
" M@@@@@@WB$@WW#oQhaMdOnnxz# \n"
" oM@@@BBBWWWB#W*hbZQpOZakddQnn)YQ \n"
" $B#*$@@@@@@@$$BWMW$@WW@@oW@@@@*ddxxOB \n"
" @@@@@$$$@@@@@$hpzc@$hBOW@$@$$@@@@@@@@@Bk \n"
" @$$@@@@@@@@@@$kWaYmccc]pJp#W#@@$@$B$Mak \n"
" @@B@$@@@@#W$*d0Cd0]vrccddd*Bb \n"
" WW@@@$Boobmhr_QXQxaa#@@ok \n"
" WB@@@@bModdOxapxd0rkbh$d \n"
" M$@Bh*WahhdphzOYQkdWBab \n"
" *a@@@Mkbo*QdkXpOMOBMB \n"
" Mo$$$BB$o*CZQhd*W@@h@ \n"
" MB@@BWo#aMdwwoh#W$@@@bp \n"
" ##@@@@@@@@@W*ahh@B$@MW@@Zj@ \n"
" h*oMM@@@@@@@@@@$BW$@$*k##W@$@@0oQmZ@ \n"
" hk#MMMMWB$@@@@@@@@B#Mo#B#daob#@@@W#pOoZzcCC*@ \n"
"oMWM###MWWB@@@@@@@@$@$BWWWo*kadhWo#WM*aJO$WhkapX0d\n"
"MM##MMMMWW$@@@@@@@@@$W$$aaOodho$*MBW*hphbd@$WawCC0\n"
"#MMMMMMWWB$@@@@@@@@@$M#okdab*WBaoBMW*Zo#$@@@#*kwJJ\n"
"MMMMMMWWWWBB@@@@@@@@@@M*ok*a$WoBB@@okdaQaQ0@@$*#d0\n"
"MMMMMMWWWWW$$@@@@@@@@@@BM#B$B#BBB$kaawdbZmzJb$$*bm \n");
printf("+--------------------------------------------------+\n");
printf("Vida: %d \n", player->status[0]);
printf("Força: %d \n", player->status[1]);
printf("NA MÃO: %s \n", player->in_hand.name);
printf("\n %s -> VIDA: %d \n", enemy.name, enemy.status[0]);
printf("\n[1] Bater \n");
printf("[2] Defender \n");
printf("[3] Gritar \n");
printf("\nO que fazer?\n");
printf("-> ");
scanf("%d", &c);
if (c == 1) {
printf("\nVocê se prepara desesperadamente para atacar.\n");
getchar();
getchar();
if (coin(1) == 0) {
printf("%s assume uma postura defensiva.\n", enemy.name);
getchar();
int damage = (player->status[1] + coin(player->in_hand.damage)) - coin(enemy.status[1]);
if (damage <= 0) {
printf("Deu tudo errado.\n");
getchar();
}
else {
enemy.status[0] -= damage;
durability(player, nada);
}
}
else {
printf("%s assume uma postura ofensiva.\n", enemy.name);
getchar();
int playerDMG = player->status[1] + coin(player->in_hand.damage);
int enemyDMG = enemy.status[1] + coin(enemy.in_hand.damage);
enemy.status[0] -= playerDMG;
player->status[0] -= enemyDMG;
} /*continuar fazendo o defender (feito)*/
}
if (c == 2) {
printf("\nVocê bloqueia a maioria dos orgãos vitais.\n");
getchar();
getchar();
printf("%s assume uma postura ofensiva.\n", enemy.name);
getchar();
int defense = coin(player->status[1]);
int enemyDMG = enemy.status[1] + coin(enemy.in_hand.damage) - defense;
if (enemyDMG <= 0) {
printf("Você sai ileso.\n");
getchar();
}
else {
player->status[0] -= enemyDMG;
}
}
if (c == 3) {
printf("\nDesesperado, você grita afim de espantar a ameaça eminente.\n");
getchar();
if (coin(1) == 0) {
printf("O(A) %s se vê intimiado pelos seus gritos guturais, ele foge, mas você sente que chamou mais atenção do que deveria.\n", enemy.name);
getchar();
player->status[4] ++;
break;
}
else {
printf("Você grita, porém isso só parece ter deixado a criatura mais agitada e irritada\n");
getchar();
printf("Ela assume uma postura extremamente ofensiva.\n");
getchar();
int enemyDMG = enemy.status[1] * 2;
player->status[0] -= enemyDMG;
}
}
system("cls");
}while(enemy.status[0] > 0 && player->status[0] > 0);
game_over(player);
}
/*função que leva o player para explorar as areas disponiveis*/
void explore(Player* player, Area area, Item nada) {
system("cls");
printf("\nVocê Saiu para explorar %s \n", area.name);
getchar();
system("cls");
int i = 1;
do {
if (player->status[2] <= 0) {
print("Tô cansado demais pra isso...");
player->status[2] = 0;
break;
}
int ant = player->status[4] + area.risk + area.loot.encounter.chance;
int prox = coin((player->status[4] * 2) + area.risk + area.loot.encounter.chance);
print("Espero achar algo de bom nessa imundisse...");
if (prox < ant) {
print("O que é aquilo? Melhor eu ir ver, talvez seja algo útil.");
if (coin(1) == 0) {
Item loot = area.loot.drops[coin(3)];
int bagIndex = search_item(nada, *player);
if (bagIndex == -1) {
print("Merda, tô sem espaço na mochila.");
}
else {
system("cls");
printf("\nÓtimo, encontrei %s \n", loot.name);
getchar();
system("cls");
player->bag[bagIndex] = loot;
}
}
else {
print("Merda, não é nada...");
}
}
else {
print("Eu estou sendo seguido.");
if (coin(1) == 0) {
encounter(player, area.loot.encounter, nada);
}
else {
print("Acho que consegui despistar.");
}
}
if (player->status[2] <= 0) {
print("Eu estou cansado demais para continuar.");
i = 0;
}
if (coin(1) == 0) {
player->status[2] --;
}
printf("sair?[0]");
scanf("%d", &i);
system("cls");
}while(i != 0 && player->status[0] > 0);
print("Eu sinto que estou chamando atenção indesejada.");
player->status[4] ++;
}
/*função que controla os eventos noturnos*/
void night(Player* player, Shack* shack, Enemy enemy_1, Enemy enemy_2, Item nada) {
int risk = 8;
shack->hour = 0;
int fuel = coin(25);
print("A noite chegou, ascenda as luzes, fique em casa e sobreviva.");
if (shack->generator >= fuel) {
print("Você liga o antigo gerador que garante um local bem iluminado.");
shack->generator -= fuel;
}
else {
print("O gerador não liga.");
risk += coin(7);
}
if (shack->living_window[0] == 0) {
print("Você fica meio histérico olhando para janela.");
risk ++;
}
if (shack->kitchen_window[0] == 0) {
print("Barulhos de paços podem ser ouvidos do lado de fora. Você está sendo sondado.");
risk ++;
}
if (shack->living_door[0] == 0) {
print("Você improvisa colocando uma cadeira na porta.");
risk++;
}
if (shack->living_door[1] == 1) {
print("Talvez você possa sair vivo dessa, talvez.");
risk -= 2;
}
do {
game_over(player);
Enemy enemies[2];
enemies[0] = enemy_1;
enemies[1] = enemy_2;
int chance = coin(player->status[4] + risk);
if (chance == 0) {
print("Nada acontece.");
player->status[2] ++;
balance(player);
shack->hour ++;
}
if (chance == 1) {
print("Você escuta o ranger da madeira velha enquanto procura qualquer anormalidade.");
shack->hour ++;
}
if (chance == 2) {
print("Você reflete e tenta se lembrar como veio parar aqui, porém nada.");
player->status[0] ++;
balance(player);
shack->hour ++;
}
if (chance == 3) {
print("Lobos, você os escuta a distância.");
player->status[4] --;
if (player->status[4] < 0) {
player->status[4] = 0;
}
shack->hour ++;
}
if (chance == 4) {
print("A luz das lampadas falham, grunidos podem ser ouvidos agora, não são lobos.");
shack->hour ++;
}
if (chance == 5) {
print("Você está tremendo, pancadas na porta te fazem correr até ela e segurar com o ombro.");
player->status[3] --;
if (player->status[3] < 0) {
player->status[3] = 0;
}
shack->hour ++;
}
if (chance == 6) {
print("A fome aperta.");
player->status[5] --;
if (player->status[5] < 0) {
player->status[5] = 0;
}
shack->hour ++;
}
if (chance == 7) {
print("Por que eu não acabo com tudo?");
player->status[3] --;
if (player->status[3] < 0) {
player->status[3] = 0;
}
shack->hour ++;
}
if (chance == 8) {
print("Você pisa em um objeto pontudo que deixou cair durante o dia, a ferida dói.");
player->status[0] --;
shack->hour ++;
}
if (chance == 9) {
print("Deus, me perdoa por favor.");
player->status[3] --;
if (player->status[3] < 0) {
player->status[3] = 0;
}
shack->hour ++;
}
if (chance == 10) {
print("Nada acontece.");
shack->hour ++;
}
if (chance > 10) {
print("...");
encounter(player, enemies[coin(1)], nada);
shack->hour ++;
}
}while(shack->hour < 6 && player->status[0] > 0);
player->status[2] = coin(player->status[5]);
balance(player);
player->status[5] --;
if (player->status[5] < 0) {
player->status[5] = 0;
}
if (player->status[0] > 0) {
player->status[0] += 5;
balance(player);
print("A noite acabou, o Sol começa a raiar.");
}
player->status[4] --;
if (player->status[4] < 0) {
player->status[4] = 0;
}
player->days ++;
}
/*função que cria a copia de um item TALVEZ ALOCAÇÃO?*/
Item copyItem (Item original)
{
Item copy;
/*Copie cada propriedade do item original para a copia */
strcpy (copy.name, original.name);
strcpy (copy.description, original.description);
copy.type[0] = original.type[0];
copy.type[1] = original.type[1];
copy.chance = original.chance;
copy.damage = original.damage;
copy.throwable[0] = original.throwable[0];
copy.throwable[1] = original.throwable[1];
copy.craftable[0] = original.craftable[0];
copy.craftable[1] = original.craftable[1];
copy.durability[0] = original.durability[0];
copy.durability[1] = original.durability[1];
copy.id = original.id; // ID imutC!vel
return copy;
}
int
main ()
{
/*Definindo as structs no main*/
srand(time(NULL));
Item graveto;
strcpy (graveto.name, "graveto");
strcpy (graveto.description, "um graveto");
graveto.type[0] = -1;
graveto.chance = 3;
graveto.damage = 1;
graveto.throwable[0], graveto.throwable[1] = 0;
graveto.craftable[0] = 1;
graveto.craftable[1] = 1;
graveto.durability[0], graveto.durability[1] = 0;
graveto.id = 1;
Item tabua;
strcpy (tabua.name, "tabua");
strcpy (tabua.description, "tabua de madeira");
tabua.type[0] = -1;
tabua.chance = 5;
tabua.damage = 0;
tabua.throwable[0], tabua.throwable[1] = 0;
tabua.craftable[0], tabua.craftable[1] = 0;
tabua.durability[0], tabua.durability[1] = 0;
tabua.id = 2;
Item pedra;
strcpy (pedra.name, "pedra");
strcpy (pedra.description, "uma pedra");
pedra.type[0] = -1;
pedra.chance = 3;
pedra.damage = 1;
pedra.throwable[0] = 1;
pedra.throwable[1] = 2;
pedra.craftable[0], pedra.craftable[1] = 0;
pedra.durability[0] = 1;
pedra.durability[1] = 1;
pedra.id = 3;
Item batata;
strcpy (batata.name, "batata");
strcpy (batata.description, "uma batata");
batata.type[0] = 5;
batata.type[1] = 1;
batata.chance = 2;
batata.damage = 1;
batata.throwable[0] = 1;
batata.throwable[1] = 1;
batata.craftable[0], batata.craftable[1] = 0;
batata.durability[0] = 1;
batata.durability[1] = 1;
batata.id = 4;
Item lanca_ponta_de_madeira;
strcpy (lanca_ponta_de_madeira.name, "lança de madeira");
strcpy (lanca_ponta_de_madeira.description, "lança com a ponta de madeira");
lanca_ponta_de_madeira.type[0] = -1;
lanca_ponta_de_madeira.chance = 7;
lanca_ponta_de_madeira.damage = 4;
lanca_ponta_de_madeira.throwable[0] = 1;
lanca_ponta_de_madeira.throwable[1] = 4;
lanca_ponta_de_madeira.craftable[0] = 1;
lanca_ponta_de_madeira.craftable[1] = 2;
lanca_ponta_de_madeira.durability[0] = 1;
lanca_ponta_de_madeira.durability[1] = 5;
lanca_ponta_de_madeira.id = 5;
Item prego;
strcpy (prego.name, "prego");
strcpy (prego.description, "um prego");
prego.type[0] = -1;
prego.chance = 1;
prego.damage = 0;
prego.throwable[0], prego.throwable[1] = 0;
prego.craftable[0], prego.craftable[1] = 0;
prego.durability[0], prego.durability[1] = 0;
prego.id = 6;
Item gasolina;
strcpy (gasolina.name, "gasolina");
strcpy (gasolina.description, "um tanque de gasolina");
gasolina.type[0] = -1;
gasolina.chance = 2;
gasolina.damage = 0;
gasolina.throwable[0], gasolina.throwable[1] = 0;
gasolina.craftable[0], gasolina.craftable[1] = 0;
gasolina.durability[0], gasolina.durability[1] = 0;
gasolina.id = 7;
Item armadilha_urso;
strcpy (armadilha_urso.name, "Armadilha de Urso");
strcpy (armadilha_urso.description, "Armadilha para uso, deve doer.");
armadilha_urso.type[0] = -1;
armadilha_urso.chance = 4;
armadilha_urso.damage = 0;
armadilha_urso.throwable[0], armadilha_urso.throwable[1] = 0;
armadilha_urso.craftable[0] = 1;
armadilha_urso.craftable[1] = 4;
armadilha_urso.durability[0], armadilha_urso.durability[1] = 0;
armadilha_urso.id = 8;
Item nada;
strcpy (nada.name, "nada");
strcpy (nada.description, "um monte de nada");
nada.type[0] = -1;
nada.chance = 5;
nada.damage = 0;
nada.throwable[0], nada.throwable[1] = 0;
nada.craftable[0], nada.craftable[1] = 0;
nada.durability[0], nada.durability[1] = 0;
nada.id = 9;
Item kit;
strcpy (kit.name, "kit médico");
strcpy (prego.description, "um kit médico usado para restaurar vida");
kit.type[0] = 0;
kit.type[1] = 5;
kit.chance = 1;
kit.damage = 0;
kit.throwable[0], prego.throwable[1] = 0;
kit.craftable[0], prego.craftable[1] = 0;
kit.durability[0], prego.durability[1] = 0;
kit.id = 10;
Enemy wolf;
strcpy (wolf.name, "LOBO");
wolf.status[0] = 8;
wolf.status[1] = 3;
wolf.max_life = 8;
wolf.chance = 4;
wolf.in_hand = nada;
wolf.body = 4;
strcpy (wolf.parts[0], "patas"); /*trocar por pescoço, (descontinuado) */
strcpy (wolf.parts[1], "pernas");
strcpy (wolf.parts[2], "barriga");
strcpy (wolf.parts[3], "cabeça");
wolf.first_encounter[0] = 1;
wolf.first_encounter[1] = 1;
Enemy savage;
strcpy (savage.name, "SELVAGEM");
savage.status[0] = 12;