package guide

import (
	"fmt"
	guidecfg "server/conf/guide"
	"server/game/mod/item"
	GoUtil "server/game_util"
	"server/msg"
)

type Guide struct {
	Guide         int
	GuideOrder    bool
	Reward        map[int]int
	PlayroomGuide bool // playroom引导奖励
}

func (g *Guide) InitData() {
	g.Reward = make(map[int]int)
	if g.Reward == nil {
		g.Reward = make(map[int]int)
	}
}

func (g *Guide) GetReward(Id int) ([]*item.Item, error) {
	Items, Num := guidecfg.GetGuideReward(Id)
	n := g.Reward[Id]
	if n >= Num {
		return nil, fmt.Errorf("Guide GetReward Id:%v has been received", Id)
	}
	g.Reward[Id]++
	return Items, nil
}

func (g *Guide) BackData() *msg.ResGuideInfo {
	return &msg.ResGuideInfo{
		Reward: GoUtil.MapIntToInt32(g.Reward),
	}
}

func (g *Guide) GetGuide() int {
	return g.Guide
}

func (g *Guide) SetGuide(guide int) {
	g.Guide = guide
}

func (g *Guide) GetGuideOrder() bool {
	return g.GuideOrder
}

func (g *Guide) SetGuideOrder(guideOrder bool) {
	g.GuideOrder = guideOrder
}

func (g *Guide) GetPlayroomGuide() bool {
	return g.PlayroomGuide
}

func (g *Guide) SetPlayroomGuide(playroomGuide bool) {
	g.PlayroomGuide = playroomGuide
}
