副本星级奖励
parent
8ad8890274
commit
4f5477e3c2
|
@ -0,0 +1,22 @@
|
|||
package com.ljsd.jieling.handler.map;
|
||||
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.MapInfoProto;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class FbStarRewardRequestHandler extends BaseHandler {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.FB_STAR_REWARD_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
MapLogic.getInstance().takeStarReward(iSession, MessageTypeProto.MessageType.FB_STAR_REWARD_RESPONSE);
|
||||
}
|
||||
}
|
|
@ -1583,6 +1583,9 @@ public class MapLogic {
|
|||
.build();
|
||||
builder.addMapInfos(mapInfo);
|
||||
}
|
||||
int starReward = user.getMapManager().getStarReward();
|
||||
SChallengeStarBox sChallengeStarBox = SChallengeStarBox.sChallengeStarBoxMap.get(starReward);
|
||||
builder.setStarNum(sChallengeStarBox.getStarNum());
|
||||
MessageUtil.sendMessage(iSession,1, msgId,builder.build(),true);
|
||||
}
|
||||
|
||||
|
@ -2095,29 +2098,37 @@ public class MapLogic {
|
|||
* @param session
|
||||
* @param messageType
|
||||
*/
|
||||
public void takeStarReward(ISession session, int id, MessageTypeProto.MessageType messageType) throws Exception {
|
||||
public void takeStarReward(ISession session, MessageTypeProto.MessageType messageType) throws Exception {
|
||||
int uid = session.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
MapManager mapManager = user.getMapManager();
|
||||
int id = mapManager.getStarReward()+1;
|
||||
SChallengeStarBox sChallengeStarBox = SChallengeStarBox.sChallengeStarBoxMap.get(id);
|
||||
|
||||
if (sChallengeStarBox == null) {
|
||||
LOGGER.info("takeStarReward uid=>{}, id=>{}", session.getUid(), id);
|
||||
MessageUtil.sendErrorResponse(session, 0, messageType.getNumber(), "");
|
||||
return;
|
||||
}
|
||||
int uid = session.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
MapManager mapManager = user.getMapManager();
|
||||
if (id <= mapManager.getStarReward()){
|
||||
LOGGER.info("takeStarReward uid=>{}, id=>{} mapManager.getStarReward()=>{}", session.getUid(), id, mapManager.getStarReward());
|
||||
MessageUtil.sendErrorResponse(session, 0, messageType.getNumber(), "");
|
||||
return;
|
||||
}
|
||||
|
||||
Map<Integer, CrossInfo> crossInfoMap = mapManager.getCrossInfoMap();
|
||||
int totalStar = 0;
|
||||
for (CrossInfo crossInfo : crossInfoMap.values()) {
|
||||
int star = crossInfo.getStars().size();
|
||||
totalStar += star;
|
||||
}
|
||||
if (totalStar <= sChallengeStarBox.getStarNum()){
|
||||
LOGGER.info("takeStarReward uid=>{}, id=>{}", session.getUid(), id);
|
||||
MessageUtil.sendErrorResponse(session, 0, messageType.getNumber(), "");
|
||||
return;
|
||||
}
|
||||
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, sChallengeStarBox.getReward(), 1);
|
||||
mapManager.setStarReward(id);
|
||||
MapInfoProto.FbStarRewardResponse.Builder FbStarRewardResponse = MapInfoProto.FbStarRewardResponse.newBuilder();
|
||||
FbStarRewardResponse.setFbStarReward(drop);
|
||||
|
||||
MessageUtil.sendMessage(session, 1, messageType.getNumber(), FbStarRewardResponse.build(), true);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue