Skip to content

Commit

Permalink
!pick - Fine tuning and "any" string
Browse files Browse the repository at this point in the history
  • Loading branch information
FlavioFS committed Feb 27, 2023
1 parent a9aeb61 commit 7e2d5a5
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ParsecSoda/ChatBot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ACommand * ChatBot::identifyUserDataMessage(const char* msg, Guest &sender, bool
//if (CommandIpFilter::containsIp(msg)) return new CommandIpFilter(msg, sender, _parsec, _ban, isHost);
if (msgIsEqual(msg, CommandJoin::prefixes())) return new CommandJoin();
if (msgIsEqual(msg, CommandMirror::prefixes())) return new CommandMirror(sender, _gamepadClient);
if (msgIsEqual(msg, CommandMultitap::prefixes())) return new CommandMultitap(sender, _gamepadClient);
if (msgIsEqual(msg, CommandMultitap::prefixes())) return new CommandMultitap(sender, _gamepadClient);
if (msgIsEqual(msg, CommandPads::prefixes())) return new CommandPads(_gamepadClient);
if (msgStartsWith(msg, CommandSwap::prefixes())) return new CommandSwap(msg, sender, _gamepadClient, _hotseatManager);
if (msgIsEqual(msg, CommandTime::prefixes())) return new CommandTime(sender, _hotseatManager);
Expand Down
2 changes: 2 additions & 0 deletions ParsecSoda/Commands/ACommandIntegerArg.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class ACommandIntegerArg : public ACommandPrefix
}
}

inline const int getArg() const { return _intArg; }

protected:
int _intArg;
};
3 changes: 3 additions & 0 deletions ParsecSoda/Commands/ACommandPrefix.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class ACommandPrefix : public ACommand
return false;
}

inline const string getPrefix() const { return _prefix; }
inline const string getMessage() const { return _msg; }

protected:
const char* _msg;
const char* _prefix;
Expand Down
3 changes: 3 additions & 0 deletions ParsecSoda/Commands/ACommandStringArg.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "ACommandPrefix.h"
#include "../Stringer.h"
#include <functional>

class ACommandStringArg : public ACommandPrefix
{
Expand All @@ -24,6 +25,8 @@ class ACommandStringArg : public ACommandPrefix
return true;
}

inline const string& getArg() const { return _stringArg; }

protected:
string _stringArg;
};
22 changes: 20 additions & 2 deletions ParsecSoda/Commands/CommandSwap.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <iostream>
#include <sstream>
#include "ACommandStringArg.h"
#include "ACommandIntegerArg.h"
#include "../GamepadClient.h"

Expand All @@ -19,8 +20,25 @@ class CommandSwap : public ACommandIntegerArg

if (!ACommandIntegerArg::run())
{
_replyMessage = "[ChatBot]\tUsage: !swap <integer in range [1, gamepadCount]>\nExample: !swap 4\0";
return false;
bool recoverySuccess = false;

const string msg = getMessage();
if (!msg.empty())
{
ACommandStringArg stringArg(msg.c_str(), internalPrefixes());
stringArg.run();
if (Stringer::compareNoCase(stringArg.getArg(), "Any") == 0)
{
_intArg = 0;
recoverySuccess = true;
}
}

if (!recoverySuccess)
{
_replyMessage = "[ChatBot]\tUsage: !swap <integer in range [1, gamepadCount]>\nExample: !swap 4\0";
return false;
}
}

bool rv = false;
Expand Down
16 changes: 15 additions & 1 deletion ParsecSoda/HotseatManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,21 @@ int HotseatManager::setDesiredSeat(uint32_t userID, int desiredSeatIndex)
if (desiredSeatIndex != currentSeatIndex && desiredSeatIndex != HotseatGuest::ANY_SEAT)
{
seat.guest.desiredSeatIndex = result;
reverse(currentSeatIndex);

if (seat.timer.getRemainingTime() > 0.90f * seat.timer.getDuration())
{
reverse(currentSeatIndex);
}
else
{
HotseatGuest guest = seat.guest;
spectateSeat(currentSeatIndex);
enqueue(guest);
}
}
else
{
seat.guest.desiredSeatIndex = result;
}
});

Expand Down

0 comments on commit 7e2d5a5

Please sign in to comment.