예제 #1
0
void Game_BattleAlgorithm::AlgorithmBase::Apply() {
	if (GetAffectedHp() != -1) {
		int hp = GetAffectedHp();
		(*current_target)->ChangeHp(IsPositive() ? hp : -hp);
	}

	if (GetAffectedSp() != -1) {
		int sp = GetAffectedSp();
		(*current_target)->SetSp((*current_target)->GetSp() + (IsPositive() ? sp : -sp));
	}

	// TODO
	if (GetAffectedAttack() != -1) {
	}

	if (GetAffectedDefense() != -1) {
	}

	if (GetAffectedSpirit() != -1) {
	}

	if (GetAffectedAgility() != -1) {
	}
	// End TODO
	if (GetAffectedSwitch() != -1) {
		Game_Switches[GetAffectedSwitch()] = true;
	}

	std::vector<RPG::State>::const_iterator it = conditions.begin();

	for (; it != conditions.end(); ++it) {
		if (IsPositive()) {
			(*current_target)->RemoveState(it->ID);
		}
		else {
			(*current_target)->AddState(it->ID);
		}
	}

	source->SetDefending(false);
}
void Game_BattleAlgorithm::AlgorithmBase::Apply() {
	if (GetAffectedHp() != -1) {
		int hp = GetAffectedHp();
		int target_hp = (*current_target)->GetHp();
		(*current_target)->ChangeHp(IsPositive() ? hp : -hp);
		if (absorb) {
			// Only absorb the hp that were left
			int src_hp = std::min(target_hp, IsPositive() ? -hp : hp);
			source->ChangeHp(src_hp);
		}
	}

	if (GetAffectedSp() != -1) {
		int sp = GetAffectedSp();
		int target_sp = (*current_target)->GetSp();
		(*current_target)->SetSp((*current_target)->GetSp() + (IsPositive() ? sp : -sp));
		if (absorb) {
			int src_sp = std::min(target_sp, IsPositive() ? -sp : sp);
			source->ChangeSp(src_sp);
		}
	}

	if (GetAffectedAttack() != -1) {
		int atk = GetAffectedAttack();
		(*current_target)->SetAtkModifier(IsPositive() ? atk : -atk);
		if (absorb) {
			source->SetAtkModifier(IsPositive() ? -atk : atk);
		}
	}

	if (GetAffectedDefense() != -1) {
		int def = GetAffectedDefense();
		(*current_target)->SetDefModifier(IsPositive() ? def : -def);
		if (absorb) {
			source->SetDefModifier(IsPositive() ? -def : def);
		}
	}

	if (GetAffectedSpirit() != -1) {
		int spi = GetAffectedSpirit();
		(*current_target)->SetSpiModifier(IsPositive() ? spi : -spi);
		if (absorb) {
			source->SetSpiModifier(IsPositive() ? -spi : spi);
		}
	}

	if (GetAffectedAgility() != -1) {
		int agi = GetAffectedAgility();
		(*current_target)->SetAgiModifier(IsPositive() ? agi : -agi);
		if (absorb) {
			source->SetAgiModifier(IsPositive() ? -agi : agi);
		}
	}

	if (GetAffectedSwitch() != -1) {
		Game_Switches[GetAffectedSwitch()] = true;
	}

	std::vector<RPG::State>::const_iterator it = conditions.begin();

	for (; it != conditions.end(); ++it) {
		if (IsPositive()) {
			if ((*current_target)->IsDead() && it->ID == 1) {
				// Was a revive skill with an effect rating of 0
				(*current_target)->ChangeHp(1);
			}

			(*current_target)->RemoveState(it->ID);
		}
		else {
			(*current_target)->AddState(it->ID);
		}
	}

	source->SetDefending(false);
}