-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfeature.c
146 lines (116 loc) · 3.47 KB
/
feature.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
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include "feature.h"
#include "entity.h"
//extern Player mainUser;
//extern Supemon Supedex;
void initJoueur (Player *mainUser){
printf("Enter your name : ");
scanf("%s", mainUser->name);
}
void Save (Player *mainUser){
FILE *file = NULL;
file = fopen("save.txt", "wb");
if (Save != NULL)
{
fprintf(file, "%s\n", mainUser->name);
fprintf(file, "%d\n", mainUser->Supcoins);
fprintf(file, "%s\n", mainUser->supemonList);
fprintf(file, "%s\n", mainUser->curSupemon);
fprintf(file, "%s\n", mainUser->objectList);
fclose(file);
}
}
void Load (Player *mainUser){
FILE *file = NULL;
file = fopen("save.txt", "rb");
if (file != NULL)
{
fscanf(file, "%s\n", mainUser->name);
fscanf(file, "%d\n", mainUser->Supcoins);
fscanf(file, "%s\n", mainUser->supemonList);
fscanf(file, "%s\n", mainUser->curSupemon);
fscanf(file, "%s\n", mainUser->objectList);
fclose(file);
}
}
void Heal (int quantityHp, int i, Player *mainUser){
mainUser->supemonList[i].HP += quantityHp;
if (mainUser->supemonList[i].HP > mainUser->supemonList[i].HP_max)
{
mainUser->supemonList[i].HP = mainUser->supemonList[i].HP_max;
}
}
// shop
void Buy (int itemSelected, Player *mainUser){
if (mainUser->Supcoins >= mainUser->objectList[itemSelected].cost)
{
mainUser->objectList[itemSelected].number += 1;
mainUser->Supcoins -= mainUser->objectList[itemSelected].cost;
}
else
{
printf("Errr... I think you can't afford it...\n");
}
}
//sell an object
void Sell (int itemSelected, Player *mainUser){
if (mainUser->objectList[itemSelected].number > 0)
{
mainUser->objectList[itemSelected].number -= 1;
mainUser->Supcoins += (mainUser->objectList[itemSelected].cost / 2);
}
else
{
printf("Do you think i'm dumb... \nyou do not have this object\n");
}
}
void RandomSupémon (Supemon Supedex[]){
srand(time(NULL));
int random = rand() % 3;
Supemon Enemy = Supedex[random];
}
void SupemonCenter (Player *mainUser){
for (int i = 0; i < 6; i++)
{
Heal (mainUser->supemonList[i].HP_max, i, mainUser);
};
}
void LevelUp (Player *mainUser){
Supemon currentSupemon = mainUser->supemonList[mainUser->curSupemon];
int expReq = 500;
while (currentSupemon.experience >= expReq){
if (currentSupemon.level > 1)
{
int expReq = 500+(1000*(currentSupemon.level-1));
}
currentSupemon.level += 1;
currentSupemon.experience = 0;
currentSupemon.HP_max = capacityUp(currentSupemon.HP_max);
currentSupemon.HP = currentSupemon.HP_max;
currentSupemon.atk = capacityUp(currentSupemon.atk);
currentSupemon.def = capacityUp(currentSupemon.def);
currentSupemon.acy = capacityUp(currentSupemon.acy);
currentSupemon.evs = capacityUp(currentSupemon.evs);
currentSupemon.speed = capacityUp(currentSupemon.speed); ;
}
}
int capacityUp (int value){
float valuetmp = 0;
valuetmp = value*1.3;
if (valuetmp == floor(valuetmp))
{
srand(time(NULL));
int random = rand() % 2;
if (random == 0){
value = floor(valuetmp);
} else {
value = ceil(valuetmp);
}
}
//one chance on two to increase the value by 1
value = valuetmp;
return value;
}