Merge branch 'master' of http://60.1.1.230/backend/jieling_server
commit
f8662be876
|
@ -16,6 +16,10 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class GetPlayerInfoHandler extends BaseHandler{
|
||||
|
||||
|
@ -50,12 +54,21 @@ public class GetPlayerInfoHandler extends BaseHandler{
|
|||
|
||||
|
||||
|
||||
}
|
||||
Map<Integer, Integer> guidePoints = user.getPlayerInfoManager().getGuidePoints();
|
||||
List<CommonProto.NewPlayerGuidePoint> list = new ArrayList<>();
|
||||
for(Map.Entry<Integer,Integer> guideItem : guidePoints.entrySet()){
|
||||
list.add(CommonProto.NewPlayerGuidePoint.newBuilder()
|
||||
.setType(guideItem.getKey())
|
||||
. setId(guideItem.getValue())
|
||||
.build());
|
||||
}
|
||||
MailLogic.getInstance().delUserMail(userId);
|
||||
CommonProto.Player player = CBean2Proto.getPlayer(userId, user.getPlayerInfoManager(), user.getPlayerInfoManager().getMapId(), user.getMapManager().getCurMapId(),user.getMapManager());
|
||||
PlayerInfoProto.GetPlayerInfoResponse getPlayerInfoResponse
|
||||
= PlayerInfoProto.GetPlayerInfoResponse.newBuilder()
|
||||
.setPlayer(player)
|
||||
.addAllNewPlayerGuidePoint(list)
|
||||
.build();
|
||||
try {
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.GET_PLAYERINFO_RESPONSE_VALUE, getPlayerInfoResponse, true);
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
package com.ljsd.jieling.handler;
|
||||
|
||||
import com.ljsd.jieling.logic.player.PlayerLogic;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.protocols.PlayerInfoProto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class SaveNewPlayerPointHandler extends BaseHandler{
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.SAVE_NEW_PLAYER_GUIDE_POINT_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
byte[] bytes = netData.parseClientProtoNetData();
|
||||
PlayerInfoProto.SaveNewPlayerPointRequest saveNewPlayerPointRequest = PlayerInfoProto.SaveNewPlayerPointRequest.parseFrom(bytes);
|
||||
int id = saveNewPlayerPointRequest.getNewPlayerGuidePoint().getId();
|
||||
int type = saveNewPlayerPointRequest.getNewPlayerGuidePoint().getType();
|
||||
PlayerLogic.getInstance().saveNewPlayerPoint(iSession,type,id);
|
||||
}
|
||||
}
|
|
@ -8,6 +8,9 @@ import com.ljsd.jieling.db.mongo.MongoKey;
|
|||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.util.MathUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class PlayerManager extends MongoBase {
|
||||
|
||||
private String openId;
|
||||
|
@ -36,6 +39,8 @@ public class PlayerManager extends MongoBase {
|
|||
|
||||
private String clientVersion;
|
||||
|
||||
private Map<Integer,Integer> guidePoints = new HashMap<>();
|
||||
|
||||
public PlayerManager(){
|
||||
this.setRootCollection(User._COLLECTION_NAME);
|
||||
}
|
||||
|
@ -156,4 +161,14 @@ public class PlayerManager extends MongoBase {
|
|||
this.clientVersion = clientVersion;
|
||||
}
|
||||
|
||||
public Map<Integer, Integer> getGuidePoints() {
|
||||
return guidePoints;
|
||||
}
|
||||
|
||||
public void updateGuidePoint(int type,int id){
|
||||
updateString("guidePoints."+type, id);
|
||||
guidePoints.put(type,id);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.ljsd.jieling.logic.dao.root.User;
|
|||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import com.ljsd.jieling.util.TimeUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
|
@ -76,6 +77,7 @@ public class UserManager {
|
|||
playerManager.setGold(100000l);
|
||||
playerManager.setGem(9999);
|
||||
playerManager.setChargeGem(666);
|
||||
playerManager.updateGuidePoint(1,1);
|
||||
playerManager.setCreateTime(TimeUtils.now());
|
||||
SGameSetting gameSetting = SGameSetting.getGameSetting();
|
||||
ItemUtil.drop(user,gameSetting.getBornItem());
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
package com.ljsd.jieling.logic.player;
|
||||
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
|
||||
public class PlayerLogic {
|
||||
|
||||
private PlayerLogic(){}
|
||||
|
||||
public static PlayerLogic getInstance(){
|
||||
return InnerClass.instance;
|
||||
}
|
||||
|
||||
static class InnerClass{
|
||||
public final static PlayerLogic instance = new PlayerLogic();
|
||||
}
|
||||
|
||||
public void saveNewPlayerPoint(ISession session,int type,int id) throws Exception {
|
||||
int uid = session.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
user.getPlayerInfoManager().updateGuidePoint(type,id);
|
||||
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.SAVE_NEW_PLAYER_GUIDE_POINT_RESPONSE_VALUE,null,true);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue