package charge

import (
	"math"
	mergeDataCfg "server/conf/mergeData"
)

func GetChessDiamond(Lv, Type int) int {
	Diamond := 0.0
	if Type == 1 {
		Diamond = 0.27 * math.Exp(float64(Lv)*0.56)
	} else {
		Diamond = 2.64 * math.Pow(float64(Lv), 2.43)
	}
	d := int(Diamond)
	if d > 10 {
		r := d % 10
		if r > 3 {
			return d - r
		}
	}
	return max(1, d)
}

func getChessMainRand(Color string) []*Rand {
	r := make([]*Rand, 0)
	for i := 6; i <= 10; i++ {
		Diamond := int(math.Pow(2, float64(i-1)) / 2.5)
		ChessId := mergeDataCfg.GetChessIdByLvAndColor(i, Color)
		r = append(r, &Rand{ChessId: ChessId, Diamond: Diamond})
	}
	return r
}

func getChessSecondaryRand(Color string) []*Rand {
	r := make([]*Rand, 0)
	for i := 5; i <= 9; i++ {
		Diamond := int((math.Pow(2, float64(i-1)) / 2.5) * 2)
		ChessId := mergeDataCfg.GetChessIdByLvAndColor(i, Color)
		r = append(r, &Rand{ChessId: ChessId, Diamond: Diamond})
	}
	return r
}

func getChessSubRand(Color string) []*Rand {
	r := make([]*Rand, 0)
	for i := 5; i <= 9; i++ {
		Diamond := int(math.Pow(2, float64(i-1))/2.5 + 6.4)
		ChessId := mergeDataCfg.GetChessIdByLvAndColor(i, Color)
		r = append(r, &Rand{ChessId: ChessId, Diamond: Diamond})
	}
	return r
}
