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})
|
||||
endif ()
|
||||
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})
|
||||
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)
|
||||
endif ()
|
||||
endif ()
|
||||
|
|
|
@ -19,9 +19,7 @@ void TurnHandler::RunTurn(ChoiceQueue* queue) {
|
|||
}
|
||||
|
||||
void TurnHandler::ExecuteChoice(BaseTurnChoice* choice) {
|
||||
if (choice == nullptr) {
|
||||
return;
|
||||
}
|
||||
AssertNotNull(choice);
|
||||
auto choiceKind = choice->GetKind();
|
||||
if (choiceKind == TurnChoiceKind::Pass) {
|
||||
return;
|
||||
|
@ -116,7 +114,7 @@ void TurnHandler::HandleAttackForTarget(ExecutingAttack* attack, Creature* targe
|
|||
return;
|
||||
}
|
||||
|
||||
bool invulnerable = fail;
|
||||
bool invulnerable = false;
|
||||
HOOK(IsInvulnerable, targetSource, attack, target, &invulnerable);
|
||||
if (invulnerable) {
|
||||
// TODO: We should probably do something when a target is invulnerable.
|
||||
|
@ -140,7 +138,6 @@ void TurnHandler::HandleAttackForTarget(ExecutingAttack* attack, Creature* targe
|
|||
break;
|
||||
}
|
||||
if (target->IsFainted()) {
|
||||
// STOP, STOP! HE'S ALREADY DEAD ;_;
|
||||
break;
|
||||
}
|
||||
auto hit = targetData->GetHit(hitIndex);
|
||||
|
|
|
@ -6,7 +6,12 @@
|
|||
using namespace CreatureLib;
|
||||
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 bKind = b->GetKind();
|
||||
if (aKind != bKind)
|
||||
|
@ -22,13 +27,11 @@ bool ___ChoiceOrderFunc(const BaseTurnChoice* a, const BaseTurnChoice* b, Arbuti
|
|||
if (aSpeed != bSpeed)
|
||||
return aSpeed > bSpeed;
|
||||
|
||||
auto randomValue = rand.Get(2);
|
||||
auto randomValue = _rand.Get(2);
|
||||
return randomValue == 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void TurnOrdering::OrderChoices(std::vector<BaseTurnChoice*>& vec, Arbutils::Random& rand) {
|
||||
auto comp = [&](const BaseTurnChoice* a, const BaseTurnChoice* b) -> bool {
|
||||
return ___ChoiceOrderFunc(a, b, rand);
|
||||
};
|
||||
std::sort(vec.begin(), vec.end(), comp);
|
||||
std::sort(vec.begin(), vec.end(), ChoiceCompare(rand));
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ Battling::Battle* Battling::Creature::GetBattle() const { return _battle; }
|
|||
|
||||
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() {
|
||||
// HOOK: On Faint
|
||||
|
@ -115,6 +115,8 @@ void Battling::Creature::Damage(uint32_t damage, Battling::DamageSource source)
|
|||
if (damage > _currentHealth) {
|
||||
damage = _currentHealth;
|
||||
}
|
||||
if (damage == 0)
|
||||
return;
|
||||
// HOOK: On Damage
|
||||
auto newHealth = _currentHealth - damage;
|
||||
auto battle = this->GetBattle();
|
||||
|
|
Loading…
Reference in New Issue