diff --git a/config/detekt/baseline.xml b/config/detekt/baseline.xml index 148cb7e..fa308ea 100644 --- a/config/detekt/baseline.xml +++ b/config/detekt/baseline.xml @@ -19,6 +19,7 @@ MagicNumber:CurrencyConverter.kt$CurrencyConverter.Companion$8 MagicNumber:Cycle.kt$Cycle$10 MagicNumber:Cycle.kt$Cycle$1000L + MagicNumber:Dice.kt$Dice$6 MagicNumber:Ignore.kt$Ignore$8 MagicNumber:Info.kt$Info.Companion$30 MagicNumber:Info.kt$Info.Companion$365 @@ -72,5 +73,6 @@ TooGenericExceptionCaught:StockQuote.kt$StockQuote.Companion$e: NullPointerException TooGenericExceptionCaught:Weather2.kt$Weather2.Companion$e: NullPointerException TooManyFunctions:Tell.kt$Tell : AbstractCommand + UnusedPrivateMember:Dice.kt$Dice$private val sides = 6 diff --git a/src/main/java/net/thauvin/erik/mobibot/modules/War.java b/src/main/java/net/thauvin/erik/mobibot/modules/War.java index 4204e37..8b15438 100644 --- a/src/main/java/net/thauvin/erik/mobibot/modules/War.java +++ b/src/main/java/net/thauvin/erik/mobibot/modules/War.java @@ -52,16 +52,8 @@ public final class War extends AbstractModule { // War command private static final String WAR_CMD = "war"; - 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}; + private static final String[] DECK = {"A", "K", "Q", "J", "10", "9", "8", "7", "6", "5", "4", "3", "2"}; + private static final String[] SUITS = {"♥", "♠", "♦", "♣"}; /** * The default constructor. @@ -91,11 +83,11 @@ public final class War extends AbstractModule { int y; while (true) { - i = RANDOM.nextInt(HEARTS.length); - y = RANDOM.nextInt(HEARTS.length); + i = RANDOM.nextInt(DECK.length); + y = RANDOM.nextInt(DECK.length); - event.respond("you drew " + DECK[RANDOM.nextInt(DECK.length)][i]); - event.getBot().sendIRC().action(channel, "drew " + DECK[RANDOM.nextInt(DECK.length)][y]); + 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; diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/commands/Versions.kt b/src/main/kotlin/net/thauvin/erik/mobibot/commands/Versions.kt index 2875e06..786f5fe 100644 --- a/src/main/kotlin/net/thauvin/erik/mobibot/commands/Versions.kt +++ b/src/main/kotlin/net/thauvin/erik/mobibot/commands/Versions.kt @@ -40,10 +40,11 @@ import org.pircbotx.hooks.types.GenericMessageEvent class Versions : AbstractCommand() { private val allVersions = listOf( - "Version: ${ReleaseInfo.VERSION} (${ReleaseInfo.BUILDDATE.toIsoLocalDate()})", - "Platform: " + System.getProperty("os.name") + ' ' + System.getProperty("os.version") - + " (" + System.getProperty("os.arch") + ')', - "Runtime: " + System.getProperty("java.runtime.name") + ' ' + System.getProperty("java.runtime.version") + "Version : ${ReleaseInfo.VERSION} (${ReleaseInfo.BUILDDATE.toIsoLocalDate()})", + "Platform : ${System.getProperty("os.name")} ${System.getProperty("os.version")}" + + " (${System.getProperty("os.arch")})", + "Runtime : ${System.getProperty("java.runtime.name")} ${System.getProperty("java.runtime.version")}" + + " (${System.getProperty("java.vendor")})" ) override val name = "versions" override val help = listOf("To view the versions data (bot, platform, java, etc.):", helpFormat("%c $name")) diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/modules/Dice.kt b/src/main/kotlin/net/thauvin/erik/mobibot/modules/Dice.kt index 9e7725d..7d471e5 100644 --- a/src/main/kotlin/net/thauvin/erik/mobibot/modules/Dice.kt +++ b/src/main/kotlin/net/thauvin/erik/mobibot/modules/Dice.kt @@ -41,6 +41,7 @@ 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() @@ -49,11 +50,11 @@ class Dice : AbstractModule() { val total = roll.first + roll.second with(event.bot()) { event.respond( - "you rolled ${DICE_FACES[roll.first]} ${DICE_FACES[roll.second]} for a total of ${total.bold()}" + "you rolled ${roll.first.bold()} and ${roll.second.bold()} for a total of ${total.bold()}" ) sendIRC().action( channel, - "rolled ${DICE_FACES[botRoll.first]} ${DICE_FACES[botRoll.second]} for a total of ${botTotal.bold()}" + "rolled ${botRoll.first.bold()} and ${botRoll.second.bold()} for a total of ${botTotal.bold()}" ) when (winLoseOrTie(botTotal, total)) { Result.WIN -> sendIRC().action(channel, "wins.") @@ -68,16 +69,13 @@ class Dice : AbstractModule() { } private fun roll(): Pair { - return (1..DICE_FACES.size).random() to (1..DICE_FACES.size).random() + return (1..6).random() to (1..6).random() } companion object { // Dice command private const val DICE_CMD = "dice" - // Dice faces - private val DICE_FACES = arrayOf("", "⚀", "⚁", "⚂", "⚃", "⚄", "⚅") - @JvmStatic fun winLoseOrTie(bot: Int, player: Int): Result { return when { diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/modules/RockPaperScissors.kt b/src/main/kotlin/net/thauvin/erik/mobibot/modules/RockPaperScissors.kt index c092548..a3e7045 100644 --- a/src/main/kotlin/net/thauvin/erik/mobibot/modules/RockPaperScissors.kt +++ b/src/main/kotlin/net/thauvin/erik/mobibot/modules/RockPaperScissors.kt @@ -32,8 +32,8 @@ 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.capitalise import net.thauvin.erik.mobibot.Utils.helpFormat import org.pircbotx.hooks.types.GenericMessageEvent @@ -67,26 +67,19 @@ class RockPaperScissors : AbstractModule() { override fun beats(hand: Hands): Boolean { return hand == SCISSORS } - - override var emoji = "\u270A" }, PAPER("covers") { override fun beats(hand: Hands): Boolean { return hand == ROCK } - - override var emoji = "\u270B" }, SCISSORS("cuts") { override fun beats(hand: Hands): Boolean { return hand == PAPER } - - override var emoji = "\u270C" }; abstract fun beats(hand: Hands): Boolean - abstract var emoji: String } companion object { @@ -107,21 +100,20 @@ class RockPaperScissors : AbstractModule() { val hand = Hands.valueOf(cmd.uppercase()) val botHand = Hands.values()[(0..Hands.values().size).random()] with(event.bot()) { - sendIRC().message(channel, "${hand.emoji} vs. ${botHand.emoji}") when { hand == botHand -> { - sendIRC().action(channel, "tied.") + sendIRC().action(channel, "tied: ${hand.name} vs. ${botHand.name}") } hand.beats(botHand) -> { sendIRC().action( channel, - "lost. ${hand.name.capitalise()} ${hand.action} ${botHand.name.lowercase()}." + "lost: ${hand.name.bold()} ${hand.action} ${botHand.name}" ) } else -> { sendIRC().action( channel, - "wins. ${botHand.name.capitalise()} ${botHand.action} ${hand.name.lowercase()}." + "wins: ${botHand.name.bold()} ${botHand.action} ${hand.name}" ) } } diff --git a/src/test/kotlin/net/thauvin/erik/mobibot/modules/CurrencyConverterTest.kt b/src/test/kotlin/net/thauvin/erik/mobibot/modules/CurrencyConverterTest.kt index 90e3e4e..468a947 100644 --- a/src/test/kotlin/net/thauvin/erik/mobibot/modules/CurrencyConverterTest.kt +++ b/src/test/kotlin/net/thauvin/erik/mobibot/modules/CurrencyConverterTest.kt @@ -35,7 +35,6 @@ import assertk.all import assertk.assertThat import assertk.assertions.any import assertk.assertions.contains -import assertk.assertions.isEqualTo import assertk.assertions.isGreaterThan import assertk.assertions.isInstanceOf import assertk.assertions.matches diff --git a/version.properties b/version.properties index 1c4029c..c4d9f71 100644 --- a/version.properties +++ b/version.properties @@ -1,9 +1,9 @@ #Generated by the Semver Plugin for Gradle -#Wed Mar 23 11:53:53 PDT 2022 -version.buildmeta=035 +#Sun Mar 27 12:29:09 PDT 2022 +version.buildmeta=090 version.major=0 version.minor=8 version.patch=0 version.prerelease=rc version.project=mobibot -version.semver=0.8.0-rc+035 +version.semver=0.8.0-rc+090