gms_exp_stamina.go 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package gm_services
  2. import (
  3. "gadmin/internal/admin/forms"
  4. "github.com/gin-gonic/gin"
  5. )
  6. // UpdatePlayAttr 更新经验、体力
  7. func UpdatePlayAttr(ctx *gin.Context, params forms.UpdateRoleReq) (err error) {
  8. /*if params.UserId == 0 {
  9. return errNoUser
  10. }
  11. playerAttr, err := player.GetAttrByUserId(params.UserId)
  12. if err != nil {
  13. return
  14. }
  15. var userAccountModel model.UserAccount
  16. //获取userAccount
  17. err = config.LDB.WithContext(ctx).Scopes(model.UserAccountTable(&userAccountModel, playerAttr.AccID)).Where("accId = ?", playerAttr.AccID).First(&userAccountModel).Error
  18. if err != nil {
  19. return
  20. }
  21. openIdArr := strings.Split(userAccountModel.Openid, "@")
  22. if params.Exp > 0 || params.TalentPoint > 0 {
  23. msg := msg2.GmAddExp{
  24. MsgId: character.GenerateMsgId(),
  25. PlayerID: params.UserId,
  26. Exp: int(params.Exp),
  27. TalentPoint: int(params.TalentPoint),
  28. OperatorId: token.GetUID(ctx),
  29. }
  30. err = gate.SendToWorld(0, &msg)
  31. if err == nil {
  32. if params.Exp > 0 {
  33. rpc_share.MsgMap[msg.MsgId] = fmt.Sprintf("%s,GM为玩家[%d]添加经验[%d]", utility.FormatSecond(time.Now()), params.UserId, params.Exp)
  34. } else {
  35. rpc_share.MsgMap[msg.MsgId] = fmt.Sprintf("%s,GM为玩家[%d]添加天赋[%d]", utility.FormatSecond(time.Now()), params.UserId, params.TalentPoint)
  36. }
  37. }
  38. } else {
  39. msg := msg2.GmAddStama{
  40. MsgId: character.GenerateMsgId(),
  41. PlayerID: params.UserId,
  42. Stama: int(params.Stamina),
  43. Energy: int(params.Energy),
  44. OperatorId: token.GetUID(ctx),
  45. ClientPlat: openIdArr[1],
  46. }
  47. err = gate.SendToWorld(0, &msg)
  48. if err == nil {
  49. rpc_share.MsgMap[msg.MsgId] = fmt.Sprintf("%s,GM为玩家[%d]变更体力[%d],精力[%d]", utility.FormatSecond(time.Now()), params.UserId, params.Stamina, params.Energy)
  50. }
  51. }*/
  52. return
  53. }