Simplified games output even more.

This commit is contained in:
Erik C. Thauvin 2022-03-27 13:37:16 -07:00
parent c26d5f53d2
commit 61248387d8
4 changed files with 27 additions and 25 deletions

View file

@ -82,24 +82,22 @@ public final class War extends AbstractModule {
int i;
int y;
while (true) {
do {
i = RANDOM.nextInt(DECK.length);
y = RANDOM.nextInt(DECK.length);
event.respond("you drew " + bold(DECK[i]) + SUITS[RANDOM.nextInt(SUITS.length)]);
event.getBot().sendIRC().action(channel, "drew " + bold(DECK[y]) + SUITS[RANDOM.nextInt(SUITS.length)]);
if (i != y) {
break;
final String result;
if (i < y) {
result = bold("lost") + '.';
} else if (i > y) {
result = bold("wins") + '.';
} else {
result = bold("tied") + ". This means " + bold("WAR!");
}
event.respond("This means " + bold("WAR") + '!');
}
if (i < y) {
event.getBot().sendIRC().action(channel, "lost.");
} else {
event.getBot().sendIRC().action(channel, "wins.");
}
event.respond("you drew " + bold(DECK[i]) + SUITS[RANDOM.nextInt(SUITS.length)]);
event.getBot().sendIRC().action(channel, "drew " + bold(DECK[y]) + SUITS[RANDOM.nextInt(SUITS.length)] +
" and " + result);
} while (i == y);
}
}

View file

@ -41,7 +41,6 @@ import org.pircbotx.hooks.types.GenericMessageEvent
*/
class Dice : AbstractModule() {
override val name = "Dice"
private val sides = 6
override fun commandResponse(channel: String, cmd: String, args: String, event: GenericMessageEvent) {
val botRoll = roll()
@ -50,17 +49,21 @@ class Dice : AbstractModule() {
val total = roll.first + roll.second
with(event.bot()) {
event.respond(
"you rolled ${roll.first.bold()} and ${roll.second.bold()} for a total of ${total.bold()}"
"you rolled 2 dice: ${roll.first.bold()} + ${roll.second.bold()} for a total of ${total.bold()}"
)
val result = when (winLoseOrTie(botTotal, total)) {
Result.WIN -> "wins"
Result.LOSE -> "lost"
else -> "tied"
}
sendIRC().action(
channel,
"rolled ${botRoll.first.bold()} and ${botRoll.second.bold()} for a total of ${botTotal.bold()}"
"rolled 2 dice: ${botRoll.first.bold()} + ${botRoll.second.bold()} for a total of ${botTotal.bold()}" +
" and ${result.bold()}."
)
when (winLoseOrTie(botTotal, total)) {
Result.WIN -> sendIRC().action(channel, "wins.")
Result.LOSE -> sendIRC().action(channel, "lost.")
else -> sendIRC().action(channel, "tied.")
}
}
}