-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from TristonPlummer/master
Sync with upstream
- Loading branch information
Showing
22 changed files
with
332 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
package gg.rsmod.plugins.api.ext | ||
|
||
import gg.rsmod.game.model.World | ||
import java.text.DecimalFormat | ||
import java.text.Format | ||
import java.util.concurrent.ThreadLocalRandom | ||
|
||
/** | ||
* @author Tom <[email protected]> | ||
*/ | ||
|
||
private val RANDOM = ThreadLocalRandom.current() | ||
|
||
fun Number.appendToString(string: String): String = "$this $string" + (if (this != 1) "s" else "") | ||
|
||
fun Number.format(format: Format): String = format.format(this) | ||
|
@@ -21,8 +23,8 @@ fun String.parseAmount(): Long = when { | |
else -> substring(0, length).toLong() | ||
} | ||
|
||
fun interpolate(minChance: Int, maxChance: Int, minLvl: Int, maxLvl: Int, playerLvl: Int): Int = | ||
minChance + (maxChance - minChance) * (playerLvl - minLvl) / (maxLvl - minLvl) | ||
fun Int.interpolate(minChance: Int, maxChance: Int, minLvl: Int, maxLvl: Int): Int = | ||
minChance + (maxChance - minChance) * (this - minLvl) / (maxLvl - minLvl) | ||
|
||
fun World.interpolate(minChance: Int, maxChance: Int, minLvl: Int, maxLvl: Int, playerLvl: Int, cap: Int): Boolean = | ||
random(cap) <= interpolate(minChance, maxChance, minLvl, maxLvl, playerLvl) | ||
fun Int.interpolate(minChance: Int, maxChance: Int, minLvl: Int, maxLvl: Int, cap: Int): Boolean = | ||
RANDOM.nextInt(cap) <= interpolate(minChance, maxChance, minLvl, maxLvl) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.