mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-14 10:30:20 -07:00
Fixed a bug with bogrog
This commit is contained in:
parent
df9c5a6f1b
commit
4e38a76b0b
1 changed files with 11 additions and 7 deletions
|
|
@ -9,6 +9,7 @@ import core.game.node.entity.skill.summoning.SummoningScroll
|
||||||
import core.game.node.item.Item
|
import core.game.node.item.Item
|
||||||
import core.game.world.map.zone.ZoneBorders
|
import core.game.world.map.zone.ZoneBorders
|
||||||
import kotlin.math.ceil
|
import kotlin.math.ceil
|
||||||
|
import kotlin.math.floor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles swapping pouches/scrolls for shards.
|
* Handles swapping pouches/scrolls for shards.
|
||||||
|
|
@ -49,21 +50,21 @@ object BogrogPouchSwapper {
|
||||||
private fun swap(player: Player, amount: Int, itemID: Int): Boolean{
|
private fun swap(player: Player, amount: Int, itemID: Int): Boolean{
|
||||||
var amt = amount
|
var amt = amount
|
||||||
val value = getValue(itemID)
|
val value = getValue(itemID)
|
||||||
if(value == 0){
|
if(value == 0.0){
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
val inInventory = player.inventory.getAmount(itemID)
|
val inInventory = player.inventory.getAmount(itemID)
|
||||||
if(amount > inInventory)
|
if(amount > inInventory)
|
||||||
amt = inInventory
|
amt = inInventory
|
||||||
player.inventory.remove(Item(itemID,amt))
|
player.inventory.remove(Item(itemID,amt))
|
||||||
player.inventory.add(Item(SPIRIT_SHARD,value * amt))
|
player.inventory.add(Item(SPIRIT_SHARD, floor(value * amt).toInt()))
|
||||||
player.interfaceManager.close(Component(644))
|
player.interfaceManager.close(Component(644))
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun sendValue(itemID: Int, player: Player): Boolean{
|
private fun sendValue(itemID: Int, player: Player): Boolean{
|
||||||
val value = getValue(itemID)
|
val value = getValue(itemID)
|
||||||
if(value == 0){
|
if(value == 0.0){
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -71,11 +72,14 @@ object BogrogPouchSwapper {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getValue(itemID: Int): Int{
|
private fun getValue(itemID: Int): Double{
|
||||||
var item = SummoningPouch.get(itemID)
|
var item = SummoningPouch.get(itemID)
|
||||||
|
var isScroll = false
|
||||||
if(item == null) item = SummoningPouch.get(Item(itemID).noteChange)
|
if(item == null) item = SummoningPouch.get(Item(itemID).noteChange)
|
||||||
if(item == null) item = SummoningPouch.get(SummoningScroll.forItemId(itemID)?.pouch ?: -1)
|
if(item == null) item = SummoningPouch.get(SummoningScroll.forItemId(itemID)?.pouch ?: -1).also { isScroll = true }
|
||||||
item ?: return 0
|
item ?: return 0.0
|
||||||
return ceil(item.items[item.items.size - 1].amount * 0.7).toInt()
|
var shardQuantity = item.items[item.items.size - 1].amount * 0.7
|
||||||
|
if(isScroll) shardQuantity /= 10.0
|
||||||
|
return shardQuantity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue