秘盒 & 英雄修改

back_recharge
wangyuan 2019-05-11 17:26:02 +08:00
parent ec99e122cd
commit 16294cfe15
17 changed files with 439 additions and 54 deletions

View File

@ -43,6 +43,10 @@ public class SCHero implements BaseConfig{
private int[][] openSkillRules;
private int[][] secondaryFactor;
private Map<Integer,Integer> secondaryFactorMap;
private Map<Integer, List<Integer>> skillListByStar;
private Map<Integer, Map<Integer,SCHero.ConsumeMaterialInfo>> consumeMaterialInfoOfPositionByStar;
@ -79,6 +83,17 @@ public class SCHero implements BaseConfig{
Map<Integer, SCHero> integerSCHeroMap = STableManager.getConfig(SCHero.class);
for(SCHero scHero : integerSCHeroMap.values()){
int[][] secondaryFactor = scHero.getSecondaryFactor();
if(secondaryFactor!=null && secondaryFactor.length>0){
Map<Integer,Integer> secondaryFactorMapTmp = new HashMap<>(secondaryFactor.length);
for(int[] secondaryFactorItem : secondaryFactor){
int property = secondaryFactorItem[0];
int propertyValue = secondaryFactorItem[1];
secondaryFactorMapTmp.put(property,propertyValue);
scHero.setSecondaryFactorMap(secondaryFactorMapTmp);
}
}
Map<Integer, Map<Integer,SCHero.ConsumeMaterialInfo>> consumeMaterialInfoByStarTmp = new HashMap<>();
int[][] openSkillRules = scHero.getOpenSkillRules();
Map<Integer, List<Integer>> skillListByStarTmp = new HashMap<>();
@ -192,4 +207,16 @@ public class SCHero implements BaseConfig{
public Map<Integer, List<Integer>> getSkillListByStar() {
return skillListByStar;
}
public int[][] getSecondaryFactor() {
return secondaryFactor;
}
public Map<Integer, Integer> getSecondaryFactorMap() {
return secondaryFactorMap;
}
public void setSecondaryFactorMap(Map<Integer, Integer> secondaryFactorMap) {
this.secondaryFactorMap = secondaryFactorMap;
}
}

View File

@ -3,6 +3,9 @@ package com.ljsd.jieling.config;
import com.ljsd.jieling.logic.STableManager;
import com.ljsd.jieling.logic.Table;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Table(name ="DifferDemonsBoxPools")
@ -16,14 +19,28 @@ public class SDifferDemonsBoxPools implements BaseConfig {
private int weight;
private static Map<Integer, List<SDifferDemonsBoxPools>> sDifferDemonsBoxPoolByPoolMap;
@Override
public void init() throws Exception {
Map<Integer, List<SDifferDemonsBoxPools>> sDifferDemonsBoxPoolByPoolMapTmp = new HashMap<>();
Map<Integer, SDifferDemonsBoxPools> config = STableManager.getConfig(SDifferDemonsBoxPools.class);
for(SDifferDemonsBoxPools sDifferDemonsBoxPool : config.values()){
int pool = sDifferDemonsBoxPool.getPool();
if(!sDifferDemonsBoxPoolByPoolMapTmp.containsKey(pool)){
sDifferDemonsBoxPoolByPoolMapTmp.put(pool,new ArrayList<>());
}
sDifferDemonsBoxPoolByPoolMapTmp.get(pool).add(sDifferDemonsBoxPool);
}
sDifferDemonsBoxPoolByPoolMap = sDifferDemonsBoxPoolByPoolMapTmp;
}
public static List<SDifferDemonsBoxPools> getsDifferDemonsBoxPoolByPoolId(int poolId) {
return sDifferDemonsBoxPoolByPoolMap.get(poolId);
}
public int getId() {
public int getId() {
return id;
}

View File

@ -3,6 +3,9 @@ package com.ljsd.jieling.config;
import com.ljsd.jieling.logic.STableManager;
import com.ljsd.jieling.logic.Table;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Table(name ="DifferDemonsBoxSeaons")
@ -16,14 +19,28 @@ public class SDifferDemonsBoxSeaons implements BaseConfig {
private int seasons;
@Override
private static Map<Integer, List<SDifferDemonsBoxSeaons>> sDifferDemonsBoxSeaonsBySeasonMap;
@Override
public void init() throws Exception {
Map<Integer, List<SDifferDemonsBoxSeaons>> sDifferDemonsBoxSeaonsBySeasonMapTmp = new HashMap<>();
Map<Integer, SDifferDemonsBoxSeaons> config = STableManager.getConfig(SDifferDemonsBoxSeaons.class);
for(SDifferDemonsBoxSeaons sDifferDemonsBoxSeaons:config.values()){
int seasons = sDifferDemonsBoxSeaons.getSeasons();
if(!sDifferDemonsBoxSeaonsBySeasonMapTmp.containsKey(seasons)){
sDifferDemonsBoxSeaonsBySeasonMapTmp.put(seasons,new ArrayList<>());
}
sDifferDemonsBoxSeaonsBySeasonMapTmp.get(seasons).add(sDifferDemonsBoxSeaons);
}
sDifferDemonsBoxSeaonsBySeasonMap = sDifferDemonsBoxSeaonsBySeasonMapTmp;
}
public static List<SDifferDemonsBoxSeaons> getsDifferDemonsBoxSeaonsBySeason(int seasons) {
return sDifferDemonsBoxSeaonsBySeasonMap.get(seasons);
}
public int getId() {
public int getId() {
return id;
}

View File

@ -10,7 +10,7 @@ public class SDifferDemonsBoxSetting implements BaseConfig {
private int id;
private int[] mainCost;
private int[][] mainCost;
private int secondaryCost;
@ -19,8 +19,6 @@ public class SDifferDemonsBoxSetting implements BaseConfig {
private int freeTime;
private int freeInterval;
private int[] extraItem;
private int seasonTimes;
@ -35,18 +33,23 @@ public class SDifferDemonsBoxSetting implements BaseConfig {
private int maxNum;
@Override
private static Map<Integer, SDifferDemonsBoxSetting> config;
@Override
public void init() throws Exception {
config = STableManager.getConfig(SDifferDemonsBoxSetting.class);
}
public static Map<Integer, SDifferDemonsBoxSetting> getConfig() {
return config;
}
public int getId() {
public int getId() {
return id;
}
public int[] getMainCost() {
public int[][] getMainCost() {
return mainCost;
}
@ -63,10 +66,6 @@ public class SDifferDemonsBoxSetting implements BaseConfig {
return freeTime;
}
public int getFreeInterval() {
return freeInterval;
}
public int[] getExtraItem() {
return extraItem;
}

View File

@ -30,4 +30,5 @@ public class MongoKey {
public final static String arenaManager = "arenaManager";
public final static String secretBoxManager = "secretBoxManager";
}

View File

@ -695,6 +695,31 @@ public class RedisUtil {
}
}
//操作sortset
public Set<ZSetOperations.TypedTuple<String>> getZsetRangeWithScore(String key, double min, double max){
for (int i = 0; i < MAX_TRY_TIMES; i++) {
try {
return redisTemplate.opsForZSet().rangeByScoreWithScores(key,min,max);
} catch (Exception e) {
TimeUtils.sleep(FAILED_SLEEP);
}
}
return null;
}
//操作sortset
public Set<String> getZsetRange(String key, double min, double max){
for (int i = 0; i < MAX_TRY_TIMES; i++) {
try {
return redisTemplate.opsForZSet().rangeByScore(key,min,max);
} catch (Exception e) {
TimeUtils.sleep(FAILED_SLEEP);
}
}
return null;
}
//操作sortset
public int getZsetSize(String key){
try {

View File

@ -0,0 +1,22 @@
package com.ljsd.jieling.handler.arena;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.arena.ArenaLogic;
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 ArenaRandomHandler extends BaseHandler {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.ARENA_RANDOM_ENEMY_REQUEST;
}
@Override
public void process(ISession iSession, PacketNetData netData) throws Exception {
ArenaLogic.getInstance().randomEnemys(iSession);
}
}

View File

@ -0,0 +1,21 @@
package com.ljsd.jieling.handler.secretBox;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.activity.ActivityLogic;
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 GetSecretBoxInfoHandler extends BaseHandler {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.GET_SECRETBOX_REQUEST;
}
@Override
public void process(ISession iSession, PacketNetData netData) throws Exception {
ActivityLogic.getInstance().getSecretBox(iSession);
}
}

View File

@ -0,0 +1,24 @@
package com.ljsd.jieling.handler.secretBox;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.activity.ActivityLogic;
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 SecretBoxRandomHandler extends BaseHandler {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.SECRETBOX_RANDOM_REQUEST;
}
@Override
public void process(ISession iSession, PacketNetData netData) throws Exception {
byte[] bytes = netData.parseClientProtoNetData();
int typeId = PlayerInfoProto.SecretBoxRandomRequest.parseFrom(bytes).getTypeId();
ActivityLogic.getInstance().randomSecretBox(iSession,typeId);
}
}

View File

@ -1,7 +1,6 @@
package com.ljsd.jieling.logic.activity;
import com.ljsd.jieling.config.SActivityRewardConfig;
import com.ljsd.jieling.config.SGlobalActivity;
import com.ljsd.jieling.config.*;
import com.ljsd.jieling.globals.Global;
import com.ljsd.jieling.logic.dao.*;
import com.ljsd.jieling.logic.dao.root.User;
@ -10,6 +9,7 @@ import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.protocols.MessageTypeProto;
import com.ljsd.jieling.protocols.PlayerInfoProto;
import com.ljsd.jieling.util.ItemUtil;
import com.ljsd.jieling.util.MathUtils;
import com.ljsd.jieling.util.MessageUtil;
import com.ljsd.jieling.util.TimeUtils;
import org.slf4j.Logger;
@ -269,4 +269,104 @@ public class ActivityLogic {
}
return defalutProgress;
}
//秘盒
public void getSecretBox(ISession session) throws Exception {
int uid = session.getUid();
User user = UserManager.getUser(uid);
SecretBoxManager secretBoxManager = user.getSecretBoxManager();
if(secretBoxManager.getCurSeason() == 0){
secretBoxManager.setCount(0);
secretBoxManager.setCurSeason(1);
Map<Integer,Integer> freeUseMap = new HashMap<>(2);
freeUseMap.put(1,1);
freeUseMap.put(2,0);
secretBoxManager.setFreeUseInfos(freeUseMap);
}
List<PlayerInfoProto.SecretBoxFreeUseInfo> secretBoxFreeUseInfoList = new ArrayList<>(2);
Map<Integer, Integer> freeUseInfos = secretBoxManager.getFreeUseInfos();
for(Map.Entry<Integer,Integer> item : freeUseInfos.entrySet()){
secretBoxFreeUseInfoList.add(PlayerInfoProto.SecretBoxFreeUseInfo.newBuilder().setId(item.getKey()).setTimes(item.getValue()).build());
}
PlayerInfoProto.GetSecretBoxInfoResponse build = PlayerInfoProto.GetSecretBoxInfoResponse.newBuilder()
.setSeason(secretBoxManager.getCurSeason())
.setCount(secretBoxManager.getCount())
.addAllSecretBoxFreeUseInfo(secretBoxFreeUseInfoList)
.build();
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.GET_SECRETBOX_RESPONSE_VALUE,build,true);
}
public void randomSecretBox(ISession session,int id) throws Exception {
int uid = session.getUid();
User user = UserManager.getUser(uid);
SecretBoxManager secretBoxManager = user.getSecretBoxManager();
SDifferDemonsBoxSetting sDifferDemonsBoxSetting = SDifferDemonsBoxSetting.getConfig().get(id);
if(sDifferDemonsBoxSetting == null){
return;
}
int freeTime = sDifferDemonsBoxSetting.getFreeTime();
Map<Integer, Integer> freeUseInfos = secretBoxManager.getFreeUseInfos();
if(freeTime>freeUseInfos.get(id)){
freeUseInfos.put(id,freeUseInfos.get(id) + 1);
secretBoxManager.setFreeUseInfos(freeUseInfos);
}else{
int[][] mainCost = sDifferDemonsBoxSetting.getMainCost();
boolean enough = ItemUtil.itemCost(user, mainCost);
if(!enough){
MessageUtil.sendErrorResponse(session,0,MessageTypeProto.MessageType.SECRETBOX_RANDOM_RESPONSE_VALUE,"道具不足");
return;
}
}
int randCount = sDifferDemonsBoxSetting.getSecondaryCost();
int count = secretBoxManager.getCount();
int[][] randDrop = new int[randCount][];
for(int i=0;i<randCount;i++){
int secretBoxRandomPool = getSecretBoxRandomPool(sDifferDemonsBoxSetting, count + i);
int[] dropInfos = getSecretBoxRewardByPool(secretBoxRandomPool);
randDrop[i] = dropInfos;
}
secretBoxManager.setCount(secretBoxManager.getCount()+randCount);
CommonProto.Drop.Builder drop = ItemUtil.drop(user, randDrop);
int[] extraItem = sDifferDemonsBoxSetting.getExtraItem();
CommonProto.Drop.Builder extraDrop = ItemUtil.drop(user, new int[][]{extraItem});
PlayerInfoProto.SecretBoxRandomResponse build = PlayerInfoProto.SecretBoxRandomResponse.newBuilder().setDrop(drop).setExtrarReward(extraDrop).build();
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.SECRETBOX_RANDOM_RESPONSE_VALUE,build,true);
}
private int[] getSecretBoxRewardByPool(int secretBoxRandomPool) {
List<SDifferDemonsBoxPools> sDifferDemonsBoxPoolsList = SDifferDemonsBoxPools.getsDifferDemonsBoxPoolByPoolId(secretBoxRandomPool);
int totalWeight =0;
for(SDifferDemonsBoxPools sDifferDemonsBoxPool : sDifferDemonsBoxPoolsList){
totalWeight+=sDifferDemonsBoxPool.getWeight();
}
int randomWeight = MathUtils.randomInt(totalWeight) +1;
for(SDifferDemonsBoxPools sDifferDemonsBoxPool : sDifferDemonsBoxPoolsList){
randomWeight -=sDifferDemonsBoxPool.getWeight();
if(randomWeight<0){
return sDifferDemonsBoxPool.getReward();
}
}
return null;
}
private int getSecretBoxRandomPool(SDifferDemonsBoxSetting sDifferDemonsBoxSetting, int count) {
int seasonTimes = sDifferDemonsBoxSetting.getSeasonTimes();
int poolId = 0;
List<SDifferDemonsBoxSeaons> sDifferDemonsBoxSeaonList = SDifferDemonsBoxSeaons.getsDifferDemonsBoxSeaonsBySeason(seasonTimes);
for(SDifferDemonsBoxSeaons sDifferDemonsBoxSeaons :sDifferDemonsBoxSeaonList){
int surelyTimes = sDifferDemonsBoxSeaons.getSurelyTimes();
if(count%surelyTimes != 0){
continue;
}
if(count/surelyTimes == 0){
poolId = sDifferDemonsBoxSeaons.getSurelyPools();
}
}
if(poolId == 0){
poolId = sDifferDemonsBoxSetting.getRandomPool();
}
return poolId;
}
}

View File

@ -43,13 +43,13 @@ public class ArenaLogic {
User user = UserManager.getUser(uid);
int level = user.getPlayerInfoManager().getLevel();
ArenaManager arenaManager = user.getArenaManager();
List<ArenaEnemy> arenaEnemies = arenaManager.getArenaEnemies();
if(arenaEnemies == null || arenaEnemies.isEmpty()){
arenaEnemies = new ArrayList<>();
if(arenaManager.getFlushNums() == 0){
List<ArenaEnemy> arenaEnemies = new ArrayList<>();
Set<Integer> robotIds = randomRobot(level, 5);
toArenaEnemy(uid,robotIds,arenaEnemies,0);
toArenaEnemy(uid,robotIds,arenaEnemies,GlobalsDef.ARENA_ROBOT_TYPE);
arenaManager.setArenaEnemies(arenaEnemies);
}
int score = RedisUtil.getInstence().getZSetScore("Arena_Rank_1", Integer.toString(uid)).intValue();
if(score == -1){
score = 1000;
@ -75,13 +75,16 @@ public class ArenaLogic {
int enemyType = arenaEnemy.getEnemyType();
if(enemyType == 0){ //机器人
SArenaRobotConfig sArenaRobotConfig = SArenaRobotConfig.getsArenaRobotConfigById(enemyId);
CommonProto.Team teamBuild = CommonProto.Team.newBuilder().addAllHeroTid(sArenaRobotConfig.getHeroList()).setTotalForce(2000).build();
arenaEnemyList.add(CommonProto.ArenaEnemy.newBuilder()
CommonProto.Team teamBuild = CommonProto.Team.newBuilder().addAllHeroTid(sArenaRobotConfig.getHeroList()).build();
CommonProto.ArenaPersonInfo personInfoBuild = CommonProto.ArenaPersonInfo.newBuilder()
.setUid(enemyId)
.setLevel(sArenaRobotConfig.getRobotLevel())
.setName(sArenaRobotConfig.getRobotName())
.setScore(defaultScore)
.setTotalForce(sArenaRobotConfig.getTotalForce())
.build();
arenaEnemyList.add(CommonProto.ArenaEnemy.newBuilder()
.setPersonInfo(personInfoBuild)
.setTeam(teamBuild)
.build());
}
@ -106,8 +109,8 @@ public class ArenaLogic {
return;
}
int fightResult=0;
int myscore = 1000;
int defScore =1000;
int myscore = SArenaSetting.getSArenaSetting().getScore();
int defScore = SArenaSetting.getSArenaSetting().getScore();
int enemyType = enemyInfo.getEnemyType();
int myscoreChange=0;
int defScoreChange=0;
@ -116,11 +119,7 @@ public class ArenaLogic {
myscore = RedisUtil.getInstence().getZSetScore("Arena_Rank_1", Integer.toString(challengeUid)).intValue();
}
arenaEnemies = new ArrayList<>();
Set<Integer> robotIds = randomRobot(user.getPlayerInfoManager().getLevel(), 5);
toArenaEnemy(uid,robotIds,arenaEnemies,0);
arenaManager.setArenaEnemies(arenaEnemies);
setMyArenaEnemys(uid,user);
RedisUtil.getInstence().incrementZsetScore("Arena_Rank_1",Integer.toString(uid),myscoreChange);
if( enemyType == GlobalsDef.ARENA_PLAYER_TYPE){
User defUser = UserManager.getUser(challengeUid);
@ -145,6 +144,19 @@ public class ArenaLogic {
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.ARENA_CHALLENGE_RESPONSE_VALUE,build,true);
}
public void setMyArenaEnemys(int uid,User user){
ArenaManager arenaManager = user.getArenaManager();
List<ArenaEnemy> arenaEnemies = new ArrayList<>();
if(arenaManager.getFlushNums()<SArenaSetting.getSArenaSetting().getPveNum()){
Set<Integer> robotIds = randomRobot(user.getPlayerInfoManager().getLevel(), 5);
toArenaEnemy(uid,robotIds,arenaEnemies,GlobalsDef.ARENA_ROBOT_TYPE);
}else{
Set<Integer> robotIds = randomPerson(user.getPlayerInfoManager().getLevel());
toArenaEnemy(uid,robotIds,arenaEnemies,GlobalsDef.ARENA_PLAYER_TYPE);
}
arenaManager.setArenaEnemies(arenaEnemies);
}
@ -153,12 +165,21 @@ public class ArenaLogic {
CommonProto.FightTeamInfo deffightTeamInfo = BehaviorUtil.getFightTeamInfo(defUser,defTeamId);
//设置战斗随机种子
int seed = (int)(System.currentTimeMillis()/1000);
byte[] snapRecord = CommonProto.FightData.newBuilder()
.setFightMaxTime(SArenaSetting.getSArenaSetting().getMostTime())
.setFightSeed(seed)
.setHeroFightInfos(fightTeamInfo)
.addMonsterList(deffightTeamInfo)
.build().toByteArray();
//defUser.getArenaManager().addArenRecoed();
LuaValue getFightData = FightDataUtil.getFinalPlayerFightData(fightTeamInfo, deffightTeamInfo);
LuaValue getOptionData = FightDataUtil.getOptionData("");
int[] checkResult = CheckFight.getInstance().checkFight(seed,SArenaSetting.getSArenaSetting().getMostTime(), getFightData, getOptionData);
return checkResult[0];
}
public int getFightResultByPersonToRobot(User mine,int myteamId,SArenaRobotConfig sArenaRobotConfig){
CommonProto.FightTeamInfo fightTeamInfo = BehaviorUtil.getFightTeamInfo(mine,myteamId);
CommonProto.FightTeamInfo deffightTeamInfo = BehaviorUtil.getRobotFightTeamInfo(sArenaRobotConfig);
@ -213,7 +234,9 @@ public class ArenaLogic {
return;
}
//刷新选手
setMyArenaEnemys(uid,user);
ArenaInfoProto.ArenaRandomResponse build = ArenaInfoProto.ArenaRandomResponse.newBuilder().addAllArenaEnemys(getArenaEnemyList(arenaManager.getArenaEnemies())).build();
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.ARENA_RANDOM_ENEMY_RESPONSE_VALUE,build,true);
}
public Set<Integer> randomRobot(int userLevel,int nums){
@ -239,59 +262,99 @@ public class ArenaLogic {
int[][] interval = SArenaSetting.getSArenaSetting().getInterval();
for(int[] item: interval){
int high = item[0];
int low = item[1];
Set<String> arenaRank = RedisUtil.getInstence().getZsetRange("Arena_Rank_1", myScore * low / 100.0f, myScore * high / 100.0f);
if(arenaRank!=null && !arenaRank.isEmpty()){
String s = randomSet(arenaRank);
if(!StringUtil.isEmpty(s)){
result.add(Integer.parseInt(s));
}
}
}
return result;
}
private String randomSet(Set<String> infos){
int num = MathUtils.randomInt(infos.size());
for(String id : infos){
if(num-- == 0){
return id;
}
}
return null;
}
private void toArenaEnemy(int uid,Set<Integer> enemyList,List<ArenaEnemy> arenaEnemies,int type){
for(Integer enemyId: enemyList){
if(1 == type && enemyId == uid){
continue;
}
arenaEnemies.add(new ArenaEnemy(enemyId,type,0));
arenaEnemies.add(new ArenaEnemy(enemyId,type,type));
}
}
public void getWorldRankByPage(ISession session,int page) throws Exception {
int num =20;
if(page>1){
num = 10;
}
if (page == 0) {
page = 1;
}
page = 1;
int start = (page - 1) * 20, end = page * 20 - 1;
List<CommonProto.ArenaEnemy> arenaRankMemberInfo = new ArrayList<>(20);
CommonProto.ArenaEnemy build =null;
Set<ZSetOperations.TypedTuple<String>> arenaRankInfo = RedisUtil.getInstence().getZsetreverseRangeWithScores("Arena_Rank_1", start, end);
for(ZSetOperations.TypedTuple<String> item : arenaRankInfo){
String value = item.getValue();
int score =item.getScore().intValue();
int uid = Integer.parseInt(value);
User user = UserManager.getUser(uid);
int totalForce = HeroLogic.getInstance().calTeamTotalForce(user, 200);
int totalForce = HeroLogic.getInstance().calTeamTotalForce(user, 101);
List<TeamPosHeroInfo> teamPosHeroInfoList = user.getTeamPosManager().getTeamPosForHero().get(101);
Map<String, Hero> heroMap = user.getHeroManager().getHeroMap();
List<Integer> heroTids = new ArrayList<>(teamPosHeroInfoList.size());
for(TeamPosHeroInfo teamPosHeroInfo:teamPosHeroInfoList){
heroTids.add(heroMap.get(teamPosHeroInfo.getHeroId()).getTemplateId());
}
CommonProto.Team teamBuild = CommonProto.Team.newBuilder().addAllHeroTid(heroTids).build();
PlayerManager playerInfoManager = user.getPlayerInfoManager();
arenaRankMemberInfo.add(CommonProto.ArenaEnemy.newBuilder().setUid(uid)
CommonProto.ArenaPersonInfo personInfoBuild = CommonProto.ArenaPersonInfo.newBuilder()
.setUid(uid)
.setLevel(playerInfoManager.getLevel())
.setName(playerInfoManager.getNickName())
.setScore(score)
.setHead(0)
.setRank(++start)
.setTotalForce(totalForce)
.build());
.build();
build = CommonProto.ArenaEnemy.newBuilder()
.setPersonInfo(personInfoBuild)
.setTeam(teamBuild)
.build();
}
for(int i=0;i<num;i++){
arenaRankMemberInfo.add(build);
}
int uid = session.getUid();
int score = RedisUtil.getInstence().getZSetScore("Arena_Rank_1", Integer.toString(uid)).intValue();
int myRank =-1;
if(score == -1){
score = 1000;
score = SArenaSetting.getSArenaSetting().getScore();
}else{
myRank= RedisUtil.getInstence().getZSetreverseRank("Arena_Rank_1", Integer.toString(uid)).intValue()+1;
}
ArenaInfoProto.GetArenaRankInfoResponse build = ArenaInfoProto.GetArenaRankInfoResponse.newBuilder()
ArenaInfoProto.GetArenaRankInfoResponse buildResponse = ArenaInfoProto.GetArenaRankInfoResponse.newBuilder()
.addAllRankInfos(arenaRankMemberInfo)
.setMyRank(myRank)
.setMyscore(score)
.build();
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.ARENA_RANK_RESPONSE_VALUE,build,true);
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.ARENA_RANK_RESPONSE_VALUE,buildResponse,true);
}

View File

@ -22,8 +22,13 @@ public class ArenaManager extends MongoBase {
private int flushTime; //刷新时间
private int flushNums; //刷新次数
private List<ArenaEnemy> arenaEnemies;
private List<ArenaRecord> arenaRecordList;
public void updateChallenge(int fightResult){
if(fightResult == 1){
successNums ++;
@ -38,7 +43,7 @@ public class ArenaManager extends MongoBase {
public void addArenRecoed(){
public void addArenRecoed(ArenaRecord arenaRecord){
}
@ -76,7 +81,9 @@ public class ArenaManager extends MongoBase {
}
public void setArenaEnemies(List<ArenaEnemy> arenaEnemies) {
flushNums++;
updateString("arenaEnemies",arenaEnemies);
updateString("flushNums",flushNums);
this.arenaEnemies = arenaEnemies;
}
@ -85,6 +92,7 @@ public class ArenaManager extends MongoBase {
this.useFreeTimes = useFreeTimes;
}
public int getFlushNums() {
return flushNums;
}
}

View File

@ -1,20 +1,27 @@
package com.ljsd.jieling.logic.dao;
import com.ljsd.common.mogodb.MongoBase;
public class ArenaRecord extends MongoBase {
public class ArenaRecord {
private int id;
private int attackId; //进攻者
private int defScore; //防守获得分数 正:代表胜利 负:代表失败
private long createTime;
private int attackForce; //战力
private byte[] fightData;
private int createTime;
public ArenaRecord(){}
public ArenaRecord(int attackId, int defScore) {
public ArenaRecord(int attackId, int defScore,byte[] fightData) {
this.attackId = attackId;
this.defScore = defScore;
this.createTime = System.currentTimeMillis();
this.fightData = fightData;
this.createTime = (int)(System.currentTimeMillis()/1000);
}
}

View File

@ -0,0 +1,40 @@
package com.ljsd.jieling.logic.dao;
import com.ljsd.common.mogodb.MongoBase;
import java.util.HashMap;
import java.util.Map;
public class SecretBoxManager extends MongoBase {
private int curSeason;
private int count;
private Map<Integer,Integer> freeUseInfos = new HashMap<>(2);
public void setCurSeason(int curSeason) {
updateString("curSeason",curSeason);
this.curSeason = curSeason;
}
public void setCount(int count) {
updateString("count",count);
this.count = count;
}
public void setFreeUseInfos(Map<Integer, Integer> freeUseInfos) {
updateString("freeUseInfos",freeUseInfos);
this.freeUseInfos = freeUseInfos;
}
public int getCurSeason() {
return curSeason;
}
public int getCount() {
return count;
}
public Map<Integer, Integer> getFreeUseInfos() {
return freeUseInfos;
}
}

View File

@ -38,6 +38,8 @@ public class User {
private ArenaManager arenaManager;
private SecretBoxManager secretBoxManager;
//构造函数必须要声明否则从mongodb读出来反编译成类不通过
public User(){
}
@ -57,6 +59,7 @@ public class User {
this.levelDifficultyManager = new LevelDifficultyManager();
this.activityManager = new ActivityManager();
this.arenaManager = new ArenaManager();
this.secretBoxManager = new SecretBoxManager();
//綁定关系
this.playerManager.init(id, MongoKey.playerManager);
@ -72,6 +75,7 @@ public class User {
this.levelDifficultyManager.init(id, MongoKey.levelDifficultyManager);
this.activityManager.init(id, MongoKey.activityManager);
this.arenaManager.init(id, MongoKey.arenaManager);
this.secretBoxManager.init(id, MongoKey.secretBoxManager);
}
public String getId() {
@ -165,4 +169,8 @@ public class User {
public ArenaManager getArenaManager() {
return arenaManager;
}
public SecretBoxManager getSecretBoxManager() {
return secretBoxManager;
}
}

View File

@ -591,7 +591,10 @@ public class HeroLogic {
}
}
Map<Integer, Integer> secondaryFactorMap = scHero.getSecondaryFactorMap();
if(secondaryFactorMap!=null && !secondaryFactorMap.isEmpty()){
result.putAll(secondaryFactorMap);
}
return result;
}
@ -616,6 +619,10 @@ public class HeroLogic {
result.put(attributeType,(int)(heroBaseValue * ( 1 + paraForHero.get(GlobalsDef.RANKUP_PARA_TYPE)/10000.f) * characterLevelPara + heroBaseValue * paraForHero.get(GlobalsDef.BREAK_PARA_TYPE)/10000.f));
}
}
Map<Integer, Integer> secondaryFactorMap = scHero.getSecondaryFactorMap();
if(secondaryFactorMap!=null && !secondaryFactorMap.isEmpty()){
result.putAll(secondaryFactorMap);
}
return result;
}

View File

@ -222,9 +222,8 @@ public class WorkShopLogic {
User user = UserManager.getUser(uid);
SWorkShopFoundationConfig sWorkShopFoundationConfig = SWorkShopFoundationConfig.getShopFoundationConfigMap().get(materialId);
if(!checkIsUnlock(GlobalsDef.WORK_BASE_TYPE,sWorkShopFoundationConfig.getType(),user.getWorkShopController(),sWorkShopFoundationConfig.getOpenRules())){
// MessageUtil.sendErrorResponse(session,0,MessageTypeProto.MessageType.WORKSHOP_FOUNDATION_RESPONSE_VALUE,"未开");
// return;
LOGGER.error("不匹配");
MessageUtil.sendErrorResponse(session,0,MessageTypeProto.MessageType.WORKSHOP_FOUNDATION_RESPONSE_VALUE,"未开");
return;
}
int[][] cost = sWorkShopFoundationConfig.getCost();
int[][] reallyCost = times2Array(cost, nums);