Implemented periodic Grand Exchange update notifications

This commit is contained in:
Player Name 2025-11-27 11:48:23 +00:00 committed by Ryan
parent 3d5cbd90ed
commit 82e5965220
3 changed files with 32 additions and 12 deletions

View file

@ -6,14 +6,11 @@ import core.cache.def.impl.ItemDefinition
import core.game.node.entity.player.Player
import core.game.node.entity.player.info.PlayerDetails
import core.game.system.command.Privilege
import core.game.system.config.ItemConfigParser
import core.game.system.task.Pulse
import core.game.world.GameWorld
import core.game.world.repository.Repository
import core.tools.Log
import core.tools.SystemLogger
import core.tools.colorize
import org.rs09.consts.Sounds
import java.lang.Integer.max
import java.util.concurrent.LinkedBlockingDeque
@ -266,9 +263,6 @@ class GrandExchange : StartupListener, Commands {
seller.completedAmount += amount
buyer.completedAmount += amount
if(seller.amountLeft < 1 && seller.player != null)
playAudio(seller.player!!, Sounds.GE_COLLECT_COINS_4042)
seller.addWithdrawItem(995, amount * if(sellerBias) buyer.offeredValue else seller.offeredValue)
buyer.addWithdrawItem(seller.itemID, amount)
@ -298,12 +292,13 @@ class GrandExchange : StartupListener, Commands {
}
*/
seller.update()
val sellerPlayer = Repository.uid_map[seller.playerUID]
sellerPlayer?.let { GrandExchangeRecords.getInstance(sellerPlayer).visualizeRecords() }
buyer.update()
val buyerPlayer = Repository.uid_map[buyer.playerUID]
buyerPlayer?.let { GrandExchangeRecords.getInstance(buyerPlayer).visualizeRecords() }
for (entity in arrayOf(buyer, seller)) {
entity.update()
val player = Repository.uid_map[entity.playerUID] ?: continue
val records = GrandExchangeRecords.getInstance(player)
records.visualizeRecords()
records.updateNotification = true
}
}
private fun canUpdatePriceIndex(seller: GrandExchangeOffer, buyer: GrandExchangeOffer): Boolean {

View file

@ -22,6 +22,7 @@ import java.util.*
class GrandExchangeRecords(private val player: Player? = null) : PersistPlayer, LoginListener {
var history = arrayOfNulls<GrandExchangeOffer>(5)
val offerRecords = arrayOfNulls<OfferRecord>(6)
var updateNotification = false
override fun login(player: Player) {
val instance = GrandExchangeRecords(player)

View file

@ -0,0 +1,24 @@
package core.game.ge
import core.api.hasAwaitingGrandExchangeCollections
import core.api.playJingle
import core.api.sendMessage
import core.game.node.entity.Entity
import core.game.node.entity.player.Player
import core.game.system.timer.RSTimer
class GrandExchangeTimer : RSTimer(500, "GE periodic poll", isSoft = true, isAuto = true) {
override fun run(entity: Entity) : Boolean {
if (entity !is Player) return false
val player = entity
val records = GrandExchangeRecords.getInstance(player)
if (records.updateNotification) {
records.updateNotification = false
if (hasAwaitingGrandExchangeCollections(player)) {
sendMessage(player, "One or more of your Grand Exchange offers have been updated.")
playJingle(player, 284)
}
}
return true
}
}