Added some entry points for RS.

Tweaked some dice name/structure so it makes more sense from the caller side
This commit is contained in:
dtookey 2023-09-10 17:46:56 -04:00
parent 483e67bb16
commit 9c3d3f2d70
5 changed files with 26 additions and 10 deletions

View File

@ -4,5 +4,5 @@ import game_logic.runescape.RunescapeRoutines
fun main() {
RunescapeRoutines.processInventoryAtFurnace(1839)
RunescapeRoutines.processInventoryAtFurnace(2137)
}

View File

@ -0,0 +1,11 @@
package entries
import game_logic.runescape.RunescapeRoutines
fun main() {
RunescapeRoutines.createNecromancyInk(2000)
}

View File

@ -2,7 +2,7 @@ package simulation.dice
object Dice {
fun regular(rollString: String, modifiers: List<DiceModifier<Int>> = ArrayList()): DiceRoller {
return DiceImpl(rollString, modifiers)
return DiceRollerImpl(rollString, modifiers)
}
fun critDice(rollString: String, modifiers: List<DiceModifier<Int>> = ArrayList()): CritDiceRoller {

View File

@ -38,6 +38,15 @@ interface DiceRoller {
val nDice: Int
val dieSize: Int
companion object {
internal fun defaultDiceStringParseFn(rollString: String): Pair<Int, Int> {
val cleanRollString = rollString.lowercase()
val parts = cleanRollString.split('d')
return Pair(parts[0].toInt(), parts[1].toInt())
}
}
/**
* Rolls the dice and returns the result.
*
@ -89,22 +98,18 @@ interface DiceRoller {
}
fun defaultParseFn(rollString: String): Pair<Int, Int> {
val cleanRollString = rollString.lowercase()
val parts = cleanRollString.split('d')
return Pair(parts[0].toInt(), parts[1].toInt())
}
}
internal class DiceImpl(
internal class DiceRollerImpl(
override val rollString: String,
override val modifiers: List<DiceModifier<Int>> = ArrayList()
) : DiceRoller {
override val nDice: Int
override val dieSize: Int
init {
val rollPair = defaultParseFn(rollString)
val rollPair = DiceRoller.defaultDiceStringParseFn(rollString)
nDice = rollPair.first
dieSize = rollPair.second
}

View File

@ -25,7 +25,7 @@ class RerollDiceImpl(
override val dieSize: Int
init {
val rollPair = this.defaultParseFn(rollString)
val rollPair = DiceRoller.defaultDiceStringParseFn(rollString)
nDice = rollPair.first
dieSize = rollPair.second
}