十绝阵奖励随机提交
parent
bab6d9a004
commit
886474443e
|
@ -89,6 +89,7 @@ public interface GlobalsDef {
|
|||
int BLOODY_TEAM =701; //血战队伍
|
||||
int CHAMPION_ATTACK_TEAM =801; //
|
||||
int CAR_DELAY_TEAM =1101; //车迟斗法
|
||||
int DEATH_PATH_TEAM = 1201;//十绝阵
|
||||
|
||||
//特权解锁类型
|
||||
int LEVEL_UNLOCK_PRIVILEGE = 1;
|
||||
|
|
|
@ -33,6 +33,7 @@ import com.ljsd.jieling.util.MessageUtil;
|
|||
import config.SErrorCodeEerverConfig;
|
||||
import config.SGuildSetting;
|
||||
import config.SGuildWarConfig;
|
||||
import config.SGuildWarRewardConfig;
|
||||
import manager.STableManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -40,10 +41,7 @@ import org.springframework.data.redis.core.ZSetOperations;
|
|||
import util.StringUtil;
|
||||
import util.TimeUtils;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
|
||||
/**
|
||||
|
@ -204,7 +202,7 @@ public class DeathPathLogic {
|
|||
ZSetOperations.TypedTuple<String> next = iterator.next();
|
||||
int guildId = Integer.valueOf(next.getValue());
|
||||
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(guildId);
|
||||
Family.DeathPathInfo info = Family.DeathPathInfo.newBuilder().setGuildName(guildInfo.getName()).setPathId(i).build();
|
||||
Family.DeathPathInfo info = Family.DeathPathInfo.newBuilder().setGuildName(guildInfo.getName()).setPathId(i).setGid(guildId).build();
|
||||
response.addInfos(info);
|
||||
}
|
||||
MessageUtil.sendMessage(session,1,messageType.getNumber(),response.build(),true);
|
||||
|
@ -229,7 +227,7 @@ public class DeathPathLogic {
|
|||
User user = UserManager.getUser(uid);
|
||||
int guildId = user.getPlayerInfoManager().getGuildId();
|
||||
SGuildWarConfig config = STableManager.getConfig(SGuildWarConfig.class).get(pathId);
|
||||
PVEFightEvent pveFightEvent = new PVEFightEvent(user.getId(), GlobalsDef.FORMATION_NORMAL, 1000, "", GameFightType.DeathPathChallenge, config.getMonsterId(), 3);
|
||||
PVEFightEvent pveFightEvent = new PVEFightEvent(user.getId(), GlobalsDef.DEATH_PATH_TEAM, 1000, "", GameFightType.DeathPathChallenge, config.getMonsterId(), 3);
|
||||
FightResult fightResult = FightDispatcher.dispatcher(pveFightEvent);
|
||||
int damage = fightResult.getCheckResult()[1];
|
||||
CommonProto.FightData fightData = CommonProto.FightData.newBuilder()
|
||||
|
@ -366,7 +364,21 @@ public class DeathPathLogic {
|
|||
public void getDeathPathReward(ISession session,int position, MessageTypeProto.MessageType messageType) throws Exception {
|
||||
int uid = session.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
int[] reward = new int[]{4,10};
|
||||
TreeMap<Integer,SGuildWarRewardConfig> treeReward = (TreeMap<Integer,SGuildWarRewardConfig>)SGuildWarRewardConfig.treeReward;
|
||||
|
||||
Map.Entry<Integer, SGuildWarRewardConfig> entry = treeReward.floorEntry(5);
|
||||
|
||||
SGuildWarRewardConfig value = entry.getValue();
|
||||
int[][] rewardArray = value.getReward();
|
||||
double[] randomArray = new double[rewardArray.length];
|
||||
for(int i = 0;i< randomArray.length;i++){
|
||||
if(rewardArray[i].length<3){
|
||||
return;
|
||||
}
|
||||
randomArray[i] = rewardArray[i][2];
|
||||
}
|
||||
int[] reward= rewardArray[nextDiscrete(randomArray)];
|
||||
int[] realReward = new int[]{reward[0],reward[1]};
|
||||
int guildId = user.getPlayerInfoManager().getGuildId();
|
||||
DeathChallengeCount countInfo = RedisUtil.getInstence().get(RedisKey.DEATH_PAHT_TOTAL_CHALLENGE_COUNT, String.valueOf(guildId), DeathChallengeCount.class);
|
||||
if (countInfo==null||!countInfo.getUserReward().containsKey(uid)){
|
||||
|
@ -379,10 +391,10 @@ public class DeathPathLogic {
|
|||
}
|
||||
countInfo = new DeathChallengeCount();
|
||||
|
||||
countInfo.putUserReward(uid,new DeathReward(reward[0],reward[1],position,user.getPlayerInfoManager().getNickName()));
|
||||
countInfo.putUserReward(uid,new DeathReward(realReward[0],realReward[1],position,user.getPlayerInfoManager().getNickName()));
|
||||
RedisUtil.getInstence().set(RedisKey.DEATH_PAHT_TOTAL_CHALLENGE_COUNT, String.valueOf(guildId),countInfo);
|
||||
ItemUtil.drop(user,new int[][]{reward},BIReason.DEATH_PAHT_RANDOM_REWARD);
|
||||
Family.RewardInfo info = Family.RewardInfo.newBuilder().setUid(uid).setItemCount(reward[1]).setItemId(reward[0]).setPosition(position).build();
|
||||
ItemUtil.drop(user,new int[][]{realReward},BIReason.DEATH_PAHT_RANDOM_REWARD);
|
||||
Family.RewardInfo info = Family.RewardInfo.newBuilder().setUid(uid).setItemCount(realReward[1]).setItemId(realReward[0]).setPosition(position).build();
|
||||
|
||||
GuildLogic.sendIndicationToMember(GuilidManager.guildInfoMap.get(guildId), MessageTypeProto.MessageType.DEATH_PATH_DO_REWARD_INDICATION,info);
|
||||
MessageUtil.sendMessage(session,1,messageType.getNumber(),null,true);
|
||||
|
@ -433,4 +445,19 @@ public class DeathPathLogic {
|
|||
redisUtil.del(RedisKey.getKey(guildRank.getRedisKey(),"",false));
|
||||
redisUtil.del(RedisKey.getKey(personRank.getRedisKey(),"",false));
|
||||
}
|
||||
|
||||
public static int nextDiscrete(double[] probs) {
|
||||
double sum = 0.0;
|
||||
for (int i = 0; i < probs.length; i++)
|
||||
sum += probs[i];
|
||||
|
||||
double r = Math.random() * sum;
|
||||
sum = 0.0;
|
||||
for (int i = 0; i < probs.length; i++) {
|
||||
sum += probs[i];
|
||||
if (sum > r)
|
||||
return i;
|
||||
}
|
||||
return probs.length - 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ package com.ljsd.jieling.logic.family;
|
|||
* @discribe
|
||||
*/
|
||||
public class DeathReward {
|
||||
private String username;
|
||||
private String username="";
|
||||
private int itemId;
|
||||
private int itemCount ;
|
||||
private int position;
|
||||
|
|
|
@ -4,6 +4,7 @@ import manager.STableManager;
|
|||
import manager.Table;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
@Table(name ="GuildWarRewardConfig")
|
||||
public class SGuildWarRewardConfig implements BaseConfig {
|
||||
|
@ -14,10 +15,14 @@ public class SGuildWarRewardConfig implements BaseConfig {
|
|||
|
||||
private int[][] reward;
|
||||
|
||||
|
||||
public static Map<Integer,SGuildWarRewardConfig> treeReward = new TreeMap<>();
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
|
||||
Map<Integer, SGuildWarRewardConfig> config = STableManager.getConfig(SGuildWarRewardConfig.class);
|
||||
for(Map.Entry<Integer,SGuildWarRewardConfig> entry:config.entrySet()){
|
||||
treeReward.putIfAbsent(entry.getValue().getSection(),entry.getValue());
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue