冒险第一版

back_recharge
wangyuan 2019-01-24 16:31:29 +08:00
parent 9b40fd7e62
commit b44af11e55
11 changed files with 312 additions and 13 deletions

View File

@ -1,5 +1,5 @@
Id OpenLevel RecommendForce RecommendHeroIds MinNum BaseReward RandomRewardGroup RecommendRewardGroup
int int int mut,int#int,1 int mut,int#int,2 mut,int#int,1 mut,int#int,1
1 10 1000 10001#10002 2 1#100|2#100 1001#1002 2001#2002#2003
2 11 2000 10001 2 1#100|2#100 1001#1002 2001#2002#2003
3 12 3000 10001 2 1#100|2#100 1001#1002 2001#2002#2003
Id OpenLevel RecommendForce RecommendHeroIds MinNum BaseRewardGroup RandomRewardGroup RecommendRewardGroup
int int int mut,int#int,1 int mut,int#int,1 mut,int#int,1 mut,int#int,1
1 10 1000 10001#10002 2 1001#1002 1001#1002 2001#2002#2003
2 11 2000 10001 2 1001#1002 1001#1002 2001#2002#2003
3 12 3000 10001 2 1001#1002 1001#1002 2001#2002#2003

View File

@ -0,0 +1,18 @@
VipLevel NeedRMB Privileges VipBoxReward VipBoxCost
int int mut,int#int,2 mut,int#int,2 mut,int#int,1
0 0 1#12 null null
1 6 1#13 null null
2 12 1#14 null null
3 18 1#15 null null
4 24 1#16 null null
5 30 1#17 null null
6 36 1#18 null null
7 42 1#19 null null
8 48 1#20 null null
9 54 1#21 null null
10 60 1#22 null null
11 66 1#23 null null
12 72 1#24 null null
13 78 1#25 null null
14 84 1#26 null null
15 90 1#27 null null

View File

@ -8,6 +8,7 @@ import java.util.Map;
@Table(name ="AdventureConfig")
public class SAdventureConfig implements BaseConfig {
private static Map<Integer, SAdventureConfig> sAdventureConfigMap;
private int id;
private int openLevel;
@ -18,7 +19,7 @@ public class SAdventureConfig implements BaseConfig {
private int minNum;
private int[][] baseReward;
private int[] baseRewardGroup;
private int[] randomRewardGroup;
@ -27,9 +28,12 @@ public class SAdventureConfig implements BaseConfig {
@Override
public void init() throws Exception {
sAdventureConfigMap = STableManager.getConfig(SAdventureConfig.class);
}
public static SAdventureConfig getsAdventureConfigByPosition(int position) {
return sAdventureConfigMap.get(position);
}
public int getId() {
return id;
@ -51,8 +55,8 @@ public class SAdventureConfig implements BaseConfig {
return minNum;
}
public int[][] getBaseReward() {
return baseReward;
public int[] getBaseRewardGroup() {
return baseRewardGroup;
}
public int[] getRandomRewardGroup() {

View File

@ -8,6 +8,8 @@ import java.util.Map;
@Table(name ="AdventureSetting")
public class SAdventureSetting implements BaseConfig {
private static Map<Integer, SAdventureSetting> sAdventureSettingMap;
private int id;
private int limitHour;
@ -25,9 +27,12 @@ public class SAdventureSetting implements BaseConfig {
@Override
public void init() throws Exception {
sAdventureSettingMap = STableManager.getConfig(SAdventureSetting.class);
}
public static Map<Integer, SAdventureSetting> getsAdventureSettingMap() {
return sAdventureSettingMap;
}
public int getId() {
return id;

View File

@ -0,0 +1,53 @@
package com.ljsd.jieling.config;
import com.ljsd.jieling.logic.STableManager;
import com.ljsd.jieling.logic.Table;
import java.util.Map;
@Table(name ="VipLevelConfig")
public class SVipLevelConfig implements BaseConfig {
private static Map<Integer, SVipLevelConfig> sVipLevelConfigMap;
private int vipLevel;
private int needRMB;
private int[][] privileges;
private int[][] vipBoxReward;
private int[] vipBoxCost;
@Override
public void init() throws Exception {
sVipLevelConfigMap = STableManager.getConfig(SVipLevelConfig.class);
}
public static Map<Integer, SVipLevelConfig> getsVipLevelConfigMap() {
return sVipLevelConfigMap;
}
public int getVipLevel() {
return vipLevel;
}
public int getNeedRMB() {
return needRMB;
}
public int[][] getPrivileges() {
return privileges;
}
public int[][] getVipBoxReward() {
return vipBoxReward;
}
public int[] getVipBoxCost() {
return vipBoxCost;
}
}

View File

@ -0,0 +1,35 @@
package com.ljsd.jieling.logic.dao;
import com.ljsd.common.mogodb.MongoBase;
import java.util.HashMap;
import java.util.Map;
public class AdventureManager extends MongoBase {
private Map<Integer,AdventureStateInfo> adventureStateInfoMap;
public AdventureManager(){
adventureStateInfoMap = new HashMap<>();
}
public void station(AdventureStateInfo adventureStateInfo) throws Exception {
int position = adventureStateInfo.getPosition();
updateString("adventureStateInfoMap." + position,adventureStateInfo);
adventureStateInfoMap.put(position,adventureStateInfo);
}
public void clearStation(int position){
removeString("adventureStateInfoMap." + position);
adventureStateInfoMap.remove(position);
}
public Map<Integer, AdventureStateInfo> getAdventureStateInfoMap() {
return adventureStateInfoMap;
}
public void setAdventureStateInfoMap(Map<Integer, AdventureStateInfo> adventureStateInfoMap) {
this.adventureStateInfoMap = adventureStateInfoMap;
}
}

View File

@ -0,0 +1,35 @@
package com.ljsd.jieling.logic.dao;
import java.util.List;
public class AdventureStateInfo {
private int position;
private List<String> heroIds;
private int startTime;
private int hourDuration;
public AdventureStateInfo(){}
public AdventureStateInfo(int position,List<String> heroIds, int startTime, int hourDuration) {
this.heroIds = heroIds;
this.startTime = startTime;
this.hourDuration = hourDuration;
this.position = position;
}
public List<String> getHeroIds() {
return heroIds;
}
public int getStartTime() {
return startTime;
}
public int getHourDuration() {
return hourDuration;
}
public int getPosition() {
return position;
}
}

View File

@ -21,6 +21,8 @@ public class User extends MongoRoot {
private EquipManager equipManager;
private AdventureManager adventureManager;
public User(int uid, PlayerManager playerManager, ItemManager itemManager,
@ -34,6 +36,7 @@ public class User extends MongoRoot {
this.teamPosManager = new TeamPosManager();
this.mailManager = new MailManager();
this.equipManager = new EquipManager();
this.adventureManager = new AdventureManager();
//綁定关系
this.playerManager.init(this, "playerManager", false);
@ -43,6 +46,7 @@ public class User extends MongoRoot {
this.teamPosManager.init(this,"teamPosManager",false);
this.mailManager.init(this,"mailManager",false);
this.equipManager.init(this,"equipManager",false);
this.adventureManager.init(this,"adventureManager",false);
}
public User(){
@ -52,12 +56,14 @@ public class User extends MongoRoot {
this.heroManager = new HeroManager();
this.mapManager = new MapManager();
this.equipManager = new EquipManager();
this.adventureManager = new AdventureManager();
//綁定关系
playerManager.init(this, "playerManager", false);
itemManager.init(this, "itemManager", false);
heroManager.init(this, "heroManager", false);
mapManager.init(this, "mapManager", false);
equipManager.init(this,"equipManager",false);
adventureManager.init(this,"adventureManager",false);
}
public static void init(LjsdMongoTemplate ljsdMongoTemplate) {
@ -120,4 +126,12 @@ public class User extends MongoRoot {
public void setMailManager(MailManager mailManager) {
this.mailManager = mailManager;
}
public EquipManager getEquipManager() {
return equipManager;
}
public AdventureManager getAdventureManager() {
return adventureManager;
}
}

View File

@ -0,0 +1,126 @@
package com.ljsd.jieling.logic.fight;
import com.ljsd.jieling.config.SAdventureConfig;
import com.ljsd.jieling.logic.STableManager;
import com.ljsd.jieling.logic.dao.AdventureManager;
import com.ljsd.jieling.logic.dao.AdventureStateInfo;
import com.ljsd.jieling.logic.dao.User;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.protocols.FightInfoProto;
import com.ljsd.jieling.util.CBean2Proto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class CombatLogic {
private static final Logger LOGGER = LoggerFactory.getLogger(CombatLogic.class);
private CombatLogic(){}
public static class Instance {
public final static CombatLogic instance = new CombatLogic();
}
public static CombatLogic getInstance() {
return CombatLogic.Instance.instance;
}
//冒险模式
public void getAdventureStateInfo(ISession session) throws Exception {
int uid = session.getUid();
User user = UserManager.getUser(uid);
AdventureManager adventureManager = user.getAdventureManager();
Map<Integer, AdventureStateInfo> adventureStateInfoMap = adventureManager.getAdventureStateInfoMap();
List<CommonProto.AdventureStateInfo> result = new ArrayList<>();
for(AdventureStateInfo adventureStateInfo : adventureStateInfoMap.values()){
result.add(CBean2Proto.getAdventureStateInfo(adventureStateInfo));
}
FightInfoProto.GetAdventureStateInfoResponse response = FightInfoProto.GetAdventureStateInfoResponse.newBuilder().addAllAdventureStateInfoList(result).build();
}
public void adventureStation(ISession session,int position,List<String> heroIds,int hourDuration) throws Exception {
if(heroIds == null || heroIds.isEmpty()){
return;
}
int uid = session.getUid();
User user = UserManager.getUser(uid);
SAdventureConfig sAdventureConfig = SAdventureConfig.getsAdventureConfigByPosition(position);
if(sAdventureConfig.getOpenLevel() > user.getPlayerInfoManager().getLevel()){
return;
}
if(sAdventureConfig.getMinNum() > heroIds.size()){
return;
}
AdventureManager adventureManager = user.getAdventureManager();
//检验
Map<Integer, AdventureStateInfo> adventureStateInfoMap = adventureManager.getAdventureStateInfoMap();
AdventureStateInfo adventureStateInfo = adventureManager.getAdventureStateInfoMap().get(position);
if(adventureStateInfo!=null){
return;
}
for(AdventureStateInfo adventureStateInfoTmp:adventureStateInfoMap.values()){
List<String> heroIds1 = adventureStateInfoTmp.getHeroIds();
for(String useHeroId : heroIds1){
if(heroIds.contains(useHeroId)){
return;
}
}
}
adventureManager.station(new AdventureStateInfo(position,heroIds,(int)(System.currentTimeMillis()),hourDuration));
//发送成功
}
public void clearStation(ISession session,int position) throws Exception {
int uid = session.getUid();
User user = UserManager.getUser(uid);
AdventureManager adventureManager = user.getAdventureManager();
AdventureStateInfo adventureStateInfo = adventureManager.getAdventureStateInfoMap().get(position);
if( null == adventureStateInfo ){
return;
}
int startTime = adventureStateInfo.getStartTime();
int hourDuration = adventureStateInfo.getHourDuration();
int now = (int)(System.currentTimeMillis()/1000);
if( (now - startTime ) /3600 < hourDuration ){
return;
}
//计算奖励
SAdventureConfig sAdventureConfig = SAdventureConfig.getsAdventureConfigByPosition(position);
int recommendForce = sAdventureConfig.getRecommendForce();
int[] baseRewardGroup = sAdventureConfig.getBaseRewardGroup();
int[] recommendHeroIds = sAdventureConfig.getRecommendHeroIds();
int[] recommendRewardGroup = sAdventureConfig.getRecommendRewardGroup();
//清除占领
adventureManager.clearStation(position);
//发送成功
}
}

View File

@ -356,7 +356,7 @@ public class HeroLogic {
return SGameSetting.getGameSetting().calSpeed(baseValue,heroLevel);
}
return baseValue * ( 1 + rankupPara/10000.f) * characterLevelPara * breakPara;
return baseValue * ( 1 + rankupPara/10000.f) + characterLevelPara * breakPara;
}

View File

@ -61,6 +61,15 @@ public class CBean2Proto {
return mailProto;
}
public static CommonProto.AdventureStateInfo getAdventureStateInfo(AdventureStateInfo adventureStateInfo){
return CommonProto.AdventureStateInfo.newBuilder()
.addAllHeroIdList(adventureStateInfo.getHeroIds())
.setStartTime(adventureStateInfo.getStartTime())
.setHourDuration(adventureStateInfo.getHourDuration())
.setPositionId(adventureStateInfo.getPosition())
.build();
}
private static List<String> getHeroEquip(List<Equip> equipList) {
List<String> equips = new ArrayList<>();