package player

// AddCoins adds coins to the player
func (p *Player) AddCoins(val int64) {
	p.GetInfoStruct().AddCoin(val)
	p.sendCurrencyUpdate()
}

// RemoveCoins removes coins from the player
func (p *Player) RemoveCoins(val int64) bool {
	if p.GetInfoStruct().GetCoin() >= val {
		p.GetInfoStruct().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.GetInfoStruct().GetCoin() >= val
}

// GetCoinsCopper returns the copper coin amount
func (p *Player) GetCoinsCopper() int32 {
	return p.GetInfoStruct().GetCoinCopper()
}

// GetCoinsSilver returns the silver coin amount
func (p *Player) GetCoinsSilver() int32 {
	return p.GetInfoStruct().GetCoinSilver()
}

// GetCoinsGold returns the gold coin amount
func (p *Player) GetCoinsGold() int32 {
	return p.GetInfoStruct().GetCoinGold()
}

// GetCoinsPlat returns the platinum coin amount
func (p *Player) GetCoinsPlat() int32 {
	return p.GetInfoStruct().GetCoinPlat()
}

// GetBankCoinsCopper returns the bank copper coin amount
func (p *Player) GetBankCoinsCopper() int32 {
	return p.GetInfoStruct().GetBankCoinCopper()
}

// GetBankCoinsSilver returns the bank silver coin amount
func (p *Player) GetBankCoinsSilver() int32 {
	return p.GetInfoStruct().GetBankCoinSilver()
}

// GetBankCoinsGold returns the bank gold coin amount
func (p *Player) GetBankCoinsGold() int32 {
	return p.GetInfoStruct().GetBankCoinGold()
}

// GetBankCoinsPlat returns the bank platinum coin amount
func (p *Player) GetBankCoinsPlat() int32 {
	return p.GetInfoStruct().GetBankCoinPlat()
}

// GetStatusPoints returns the player's status points
func (p *Player) GetStatusPoints() int32 {
	return p.GetInfoStruct().GetStatusPoints()
}

// 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
	}
}
