Implemented periodic Grand Exchange update notifications
This commit is contained in:
@@ -6,14 +6,11 @@ import core.cache.def.impl.ItemDefinition
|
|||||||
import core.game.node.entity.player.Player
|
import core.game.node.entity.player.Player
|
||||||
import core.game.node.entity.player.info.PlayerDetails
|
import core.game.node.entity.player.info.PlayerDetails
|
||||||
import core.game.system.command.Privilege
|
import core.game.system.command.Privilege
|
||||||
import core.game.system.config.ItemConfigParser
|
|
||||||
import core.game.system.task.Pulse
|
import core.game.system.task.Pulse
|
||||||
import core.game.world.GameWorld
|
import core.game.world.GameWorld
|
||||||
import core.game.world.repository.Repository
|
import core.game.world.repository.Repository
|
||||||
import core.tools.Log
|
import core.tools.Log
|
||||||
import core.tools.SystemLogger
|
import core.tools.SystemLogger
|
||||||
import core.tools.colorize
|
|
||||||
import org.rs09.consts.Sounds
|
|
||||||
import java.lang.Integer.max
|
import java.lang.Integer.max
|
||||||
import java.util.concurrent.LinkedBlockingDeque
|
import java.util.concurrent.LinkedBlockingDeque
|
||||||
|
|
||||||
@@ -266,9 +263,6 @@ class GrandExchange : StartupListener, Commands {
|
|||||||
seller.completedAmount += amount
|
seller.completedAmount += amount
|
||||||
buyer.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)
|
seller.addWithdrawItem(995, amount * if(sellerBias) buyer.offeredValue else seller.offeredValue)
|
||||||
buyer.addWithdrawItem(seller.itemID, amount)
|
buyer.addWithdrawItem(seller.itemID, amount)
|
||||||
|
|
||||||
@@ -298,12 +292,13 @@ class GrandExchange : StartupListener, Commands {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
seller.update()
|
for (entity in arrayOf(buyer, seller)) {
|
||||||
val sellerPlayer = Repository.uid_map[seller.playerUID]
|
entity.update()
|
||||||
sellerPlayer?.let { GrandExchangeRecords.getInstance(sellerPlayer).visualizeRecords() }
|
val player = Repository.uid_map[entity.playerUID] ?: continue
|
||||||
buyer.update()
|
val records = GrandExchangeRecords.getInstance(player)
|
||||||
val buyerPlayer = Repository.uid_map[buyer.playerUID]
|
records.visualizeRecords()
|
||||||
buyerPlayer?.let { GrandExchangeRecords.getInstance(buyerPlayer).visualizeRecords() }
|
records.updateNotification = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun canUpdatePriceIndex(seller: GrandExchangeOffer, buyer: GrandExchangeOffer): Boolean {
|
private fun canUpdatePriceIndex(seller: GrandExchangeOffer, buyer: GrandExchangeOffer): Boolean {
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import java.util.*
|
|||||||
class GrandExchangeRecords(private val player: Player? = null) : PersistPlayer, LoginListener {
|
class GrandExchangeRecords(private val player: Player? = null) : PersistPlayer, LoginListener {
|
||||||
var history = arrayOfNulls<GrandExchangeOffer>(5)
|
var history = arrayOfNulls<GrandExchangeOffer>(5)
|
||||||
val offerRecords = arrayOfNulls<OfferRecord>(6)
|
val offerRecords = arrayOfNulls<OfferRecord>(6)
|
||||||
|
var updateNotification = false
|
||||||
|
|
||||||
override fun login(player: Player) {
|
override fun login(player: Player) {
|
||||||
val instance = GrandExchangeRecords(player)
|
val instance = GrandExchangeRecords(player)
|
||||||
|
|||||||
@@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user