11package content.entity.combat
22
3+ import FakeRandom
4+ import WorldTest
5+ import content.entity.combat.hit.npcCombatDamage
6+ import content.entity.player.effect.skull
7+ import equipItem
8+ import interfaceOption
39import kotlinx.coroutines.test.runTest
10+ import npcOption
411import org.junit.jupiter.api.Assertions.*
512import org.junit.jupiter.api.BeforeEach
613import org.junit.jupiter.api.Test
7- import FakeRandom
8- import WorldTest
14+ import playerOption
915import world.gregs.voidps.engine.entity.character.player.appearance
1016import world.gregs.voidps.engine.entity.character.player.skill.Skill
1117import world.gregs.voidps.engine.entity.character.player.skill.level.Levels
@@ -16,18 +22,14 @@ import world.gregs.voidps.network.client.instruction.InteractPlayer
1622import world.gregs.voidps.network.login.protocol.visual.update.player.EquipSlot
1723import world.gregs.voidps.type.Tile
1824import world.gregs.voidps.type.setRandom
19- import content.entity.combat.hit.npcCombatDamage
20- import equipItem
21- import interfaceOption
22- import npcOption
23- import playerOption
24- import kotlin.random.Random
2525
2626internal class CombatTest : WorldTest () {
2727
2828 @BeforeEach
2929 fun setup () {
30- setRandom(Random )
30+ setRandom(object : FakeRandom () {
31+ override fun nextInt (until : Int ) = until
32+ })
3133 }
3234
3335 @Test
@@ -178,33 +180,34 @@ internal class CombatTest : WorldTest() {
178180
179181 @Test
180182 fun `Kill player with melee` () {
181- val player = createPlayer(" player" , emptyTile)
182- val target = createPlayer(" target" , emptyTile.addY(4 ))
183+ val startTile = Tile (3143 , 3553 )
184+ val targetTile = startTile.addX(3 )
185+ val player = createPlayer(" player" , startTile)
186+ val target = createPlayer(" target" , targetTile)
183187
184188 player.equipment.set(EquipSlot .Weapon .index, " dragon_longsword" )
185189 player.experience.set(Skill .Attack , EXPERIENCE )
186190 player.experience.set(Skill .Strength , EXPERIENCE )
187191 player.experience.set(Skill .Defence , EXPERIENCE )
188192 player.levels.boost(Skill .Attack , 25 )
189193 player.levels.boost(Skill .Strength , 25 )
190- player[" in_wilderness" ] = true
191- target[" in_wilderness" ] = true
192194 target.appearance.combatLevel = 90
193195 target.inventory.add(" dragon_longsword" , 1 )
194196 target.inventory.add(" magic_shortbow" , 1 )
195197 target.inventory.add(" rune_arrow" , 10 )
196- target.inventory.add(" excalibur" , 1 )
198+ target.inventory.add(" plague_jacket" , 1 )
199+ target.skull()
197200
198201 player.interfaceOption(" combat_styles" , " style3" )
199202 player.playerOption(target, " Attack" )
200203 tickIf { target.levels.get(Skill .Constitution ) > 0 }
201204 tick(6 ) // player death
202205
203- assertNotEquals(emptyTile , player.tile)
206+ assertNotEquals(startTile , player.tile)
204207 assertTrue(player.experience.get(Skill .Attack ) > EXPERIENCE )
205208 assertTrue(player.experience.get(Skill .Strength ) > EXPERIENCE )
206209 assertTrue(player.experience.get(Skill .Defence ) > EXPERIENCE )
207- val items = floorItems[emptyTile.addY( 4 ) ]
210+ val items = floorItems[targetTile ]
208211 assertTrue(items.any { it.id == " coins" })
209212 assertTrue(items.any { it.id == " rune_arrow" && it.amount > 1 })
210213 assertTrue(items.any { it.id == " bones" })
0 commit comments