Cleanup
This commit is contained in:
parent
d2cf26e950
commit
75baf19ebd
|
@ -17,10 +17,10 @@ if (NOT EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
||||||
SET(VERSION ${VERSION}.${MINOR})
|
SET(VERSION ${VERSION}.${MINOR})
|
||||||
endif ()
|
endif ()
|
||||||
if (NOT WINDOWS)
|
if (NOT WINDOWS)
|
||||||
execute_process(COMMAND conan install ${CMAKE_SOURCE_DIR} --install-folder=${CMAKE_BINARY_DIR} --build missing
|
execute_process(COMMAND conan install ${CMAKE_SOURCE_DIR} --install-folder=${CMAKE_BINARY_DIR} --build outdated
|
||||||
-s compiler=clang -s compiler.libcxx=libstdc++11 -s compiler.version=${VERSION})
|
-s compiler=clang -s compiler.libcxx=libstdc++11 -s compiler.version=${VERSION})
|
||||||
else ()
|
else ()
|
||||||
execute_process(COMMAND conan install ${CMAKE_SOURCE_DIR} --install-folder=${CMAKE_BINARY_DIR} --build missing
|
execute_process(COMMAND conan install ${CMAKE_SOURCE_DIR} --install-folder=${CMAKE_BINARY_DIR} --build outdated
|
||||||
-s compiler=gcc -s compiler.libcxx=libstdc++11 -s compiler.version=${VERSION} -s os=Windows)
|
-s compiler=gcc -s compiler.libcxx=libstdc++11 -s compiler.version=${VERSION} -s os=Windows)
|
||||||
endif ()
|
endif ()
|
||||||
endif ()
|
endif ()
|
||||||
|
|
|
@ -19,9 +19,7 @@ void TurnHandler::RunTurn(ChoiceQueue* queue) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TurnHandler::ExecuteChoice(BaseTurnChoice* choice) {
|
void TurnHandler::ExecuteChoice(BaseTurnChoice* choice) {
|
||||||
if (choice == nullptr) {
|
AssertNotNull(choice);
|
||||||
return;
|
|
||||||
}
|
|
||||||
auto choiceKind = choice->GetKind();
|
auto choiceKind = choice->GetKind();
|
||||||
if (choiceKind == TurnChoiceKind::Pass) {
|
if (choiceKind == TurnChoiceKind::Pass) {
|
||||||
return;
|
return;
|
||||||
|
@ -116,7 +114,7 @@ void TurnHandler::HandleAttackForTarget(ExecutingAttack* attack, Creature* targe
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool invulnerable = fail;
|
bool invulnerable = false;
|
||||||
HOOK(IsInvulnerable, targetSource, attack, target, &invulnerable);
|
HOOK(IsInvulnerable, targetSource, attack, target, &invulnerable);
|
||||||
if (invulnerable) {
|
if (invulnerable) {
|
||||||
// TODO: We should probably do something when a target is invulnerable.
|
// TODO: We should probably do something when a target is invulnerable.
|
||||||
|
@ -140,7 +138,6 @@ void TurnHandler::HandleAttackForTarget(ExecutingAttack* attack, Creature* targe
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (target->IsFainted()) {
|
if (target->IsFainted()) {
|
||||||
// STOP, STOP! HE'S ALREADY DEAD ;_;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
auto hit = targetData->GetHit(hitIndex);
|
auto hit = targetData->GetHit(hitIndex);
|
||||||
|
|
|
@ -6,7 +6,12 @@
|
||||||
using namespace CreatureLib;
|
using namespace CreatureLib;
|
||||||
using namespace Battling;
|
using namespace Battling;
|
||||||
|
|
||||||
bool ___ChoiceOrderFunc(const BaseTurnChoice* a, const BaseTurnChoice* b, Arbutils::Random& rand) {
|
class ChoiceCompare {
|
||||||
|
Arbutils::Random& _rand;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit ChoiceCompare(Arbutils::Random& rand) : _rand(rand) {}
|
||||||
|
bool operator()(const BaseTurnChoice* a, const BaseTurnChoice* b) {
|
||||||
auto aKind = a->GetKind();
|
auto aKind = a->GetKind();
|
||||||
auto bKind = b->GetKind();
|
auto bKind = b->GetKind();
|
||||||
if (aKind != bKind)
|
if (aKind != bKind)
|
||||||
|
@ -22,13 +27,11 @@ bool ___ChoiceOrderFunc(const BaseTurnChoice* a, const BaseTurnChoice* b, Arbuti
|
||||||
if (aSpeed != bSpeed)
|
if (aSpeed != bSpeed)
|
||||||
return aSpeed > bSpeed;
|
return aSpeed > bSpeed;
|
||||||
|
|
||||||
auto randomValue = rand.Get(2);
|
auto randomValue = _rand.Get(2);
|
||||||
return randomValue == 0;
|
return randomValue == 0;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
void TurnOrdering::OrderChoices(std::vector<BaseTurnChoice*>& vec, Arbutils::Random& rand) {
|
void TurnOrdering::OrderChoices(std::vector<BaseTurnChoice*>& vec, Arbutils::Random& rand) {
|
||||||
auto comp = [&](const BaseTurnChoice* a, const BaseTurnChoice* b) -> bool {
|
std::sort(vec.begin(), vec.end(), ChoiceCompare(rand));
|
||||||
return ___ChoiceOrderFunc(a, b, rand);
|
|
||||||
};
|
|
||||||
std::sort(vec.begin(), vec.end(), comp);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,7 @@ Battling::Battle* Battling::Creature::GetBattle() const { return _battle; }
|
||||||
|
|
||||||
Battling::BattleSide* Battling::Creature::GetBattleSide() const { return _side; }
|
Battling::BattleSide* Battling::Creature::GetBattleSide() const { return _side; }
|
||||||
|
|
||||||
bool Battling::Creature::IsFainted() const noexcept { return this->_currentHealth <= 0; }
|
bool Battling::Creature::IsFainted() const noexcept { return this->_currentHealth == 0; }
|
||||||
|
|
||||||
void Battling::Creature::OnFaint() {
|
void Battling::Creature::OnFaint() {
|
||||||
// HOOK: On Faint
|
// HOOK: On Faint
|
||||||
|
@ -115,6 +115,8 @@ void Battling::Creature::Damage(uint32_t damage, Battling::DamageSource source)
|
||||||
if (damage > _currentHealth) {
|
if (damage > _currentHealth) {
|
||||||
damage = _currentHealth;
|
damage = _currentHealth;
|
||||||
}
|
}
|
||||||
|
if (damage == 0)
|
||||||
|
return;
|
||||||
// HOOK: On Damage
|
// HOOK: On Damage
|
||||||
auto newHealth = _currentHealth - damage;
|
auto newHealth = _currentHealth - damage;
|
||||||
auto battle = this->GetBattle();
|
auto battle = this->GetBattle();
|
||||||
|
|
Loading…
Reference in New Issue