80 lines
2.0 KiB
Go
80 lines
2.0 KiB
Go
package player
|
|
|
|
// AddCoins adds coins to the player
|
|
func (p *Player) AddCoins(val int64) {
|
|
p.AddCoin(val)
|
|
p.sendCurrencyUpdate()
|
|
}
|
|
|
|
// RemoveCoins removes coins from the player
|
|
func (p *Player) RemoveCoins(val int64) bool {
|
|
if p.GetCoin() >= val {
|
|
p.SubtractCoin(val)
|
|
p.sendCurrencyUpdate()
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
// HasCoins checks if the player has enough coins
|
|
func (p *Player) HasCoins(val int64) bool {
|
|
return p.GetCoin() >= val
|
|
}
|
|
|
|
// GetCoinsCopper returns the copper coin amount
|
|
func (p *Player) GetCoinsCopper() int32 {
|
|
return p.GetInfoStructCoinCopper()
|
|
}
|
|
|
|
// GetCoinsSilver returns the silver coin amount
|
|
func (p *Player) GetCoinsSilver() int32 {
|
|
return p.GetInfoStructCoinSilver()
|
|
}
|
|
|
|
// GetCoinsGold returns the gold coin amount
|
|
func (p *Player) GetCoinsGold() int32 {
|
|
return p.GetInfoStructCoinGold()
|
|
}
|
|
|
|
// GetCoinsPlat returns the platinum coin amount
|
|
func (p *Player) GetCoinsPlat() int32 {
|
|
return p.GetInfoStructCoinPlat()
|
|
}
|
|
|
|
// GetBankCoinsCopper returns the bank copper coin amount
|
|
func (p *Player) GetBankCoinsCopper() int32 {
|
|
return p.GetInfoStructBankCoinCopper()
|
|
}
|
|
|
|
// GetBankCoinsSilver returns the bank silver coin amount
|
|
func (p *Player) GetBankCoinsSilver() int32 {
|
|
return p.GetInfoStructBankCoinSilver()
|
|
}
|
|
|
|
// GetBankCoinsGold returns the bank gold coin amount
|
|
func (p *Player) GetBankCoinsGold() int32 {
|
|
return p.GetInfoStructBankCoinGold()
|
|
}
|
|
|
|
// GetBankCoinsPlat returns the bank platinum coin amount
|
|
func (p *Player) GetBankCoinsPlat() int32 {
|
|
return p.GetInfoStructBankCoinPlat()
|
|
}
|
|
|
|
// GetStatusPoints returns the player's status points
|
|
func (p *Player) GetStatusPoints() int32 {
|
|
return p.GetInfoStructStatusPoints()
|
|
}
|
|
|
|
// sendCurrencyUpdate sends currency update packet to client
|
|
func (p *Player) sendCurrencyUpdate() {
|
|
// TODO: When packet system is available, send currency update packet
|
|
// packet := CreateCurrencyUpdatePacket(p.GetInfoStruct())
|
|
// p.GetClient().SendPacket(packet)
|
|
|
|
// For now, mark that currency has changed
|
|
if p.GetInfoStruct() != nil {
|
|
// Currency update will be sent on next info struct update
|
|
}
|
|
}
|