|
@@ -0,0 +1,44 @@
|
|
|
+package com.incubator.game.handler.http;
|
|
|
+
|
|
|
+import com.incubator.common.MessageHandler;
|
|
|
+import com.incubator.core.net.http.HttpHandler;
|
|
|
+import com.incubator.core.net.http.HttpRequest;
|
|
|
+import com.incubator.core.net.http.HttpResponse;
|
|
|
+import com.incubator.game.player.Player;
|
|
|
+import com.incubator.game.util.PlayerUtil;
|
|
|
+import com.incubator.game.util.ProtoUtil;
|
|
|
+import com.incubator.message.proto.CommonProto;
|
|
|
+
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Author: xhb
|
|
|
+ * Date: 2025-01-07 16:47
|
|
|
+ */
|
|
|
+@MessageHandler(httpPath = "/updatePlayer")
|
|
|
+public class UpdatePlayer extends HttpHandler {
|
|
|
+ /**
|
|
|
+ * 修改个人信息数据
|
|
|
+ **/
|
|
|
+ @Override
|
|
|
+ public HttpResponse onDate(HttpRequest request, Map<String, String> params) throws Exception {
|
|
|
+ HttpResponse httpResponse = new HttpResponse();
|
|
|
+ String userId = params.get("userId");
|
|
|
+ long gold = Long.parseLong(params.get("gold"));
|
|
|
+ long diamond = Long.parseLong(params.get("diamond"));
|
|
|
+ long foca = Long.parseLong(params.get("foca"));
|
|
|
+ Player player = (Player) PlayerUtil.getOnlinePlayer(userId);
|
|
|
+ player.data.foca = foca;
|
|
|
+ player.data.gold = gold;
|
|
|
+ player.data.diamond = diamond;
|
|
|
+ // 正常返回
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("playerInfo", ProtoUtil.playerInfoToMessage(player));
|
|
|
+ player.receive(CommonProto.Cmd.PersonalDataChanges_VALUE, map);
|
|
|
+ httpResponse.setCode(200);
|
|
|
+ httpResponse.setMessage("成功!");
|
|
|
+ return httpResponse;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|