mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-01 19:13:55 -07:00
Backwards Compatibility for rolling dice
This commit is contained in:
parent
b7fbc12ac0
commit
f04702fdd1
2 changed files with 11 additions and 5 deletions
|
|
@ -1963,10 +1963,7 @@ void Player::eventShuffle(const Event_Shuffle &event)
|
||||||
|
|
||||||
void Player::eventRollDie(const Event_RollDie &event)
|
void Player::eventRollDie(const Event_RollDie &event)
|
||||||
{
|
{
|
||||||
if (event.value()) {
|
if (!event.values().empty()) {
|
||||||
// Backwards compatibility for old clients
|
|
||||||
emit logRollDie(this, static_cast<int>(event.sides()), {event.value()});
|
|
||||||
} else {
|
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
||||||
QList<uint> rolls(event.values().begin(), event.values().end());
|
QList<uint> rolls(event.values().begin(), event.values().end());
|
||||||
#else
|
#else
|
||||||
|
|
@ -1978,6 +1975,10 @@ void Player::eventRollDie(const Event_RollDie &event)
|
||||||
std::sort(rolls.begin(), rolls.end());
|
std::sort(rolls.begin(), rolls.end());
|
||||||
emit logRollDie(this, static_cast<int>(event.sides()), rolls);
|
emit logRollDie(this, static_cast<int>(event.sides()), rolls);
|
||||||
}
|
}
|
||||||
|
else if (event.value()) {
|
||||||
|
// Backwards compatibility for old clients
|
||||||
|
emit logRollDie(this, static_cast<int>(event.sides()), {event.value()});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::eventCreateArrow(const Event_CreateArrow &event)
|
void Player::eventCreateArrow(const Event_CreateArrow &event)
|
||||||
|
|
|
||||||
|
|
@ -1076,7 +1076,12 @@ Server_Player::cmdRollDie(const Command_RollDie &cmd, ResponseContainer & /*rc*/
|
||||||
Event_RollDie event;
|
Event_RollDie event;
|
||||||
event.set_sides(validatedSides);
|
event.set_sides(validatedSides);
|
||||||
for (auto i = 0; i < validatedDiceToRoll; ++i) {
|
for (auto i = 0; i < validatedDiceToRoll; ++i) {
|
||||||
event.add_values(rng->rand(1, validatedSides));
|
const auto roll = rng->rand(1, validatedSides);
|
||||||
|
if (i == 0) {
|
||||||
|
// Backwards compatibility
|
||||||
|
event.set_value(roll);
|
||||||
|
}
|
||||||
|
event.add_values(roll);
|
||||||
}
|
}
|
||||||
ges.enqueueGameEvent(event, playerId);
|
ges.enqueueGameEvent(event, playerId);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue