package gm_services

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

func UpdateElRank(ctx *gin.Context, params forms.UpdatePlayerElRankReq) (err error) {
	/*if params.ServerId <= 0 {
		err = errors.New("请选择一个有效的服务器")
		return
	}

	if params.MaxRoomCount == 0 {
		params.MaxRoomCount = params.RoomCount
	}

	DB, err := player.GetDBByServerID(params.ServerId)
	if err != nil {
		return
	}

	msg := msg2.GmUpdateElRank{
		MsgId:      character.GenerateMsgId(),
		PlayerID:   int64(params.PlayerId),
		RoomCount:  params.RoomCount,
		MaxCount:   params.MaxRoomCount,
		OperatorId: token.GetUID(ctx),
	}

	rpc_share.MsgMap[msg.MsgId] = fmt.Sprintf("%s,GM调整玩家[%d]的无尽排行房间数[%d],最大房间数[%d]",
		utility.FormatSecond(time.Now()),
		params.PlayerId,
		params.RoomCount,
		params.MaxRoomCount,
	)

	var resp *msg2.ResponseGmUpdateElRank
	res, err := config.GmNats.GmRequest(DB, "GmUpdateElRank", msg)
	if err != nil {
		return
	}

	if err = json.Unmarshal(res, &resp); err != nil {
		return
	}

	rpc_share.LogChan <- rpc_share.LogMsg{
		MsgID: msg.MsgId,
		Data:  resp,
	}

	//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.PlayerId,
	//		params.RoomCount,
	//		params.MaxRoomCount,
	//	)
	//}*/
	return
}
