fight
parent
4eb0121eef
commit
0d473165c8
|
@ -65,6 +65,7 @@ local effectList = {
|
|||
local f1 = args[2]
|
||||
local f2 = args[3]
|
||||
local ct = args[4]
|
||||
|
||||
BattleLogic.WaitForTrigger(interval, function ()
|
||||
target:AddBuff(Buff.Create(caster, BuffName.PropertyChange, f2, propertyList[pro1], f1, ct))
|
||||
end)
|
||||
|
|
|
@ -209,7 +209,7 @@ function Skill:Cast()
|
|||
local duration = effectGroup.duration
|
||||
local effects = effectGroup.effects
|
||||
local nn = floor(chooseId / 10000) % 10
|
||||
local count = chooseId % 10
|
||||
local count = min(chooseId % 10, #arr)
|
||||
if count == 0 then
|
||||
count = #arr
|
||||
end
|
||||
|
|
|
@ -275,6 +275,58 @@ function BattleLogic.GetOption()
|
|||
return optionRecord
|
||||
end
|
||||
|
||||
--执行操作逻辑
|
||||
function BattleLogic.ExecuteOption(option)
|
||||
local opType = option[2]
|
||||
local opArg = option[3]
|
||||
if opType == 1 then --全局自动手动
|
||||
for i=1, objList.size do
|
||||
local tmpObj = objList.vList[i]
|
||||
if tmpObj.camp == 0 then
|
||||
tmpObj.Auto = opArg == 1
|
||||
end
|
||||
end
|
||||
elseif opType == 2 then --释放skill
|
||||
local role = objList.kvList[opArg]
|
||||
if role and role.skill then
|
||||
role.skill:Cast()
|
||||
end
|
||||
elseif opType == 3 then --释放superSkill
|
||||
local role = objList.kvList[opArg]
|
||||
if role and role.superSkill then
|
||||
role.superSkill:Cast()
|
||||
end
|
||||
elseif opType == 4 then --释放teamSkill
|
||||
local teamSkill = playerTeamSkillList[playerTeamSkillIndex]
|
||||
if teamSkill then
|
||||
teamSkill:Cast()
|
||||
playerTeamSkillIndex = playerTeamSkillIndex + 1
|
||||
if playerTeamSkillIndex > #playerTeamSkillList then
|
||||
playerTeamSkillIndex = 1
|
||||
end
|
||||
playerMP = 0
|
||||
end
|
||||
elseif opType == 4 then --释放teamSkill
|
||||
local teamSkill = playerTeamSkillList[playerTeamSkillIndex]
|
||||
if teamSkill then
|
||||
teamSkill:Cast()
|
||||
playerTeamSkillIndex = playerTeamSkillIndex + 1
|
||||
if playerTeamSkillIndex > #playerTeamSkillList then
|
||||
playerTeamSkillIndex = 1
|
||||
end
|
||||
playerMP = 0
|
||||
end
|
||||
elseif opType == 5 then --设置teamSkill自动手动
|
||||
isAuto = opArg == 1
|
||||
elseif opType == 6 then --切换单个角色自动手动 arg == uid * 10 + auto(0手动,1自动)
|
||||
local auto = opArg % 10
|
||||
local uid = floor(opArg / 10)
|
||||
if objList.kvList[uid] then
|
||||
objList.kvList[uid].Auto = auto == 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function BattleLogic.HasObj(obj)
|
||||
return obj and objList.kvList[obj.uid]
|
||||
end
|
||||
|
@ -343,37 +395,7 @@ function BattleLogic.Update()
|
|||
|
||||
for i=1, #optionRecord do
|
||||
if optionRecord[i][1] == curFrame then
|
||||
local opType = optionRecord[i][2]
|
||||
local opArg = optionRecord[i][3]
|
||||
if opType == 1 then --自动手动
|
||||
isAuto = opArg == 1
|
||||
for i=1, objList.size do
|
||||
local tmpObj = objList.vList[i]
|
||||
if tmpObj.camp == 0 then
|
||||
tmpObj.Auto = opArg == 1
|
||||
end
|
||||
end
|
||||
elseif opType == 2 then --释放skill
|
||||
local role = objList.kvList[opArg]
|
||||
if role and role.skill then
|
||||
role.skill:Cast()
|
||||
end
|
||||
elseif opType == 3 then --释放superSkill
|
||||
local role = objList.kvList[opArg]
|
||||
if role and role.superSkill then
|
||||
role.superSkill:Cast()
|
||||
end
|
||||
elseif opType == 4 then --释放teamSkill
|
||||
local teamSkill = playerTeamSkillList[playerTeamSkillIndex]
|
||||
if teamSkill then
|
||||
teamSkill:Cast()
|
||||
playerTeamSkillIndex = playerTeamSkillIndex + 1
|
||||
if playerTeamSkillIndex > #playerTeamSkillList then
|
||||
playerTeamSkillIndex = 1
|
||||
end
|
||||
playerMP = 0
|
||||
end
|
||||
end
|
||||
BattleLogic.ExecuteOption(optionRecord[i])
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ end
|
|||
--间隔N帧触发,返回true时表示继续触发,返回false立刻触发OnEnd
|
||||
function HOT:OnTrigger()
|
||||
--log("HOT:OnTrigger")
|
||||
if not self.target.ctrl_noheal then --禁疗无法加血
|
||||
if not self.target.ctrl_noheal or self.target.isDead then --禁疗和死亡无法加血
|
||||
BattleUtil.ApplyTreat(self.caster, self.target, self.healValue)
|
||||
end
|
||||
return true
|
||||
|
|
|
@ -179,7 +179,7 @@ function BattleUtil.CalDamage(atkRole, defRole, damageType, baseFactor, ignoreDe
|
|||
end
|
||||
|
||||
function BattleUtil.CalTreat(castRole, targetRole, value, baseFactor)
|
||||
if targetRole.ctrl_noheal then --禁疗无法加血
|
||||
if targetRole.ctrl_noheal or targetRole.isDead then --禁疗和死亡无法加血
|
||||
return
|
||||
end
|
||||
targetRole.Event:DispatchEvent(BattleEventName.RoleBeHealed, castRole)
|
||||
|
|
|
@ -134,4 +134,8 @@ public class SArenaRobotConfig implements BaseConfig {
|
|||
public void setBreakId(int breakId) {
|
||||
this.breakId = breakId;
|
||||
}
|
||||
|
||||
public void setStarOfHeroMap(Map<Integer, Integer> starOfHeroMap) {
|
||||
this.starOfHeroMap = starOfHeroMap;
|
||||
}
|
||||
}
|
|
@ -1,7 +1,9 @@
|
|||
package com.ljsd.jieling.logic.arena;
|
||||
|
||||
import com.googlecode.protobuf.format.JsonFormat;
|
||||
import com.ljsd.jieling.config.*;
|
||||
import com.ljsd.jieling.core.GlobalsDef;
|
||||
import com.ljsd.jieling.db.mongo.MongoUtil;
|
||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
import com.ljsd.jieling.handler.map.behavior.BehaviorUtil;
|
||||
import com.ljsd.jieling.logic.dao.*;
|
||||
|
@ -88,55 +90,57 @@ public class ArenaLogic {
|
|||
}
|
||||
|
||||
|
||||
public void challenge(ISession session,int challengeUid,int teamId) throws Exception {
|
||||
int uid = session.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
String err = checkChallenge(user);
|
||||
if(!"".equals(err)){
|
||||
MessageUtil.sendErrorResponse(session,0, MessageTypeProto.MessageType.ARENA_CHALLENGE_RESPONSE_VALUE,err);
|
||||
return;
|
||||
}
|
||||
ArenaManager arenaManager = user.getArenaManager();
|
||||
List<ArenaEnemy> arenaEnemies = arenaManager.getArenaEnemies();
|
||||
ArenaEnemy enemyInfo = getEnemyInList(challengeUid, arenaEnemies);
|
||||
if( null == enemyInfo ){
|
||||
MessageUtil.sendErrorResponse(session,0, MessageTypeProto.MessageType.ARENA_CHALLENGE_RESPONSE_VALUE,"对手错误");
|
||||
return;
|
||||
}
|
||||
int fightResult=0;
|
||||
int myscore = 2000;
|
||||
int defScore =1000;
|
||||
int enemyType = enemyInfo.getEnemyType();
|
||||
int myscoreChange=0;
|
||||
int defScoreChange=0;
|
||||
public void challenge(ISession session,int challengeUid,int teamId) throws Exception {
|
||||
int uid = session.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
String err = checkChallenge(user);
|
||||
if(!"".equals(err)){
|
||||
MessageUtil.sendErrorResponse(session,0, MessageTypeProto.MessageType.ARENA_CHALLENGE_RESPONSE_VALUE,err);
|
||||
return;
|
||||
}
|
||||
ArenaManager arenaManager = user.getArenaManager();
|
||||
List<ArenaEnemy> arenaEnemies = arenaManager.getArenaEnemies();
|
||||
ArenaEnemy enemyInfo = getEnemyInList(challengeUid, arenaEnemies);
|
||||
if( null == enemyInfo ){
|
||||
MessageUtil.sendErrorResponse(session,0, MessageTypeProto.MessageType.ARENA_CHALLENGE_RESPONSE_VALUE,"对手错误");
|
||||
return;
|
||||
}
|
||||
int fightResult=0;
|
||||
int myscore = 2000;
|
||||
int defScore =1000;
|
||||
int enemyType = enemyInfo.getEnemyType();
|
||||
int myscoreChange=0;
|
||||
int defScoreChange=0;
|
||||
|
||||
arenaEnemies = new ArrayList<>();
|
||||
Set<Integer> robotIds = randomRobot(user.getPlayerInfoManager().getLevel(), 5);
|
||||
toArenaEnemy(uid,robotIds,arenaEnemies,0);
|
||||
arenaManager.setArenaEnemies(arenaEnemies);
|
||||
myscoreChange = calScore(myscore, defScore,fightResult);
|
||||
defScoreChange = calScore(defScore, myscore,fightResult);
|
||||
arenaEnemies = new ArrayList<>();
|
||||
Set<Integer> robotIds = randomRobot(user.getPlayerInfoManager().getLevel(), 5);
|
||||
toArenaEnemy(uid,robotIds,arenaEnemies,0);
|
||||
arenaManager.setArenaEnemies(arenaEnemies);
|
||||
myscoreChange = calScore(myscore, defScore,fightResult);
|
||||
defScoreChange = calScore(defScore, myscore,fightResult);
|
||||
|
||||
RedisUtil.getInstence().incrementZsetScore("Arena_Rank_1",Integer.toString(uid),myscoreChange);
|
||||
if( enemyType == GlobalsDef.ARENA_PLAYER_TYPE){
|
||||
RedisUtil.getInstence().incrementZsetScore("Arena_Rank_1",Integer.toString(challengeUid),defScoreChange);
|
||||
}
|
||||
//组战斗数据
|
||||
ArenaInfoProto.ArenaChallengeResponse build = ArenaInfoProto.ArenaChallengeResponse.newBuilder().setMyScoreChange(myscoreChange).setDefScoreChange(defScoreChange).addAllArenaEnemys(getArenaEnemyList(arenaManager.getArenaEnemies())).build();
|
||||
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.ARENA_CHALLENGE_RESPONSE_VALUE,build,true);
|
||||
}
|
||||
RedisUtil.getInstence().incrementZsetScore("Arena_Rank_1",Integer.toString(uid),myscoreChange);
|
||||
if( enemyType == GlobalsDef.ARENA_PLAYER_TYPE){
|
||||
RedisUtil.getInstence().incrementZsetScore("Arena_Rank_1",Integer.toString(challengeUid),defScoreChange);
|
||||
}
|
||||
//组战斗数据
|
||||
ArenaInfoProto.ArenaChallengeResponse build = ArenaInfoProto.ArenaChallengeResponse.newBuilder().setMyScoreChange(myscoreChange).setDefScoreChange(defScoreChange).addAllArenaEnemys(getArenaEnemyList(arenaManager.getArenaEnemies())).build();
|
||||
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.ARENA_CHALLENGE_RESPONSE_VALUE,build,true);
|
||||
}
|
||||
|
||||
|
||||
public int getFightResultByPersonToPerson(User mine,int myteamId,User defUser,int defTeamId){
|
||||
CommonProto.FightTeamInfo fightTeamInfo = BehaviorUtil.getFightTeamInfo(mine,myteamId);
|
||||
CommonProto.FightTeamInfo deffightTeamInfo = BehaviorUtil.getFightTeamInfo(defUser,defTeamId);
|
||||
//设置战斗随机种子
|
||||
int seed = (int)(System.currentTimeMillis()/1000);
|
||||
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 static int getFightResultByPersonToPerson(User mine,int myteamId,User defUser,int defTeamId){
|
||||
CommonProto.FightTeamInfo fightTeamInfo = BehaviorUtil.getFightTeamInfo(mine,myteamId);
|
||||
CommonProto.FightTeamInfo deffightTeamInfo = BehaviorUtil.getFightTeamInfo(defUser,defTeamId);
|
||||
//设置战斗随机种子
|
||||
int seed = (int)(System.currentTimeMillis()/1000);
|
||||
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);
|
||||
|
@ -149,22 +153,22 @@ public class ArenaLogic {
|
|||
return checkResult[0];
|
||||
}
|
||||
|
||||
private String checkChallenge(User user) throws Exception {
|
||||
ArenaManager arenaManager = user.getArenaManager();
|
||||
SArenaSetting sArenaSetting = SArenaSetting.getSArenaSetting();
|
||||
int useFreeTimes = arenaManager.getUseFreeTimes();
|
||||
int battleFree = sArenaSetting.getBattleFree();
|
||||
if(useFreeTimes>=battleFree){
|
||||
//校验消耗
|
||||
boolean enough = ItemUtil.itemCost(user, sArenaSetting.getCostItem());
|
||||
if(!enough){
|
||||
return "道具不足";
|
||||
}
|
||||
}else{
|
||||
arenaManager.setUseFreeTimes(useFreeTimes+1);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
private String checkChallenge(User user) throws Exception {
|
||||
ArenaManager arenaManager = user.getArenaManager();
|
||||
SArenaSetting sArenaSetting = SArenaSetting.getSArenaSetting();
|
||||
int useFreeTimes = arenaManager.getUseFreeTimes();
|
||||
int battleFree = sArenaSetting.getBattleFree();
|
||||
if(useFreeTimes>=battleFree){
|
||||
//校验消耗
|
||||
boolean enough = ItemUtil.itemCost(user, sArenaSetting.getCostItem());
|
||||
if(!enough){
|
||||
return "道具不足";
|
||||
}
|
||||
}else{
|
||||
arenaManager.setUseFreeTimes(useFreeTimes+1);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private ArenaEnemy getEnemyInList(int challengeUid, List<ArenaEnemy> enemys) {
|
||||
for (ArenaEnemy data : enemys) {
|
||||
|
|
|
@ -620,17 +620,20 @@ public class HeroLogic {
|
|||
}
|
||||
|
||||
//根据英雄等级计算出brealId,从而也可以获取星级
|
||||
public int calRobotStarByLevel(int heroTid,int heroLevel){
|
||||
public int calRobotStarByLevel(int heroTid,int heroLevel,Map<Integer,Integer> starHeroMap){
|
||||
SCHero scHero = SCHero.getsCHero().get(heroTid);
|
||||
int star = scHero.getStar();
|
||||
Map<Integer, SCHeroRankUpConfig> scHeroRankUpConfigByType = SCHeroRankUpConfig.getScHeroRankUpConfigByShow(GlobalsDef.UP_STAR_TYPE,scHero.getStar());
|
||||
if(scHeroRankUpConfigByType == null){
|
||||
scHeroRankUpConfigByType = SCHeroRankUpConfig.getScHeroRankUpConfigByShow(GlobalsDef.BREAK_TYPE,scHero.getStar());
|
||||
}
|
||||
for(SCHeroRankUpConfig scHeroRankUpConfig : scHeroRankUpConfigByType.values()){
|
||||
if (heroLevel>=scHeroRankUpConfig.getLimitLevel() && heroLevel <= scHeroRankUpConfig.getOpenLevel()){
|
||||
starHeroMap.put(heroTid,scHeroRankUpConfig.getOpenStar());
|
||||
return scHeroRankUpConfig.getId();
|
||||
}
|
||||
}
|
||||
starHeroMap.put(heroTid,star);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1237,7 +1240,7 @@ public class HeroLogic {
|
|||
int differDemonsLv = sArenaRobotConfig.getDifferDemonsLv();
|
||||
int robotLevel = sArenaRobotConfig.getRobotLevel();
|
||||
for(Integer heroTid :heroList){
|
||||
int heroBreakId = calRobotStarByLevel(heroTid, robotLevel);
|
||||
int heroBreakId = sArenaRobotConfig.getBreakId();
|
||||
Map<Integer, Integer> robotHeroAttribute = calRobotHeroAttribute(heroTid, robotLevel, heroBreakId, differDemonsId, differDemonsLv);
|
||||
totalForce+=calForce(robotHeroAttribute);
|
||||
}
|
||||
|
@ -1249,13 +1252,13 @@ public class HeroLogic {
|
|||
for(SArenaRobotConfig sArenaRobotConfig : integerSArenaRobotConfigMap.values()){
|
||||
List<Integer> heroList = sArenaRobotConfig.getHeroList();
|
||||
int robotLevel = sArenaRobotConfig.getRobotLevel();
|
||||
Map<Integer,Integer> starHeroMap = new HashMap<>();
|
||||
for(Integer heroTid :heroList){
|
||||
int heroBreakId = calRobotStarByLevel(heroTid, robotLevel);
|
||||
int heroBreakId = calRobotStarByLevel(heroTid, robotLevel,starHeroMap);
|
||||
sArenaRobotConfig.setBreakId(heroBreakId);
|
||||
sArenaRobotConfig.setStarOfHeroMap(starHeroMap);
|
||||
}
|
||||
sArenaRobotConfig.setTotalForce(HeroLogic.getInstance().calRobotTotalForce(sArenaRobotConfig));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ public class FightDataUtil {
|
|||
public static LuaValue getFinalFightData(CommonProto.FightTeamInfo heroTeam, List<CommonProto.FightTeamInfo> monsterTeamList) {
|
||||
|
||||
LuaValue LuaTable = new LuaTable();
|
||||
LuaTable.set("playerData", getPlayerData(heroTeam));
|
||||
LuaTable.set("playerData", getPlayerData(heroTeam,0));
|
||||
LuaTable.set("enemyData", getEnemyData(monsterTeamList));
|
||||
return LuaTable;
|
||||
|
||||
|
@ -46,8 +46,10 @@ public class FightDataUtil {
|
|||
public static LuaValue getFinalPlayerFightData(CommonProto.FightTeamInfo heroTeam, CommonProto.FightTeamInfo enemyHeroTeam) {
|
||||
|
||||
LuaValue LuaTable = new LuaTable();
|
||||
LuaTable.set("playerData", getPlayerData(heroTeam));
|
||||
LuaTable.set("enemyData", getPlayerData(enemyHeroTeam));
|
||||
LuaTable.set("playerData", getPlayerData(heroTeam,0));
|
||||
LuaValue enemyData = new LuaTable();
|
||||
enemyData.rawset( 1, getPlayerData(enemyHeroTeam,1));
|
||||
LuaTable.set("enemyData", enemyData);
|
||||
return LuaTable;
|
||||
|
||||
}
|
||||
|
@ -172,10 +174,10 @@ public class FightDataUtil {
|
|||
}
|
||||
|
||||
|
||||
public static LuaValue getPlayerData(CommonProto.FightTeamInfo heroTeam) {
|
||||
public static LuaValue getPlayerData(CommonProto.FightTeamInfo heroTeam,int position) {
|
||||
LuaValue playerData = new LuaTable();
|
||||
for (int i = 1; i <= heroTeam.getFightUnitListCount(); i++) {
|
||||
playerData.rawset(i, getHeroFightUnit(heroTeam.getFightUnitList(i - 1)));
|
||||
playerData.rawset(i, getHeroFightUnit(heroTeam.getFightUnitList(i - 1),position));
|
||||
}
|
||||
playerData.set("teamSkill", getTeamSkill(heroTeam.getTeamSkillList()));
|
||||
return playerData;
|
||||
|
@ -196,7 +198,13 @@ public class FightDataUtil {
|
|||
}
|
||||
|
||||
|
||||
private static LuaValue getHeroFightUnit(CommonProto.FightUnitInfo data) {
|
||||
/**
|
||||
*
|
||||
* @param data
|
||||
* @param postion 0:我方 1:敌方
|
||||
* @return
|
||||
*/
|
||||
private static LuaValue getHeroFightUnit(CommonProto.FightUnitInfo data,int postion) {
|
||||
String unitId = data.getUnitId();
|
||||
String[] skillIds = data.getUnitSkillIds().trim().split("#");
|
||||
String property = data.getProperty();
|
||||
|
@ -204,7 +212,7 @@ public class FightDataUtil {
|
|||
LuaValue unitData = new LuaTable();
|
||||
unitData.set("roleId", hero.getId());
|
||||
unitData.set("professionId", hero.getProfession());
|
||||
unitData.set("camp", 0);
|
||||
unitData.set("camp", postion);
|
||||
unitData.set("type", 1);
|
||||
unitData.set("quality", 1);
|
||||
unitData.set("element", hero.getPropertyName());
|
||||
|
|
Loading…
Reference in New Issue