Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package content.quest.free.gunnars_ground

import content.entity.player.dialogue.type.skillLamp
import content.entity.player.dialogue.type.statement
import world.gregs.voidps.engine.Script
import world.gregs.voidps.engine.entity.character.player.skill.exp.exp
import world.gregs.voidps.engine.inv.inventory
import world.gregs.voidps.engine.inv.remove

class AntiqueLamp : Script {

Check warning on line 10 in game/src/main/kotlin/content/quest/free/gunnars_ground/AntiqueLamp.kt

View workflow job for this annotation

GitHub Actions / qodana

Unused symbol

Class "AntiqueLamp" is never used

init {
itemOption("Rub", "antique_lamp_gunnars_ground") { (item, slot) ->
val skill = skillLamp()

if (this.levels.get(skill) < 5) {
statement("<red>This skill is not high enough to gain experience from this lamp.")

return@itemOption
}

if (inventory.remove(slot, item.id)) {
exp(skill, 200.0)
statement("<blue>Your wish has been granted!<br><black>You have been awarded 200 ${skill.name} experience!")
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package content.quest.free.gunnars_ground

import WorldTest
import interfaceOption
import itemOption
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import world.gregs.voidps.engine.entity.character.player.skill.Skill
import world.gregs.voidps.engine.inv.add
import world.gregs.voidps.engine.inv.inventory

class AntiqueLampTest : WorldTest() {

@Test
fun `rub antique lamp with skill over level 5`() {
val player = createPlayer()
val lampId = "antique_lamp_gunnars_ground"

player.inventory.add(lampId)
player.levels.set(Skill.Attack, 5)
player.levels.set(Skill.Defence, 4)
player.levels.set(Skill.Magic, 6)
val initialExperience = player.experience.get(Skill.Magic)

player.itemOption("Rub", lampId)
player.interfaceOption(
"skill_stat_advance",
"magic",
"Select",
optionIndex = 0,
)
player.interfaceOption("skill_stat_advance", "confirm", "Confirm")

assertEquals(0, player.inventory.count(lampId))
assertEquals(initialExperience + 200.0, player.experience.get(Skill.Magic))
}

@Test
fun `rub antique lamp with skill at level 5`() {
val player = createPlayer()
val lampId = "antique_lamp_gunnars_ground"

player.inventory.add(lampId)
player.levels.set(Skill.Attack, 5)
player.levels.set(Skill.Defence, 4)
player.levels.set(Skill.Magic, 6)
val initialExperience = player.experience.get(Skill.Attack)

player.itemOption("Rub", lampId)
player.interfaceOption(
"skill_stat_advance",
"attack",
"Select",
optionIndex = 0,
)
player.interfaceOption("skill_stat_advance", "confirm", "Confirm")

assertEquals(0, player.inventory.count(lampId))
assertEquals(initialExperience + 200.0, player.experience.get(Skill.Attack))
}

@Test
fun `rub antique lamp with skill below level 5`() {
val player = createPlayer()
val lampId = "antique_lamp_gunnars_ground"

player.inventory.add(lampId)
player.levels.set(Skill.Attack, 5)
player.levels.set(Skill.Defence, 4)
player.levels.set(Skill.Magic, 6)
val initialExperience = player.experience.get(Skill.Defence)

player.itemOption("Rub", lampId)
player.interfaceOption(
"skill_stat_advance",
"defence",
"Select",
optionIndex = 0,
)
player.interfaceOption("skill_stat_advance", "confirm", "Confirm")

assertEquals(1, player.inventory.count(lampId))
assertEquals(initialExperience, player.experience.get(Skill.Defence))
}
}