|
@@ -111,15 +111,15 @@ double Unit::getExperience() {
|
|
|
return experience_;
|
|
|
}
|
|
|
|
|
|
-double Unit::getLevel() {
|
|
|
+int Unit::getLevel() {
|
|
|
return level_;
|
|
|
}
|
|
|
|
|
|
-double Unit::getHealthPoints() {
|
|
|
+int Unit::getHealthPoints() {
|
|
|
return health_points_;
|
|
|
}
|
|
|
|
|
|
-double Unit::getAttackRange() {
|
|
|
+int Unit::getAttackRange() {
|
|
|
return attack_range_;
|
|
|
}
|
|
|
|
|
@@ -147,23 +147,19 @@ int Unit::getAttackCost(){
|
|
|
return attack_cost_;
|
|
|
}
|
|
|
|
|
|
-double Unit::getInitiative() {
|
|
|
+int Unit::getInitiative() {
|
|
|
return initiative_;
|
|
|
}
|
|
|
|
|
|
-double Unit::getDamagePerHit() {
|
|
|
- return damage_per_hit_;
|
|
|
-}
|
|
|
-
|
|
|
-double Unit::getIntelligence() {
|
|
|
+int Unit::getIntelligence() {
|
|
|
return intelligence_;
|
|
|
}
|
|
|
|
|
|
-double Unit::getStrength() {
|
|
|
+int Unit::getStrength() {
|
|
|
return strength_;
|
|
|
}
|
|
|
|
|
|
-double Unit::getAgility() {
|
|
|
+int Unit::getAgility() {
|
|
|
return agility_;
|
|
|
}
|
|
|
|
|
@@ -171,11 +167,11 @@ int Unit::getAttackPoints(){
|
|
|
return attack_cost_;
|
|
|
}
|
|
|
|
|
|
-double Unit::getMagicDefence() {
|
|
|
+int Unit::getMagicDefence() {
|
|
|
return magic_defence_;
|
|
|
}
|
|
|
|
|
|
-double Unit::getPhysicDefence() {
|
|
|
+int Unit::getPhysicDefence() {
|
|
|
return physic_defence_;
|
|
|
}
|
|
|
|
|
@@ -195,25 +191,49 @@ void Unit::setRealY(double y) {
|
|
|
real_y_ = y;
|
|
|
}
|
|
|
|
|
|
-void Unit::calculateDamagePerHit() {
|
|
|
- damage_per_hit_ = 0.5 * std::max(getAgility(), std::max(getStrength(), getIntelligence()));
|
|
|
+bool Unit::isCharacter(){
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
+int Unit::theSameNear(){
|
|
|
+ short near_qnt = 0;
|
|
|
+ if (this->location_->getleftUp()->getCharacter()->base_class_id_ == this->base_class_id_){
|
|
|
+ near_qnt++;
|
|
|
+ }
|
|
|
+ if (this->location_->getleft()->getCharacter()->base_class_id_ == this->base_class_id_){
|
|
|
+ near_qnt++;
|
|
|
+ }
|
|
|
+ if (this->location_->getleftDown()->getCharacter()->base_class_id_ == this->base_class_id_){
|
|
|
+ near_qnt++;
|
|
|
+ }
|
|
|
+ if (this->location_->getrightUp()->getCharacter()->base_class_id_ == this->base_class_id_){
|
|
|
+ near_qnt++;
|
|
|
+ }
|
|
|
+ if (this->location_->getright()->getCharacter()->base_class_id_ == this->base_class_id_){
|
|
|
+ near_qnt++;
|
|
|
+ }
|
|
|
+ if (this->location_->getrightDown()->getCharacter()->base_class_id_ == this->base_class_id_){
|
|
|
+ near_qnt++;
|
|
|
+ }
|
|
|
+
|
|
|
+ return near_qnt;
|
|
|
}
|
|
|
|
|
|
-double Unit::reduceIncomingDamage(std::string damageType, int damage) { //returns damage after reducing by defence
|
|
|
+int Unit::reduceIncomingDamage(std::string damageType, int damage) { //returns damage after reducing by defence
|
|
|
assert("Incorrect damage type in call reduceIncomingDamage(), expected" &&
|
|
|
(damageType[0] == 'p' || damageType[0] == 'P' || damageType[0] == 'm' || damageType[0] == 'M'));
|
|
|
assert("Magic defence of unit is incorrectly high (>40), but must be" && magic_defence_ <= 40);
|
|
|
assert("Physic defence of unit is incorrectly high (>40), but must be" && physic_defence_ <= 40);
|
|
|
if (damageType[0] == 'p' || damageType[0] == 'P') {
|
|
|
- return (1 - 2.5 * physic_defence_ / 100) * damage;
|
|
|
+ return (damage - 2.5 * double(damage) * double(physic_defence_) / 100.0);
|
|
|
}
|
|
|
else if (damageType[0] == 'm' || damageType[0] == 'M') {
|
|
|
- return (1 - 2.5 * magic_defence_ / 100) * damage;
|
|
|
+ return (damage - 2.5 * double(damage) * double(magic_defence_) / 100.0);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
int Unit::lenOfActualPath(Cell* destination) {
|
|
|
- return getLocation()->actualPath(destination).size();
|
|
|
+ return getLocation()->actualPath(destination).size() - 1;
|
|
|
}
|
|
|
|
|
|
bool Unit::canMoveForDistance(int distance) {
|
|
@@ -228,7 +248,9 @@ void Unit::moveToCell(Cell* destination) {
|
|
|
if (!canMoveToCell(destination))
|
|
|
return; //here could be a gui-message about failed move (x-mark, for example)
|
|
|
else {
|
|
|
- movement_speed_ -= lenOfActualPath(destination);
|
|
|
+ activity_points_ -= lenOfActualPath(destination)/movement_speed_;
|
|
|
+ if (lenOfActualPath(destination) % movement_speed_)
|
|
|
+ activity_points_ -= 1;
|
|
|
setLocation(destination);
|
|
|
}
|
|
|
}
|