Formatting if-else, Minor Nitpick
This commit is contained in:
parent
778153c94c
commit
f2fe5227d6
@ -439,7 +439,7 @@ int AOClient::genRand(int min, int max)
|
||||
#endif
|
||||
}
|
||||
|
||||
void AOClient::diceThrower(int argc, QStringList argv, RollType Type)
|
||||
void AOClient::diceThrower(int argc, QStringList argv, RollType type)
|
||||
{
|
||||
QString sender_name = ooc_name;
|
||||
int max_value = server->getDiceValue("max_value");
|
||||
@ -448,54 +448,45 @@ void AOClient::diceThrower(int argc, QStringList argv, RollType Type)
|
||||
int bounded_amount;
|
||||
QString dice_results;
|
||||
|
||||
if (argc == 0)
|
||||
{
|
||||
if (argc == 0) {
|
||||
dice_results = QString::number(genRand(1, 6)); // Self-explanatory
|
||||
}
|
||||
else if (argc == 1)
|
||||
{
|
||||
else if (argc == 1) {
|
||||
bounded_value = qBound(1, argv[0].toInt(), max_value); // faces, max faces
|
||||
dice_results = QString::number(genRand(1, bounded_value));
|
||||
}
|
||||
else if (argc == 2)
|
||||
{
|
||||
else if (argc == 2) {
|
||||
bounded_value = qBound(1, argv[0].toInt(), max_value); // 1, faces, max faces
|
||||
bounded_amount = qBound(1, argv[1].toInt(), max_dice); // 1, amount, max amount
|
||||
|
||||
for (int i = 1; i <= bounded_amount ; i++) // Loop as multiple dices are thrown
|
||||
{
|
||||
QString dice_result = QString::number(genRand(1, bounded_value));
|
||||
if (i == bounded_amount)
|
||||
{
|
||||
if (i == bounded_amount) {
|
||||
dice_results = dice_results.append(dice_result);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
dice_results = dice_results.append(dice_result + ",");
|
||||
}
|
||||
}
|
||||
}
|
||||
// Switch to change message behaviour, isEmpty check or the entire server crashes due to an out of range issue in the QStringList
|
||||
switch(Type)
|
||||
switch(type)
|
||||
{
|
||||
case ROLL:
|
||||
if (argv.isEmpty())
|
||||
{
|
||||
if (argv.isEmpty()){
|
||||
sendServerMessageArea(sender_name + " rolled " + dice_results + " out of 6");
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
sendServerMessageArea(sender_name + " rolled " + dice_results + " out of " + QString::number(bounded_value));
|
||||
}
|
||||
break;
|
||||
case ROLLP:
|
||||
if (argv.isEmpty())
|
||||
{
|
||||
if (argv.isEmpty()){
|
||||
sendServerMessage(sender_name + " rolled " + dice_results + " out of 6");
|
||||
sendServerMessageArea((sender_name + " rolled in secret."));
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
sendServerMessageArea(sender_name + " rolled " + dice_results + " out of " + QString::number(bounded_value));
|
||||
sendServerMessageArea((sender_name + " rolled in secret."));
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ int Server::getDiceValue(QString value_type)
|
||||
|
||||
settings.beginGroup("Dice");
|
||||
int value = settings.value(value_type, "100").toUInt();
|
||||
|
||||
settings.endGroup();
|
||||
return value;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user