package dailyTask

import (
	"math"
	"server/GoUtil"
	dailyTaskCfg "server/conf/dailyTask"
	"server/game/mod/item"
	"sort"
)

func getTaskReward(Id, AreaId int) []*item.Item {
	switch Id {
	case 1:
		return []*item.Item{{Id: item.ITEM_ENERGY_ID, Num: 5}}
	case 2:
		StarNum := int(50 * math.Pow(1.04, float64(AreaId)))
		return []*item.Item{{Id: item.ITEM_STAR_ID, Num: StarNum}}
	case 3:
		return []*item.Item{{Id: item.ITEM_ENERGY_ID, Num: 10}}
	}
	return []*item.Item{{Id: item.ITEM_ENERGY_ID, Num: 5}}
}

func randJackpot(jackpot map[int]dailyTaskCfg.Jackpot, num int) map[int][]*item.Item {
	Ids := GoUtil.GetMapKey(jackpot)
	r := make(map[int][]*item.Item)
	t := 0
	for {
		Ids1 := GoUtil.RandSliceNum(Ids, num)
		sort.Ints(Ids1)
		b := 0
		finish := true
		for _, k := range Ids1 {
			jack := jackpot[k]
			if b == jack.Is_card && b == 1 {
				finish = false
				break
			}
			b = jack.Is_card
		}

		if finish {
			for _, k := range Ids1 {
				r[k] = jackpot[k].Items
			}
			return r
		}
		t++
		if t > 100 {
			return r
		}
	}

}
