-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0b3bf2a
commit 0f27bbb
Showing
20 changed files
with
380 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#pragma once | ||
|
||
#include "data/spells/Type.h" | ||
|
||
namespace linguine { | ||
|
||
struct UnitType { | ||
Type type; | ||
}; | ||
|
||
} // namespace linguine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#pragma once | ||
|
||
namespace linguine { | ||
|
||
enum Type { | ||
Fire, | ||
Water, | ||
Storm, | ||
Earth, | ||
Decay, | ||
Growth | ||
}; | ||
|
||
} // namespace linguine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#pragma once | ||
|
||
#include "Type.h" | ||
|
||
namespace linguine { | ||
|
||
class TypeEvaluator { | ||
public: | ||
static float calculateModifier(Type spellType, Type targetType) { | ||
switch (targetType) { | ||
case Fire: | ||
switch (spellType) { | ||
case Fire: | ||
case Storm: | ||
return Heal; | ||
case Water: | ||
case Earth: | ||
return Weak; | ||
default: | ||
return Base; | ||
} | ||
case Water: | ||
switch (spellType) { | ||
case Fire: | ||
return Resist; | ||
case Water: | ||
return Heal; | ||
case Storm: | ||
return Weak; | ||
default: | ||
return Base; | ||
} | ||
case Storm: | ||
switch (spellType) { | ||
case Storm: | ||
return Heal; | ||
default: | ||
return Base; | ||
} | ||
case Earth: | ||
switch (spellType) { | ||
case Fire: | ||
case Storm: | ||
return Resist; | ||
case Water: | ||
case Growth: | ||
return Weak; | ||
case Earth: | ||
return Heal; | ||
default: | ||
return Base; | ||
} | ||
break; | ||
case Decay: | ||
switch (spellType) { | ||
case Fire: | ||
case Growth: | ||
return Weak; | ||
case Decay: | ||
return Heal; | ||
default: | ||
return Base; | ||
} | ||
break; | ||
case Growth: | ||
switch (spellType) { | ||
case Fire: | ||
case Decay: | ||
return Weak; | ||
case Water: | ||
case Growth: | ||
return Heal; | ||
case Earth: | ||
return Resist; | ||
default: | ||
return Base; | ||
} | ||
break; | ||
default: | ||
throw std::runtime_error("Unsupported type application"); | ||
} | ||
} | ||
|
||
private: | ||
constexpr static float Base = -1.0f; | ||
constexpr static float Resist = -0.5f; | ||
constexpr static float Weak = -2.0f; | ||
constexpr static float Heal = 1.0f; | ||
}; | ||
|
||
} // namespace linguine |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include "ModifyHealth.h" | ||
|
||
#include <glm/common.hpp> | ||
|
||
#include "components/Health.h" | ||
#include "components/UnitType.h" | ||
#include "data/spells/TypeEvaluator.h" | ||
#include "entity/Result.h" | ||
|
||
namespace linguine { | ||
|
||
void ModifyHealth::execute(Entity& target) { | ||
auto health = target.get<Health>(); | ||
auto targetType = target.get<UnitType>(); | ||
|
||
auto modifier = static_cast<int32_t>( | ||
glm::round(static_cast<float>(_power) * TypeEvaluator::calculateModifier(_type, targetType->type)) | ||
); | ||
|
||
health->current = glm::min(health->current + modifier, health->max); | ||
} | ||
|
||
} // namespace linguine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#pragma once | ||
|
||
#include "Action.h" | ||
|
||
#include "data/spells/Type.h" | ||
#include "entity/EntityManager.h" | ||
|
||
namespace linguine { | ||
|
||
class ModifyHealth : public Action { | ||
public: | ||
ModifyHealth(EntityManager& entityManager, Type type, int32_t power) | ||
: _entityManager(entityManager), _type(type), _power(power) {} | ||
|
||
~ModifyHealth() override = default; | ||
|
||
void execute(Entity& target) override; | ||
|
||
private: | ||
EntityManager& _entityManager; | ||
Type _type; | ||
int32_t _power; | ||
}; | ||
|
||
} // namespace linguine |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include "ModifyHealthOverTime.h" | ||
|
||
#include <glm/common.hpp> | ||
|
||
#include "components/EffectTracker.h" | ||
#include "components/Health.h" | ||
#include "components/UnitType.h" | ||
#include "data/spells/TypeEvaluator.h" | ||
#include "entity/Entity.h" | ||
|
||
namespace linguine { | ||
|
||
void ModifyHealthOverTime::onTick(Component<EffectTracker>& tracker) { | ||
auto target = _entityManager.getById(tracker->targetId); | ||
auto health = target->get<Health>(); | ||
auto targetType = target->get<UnitType>(); | ||
|
||
auto modifier = static_cast<int32_t>( | ||
glm::round(static_cast<float>(_powerPerTick) * TypeEvaluator::calculateModifier(getType(), targetType->type)) | ||
); | ||
|
||
health->current = glm::min(health->current + modifier, health->max); | ||
} | ||
|
||
} // namespace linguine |
Oops, something went wrong.