HALTED: major overhaul for character
This commit is contained in:
@ -54,10 +54,6 @@ int character::get_room_num() const {
|
||||
return room_num;
|
||||
}
|
||||
|
||||
bool character::is_hostile() const {
|
||||
return hostile;
|
||||
}
|
||||
|
||||
void character::set_room_num(const int room) {
|
||||
room_num = room;
|
||||
}
|
||||
@ -86,36 +82,6 @@ void character::set_hitrate(const fraction nhitrate) {
|
||||
base_hit_rate = nhitrate;
|
||||
}
|
||||
|
||||
void character::set_hostile(const bool is_hostile) {
|
||||
hostile = is_hostile;
|
||||
}
|
||||
|
||||
void character::apply_buff(const stat_name statn, const int amount) {
|
||||
// TODO: add checks for bounds
|
||||
switch (statn) {
|
||||
case stat_name::HP:
|
||||
HP += amount;
|
||||
break;
|
||||
|
||||
case stat_name::ATK:
|
||||
ATK += amount;
|
||||
break;
|
||||
|
||||
case stat_name::DEF:
|
||||
DEF += amount;
|
||||
break;
|
||||
|
||||
case stat_name::hostile: {
|
||||
if (amount > 0)
|
||||
hostile = true;
|
||||
else
|
||||
hostile = false;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
direction_list character::moveable(const position_list &available_positions)
|
||||
const {
|
||||
direction_list result;
|
||||
@ -128,13 +94,17 @@ const {
|
||||
return result;
|
||||
}
|
||||
|
||||
void character::apply(direction &dir, potion_list &plist) {
|
||||
character::apply_result character::apply(const direction &dir,
|
||||
potion_list &plist) {
|
||||
for (size_t i = 0; i < plist.size(); ++i)
|
||||
if (pos + MOVE[dir] == plist[i]->get_pos()) {
|
||||
apply_result res{applied, plist[i]};
|
||||
insert_potion(plist[i]);
|
||||
plist.erase(plist.begin() + i);
|
||||
return;
|
||||
return res;
|
||||
}
|
||||
|
||||
return {applied_nothing, nullptr};
|
||||
}
|
||||
|
||||
void character::insert_potion(potion *p) {
|
||||
@ -191,30 +161,7 @@ result character::move(const direction dir,
|
||||
return result::fine;
|
||||
}
|
||||
|
||||
result character::move_or_attack(const direction dir,
|
||||
const position_list &available_positions,
|
||||
character_list &chlist) {
|
||||
auto res = this->move(dir, available_positions);
|
||||
|
||||
if (res != result::fine)
|
||||
return res;
|
||||
|
||||
return this->attack(dir, chlist);
|
||||
}
|
||||
|
||||
result character::move_or_attack(const direction dir,
|
||||
const position_list &available_positions,
|
||||
character *ch) {
|
||||
auto res = this->move(dir, available_positions);
|
||||
|
||||
if (res != result::fine)
|
||||
return res;
|
||||
|
||||
return this->attack(dir, ch);
|
||||
}
|
||||
|
||||
|
||||
int calc_dmg(const int ATK, const int DEF) {
|
||||
return ceil((100 / (100 + DEF)) * ATK);
|
||||
return ceil((100.0f / (100.0f + DEF)) * ATK);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user