package game

import (
	itemCfg "server/conf/item"
	playroomCfg "server/conf/playroom"
	"server/game/mod/item"
)

func (p *Player) PlayerDecoLog(Type string, Id int, Label string) {
	p.TeLog("playerdeco_income", map[string]interface{}{
		"playerdeco_type": Type,
		"playerdeco_id":   Id,
		"income_from":     Label,
	})
}

func (p *Player) PlayerDecoSetLog(Type string, Id int, Set string) {
	p.TeLog("playerdeco_set", map[string]interface{}{
		"playerdeco_type": Type,
		"playerdeco_id":   Id,
		"set_function":    Set,
	})
}

func (p *Player) PetItemGetLog(Item []*item.Item, Cost []*item.Item, Label string) {
	CostType := ""
	CostNum := 0
	if len(Cost) > 0 {
		switch Cost[0].Id {
		case item.ITEM_DIAMOND_ID:
			CostType = "diamond"
		case item.ITEM_STAR_ID:
			CostType = "star"
		case 0:
			CostType = "ad"
		default:
			CostType = "unknown"
		}
		CostNum = -Cost[0].Num
	}
	for _, v := range Item {
		Type := itemCfg.GetItemType(v.Id)
		if Type == item.ITEM_TYPE_PLAYROOM_PET {
			Name, _ := itemCfg.GetItemName(v.Id)
			Effect := itemCfg.GetItemEffect(v.Id)
			p.PetItemGetLog_(Effect, Name, Label, CostType, CostNum)
		}
	}
}

func (p *Player) PetItemGetLog_(Type int, Name string, Label string, CostType string, CostNum int) {
	p.TeLog("pet_item_get", map[string]interface{}{
		"pet_item_type":      Type,
		"pet_item_name":      Name,
		"pet_item_get_type":  Label,
		"pet_item_cost_type": CostType,
		"pet_item_cost":      CostNum,
	})
}

func (p *Player) PetItemUseLog(Item []*item.Item) {
	for _, v := range Item {
		Type := itemCfg.GetItemType(v.Id)
		if Type == item.ITEM_TYPE_PLAYROOM_PET && v.Num < 0 {
			Name, _ := itemCfg.GetItemName(v.Id)
			Effect := itemCfg.GetItemEffect(v.Id)
			p.TeLog("pet_item_use", map[string]interface{}{
				"pet_item_type": Effect,
				"pet_item_name": Name,
			})
		}
	}
}

func (p *Player) RoomDecoSetLog(Diff map[int]int) {
	for _, v := range Diff {
		Type, Name := playroomCfg.GetDecoInfo(v)
		p.TeLog("room_deco_set", map[string]interface{}{
			"room_deco_type": Type,
			"room_deco_name": Name,
		})
	}
}

func (p *Player) PetDecoSetLog(Diff map[int]int) {
	for _, v := range Diff {
		Type := playroomCfg.GetDressPart(v)
		Name := playroomCfg.GetDressName(v)
		p.TeLog("pet_deco_set", map[string]interface{}{
			"pet_deco_type": Type,
			"pet_deco_name": Name,
		})
	}
}
