-
Notifications
You must be signed in to change notification settings - Fork 0
/
Player.cpp
127 lines (106 loc) · 2.21 KB
/
Player.cpp
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
#include "Arduino.h"
#include "Player.h"
Player::Player(bool debug)
{
curr = 0;
primary = 0;
lifetimeCount = 0;
mult = 1;
if(debug)
size = 5;
else
size = 3;
for(int i = 0; i < size; i++)
mon[i] = Monster((species)i, random(2));
}
Player::Player()
{
curr = 0;
primary = 0;
lifetimeCount = 0;
mult = 1;
size = 1;
for(int i = 0; i < size; i++)
mon[i] = Monster((species)i, random(2));
}
Monster *Player::getPrimary()
{
return &mon[primary];
}
Monster *Player::breedNew(uint8_t one, uint8_t two)
{
uint16_t atk1 = mon[one].atk;
uint16_t def1 = mon[one].def;
uint16_t agl1 = mon[one].agl;
uint16_t intl1 = mon[one].intl;
uint16_t hp1 = mon[one].hp;
uint16_t mp1 = mon[one].mp;
uint16_t atk2 = mon[two].atk;
uint16_t def2 = mon[two].def;
uint16_t agl2 = mon[two].agl;
uint16_t intl2 = mon[two].intl;
uint16_t hp2 = mon[two].hp;
uint16_t mp2 = mon[two].mp;
Monster bred = Monster(mon[two].breed, random(2));
bred.atk += (atk1 + atk2) / 4;
bred.def += (def1 + def2) / 4;
bred.agl += (agl1 + agl2) / 4;
bred.intl += (intl1 + intl2) / 4;
bred.hp += (hp1 + hp2) / 4;
bred.mp += (mp1 + mp2) / 4;
return &bred;
}
Monster *Player::setPrimary(uint8_t num)
{
primary = num;
return &mon[num];
}
Monster *Player::setPrimary()
{
primary = curr;
return &mon[curr];
}
Monster *Player::getCurr()
{
return &mon[curr];
}
Monster *Player::getNext()
{
++curr;
curr %= size;
return &mon[curr];
}
Monster *Player::getPrev()
{
--curr;
if(curr > size) curr = size-1;
return &mon[curr];
}
void Player::updateEXP(uint16_t num)
{
getPrimary()->pumpEXP(num * mult);
}
void Player::updateSteps(uint64_t num)
{
lifetimeCount += num;
if(lifetimeCount > 128000)
{
mon[1] = Monster(jellyfish, random(2));
size = 5;
}
else if(lifetimeCount > 64000)
{
mon[1] = Monster(jellyfish, random(2));
size = 4;
}
else if(lifetimeCount > 32000)
{
mon[1] = Monster(jellyfish, random(2));
size = 3;
}
else if(lifetimeCount > 16000)
{
mon[1] = Monster(jellyfish, random(2));
size = 2;
}
}