Changed GE database uids to account database format

This commit is contained in:
Ryan 2022-09-03 08:47:53 +00:00
parent 2de2f9607d
commit 0ea1438a33
5 changed files with 13 additions and 16 deletions

View file

@ -534,7 +534,7 @@ class ScriptAPI(private val bot: Player) {
else -> Repository.sendNews(SERVER_GE_NAME + " just offered " + itemAmt + " " + ItemDefinition.forId(actualId).name.toLowerCase() + " on the GE.") else -> Repository.sendNews(SERVER_GE_NAME + " just offered " + itemAmt + " " + ItemDefinition.forId(actualId).name.toLowerCase() + " on the GE.")
} }
} }
bot.bank.remove(item).also { SystemLogger.logAI("$item has been listed on the GE.") } bot.bank.remove(item)
bot.bank.refresh() bot.bank.refresh()
} }
return true return true

View file

@ -231,9 +231,9 @@ class GrandExchange : StartupListener, Commands {
} }
if ( player.isArtificial ) if ( player.isArtificial )
offer.playerUID = PlayerDetails.getDetails("2009scape").usernameHashcode.also { offer.isBot = true } offer.playerUID = 0.also { offer.isBot = true }
else else
offer.playerUID = player.details.usernameHashcode offer.playerUID = player.details.accountInfo.uid
offer.offerState = OfferState.REGISTERED offer.offerState = OfferState.REGISTERED
//GrandExchangeRecords.getInstance(player).update(offer) //GrandExchangeRecords.getInstance(player).update(offer)
@ -315,10 +315,10 @@ class GrandExchange : StartupListener, Commands {
*/ */
seller.update() seller.update()
val sellerPlayer = Repository.uid_map[seller.playerUID] val sellerPlayer = Repository.players.firstOrNull { it.details.accountInfo.uid == seller.playerUID }
sellerPlayer?.let { GrandExchangeRecords.getInstance(sellerPlayer).visualizeRecords() } sellerPlayer?.let { GrandExchangeRecords.getInstance(sellerPlayer).visualizeRecords() }
buyer.update() buyer.update()
val buyerPlayer = Repository.uid_map[buyer.playerUID] val buyerPlayer = Repository.players.firstOrNull { it.details.accountInfo.uid == buyer.playerUID }
buyerPlayer?.let { GrandExchangeRecords.getInstance(buyerPlayer).visualizeRecords() } buyerPlayer?.let { GrandExchangeRecords.getInstance(buyerPlayer).visualizeRecords() }
} }

View file

@ -211,9 +211,7 @@ class GrandExchangeOffer() {
o.totalCoinExchange = result.getInt("total_coin_xc") o.totalCoinExchange = result.getInt("total_coin_xc")
o.playerUID = result.getInt("player_uid") o.playerUID = result.getInt("player_uid")
o.index = result.getInt("slot_index") o.index = result.getInt("slot_index")
o.player = Repository.players.firstOrNull { it.details.accountInfo.uid == o.playerUID }
if(Repository.uid_map[o.playerUID] != null)
o.player = Repository.uid_map[o.playerUID]
return o return o
} }

View file

@ -55,7 +55,7 @@ class GrandExchangeRecords(private val player: Player? = null) : PersistPlayer,
GEDB.run { conn -> GEDB.run { conn ->
val stmt = conn.createStatement() val stmt = conn.createStatement()
val offer_records = stmt.executeQuery("SELECT * from player_offers where player_uid = ${player.details.usernameHashcode} AND offer_state < 6") val offer_records = stmt.executeQuery("SELECT * from player_offers where player_uid = ${player.details.accountInfo.uid} AND offer_state < 6")
while (offer_records.next()) { while (offer_records.next()) {
val offer = GrandExchangeOffer.fromQuery(offer_records) val offer = GrandExchangeOffer.fromQuery(offer_records)
@ -101,7 +101,6 @@ class GrandExchangeRecords(private val player: Player? = null) : PersistPlayer,
historyEntry["totalCoinExchange"] = it.totalCoinExchange.toString() historyEntry["totalCoinExchange"] = it.totalCoinExchange.toString()
historyEntry["completedAmount"] = it.completedAmount.toString() historyEntry["completedAmount"] = it.completedAmount.toString()
history.add(historyEntry) history.add(historyEntry)
SystemLogger.logInfo("Adding history entry for ${it.itemID}")
} }
} }
save["ge-history"] = history save["ge-history"] = history

View file

@ -25,7 +25,7 @@ import kotlin.random.Random
fun generateOffer(itemId: Int, amount: Int, price: Int, sale: Boolean, username: String = "test ${System.currentTimeMillis()}") : GrandExchangeOffer { fun generateOffer(itemId: Int, amount: Int, price: Int, sale: Boolean, username: String = "test ${System.currentTimeMillis()}") : GrandExchangeOffer {
val offer = GrandExchangeOffer() val offer = GrandExchangeOffer()
val uid = username.hashCode() val uid = username.hashCode() // normally this would be the account's uid but in the test we don't have an account
offer.offerState = OfferState.REGISTERED offer.offerState = OfferState.REGISTERED
offer.itemID = itemId offer.itemID = itemId
offer.offeredValue = price offer.offeredValue = price