package gm_services

import (
	"gadmin/internal/admin/forms"
	"github.com/gin-gonic/gin"
)

// UpdatePlayAttr 更新经验、体力
func UpdatePlayAttr(ctx *gin.Context, params forms.UpdateRoleReq) (err error) {
	/*if params.UserId == 0 {
		return errNoUser
	}

	playerAttr, err := player.GetAttrByUserId(params.UserId)
	if err != nil {
		return
	}
	var userAccountModel model.UserAccount

	//获取userAccount
	err = config.LDB.WithContext(ctx).Scopes(model.UserAccountTable(&userAccountModel, playerAttr.AccID)).Where("accId = ?", playerAttr.AccID).First(&userAccountModel).Error
	if err != nil {
		return
	}
	openIdArr := strings.Split(userAccountModel.Openid, "@")

	if params.Exp > 0 || params.TalentPoint > 0 {
		msg := msg2.GmAddExp{
			MsgId:       character.GenerateMsgId(),
			PlayerID:    params.UserId,
			Exp:         int(params.Exp),
			TalentPoint: int(params.TalentPoint),
			OperatorId:  token.GetUID(ctx),
		}
		err = gate.SendToWorld(0, &msg)
		if err == nil {
			if params.Exp > 0 {
				rpc_share.MsgMap[msg.MsgId] = fmt.Sprintf("%s,GM为玩家[%d]添加经验[%d]", utility.FormatSecond(time.Now()), params.UserId, params.Exp)
			} else {
				rpc_share.MsgMap[msg.MsgId] = fmt.Sprintf("%s,GM为玩家[%d]添加天赋[%d]", utility.FormatSecond(time.Now()), params.UserId, params.TalentPoint)
			}
		}
	} else {
		msg := msg2.GmAddStama{
			MsgId:      character.GenerateMsgId(),
			PlayerID:   params.UserId,
			Stama:      int(params.Stamina),
			Energy:     int(params.Energy),
			OperatorId: token.GetUID(ctx),
			ClientPlat: openIdArr[1],
		}
		err = gate.SendToWorld(0, &msg)
		if err == nil {
			rpc_share.MsgMap[msg.MsgId] = fmt.Sprintf("%s,GM为玩家[%d]变更体力[%d],精力[%d]", utility.FormatSecond(time.Now()), params.UserId, params.Stamina, params.Energy)
		}
	}*/
	return
}
