return null;
}
@Override
protected InformationParameters executeAgent() {
Agent target = null, attacker = null;
int range = 0, target_life, attacker_attack, target_defense, speed;
PropertyHolder target_property_holder, attacker_property_holder;
StateHolder target_state_holder, attacker_state_holder;
//Get target and the attacker
target = getTarget();
attacker = getAttacker();
//states holders
target_state_holder = target.getState_holder();
attacker_state_holder = attacker.getState_holder();
//Range
range = getRange();
Coordinate target_position = target.getCoordinate(),
attacker_position = attacker.getCoordinate();
//Properties
target_property_holder = target.getProperty_holder();
attacker_property_holder = attacker.getProperty_holder();
//TODO Is the target visible?
int visibility = attacker.getVisibility();
if(target_position.isClose(attacker_position, visibility)){
//If the target is close enough for a close range attack
if (target_position.isClose(attacker_position, range)){
//Attack the target properties!
target_life = target.getLife();
if(target_life > 0) {//is it alive?
//TODO define a method to obtain the properties casted
//TODO Define a practical formulas, this is just for testing
target_defense = target.getArmor();
attacker_attack = attacker.getStrength()* 2;
target_life -= attacker_attack - target_defense;
target.setLife(target_life);
//Add states
target_state_holder.addState(this);
attacker_state_holder.addState(this);
return this;
}else{
//Remove states if the target is dead
removeStates();
}
}else{ //It's too far, lets get closer
speed = attacker.getSpeed();
attacker.move(target.getCoordinate(), speed);
}
}else{
//Remove states if the target is far away
removeStates();
}