diff --git a/conf/BattleMain.lua b/conf/BattleMain.lua index 40b1afa23..c32f2d47e 100644 --- a/conf/BattleMain.lua +++ b/conf/BattleMain.lua @@ -129,7 +129,7 @@ local function addBattleData() _BattleErrorCache[_BattleErrorIndex] = str end -local function AddRecord() +local function AddRecord(fightData) BattleRecord = {} BattleLogic.Event:AddEvent(BattleEventName.AddRole, function (role) local record = {} @@ -141,15 +141,72 @@ local function AddRecord() end) BattleRecord[role.uid] = record end) + + for i=1, #fightData.playerData.teamSkill do + local teamCaster = BattleLogic.GetTeamSkillCaster(0) + local teamSkill = fightData.playerData.teamSkill[i] + local teamType = math.floor(teamSkill[1] / 100) + + local str = "order:1".."camp:"..teamCaster.camp.." team"..teamSkill[1] + + local record = {} + record.uid = str + record.camp = teamCaster.camp + record.damage = 0 + record.order = 1 + + local curSkill + teamCaster.Event:AddEvent(BattleEventName.SkillCast, function (skill) + if skill.owner.camp == record.camp then + curSkill = skill + end + end) + teamCaster.Event:AddEvent(BattleEventName.RoleDamage, function (defRole, damage, bCrit, finalDmg) + if curSkill and curSkill.teamSkillType == teamType then + record.damage = record.damage + finalDmg + end + end) + BattleRecord[str] = record + end + + for i=1, #fightData.enemyData do + for j=1, #fightData.enemyData[i].teamSkill do + local teamCaster = BattleLogic.GetTeamSkillCaster(1) + local teamSkill = fightData.enemyData[i].teamSkill[j] + local teamType = math.floor(teamSkill[1] / 100) + + local str = "order:"..i.."camp:"..teamCaster.camp.." team"..teamSkill[1] + + local record = {} + record.uid = str + record.camp = teamCaster.camp + record.damage = 0 + record.order = i + + local curSkill + teamCaster.Event:AddEvent(BattleEventName.SkillCast, function (skill) + if skill.owner.camp == record.camp then + curSkill = skill + end + end) + teamCaster.Event:AddEvent(BattleEventName.RoleDamage, function (defRole, damage, bCrit, finalDmg) + if curSkill and curSkill.teamSkillType == teamType and record.order == BattleLogic.CurOrder then + record.damage = record.damage + finalDmg + end + end) + BattleRecord[str] = record + end + end end function BattleMain.Execute(args, fightData, optionData) + print("trfghjdfgucvhbjnfdcgvj") _seed = args.seed _type = args.type _fightData = fightData _optionData = optionData or {} --该开关用于输出战斗过程中的日志,用于验证前后端是否出现战斗不同步 - BattleLogic.IsOpenBattleRecord = true + BattleLogic.IsOpenBattleRecord = false local isError = false local errorCache @@ -158,7 +215,7 @@ function BattleMain.Execute(args, fightData, optionData) BattleLogic.Init(args.maxTime, fightData, optionData) BattleLogic.Type = _type if _type == 9 then - AddRecord() + AddRecord(fightData) end BattleLogic.StartOrder() @@ -234,5 +291,4 @@ function BattleMain.Execute(args, fightData, optionData) end return { result = -1 } end - return BattleMain \ No newline at end of file diff --git a/luafight/BattleMain.lua b/luafight/BattleMain.lua index 25090acee..c011c7395 100644 --- a/luafight/BattleMain.lua +++ b/luafight/BattleMain.lua @@ -130,7 +130,7 @@ local function addBattleData() _BattleErrorCache[_BattleErrorIndex] = str end -local function AddRecord() +local function AddRecord(fightData) BattleRecord = {} BattleLogic.Event:AddEvent(BattleEventName.AddRole, function (role) local record = {} @@ -142,15 +142,72 @@ local function AddRecord() end) BattleRecord[role.uid] = record end) + + for i=1, #fightData.playerData.teamSkill do + local teamCaster = BattleLogic.GetTeamSkillCaster(0) + local teamSkill = fightData.playerData.teamSkill[i] + local teamType = math.floor(teamSkill[1] / 100) + + local str = "order:1".."camp:"..teamCaster.camp.." team"..teamSkill[1] + + local record = {} + record.uid = str + record.camp = teamCaster.camp + record.damage = 0 + record.order = 1 + + local curSkill + teamCaster.Event:AddEvent(BattleEventName.SkillCast, function (skill) + if skill.owner.camp == record.camp then + curSkill = skill + end + end) + teamCaster.Event:AddEvent(BattleEventName.RoleDamage, function (defRole, damage, bCrit, finalDmg) + if curSkill and curSkill.teamSkillType == teamType then + record.damage = record.damage + finalDmg + end + end) + BattleRecord[str] = record + end + + for i=1, #fightData.enemyData do + for j=1, #fightData.enemyData[i].teamSkill do + local teamCaster = BattleLogic.GetTeamSkillCaster(1) + local teamSkill = fightData.enemyData[i].teamSkill[j] + local teamType = math.floor(teamSkill[1] / 100) + + local str = "order:"..i.."camp:"..teamCaster.camp.." team"..teamSkill[1] + + local record = {} + record.uid = str + record.camp = teamCaster.camp + record.damage = 0 + record.order = i + + local curSkill + teamCaster.Event:AddEvent(BattleEventName.SkillCast, function (skill) + if skill.owner.camp == record.camp then + curSkill = skill + end + end) + teamCaster.Event:AddEvent(BattleEventName.RoleDamage, function (defRole, damage, bCrit, finalDmg) + if curSkill and curSkill.teamSkillType == teamType and record.order == BattleLogic.CurOrder then + record.damage = record.damage + finalDmg + end + end) + BattleRecord[str] = record + end + end end function BattleMain.Execute(args, fightData, optionData) + print("trfghjdfgucvhbjnfdcgvj") _seed = args.seed _type = args.type _fightData = fightData _optionData = optionData or {} --该开关用于输出战斗过程中的日志,用于验证前后端是否出现战斗不同步 - BattleLogic.IsOpenBattleRecord = true + BattleLogic.IsOpenBattleRecord = false local isError = false local errorCache @@ -159,7 +216,7 @@ function BattleMain.Execute(args, fightData, optionData) BattleLogic.Init(args.maxTime, fightData, optionData) BattleLogic.Type = _type if _type == 9 then - AddRecord() + AddRecord(fightData) end BattleLogic.StartOrder() @@ -235,5 +292,4 @@ function BattleMain.Execute(args, fightData, optionData) end return { result = -1 } end - return BattleMain \ No newline at end of file diff --git a/serverlogic/src/main/java/com/ljsd/DbClear.java b/serverlogic/src/main/java/com/ljsd/DbClear.java new file mode 100644 index 000000000..c7f34a5a4 --- /dev/null +++ b/serverlogic/src/main/java/com/ljsd/DbClear.java @@ -0,0 +1,42 @@ +package com.ljsd; + + + +import com.mongodb.Mongo; +import com.mongodb.MongoClient; +import com.mongodb.MongoClientURI; +import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; +import org.springframework.data.redis.core.StringRedisTemplate; + +import java.io.*; +import java.util.Properties; + +public class DbClear { + public static void main(String[] args) throws IOException { + Properties properties = new Properties(); + File file = new File("serverlogic/src/main/resources/application.properties"); + //BufferedInputStream bufferedInputStream = new BufferedInputStream(DbClear.class.getResourceAsStream("application.properties")); + System.out.println(file.getAbsolutePath()); + properties.load(new FileReader(file)); + String property = properties.getProperty("spring.data.mongodb.uri"); + MongoClientURI mongoClientURI = new MongoClientURI(property); + MongoClient mongoClient = new MongoClient(mongoClientURI); + mongoClient.dropDatabase(mongoClientURI.getDatabase()); + StringRedisTemplate redisTemplate = getRedisTemplate(); + redisTemplate.delete(redisTemplate.keys(properties.get("server.id")+"*")); + + + } + + public static StringRedisTemplate getRedisTemplate(){ + JedisConnectionFactory connectionFactory = new JedisConnectionFactory(); + //设置host + connectionFactory.setHostName("60.1.1.21"); + //设置端口 + connectionFactory.setPort(6379); + //初始化connectionFactory + connectionFactory.afterPropertiesSet(); + //实例化 + return new StringRedisTemplate(connectionFactory); + } +}