Games modules are restricted to one-line response.

This commit is contained in:
Erik C. Thauvin 2022-03-28 21:20:10 -07:00
parent a3eada1727
commit a90db36fe2
3 changed files with 30 additions and 26 deletions

View file

@ -52,8 +52,16 @@ public final class War extends AbstractModule {
// War command
private static final String WAR_CMD = "war";
private static final String[] DECK = {"A", "K", "Q", "J", "10", "9", "8", "7", "6", "5", "4", "3", "2"};
private static final String[] SUITS = {"", "", "", ""};
private static final String[] HEARTS =
{"🂱", "🂾", "🂽", "🂻", "🂺", "🂹", "🂸", "🂷", "🂶", "🂵", "🂴", "🂳", "🂲"};
private static final String[] SPADES =
{"🂡", "🂮", "🂭", "🂫", "🂪", "🂩", "🂨", "🂧", "🂦", "🂥", "🂤", "🂣", "🂢"};
private static final String[] DIAMONDS =
{"🃁", "🃎", "🃍", "🃋", "🃊", "🃉", "🃈", "🃇", "🃆", "🃅", "🃄", "🃃", "🃂"};
private static final String[] CLUBS =
{"🃑", "🃞", "🃝", "🃛", "🃚", "🃙", "🃘", "🃗", "🃖", "🃕", "🃔", "🃓", "🃒"};
private static final String[][] DECK = {HEARTS, SPADES, DIAMONDS, CLUBS};
/**
* The default constructor.
@ -83,22 +91,21 @@ public final class War extends AbstractModule {
int y;
do {
i = RANDOM.nextInt(DECK.length);
y = RANDOM.nextInt(DECK.length);
event.respond("you drew " + bold(DECK[i]) + SUITS[RANDOM.nextInt(SUITS.length)]);
i = RANDOM.nextInt(HEARTS.length);
y = RANDOM.nextInt(HEARTS.length);
final String result;
if (i < y) {
result = bold("lost") + '.';
result = bold("win");
} else if (i > y) {
result = bold("wins") + '.';
result = bold("lose");
} else {
result = bold("tied") + ". This means " + bold("WAR!");
result = bold("tie") + ". This means " + bold("WAR");
}
event.getBot().sendIRC().action(channel, "drew " + bold(DECK[y]) + SUITS[RANDOM.nextInt(SUITS.length)] +
" and " + result);
event.respond(DECK[RANDOM.nextInt(DECK.length)][i] + " " + DECK[RANDOM.nextInt(DECK.length)][y] +
" » You " + result + '!');
} while (i == y);
}
}

View file

@ -33,7 +33,6 @@
package net.thauvin.erik.mobibot.modules
import net.thauvin.erik.mobibot.Utils.bold
import net.thauvin.erik.mobibot.Utils.bot
import net.thauvin.erik.mobibot.Utils.helpFormat
import org.pircbotx.hooks.types.GenericMessageEvent
@ -99,17 +98,15 @@ class RockPaperScissors : AbstractModule() {
override fun commandResponse(channel: String, cmd: String, args: String, event: GenericMessageEvent) {
val hand = Hands.valueOf(cmd.uppercase())
val botHand = Hands.values()[(0..Hands.values().size).random()]
with(event.bot()) {
when {
hand == botHand -> {
sendIRC().action(channel, "tied: ${hand.name} vs. ${botHand.name}")
event.respond("${hand.name} vs. ${botHand.name} » You ${"tie".bold()}.")
}
hand.beats(botHand) -> {
sendIRC().action(channel, "lost: ${hand.name.bold()} ${hand.action} ${botHand.name}")
event.respond("${hand.name.bold()} ${hand.action} ${botHand.name} » You ${"win".bold()}!")
}
else -> {
sendIRC().action(channel, "wins: ${botHand.name.bold()} ${botHand.action} ${hand.name}")
}
event.respond("${botHand.name.bold()} ${botHand.action} ${hand.name} » You ${"lose".bold()}!")
}
}
}

View file

@ -1,9 +1,9 @@
#Generated by the Semver Plugin for Gradle
#Sun Mar 27 22:37:50 PDT 2022
version.buildmeta=142
#Mon Mar 28 20:39:02 PDT 2022
version.buildmeta=214
version.major=0
version.minor=8
version.patch=0
version.prerelease=rc
version.project=mobibot
version.semver=0.8.0-rc+142
version.semver=0.8.0-rc+214