Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GregHib committed Dec 22, 2024
1 parent 74e853e commit 4cdc657
Showing 1 changed file with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package world.gregs.voidps.world.activity.skill.thieving

import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test
import world.gregs.voidps.FakeRandom
import world.gregs.voidps.engine.entity.character.player.skill.Skill
import world.gregs.voidps.engine.inv.add
import world.gregs.voidps.engine.inv.inventory
import world.gregs.voidps.type.setRandom
import world.gregs.voidps.world.interact.entity.effect.stunned
import world.gregs.voidps.world.script.WorldTest
import world.gregs.voidps.world.script.npcOption
import kotlin.random.Random
import kotlin.test.assertEquals
import kotlin.test.assertFalse

internal class PickpocketTest : WorldTest() {

@Test
fun `Successfully pickpocket`() {
setRandom(object : FakeRandom() {
override fun nextInt(until: Int) = 0
})
val player = createPlayer("thief", emptyTile)
val man = createNPC("man", emptyTile.addY(1))

player.npcOption(man, "Pickpocket")
tick(4)

assertEquals(player.inventory.count("coins"), 3)
assertEquals(player.experience.get(Skill.Thieving), 8.0)
assertFalse(player.stunned)
}

@Test
fun `Fail to pickpocket`() {
setRandom(object : FakeRandom() {
override fun nextInt(until: Int) = until
})
val player = createPlayer("thief", emptyTile)
val man = createNPC("man", emptyTile.addY(1))

player.npcOption(man, "Pickpocket")
tick(4)

assertEquals(player.inventory.count("coins"), 0)
assertEquals(player.experience.get(Skill.Thieving), 0.0)
assertTrue(player.stunned)
}

}

0 comments on commit 4cdc657

Please sign in to comment.