-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add the ability to make lanterns and lamps to
item-on-item.yml
* Add `LightSources` data class to handle when `lighting` and `extinguish` light sources * Add `LightSource.kts` to handle the logic when `lighting` and `extinguish` light sources * Add `Firemaking cape` and `Firemaking cape t` as accepted light sources for `Giant Mole`, including if the players are wearing these capes.
- Loading branch information
1 parent
9c4368f
commit fa240d5
Showing
6 changed files
with
225 additions
and
2 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
23 changes: 23 additions & 0 deletions
23
engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/data/LightSources.kt
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package world.gregs.voidps.engine.data.definition.data | ||
|
||
/** | ||
* @param onceLit the item that is given once the player lights a light source | ||
* @param onceExtinguish the item that is given once the player extinguishes the light source | ||
* @param level the firemaking level required to light the light source | ||
*/ | ||
data class LightSources( | ||
val onceLit: String = "", | ||
val onceExtinguish: String = "", | ||
val level: Int = -1 | ||
) { | ||
companion object { | ||
|
||
operator fun invoke(map: Map<String, Any>) = LightSources( | ||
onceLit = map["once_lit"] as? String ?: EMPTY.onceLit, | ||
onceExtinguish = map["once_extinguish"] as? String ?: EMPTY.onceExtinguish, | ||
level = map["level"] as? Int ?: EMPTY.level, | ||
) | ||
|
||
val EMPTY = LightSources() | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
game/src/main/kotlin/world/gregs/voidps/world/activity/skill/firemaking/LightSource.kts
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package world.gregs.voidps.world.activity.skill.firemaking | ||
|
||
import world.gregs.voidps.engine.client.message | ||
import world.gregs.voidps.engine.client.ui.interact.itemOnItem | ||
import world.gregs.voidps.engine.data.definition.data.LightSources | ||
import world.gregs.voidps.engine.entity.character.player.chat.ChatType | ||
import world.gregs.voidps.engine.entity.character.player.skill.Skill | ||
import world.gregs.voidps.engine.entity.character.player.skill.level.Level.has | ||
import world.gregs.voidps.engine.inv.inventory | ||
import world.gregs.voidps.engine.inv.transact.operation.ReplaceItem.replace | ||
import world.gregs.voidps.world.interact.entity.player.equip.inventoryItem | ||
|
||
|
||
itemOnItem("tinderbox*") { | ||
val needsFlame: LightSources = toItem.def.getOrNull("light_source") ?: return@itemOnItem | ||
|
||
if (!it.has(Skill.Firemaking, needsFlame.level, true)) { | ||
return@itemOnItem | ||
} | ||
|
||
it.inventory.transaction { | ||
replace(toItem.id, needsFlame.onceLit) | ||
} | ||
|
||
val litItem = determineLightSource(needsFlame.onceLit) | ||
it.message("You light the $litItem", ChatType.Game) | ||
|
||
} | ||
|
||
inventoryItem("Extinguish") { | ||
val toExtinguish: LightSources = item.def.getOrNull("light_source") ?: return@inventoryItem | ||
player.inventory.transaction { | ||
replace(item.id, toExtinguish.onceExtinguish) | ||
} | ||
|
||
player.message("You extinguish the flame.", ChatType.Game) | ||
} | ||
|
||
fun determineLightSource(itemName: String): String { | ||
return when { | ||
itemName.contains("lantern", ignoreCase = true) -> "lantern." | ||
itemName.contains("candle", ignoreCase = true) -> "candle." | ||
else -> "null" | ||
} | ||
} |
Oops, something went wrong.