back_recharge
lvxinran 2019-12-31 17:50:17 +08:00
commit c52180e981
3 changed files with 162 additions and 8 deletions

View File

@ -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

View File

@ -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

View File

@ -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);
}
}