Games modules are restricted to one-line response.
This commit is contained in:
parent
a3eada1727
commit
a90db36fe2
3 changed files with 30 additions and 26 deletions
|
@ -52,8 +52,16 @@ public final class War extends AbstractModule {
|
||||||
// War command
|
// War command
|
||||||
private static final String WAR_CMD = "war";
|
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[] HEARTS =
|
||||||
private static final String[] SUITS = {"♥", "♠", "♦", "♣"};
|
{"🂱", "🂾", "🂽", "🂻", "🂺", "🂹", "🂸", "🂷", "🂶", "🂵", "🂴", "🂳", "🂲"};
|
||||||
|
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.
|
* The default constructor.
|
||||||
|
@ -83,22 +91,21 @@ public final class War extends AbstractModule {
|
||||||
int y;
|
int y;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
i = RANDOM.nextInt(DECK.length);
|
i = RANDOM.nextInt(HEARTS.length);
|
||||||
y = RANDOM.nextInt(DECK.length);
|
y = RANDOM.nextInt(HEARTS.length);
|
||||||
|
|
||||||
event.respond("you drew " + bold(DECK[i]) + SUITS[RANDOM.nextInt(SUITS.length)]);
|
|
||||||
|
|
||||||
final String result;
|
final String result;
|
||||||
if (i < y) {
|
if (i < y) {
|
||||||
result = bold("lost") + '.';
|
result = bold("win");
|
||||||
} else if (i > y) {
|
} else if (i > y) {
|
||||||
result = bold("wins") + '.';
|
result = bold("lose");
|
||||||
} else {
|
} 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)] +
|
event.respond(DECK[RANDOM.nextInt(DECK.length)][i] + " " + DECK[RANDOM.nextInt(DECK.length)][y] +
|
||||||
" and " + result);
|
" » You " + result + '!');
|
||||||
|
|
||||||
} while (i == y);
|
} while (i == y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,6 @@
|
||||||
package net.thauvin.erik.mobibot.modules
|
package net.thauvin.erik.mobibot.modules
|
||||||
|
|
||||||
import net.thauvin.erik.mobibot.Utils.bold
|
import net.thauvin.erik.mobibot.Utils.bold
|
||||||
import net.thauvin.erik.mobibot.Utils.bot
|
|
||||||
import net.thauvin.erik.mobibot.Utils.helpFormat
|
import net.thauvin.erik.mobibot.Utils.helpFormat
|
||||||
import org.pircbotx.hooks.types.GenericMessageEvent
|
import org.pircbotx.hooks.types.GenericMessageEvent
|
||||||
|
|
||||||
|
@ -99,17 +98,15 @@ class RockPaperScissors : AbstractModule() {
|
||||||
override fun commandResponse(channel: String, cmd: String, args: String, event: GenericMessageEvent) {
|
override fun commandResponse(channel: String, cmd: String, args: String, event: GenericMessageEvent) {
|
||||||
val hand = Hands.valueOf(cmd.uppercase())
|
val hand = Hands.valueOf(cmd.uppercase())
|
||||||
val botHand = Hands.values()[(0..Hands.values().size).random()]
|
val botHand = Hands.values()[(0..Hands.values().size).random()]
|
||||||
with(event.bot()) {
|
|
||||||
when {
|
when {
|
||||||
hand == botHand -> {
|
hand == botHand -> {
|
||||||
sendIRC().action(channel, "tied: ${hand.name} vs. ${botHand.name}")
|
event.respond("${hand.name} vs. ${botHand.name} » You ${"tie".bold()}.")
|
||||||
}
|
}
|
||||||
hand.beats(botHand) -> {
|
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 -> {
|
else -> {
|
||||||
sendIRC().action(channel, "wins: ${botHand.name.bold()} ${botHand.action} ${hand.name}")
|
event.respond("${botHand.name.bold()} ${botHand.action} ${hand.name} » You ${"lose".bold()}!")
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#Generated by the Semver Plugin for Gradle
|
#Generated by the Semver Plugin for Gradle
|
||||||
#Sun Mar 27 22:37:50 PDT 2022
|
#Mon Mar 28 20:39:02 PDT 2022
|
||||||
version.buildmeta=142
|
version.buildmeta=214
|
||||||
version.major=0
|
version.major=0
|
||||||
version.minor=8
|
version.minor=8
|
||||||
version.patch=0
|
version.patch=0
|
||||||
version.prerelease=rc
|
version.prerelease=rc
|
||||||
version.project=mobibot
|
version.project=mobibot
|
||||||
version.semver=0.8.0-rc+142
|
version.semver=0.8.0-rc+214
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue