Skip to content

Commit

Permalink
Add variable to diango codes
Browse files Browse the repository at this point in the history
  • Loading branch information
GregHib committed Aug 7, 2024
1 parent 1c02d1e commit bcf29ad
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion data/definitions/diango-codes.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
flagstaff_runefest:
flagstaff:
variable: flagstaff_runefest
add: [ flagstaff_of_festivities ]
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@ import world.gregs.voidps.engine.entity.item.Item

/**
* Codes to redeem holiday items from django
* @param variable the variable to unlock this item
* @param add the items added with this code
*/
data class DiangoCodeDefinition(
val variable: String = "",
val add: List<Item> = emptyList(),
) {

companion object {

@Suppress("UNCHECKED_CAST")
operator fun invoke(map: Map<String, Any>) = DiangoCodeDefinition(
variable = map["variable"] as? String ?: EMPTY.variable,
add = map["add"] as? List<Item> ?: EMPTY.add,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ npcOperate("Redeem-code", "diango") {
return@npcOperate
}
for (item in definition.add) {
if (player[code, false]) {
if (player[definition.variable, false]) {
player.message("You have already claimed this code.")
return@npcOperate
}
Expand All @@ -61,7 +61,7 @@ npcOperate("Redeem-code", "diango") {
}
}
if (success) {
player[code] = true
player[definition.variable] = true
player.message("Your code has been successfully processed.")
} else {
player.inventoryFull()
Expand Down

0 comments on commit bcf29ad

Please sign in to comment.