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

@ -1,5 +1,6 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<option name="WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN" value="true" />
<JetCodeStyleSettings>
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
<value />

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.")
}
}
}

View file

@ -1,9 +1,9 @@
#Generated by the Semver Plugin for Gradle
#Sun Mar 27 12:29:09 PDT 2022
version.buildmeta=090
#Sun Mar 27 13:34:01 PDT 2022
version.buildmeta=101
version.major=0
version.minor=8
version.patch=0
version.prerelease=rc
version.project=mobibot
version.semver=0.8.0-rc+090
version.semver=0.8.0-rc+101