Skip to content

Commit

Permalink
Update voting thing
Browse files Browse the repository at this point in the history
  • Loading branch information
ScriptedSnark committed Mar 16, 2024
1 parent 10ebbd9 commit 267daef
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
27 changes: 15 additions & 12 deletions GSChaos/CChaos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,19 +164,22 @@ void CChaos::Vote(const std::string& user, const std::string& msg)
return;
}

// TODO: rename voting commands
if (msg.find("effect1") != std::string::npos)
voteValue = 0;
else if (msg.find("effect2") != std::string::npos)
voteValue = 1;
else if (msg.find("effect3") != std::string::npos)
voteValue = 2;

if (voteValue != -1)
if (msg.size() == 1 && std::isdigit(msg[0]))
{
m_twitchVoters.push_back({ user, voteValue });
m_aiVoteValues[voteValue]++;
DEBUG_PRINT("Twitch user %s voted for option %i\n", user.c_str(), voteValue + 1);
voteValue = std::stoi(msg);
if (voteValue >= 1 && voteValue <= 3)
{
m_twitchVoters.push_back({ user, voteValue - 1 });
m_aiVoteValues[voteValue - 1]++;
DEBUG_PRINT("Twitch user %s voted for option %i\n", user.c_str(), voteValue);
}
else
{
DEBUG_PRINT("Invalid vote value: %i\n", voteValue);
}
}
else {
DEBUG_PRINT("Invalid vote message: %s\n", msg.c_str());
}
}

Expand Down
4 changes: 2 additions & 2 deletions GSChaos/CFeatureNothing.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* Copyright - ScriptedSnark, 2024.
* CFeatureNothing.h - description
* CFeatureNothing.h
*
* Project (Project desc) header file
* Project (GSChaos) header file
* Authors: ScriptedSnark.
* Do not delete this comment block. Respect others' work!
*/
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ GSChaos supports Twitch chat voting. If you want to use it, then do some steps:

7. Run the game and check if everything is installed successfully (wait for 10 seconds in game after chaos bar activating so you can check voting system)

To vote, you need to type `effectNUMBER` in chat (for example, `effect2`).
To vote, you need to type `NUMBER` in chat (for example, `2`).
If you don't want to play with this feature, rename `twitch.ini` to `twitch_DISABLED.ini`.

## Effects
Expand Down

0 comments on commit 267daef

Please sign in to comment.