-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added effects "Majority Voting" and "Minority Voting"
- Loading branch information
Showing
15 changed files
with
216 additions
and
12 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
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
11 changes: 11 additions & 0 deletions
11
ChaosMod/Effects/Condition/ConditionProportionalVotingEnabled.cpp
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 @@ | ||
#include <stdafx.h> | ||
|
||
#include "Components/Voting.h" | ||
#include "Effects/Condition/EffectCondition.h" | ||
|
||
static bool OnCondition() | ||
{ | ||
return ComponentExists<Voting>() && GetComponent<Voting>()->IsEnabled() && GetComponent<Voting>()->GetVotingMode() == VotingMode::Percentage; | ||
} | ||
|
||
REGISTER_EFFECT_CONDITION(EffectConditionType::ProportionalVotingEnabled, OnCondition); |
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,49 @@ | ||
/* | ||
Effects by Regynate | ||
*/ | ||
|
||
#include <stdafx.h> | ||
|
||
#include "Components/MetaModifiers.h" | ||
#include "Effects/Register/RegisterEffect.h" | ||
|
||
static void OnStop() | ||
{ | ||
GetComponent<MetaModifiers>()->VotingModeOverride = VotingMode::None; | ||
} | ||
|
||
static void OnStart_Majority() | ||
{ | ||
GetComponent<MetaModifiers>()->VotingModeOverride = VotingMode::Majority; | ||
} | ||
|
||
// clang-format off | ||
REGISTER_EFFECT(OnStart_Majority, OnStop, nullptr, | ||
{ | ||
.Name = "Majority Voting", | ||
.Id = "meta_votingmode_majority", | ||
.IsTimed = true, | ||
.IncompatibleWith = { "meta_votingmode_antimajority" }, | ||
.ExecutionType = EffectExecutionType::Meta, | ||
.ConditionType = EffectConditionType::ProportionalVotingEnabled | ||
} | ||
); | ||
// clang-format on | ||
|
||
static void OnStart_Antimajority() | ||
{ | ||
GetComponent<MetaModifiers>()->VotingModeOverride = VotingMode::Antimajority; | ||
} | ||
|
||
// clang-format off | ||
REGISTER_EFFECT(OnStart_Antimajority, OnStop, nullptr, | ||
{ | ||
.Name = "Minority Voting", | ||
.Id = "meta_votingmode_antimajority", | ||
.IsTimed = true, | ||
.IncompatibleWith = { "meta_votingmode_majority" }, | ||
.ExecutionType = EffectExecutionType::Meta, | ||
.ConditionType = EffectConditionType::VotingEnabled | ||
} | ||
); | ||
// clang-format on |
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,50 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
|
||
class VotingMode | ||
{ | ||
public: | ||
enum Value | ||
{ | ||
None, | ||
Majority, | ||
Percentage, | ||
Antimajority | ||
}; | ||
|
||
VotingMode() : value(None) | ||
{ | ||
} | ||
|
||
VotingMode(Value mode) : value(mode) | ||
{ | ||
} | ||
|
||
bool operator==(VotingMode a) const | ||
{ | ||
return value == a.value; | ||
} | ||
bool operator!=(VotingMode a) const | ||
{ | ||
return value != a.value; | ||
} | ||
|
||
std::string ToString() | ||
{ | ||
switch (value) | ||
{ | ||
case VotingMode::None: | ||
return "NONE"; | ||
case VotingMode::Majority: | ||
return "MAJORITY"; | ||
case VotingMode::Percentage: | ||
return "PERCENTAGE"; | ||
case VotingMode::Antimajority: | ||
return "ANTIMAJORITY"; | ||
} | ||
} | ||
|
||
private: | ||
Value value; | ||
}; |
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
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
Oops, something went wrong.