血战积分奖励
parent
c7d61c098d
commit
a5a285f081
|
@ -0,0 +1,51 @@
|
|||
package com.ljsd.jieling.config;
|
||||
|
||||
import com.ljsd.jieling.logic.STableManager;
|
||||
import com.ljsd.jieling.logic.Table;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Table(name ="BloodyBattleTreasure")
|
||||
public class SBloodyBattleTreasure implements BaseConfig {
|
||||
|
||||
private int id;
|
||||
|
||||
private int seasonPass;
|
||||
|
||||
private int type;
|
||||
|
||||
private int[][] seasonReward;
|
||||
|
||||
private int[][] seasonTokenReward;
|
||||
|
||||
public static Map<Integer, SBloodyBattleTreasure> sBloodyBattleTreasureMap;
|
||||
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
sBloodyBattleTreasureMap = STableManager.getConfig(SBloodyBattleTreasure.class);
|
||||
}
|
||||
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getSeasonPass() {
|
||||
return seasonPass;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public int[][] getSeasonReward() {
|
||||
return seasonReward;
|
||||
}
|
||||
|
||||
public int[][] getSeasonTokenReward() {
|
||||
return seasonTokenReward;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -40,4 +40,5 @@ public class MongoKey {
|
|||
|
||||
public final static String guildMyInfo = "guildMyInfo";
|
||||
public final static String questionManager = "questionManager";
|
||||
public final static String bloodyInfo = "bloodyInfo";
|
||||
}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package com.ljsd.jieling.handler.bloody;
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.blood.BloodLogic;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class BloodyBuyScoreRewardHandler extends BaseHandler {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.BLOOD_BUY_SCORE_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
BloodLogic.getInstance().buyBloodyScore(iSession);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.ljsd.jieling.handler.bloody;
|
||||
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.blood.BloodLogic;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.protocols.RoomProto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class BloodyTakeScoreRewardHandler extends BaseHandler<RoomProto.BloodyTakeScoreRewardRequet> {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.BLOOD_TAKE_SCORE_REWARD_REQEUST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processWithProto(ISession iSession, RoomProto.BloodyTakeScoreRewardRequet proto) throws Exception {
|
||||
BloodLogic.getInstance().takeBloodyScoreReward(iSession,proto.getId());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.ljsd.jieling.handler.bloody;
|
||||
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.blood.BloodLogic;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class GetBloodyScoreInfoHandler extends BaseHandler {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.BLOOD_GETSCORE_INFO_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
BloodLogic.getInstance().getBloodySsoreInfo(iSession);
|
||||
}
|
||||
}
|
|
@ -190,10 +190,10 @@ public class GlobalDataManaager {
|
|||
break;
|
||||
case Endless:
|
||||
MapLogic.getInstance().resetEndlessInfo();
|
||||
BloodLogic.getInstance().bloodSeasonReward();
|
||||
break;
|
||||
case Blood:
|
||||
|
||||
BloodLogic.getInstance().bloodSeasonReward();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
package com.ljsd.jieling.logic.blood;
|
||||
|
||||
import com.ljsd.GameApplication;
|
||||
import com.ljsd.jieling.config.SBloodyBattleTreasure;
|
||||
import com.ljsd.jieling.config.SBloodyRankConfig;
|
||||
import com.ljsd.jieling.db.redis.RedisKey;
|
||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
import com.ljsd.jieling.globals.BIReason;
|
||||
import com.ljsd.jieling.ktbeans.KtEventUtils;
|
||||
import com.ljsd.jieling.ktbeans.parmsBean.ParamEventBean;
|
||||
import com.ljsd.jieling.logic.activity.ActivityType;
|
||||
import com.ljsd.jieling.logic.dao.*;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.family.GuildLogic;
|
||||
|
@ -16,6 +21,7 @@ import com.ljsd.jieling.network.session.ISession;
|
|||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.protocols.RoomProto;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import com.ljsd.jieling.util.StringUtil;
|
||||
import com.ljsd.jieling.util.TimeUtils;
|
||||
|
@ -169,4 +175,116 @@ public class BloodLogic {
|
|||
|
||||
}
|
||||
|
||||
//获取血战积分以及领取状态信息
|
||||
public void getBloodySsoreInfo(ISession session) throws Exception {
|
||||
int uid = session.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
BloodyInfo bloodyInfo = user.getBloodyInfo();
|
||||
bloodyInfo.setScore(99999);
|
||||
Map<Integer, SBloodyBattleTreasure> sBloodyBattleTreasureMap = SBloodyBattleTreasure.sBloodyBattleTreasureMap;
|
||||
RoomProto.GetBloodyScoreInfoResponse.Builder builder = RoomProto.GetBloodyScoreInfoResponse.newBuilder().setScore(bloodyInfo.getScore()).setHadBuy(bloodyInfo.getHadBuy());
|
||||
if(bloodyInfo.getStateInfo().isEmpty()){
|
||||
for(Integer id : sBloodyBattleTreasureMap.keySet()){
|
||||
bloodyInfo.updateStateInfo(id,0);
|
||||
}
|
||||
}
|
||||
|
||||
for(Map.Entry<Integer,Integer> entry : bloodyInfo.getStateInfo().entrySet()){
|
||||
Integer key = entry.getKey();
|
||||
Integer value = entry.getValue();
|
||||
builder.addBloodyScoreItemInfo(RoomProto.BloodyScoreItemInfo.newBuilder().setId(key).setStatus(value).build());
|
||||
}
|
||||
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.BLOOD_GETSCORE_INFO_RESPONSE_VALUE,builder.build(),true);
|
||||
}
|
||||
|
||||
//领取血战积分奖励
|
||||
public void takeBloodyScoreReward(ISession session,int id) throws Exception {
|
||||
int resId = MessageTypeProto.MessageType.BLOOD_TAKE_SCORE_REWARD_RESPONSE_VALUE;
|
||||
int uid = session.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
BloodyInfo bloodyInfo = user.getBloodyInfo();
|
||||
Map<Integer, Integer> stateInfo = bloodyInfo.getStateInfo();
|
||||
int changeState = 1;
|
||||
int hadBuy = bloodyInfo.getHadBuy();
|
||||
if (hadBuy == 1) {
|
||||
changeState = 2;
|
||||
}
|
||||
CommonProto.Drop.Builder drop=null;
|
||||
int score = bloodyInfo.getScore();
|
||||
List<Integer> changeInfo = new ArrayList<>();
|
||||
if(id == -1){
|
||||
List<int[][]> dropList = new ArrayList<>(10);
|
||||
for(Map.Entry<Integer,Integer> item : stateInfo.entrySet()){
|
||||
Integer misisonId = item.getKey();
|
||||
Integer status = item.getValue();
|
||||
SBloodyBattleTreasure sBloodyBattleTreasure = SBloodyBattleTreasure.sBloodyBattleTreasureMap.get(misisonId);
|
||||
if(changeState == status || score< sBloodyBattleTreasure.getSeasonPass()){
|
||||
continue;
|
||||
}
|
||||
if (status == 0) {
|
||||
dropList.add(sBloodyBattleTreasure.getSeasonReward());
|
||||
}
|
||||
if (changeState == 2) {
|
||||
dropList.add(sBloodyBattleTreasure.getSeasonTokenReward());
|
||||
}
|
||||
changeInfo.add(misisonId);
|
||||
}
|
||||
if(dropList.isEmpty()){
|
||||
MessageUtil.sendErrorResponse(session,0,resId,"没有奖励可以领取");
|
||||
return;
|
||||
}
|
||||
drop = ItemUtil.drop(user, dropList, BIReason.TAKE_ACTIVITY_REWARD);
|
||||
|
||||
}else{
|
||||
SBloodyBattleTreasure sBloodyBattleTreasure = SBloodyBattleTreasure.sBloodyBattleTreasureMap.get(id);
|
||||
if(sBloodyBattleTreasure == null){
|
||||
MessageUtil.sendErrorResponse(session,0,resId,"");
|
||||
return;
|
||||
}
|
||||
int seasonPass = sBloodyBattleTreasure.getSeasonPass();
|
||||
if(score < seasonPass){
|
||||
MessageUtil.sendErrorResponse(session,0,resId,"未达成条件");
|
||||
return;
|
||||
}
|
||||
Integer status = stateInfo.get(id);
|
||||
if(status == null){
|
||||
status =0;
|
||||
}
|
||||
if(changeState == status){
|
||||
MessageUtil.sendErrorResponse(session,0,resId,"已领取");
|
||||
return;
|
||||
}
|
||||
List<int[][]> dropList = new ArrayList<>(2);
|
||||
if (status == 0) {
|
||||
dropList.add(sBloodyBattleTreasure.getSeasonReward());
|
||||
}
|
||||
if (changeState == 2) {
|
||||
dropList.add(sBloodyBattleTreasure.getSeasonTokenReward());
|
||||
}
|
||||
changeInfo.add(id);
|
||||
drop = ItemUtil.drop(user, dropList, BIReason.TAKE_ACTIVITY_REWARD);
|
||||
bloodyInfo.updateStateInfo(id,changeState);
|
||||
}
|
||||
RoomProto.BloodyTakeScoreRewardResponse.Builder builder = RoomProto.BloodyTakeScoreRewardResponse.newBuilder().setDrop(drop);
|
||||
for(Integer chnageId : changeInfo){
|
||||
builder.addChangeItemInfo(RoomProto.BloodyScoreItemInfo.newBuilder().setId(chnageId).setStatus(stateInfo.get(chnageId)).build());
|
||||
}
|
||||
|
||||
MessageUtil.sendMessage(session,1,resId,builder.build(),true);
|
||||
}
|
||||
|
||||
public void buyBloodyScore(ISession session) throws Exception {
|
||||
int uid = session.getUid();
|
||||
int resId = MessageTypeProto.MessageType.BLOOD_BUY_SCORE_RESPONSE_VALUE;
|
||||
User user = UserManager.getUser(uid);
|
||||
BloodyInfo bloodyInfo = user.getBloodyInfo();
|
||||
int hadBuy = bloodyInfo.getHadBuy();
|
||||
if(hadBuy == 1){
|
||||
MessageUtil.sendErrorResponse(session,0,resId,"已购买");
|
||||
return;
|
||||
}
|
||||
bloodyInfo.setHadBuy(1);
|
||||
MessageUtil.sendMessage(session,1,resId,null,true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
package com.ljsd.jieling.logic.dao;
|
||||
|
||||
import com.ljsd.common.mogodb.MongoBase;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class BloodyInfo extends MongoBase {
|
||||
public static final String _COLLECTION_NAME = "bloodyInfo";
|
||||
|
||||
private int score;
|
||||
|
||||
private int hadBuy; //是否已购
|
||||
|
||||
private Map<Integer, Integer> stateInfo = new HashMap<>();
|
||||
|
||||
|
||||
public int getScore() {
|
||||
return score;
|
||||
}
|
||||
|
||||
public int getHadBuy() {
|
||||
return hadBuy;
|
||||
}
|
||||
|
||||
public Map<Integer, Integer> getStateInfo() {
|
||||
return stateInfo;
|
||||
}
|
||||
|
||||
public void setScore(int score) {
|
||||
updateString("score",score);
|
||||
this.score = score;
|
||||
}
|
||||
|
||||
public void setHadBuy(int hadBuy) {
|
||||
updateString("hadBuy",hadBuy);
|
||||
this.hadBuy = hadBuy;
|
||||
}
|
||||
|
||||
public void updateStateInfo(int missionId,int status){
|
||||
updateString("stateInfo." + missionId,status);
|
||||
this.stateInfo.put(missionId,status);
|
||||
}
|
||||
}
|
|
@ -91,7 +91,7 @@ public class GuilidManager {
|
|||
String key = RedisUtil.getInstence().getKey("guild-release", "");
|
||||
while (needContinue){
|
||||
Set<ZSetOperations.TypedTuple<String>> zsetreverseRangeWithScores = RedisUtil.getInstence().getZsetreverseRangeWithScores("guild-release", "", round*5, (round+1)*5);
|
||||
if(zsetreverseRangeWithScores.isEmpty()){
|
||||
if(zsetreverseRangeWithScores == null || zsetreverseRangeWithScores.isEmpty()){
|
||||
return;
|
||||
}
|
||||
for(ZSetOperations.TypedTuple<String> item : zsetreverseRangeWithScores){
|
||||
|
|
|
@ -50,6 +50,7 @@ public class User {
|
|||
private RoomInfo roomInfo;
|
||||
|
||||
private QuestionManager questionManager;
|
||||
private BloodyInfo bloodyInfo;
|
||||
|
||||
//构造函数必须要声明,否则从mongodb读出来反编译成类不通过
|
||||
public User(){
|
||||
|
@ -76,6 +77,7 @@ public class User {
|
|||
this.friendManager = new FriendManager();
|
||||
this.guildMyInfo = new GuildMyInfo();
|
||||
this.questionManager = new QuestionManager();
|
||||
this.bloodyInfo = new BloodyInfo();
|
||||
|
||||
//綁定关系
|
||||
|
||||
|
@ -98,6 +100,7 @@ public class User {
|
|||
this.friendManager.init(id,MongoKey.friendManager);
|
||||
this.guildMyInfo.init(id,MongoKey.guildMyInfo);
|
||||
this.questionManager.init(id,MongoKey.questionManager);
|
||||
this.bloodyInfo.init(id,MongoKey.bloodyInfo);
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
|
@ -226,4 +229,9 @@ public class User {
|
|||
}
|
||||
return questionManager;
|
||||
}
|
||||
|
||||
|
||||
public BloodyInfo getBloodyInfo() {
|
||||
return bloodyInfo;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue