Date: 2017/09/05 02:16:00 UTC-07:00
Type: Denizen Script
- case "claim":
- if <player.flag[rank]> == leader {
- define unclaimed true
- foreach <yaml[<player.flag[nation]>].list_keys[claimed_chunks]> {
- if <def[value]> == <player.location.chunk> {
- narrate "<&c>You can't claim a chunk that you already own!"
- define unclaimed false
}
- if <def[value].contains[<li@player.location.chunk.add[0,1]|player.location.chunk.add[0,-1]|player.location.chunk.add[1,0]|player.location.chunk.add[-1,0]>]> {
- narrate "<&c>Your claimed chunk must be adjacent to your currently claimed territory!"
- define unclaimed false
}
}
- foreach <li@ek|fn|wt|nat|eat|sat|wat|bht|bhs|sw|fst> {
- if <yaml[<def[value]>].list_keys[claimed_chunks].contains[<player.location.chunk>]||false> && <yaml[<def[value]>].read[power]||0> > <yaml[<player.flag[nation]>].read[power]||0> && !<yaml[<player.flag[nation]>].read[enemies].contains[<def[value]>]||false> {
- define unclaimed false
- narrate "<&c>This chunk has been claimed by <def[value]>. You may not claim it."
- break
}
}
- if <def[unclaimed]> {
- narrate "<&a>Chunk is unclaimed. Adding it to this nation's territory."
- yaml id:<player.flag[nation]> set claimed_chunks.<player.location.chunk>
- yaml "savefile:dNations/<player.flag[nation]>.yml" id:<player.flag[nation]>
}
}
else {
- narrate "<&c>Only nation leaders can claim land!"
}
- case "unclaim":
- if <yaml[<player.flag[nation]>].read[claimed_chunks].contains[<player.location.chunk>]> {
- yaml id:<player.flag[nation]> set claimed_chunks.<player.location.chunk>:!
}