Commit 3b0526d2fbca515f69fd15311d075cf04aefce88

Authored by zhouhaihai
1 parent 9407543b

冒险demo

@@ -99,7 +99,7 @@ AdvBackEventType = { @@ -99,7 +99,7 @@ AdvBackEventType = {
99 Next = 7, --进入下一层 99 Next = 7, --进入下一层
100 End = 8, -- 结束 100 End = 8, -- 结束
101 BlockChange = 9, -- 块改变 101 BlockChange = 9, -- 块改变
102 - PowerChange = 10, --体力改变 102 + SpChange = 10, --体力改变
103 Dead = 11, --怪死亡 103 Dead = 11, --怪死亡
104 DefChange = 12, -- 防御变化 104 DefChange = 12, -- 防御变化
105 Passive = 13, -- 獲得被動 105 Passive = 13, -- 獲得被動
src/ProtocolCode.lua
@@ -35,8 +35,6 @@ actionCodes = { @@ -35,8 +35,6 @@ actionCodes = {
35 Adv_useItemRpc = 154, 35 Adv_useItemRpc = 154,
36 Adv_usePotionRpc = 155, 36 Adv_usePotionRpc = 155,
37 Adv_exitAdvRpc = 156, 37 Adv_exitAdvRpc = 156,
38 - Adv_nextTurnRpc = 157,  
39 - Adv_specialSkillRpc = 158,  
40 38
41 Hero_loadInfos = 201, 39 Hero_loadInfos = 201,
42 Hero_updateProperty = 202, 40 Hero_updateProperty = 202,
src/actions/AdvAction.lua
@@ -90,17 +90,6 @@ function _M.usePotionRpc(agent, data) @@ -90,17 +90,6 @@ function _M.usePotionRpc(agent, data)
90 return true 90 return true
91 end 91 end
92 92
93 ---使用战斗技能  
94 -function _M.specialSkillRpc(agent, data)  
95 - local role = agent.role  
96 - local msg = MsgPack.unpack(data)  
97 - local adv = role:getAdvData()  
98 - local status = adv:useSpecialSkill(msg.skillId)  
99 - -- if not status then return end  
100 - SendPacket(actionCodes.Adv_specialSkillRpc, MsgPack.pack({}))  
101 - return true  
102 -end  
103 -  
104 --退出 93 --退出
105 function _M.exitAdvRpc(agent, data) 94 function _M.exitAdvRpc(agent, data)
106 local role = agent.role 95 local role = agent.role
@@ -111,18 +100,5 @@ function _M.exitAdvRpc(agent, data) @@ -111,18 +100,5 @@ function _M.exitAdvRpc(agent, data)
111 return true 100 return true
112 end 101 end
113 102
114 ---继续战斗  
115 -function _M.nextTurnRpc(agent, data)  
116 - local role = agent.role  
117 - local msg = MsgPack.unpack(data)  
118 - local adv = role:getAdvData()  
119 - local status = adv:nextBattleTurn(msg.turn)  
120 - if not status then -- 数据不同步则发送缓存数据  
121 - SendPacket(actionCodes.Adv_nextTurnRpc, MsgPack.pack({events = adv.tempBackEvents}))  
122 - return true  
123 - end  
124 - SendPacket(actionCodes.Adv_nextTurnRpc, MsgPack.pack({events = adv:popBackEvents()}))  
125 - return true  
126 -end  
127 103
128 return _M 104 return _M
129 \ No newline at end of file 105 \ No newline at end of file
@@ -112,7 +112,6 @@ local function randomAdvMap(role, chapterId, level, notNotify) @@ -112,7 +112,6 @@ local function randomAdvMap(role, chapterId, level, notNotify)
112 local lastMapId = advInfo.mapId --非同一层不连续随出同一张类似的地图 112 local lastMapId = advInfo.mapId --非同一层不连续随出同一张类似的地图
113 local lastChapterId = advInfo.chapter 113 local lastChapterId = advInfo.chapter
114 local lastScore = advInfo.score or {} -- 分数 114 local lastScore = advInfo.score or {} -- 分数
115 - local power = advInfo.power or 100 --MP  
116 115
117 local pool = {} 116 local pool = {}
118 for _, mapId in ipairs(raw_pool) do 117 for _, mapId in ipairs(raw_pool) do
@@ -139,7 +138,6 @@ local function randomAdvMap(role, chapterId, level, notNotify) @@ -139,7 +138,6 @@ local function randomAdvMap(role, chapterId, level, notNotify)
139 advInfo.chapter = chapterId 138 advInfo.chapter = chapterId
140 advInfo.level = level 139 advInfo.level = level
141 advInfo.mapId = mapId 140 advInfo.mapId = mapId
142 - advInfo.power = power  
143 advInfo.score = lastScore 141 advInfo.score = lastScore
144 advInfo.enemyId = 1 --怪递增的索引 142 advInfo.enemyId = 1 --怪递增的索引
145 advInfo.rooms = {} -- {[roomId] = {event = {}, open = {}},} -- event 事件信息(具体信息查看randomEvent), open 是否解锁 143 advInfo.rooms = {} -- {[roomId] = {event = {}, open = {}},} -- event 事件信息(具体信息查看randomEvent), open 是否解锁
@@ -947,22 +945,6 @@ function Adv:clickBlock(roomId, blockId, params) @@ -947,22 +945,6 @@ function Adv:clickBlock(roomId, blockId, params)
947 return status 945 return status
948 end 946 end
949 947
950 ---继续战斗  
951 -function Adv:nextBattleTurn(turn)  
952 - local enemy = self.battle.enemy  
953 - if not enemy or self.battle:checkTurn(turn) then  
954 - return  
955 - end  
956 - local roomId, blockId = self.battle:getRBByEnemyId(enemy.id)  
957 - self.battle:doBattleTurn()  
958 - if self.battle:isBattleEnd() then  
959 - self:backBlockChange(roomId, blockId)  
960 - self:afterRound()  
961 - end  
962 - self:saveDB()  
963 - return true  
964 -end  
965 -  
966 --使用道具产生效果 948 --使用道具产生效果
967 function Adv:useItem(itemId, count, target) 949 function Adv:useItem(itemId, count, target)
968 count = count or 1 950 count = count or 1
@@ -994,9 +976,6 @@ end @@ -994,9 +976,6 @@ end
994 function Adv:usePotion(potionId, potionLevel, target) 976 function Adv:usePotion(potionId, potionLevel, target)
995 -- cost 977 -- cost
996 local potionData = csvdb["adv_potionCsv"][potionId][potionLevel] 978 local potionData = csvdb["adv_potionCsv"][potionId][potionLevel]
997 - -- if self.advInfo.power < skillData.cost then return end  
998 - -- self.advInfo.power = self.advInfo.power - skillData.cost  
999 - -- target  
1000 local enemy = self.battle:getEnemy(target.roomId, target.blockId) 979 local enemy = self.battle:getEnemy(target.roomId, target.blockId)
1001 if not enemy then return end 980 if not enemy then return end
1002 --生效 981 --生效
@@ -1013,29 +992,6 @@ function Adv:usePotion(potionId, potionLevel, target) @@ -1013,29 +992,6 @@ function Adv:usePotion(potionId, potionLevel, target)
1013 return true 992 return true
1014 end 993 end
1015 994
1016 ---使用战斗技能  
1017 -function Adv:useSpecialSkill(skillId)  
1018 - if not csvdb["adv_skill_specialCsv"][skillId] or self.battle:isBattleEnd() then return end  
1019 - local skillLevel = nil  
1020 - for slot, heroId in pairs(self.advTeam.heros) do  
1021 - if self.owner.heros[heroId] then  
1022 - if csvdb["unitCsv"][self.owner.heros[heroId]:getSkinId()]["adv"] == skillId then  
1023 - skillLevel = self.owner.heros[heroId]:getSkillLevel(2)  
1024 - break  
1025 - end  
1026 - end  
1027 - end  
1028 - if not skillLevel or not csvdb["adv_skill_specialCsv"][skillId][skillLevel] then return end  
1029 - local skillData = csvdb["adv_skill_specialCsv"][skillId][skillLevel]  
1030 - --cost  
1031 - if self.advInfo.power < skillData.cost then return end  
1032 - self:changePower( -skillData.cost, 0)  
1033 - -- self.advInfo.power = self.advInfo.power - skillData.cost  
1034 - local enemy = self.battle.enemy  
1035 - self.battle.player:addSpecialSkill(skillId, skillLevel, enemy)  
1036 - return true  
1037 -end  
1038 -  
1039 --敌人死亡 995 --敌人死亡
1040 function Adv:enemyDead(roomId, blockId, escape) 996 function Adv:enemyDead(roomId, blockId, escape)
1041 local room = self.rooms[roomId] 997 local room = self.rooms[roomId]
@@ -1072,17 +1028,6 @@ function Adv:enemyDead(roomId, blockId, escape) @@ -1072,17 +1028,6 @@ function Adv:enemyDead(roomId, blockId, escape)
1072 self:backBlockChange(roomId, blockId) 1028 self:backBlockChange(roomId, blockId)
1073 end 1029 end
1074 1030
1075 ---cType 0 or nil 值 1 百分比  
1076 -function Adv:changePower(value, cType)  
1077 - cType = cType or 0  
1078 - if cType == 0 then  
1079 - self.advInfo.power = self.advInfo.power + value  
1080 - elseif cType == 1 then  
1081 - self.advInfo.power = self.advInfo.power + self.advInfo.power * value / 100  
1082 - end  
1083 - self.advInfo.power = math.floor(math.max(0, self.advInfo.power))  
1084 - self:pushBackEvent(AdvBackEventType.PowerChange)  
1085 -end  
1086 1031
1087 function Adv:pushBackEvent(btype, params) 1032 function Adv:pushBackEvent(btype, params)
1088 table.insert(self.backEvents, {btype = btype, params = params}) 1033 table.insert(self.backEvents, {btype = btype, params = params})
@@ -1144,14 +1089,6 @@ function Adv:backDead(enemyId) @@ -1144,14 +1089,6 @@ function Adv:backDead(enemyId)
1144 self:pushBackEvent(AdvBackEventType.Dead, {enemyId = enemyId}) 1089 self:pushBackEvent(AdvBackEventType.Dead, {enemyId = enemyId})
1145 end 1090 end
1146 1091
1147 -function Adv:backTurnEnd()  
1148 - self:pushBackEvent(AdvBackEventType.TurnEnd, {})  
1149 -end  
1150 -  
1151 -function Adv:backBattleBegin()  
1152 - self:pushBackEvent(AdvBackEventType.BattleBegin, {})  
1153 -end  
1154 -  
1155 function Adv:backTrap() 1092 function Adv:backTrap()
1156 self:pushBackEvent(AdvBackEventType.Trap, {}) 1093 self:pushBackEvent(AdvBackEventType.Trap, {})
1157 end 1094 end
src/adv/AdvBattle.lua
@@ -6,7 +6,6 @@ function Battle:ctor(adv) @@ -6,7 +6,6 @@ function Battle:ctor(adv)
6 self.adv = adv 6 self.adv = adv
7 self.player = nil --玩家 7 self.player = nil --玩家
8 self.isNewPlayer = false 8 self.isNewPlayer = false
9 - self.enemy = nil  
10 self.enemys = {} --怪 9 self.enemys = {} --怪
11 self.tempData = {} -- 临时回合数据 10 self.tempData = {} -- 临时回合数据
12 self:initPlayer() 11 self:initPlayer()
@@ -22,10 +21,6 @@ function Battle:initAfter() @@ -22,10 +21,6 @@ function Battle:initAfter()
22 for _, enemy in pairs(self.enemys) do 21 for _, enemy in pairs(self.enemys) do
23 enemy:initAfter(self.adv.rooms[enemy.roomId].blocks[enemy.blockId].event.enemy) 22 enemy:initAfter(self.adv.rooms[enemy.roomId].blocks[enemy.blockId].event.enemy)
24 end 23 end
25 - if self.adv.advTeam.enemyId then  
26 - local enemy = self:getEnemyById(self.adv.advTeam.enemyId)  
27 - self.enemy = enemy  
28 - end  
29 end 24 end
30 --[[ 25 --[[
31 队伍总属性 = 基础属性 + 等级 × 成长率 26 队伍总属性 = 基础属性 + 等级 × 成长率
@@ -56,6 +51,7 @@ function Battle:initPlayer() @@ -56,6 +51,7 @@ function Battle:initPlayer()
56 player.growth = (self.adv.owner:getRealBattleValue(self.adv.advTeam.heros) / 80) ^ 0.52 + math.floor(heroLevel / 50) / 50 51 player.growth = (self.adv.owner:getRealBattleValue(self.adv.advTeam.heros) / 80) ^ 0.52 + math.floor(heroLevel / 50) / 50
57 player.level = 1 52 player.level = 1
58 player.exp = 0 53 player.exp = 0
  54 + player.sp = 100
59 local activeRelation = self.adv.owner:getHeroActiveRelation() 55 local activeRelation = self.adv.owner:getHeroActiveRelation()
60 local baseAttr = csvdb["adv_unitCsv"][math.floor(self.adv.advInfo.chapter / 100)] 56 local baseAttr = csvdb["adv_unitCsv"][math.floor(self.adv.advInfo.chapter / 100)]
61 for _, attr in pairs(AttsEnumEx) do 57 for _, attr in pairs(AttsEnumEx) do
@@ -121,75 +117,6 @@ function Battle:getRBByEnemyId(enemyId) @@ -121,75 +117,6 @@ function Battle:getRBByEnemyId(enemyId)
121 return enemy.roomId, enemy.blockId 117 return enemy.roomId, enemy.blockId
122 end 118 end
123 119
124 -function Battle:isBattleEnd()  
125 - if not self.enemy then  
126 - return true  
127 - end  
128 -end  
129 -  
130 ---战斗开始  
131 -function Battle:battleBegin(roomId, blockId, isQuick)  
132 - self.tempData = {} -- 清理上次战斗数据  
133 - if self.enemy then  
134 - self.player:reset(self.adv.advTeam.player)  
135 - self.enemy:reset(self.adv.rooms[self.enemy.roomId].blocks[self.enemy.blockId].event.enemy)  
136 - end  
137 - local enemy = self:getEnemy(roomId, blockId)  
138 - if enemy then  
139 - self.adv:backBattleBegin()  
140 - self.enemy = enemy  
141 - self.player:battleBegin()  
142 - self.enemy:battleBegin()  
143 - if not isQuick then  
144 - self:doBattleTurn()  
145 - return  
146 - end  
147 - while not enemy.isDead and not self.player.isDead do  
148 - self:doBattleTurn()  
149 - end  
150 - end  
151 -end  
152 -  
153 --- 检查回合数同步  
154 -function Battle:checkTurn(turn)  
155 - if self.tempData[turn] then  
156 - return true  
157 - end  
158 -end  
159 -  
160 --- 战斗内一回合  
161 -function Battle:doBattleTurn()  
162 - local enemy = self.enemy  
163 - -- 玩家先出手  
164 - self.adv:backAtk(nil, enemy.id)  
165 - self:doPlayerTurn(self.player, enemy)  
166 - --是否无法攻击  
167 - if not enemy.isDead and not enemy:hadBuff(Buff.CANT_BACK_ATK) then  
168 - self.adv:backAtk(enemy.id, nil)  
169 - self:doPlayerTurn(enemy, self.player)  
170 - end  
171 - -- 判定死亡  
172 - if enemy.isDead or self.player.isDead then  
173 - local deadPlayer = enemy.isDead and enemy or self.player  
174 - deadPlayer:battleEnd()  
175 - self.enemy = nil  
176 - else  
177 - self.adv:backTurnEnd()  
178 - end  
179 - self:getTempDB()  
180 -end  
181 -  
182 ---战斗内角色回合逻辑  
183 -function Battle:doPlayerTurn(atkPlayer, hurtPlayer)  
184 - atkPlayer:beforeTurn()  
185 - if #(atkPlayer.skillOrder) > 0 then  
186 - atkPlayer:releaseSpecialSkill()  
187 - else  
188 - hurtPlayer:hurt(atkPlayer:getHurtValue(), atkPlayer, {hurtType = 1})  
189 - end  
190 - atkPlayer:afterTurn()  
191 - atkPlayer:clearTurn()  
192 -end  
193 120
194 --触发全员被动技能 121 --触发全员被动技能
195 function Battle:triggerPassive(condType, params) 122 function Battle:triggerPassive(condType, params)
@@ -225,24 +152,9 @@ function Battle:afterRound() @@ -225,24 +152,9 @@ function Battle:afterRound()
225 end 152 end
226 end 153 end
227 154
228 --- 写入临时数据  
229 -function Battle:getTempDB()  
230 - local turnDB = {}  
231 - if self.enemy then  
232 - turnDB.enemy = self.enemy:getDB()  
233 - end  
234 - turnDB.player = self.player:getDB()  
235 - table.insert(self.tempData, turnDB)  
236 -end  
237 155
238 --写入数据 156 --写入数据
239 function Battle:getDB() 157 function Battle:getDB()
240 - if not self.enemy then  
241 - self.adv.advTeam.enemyId = nil  
242 - else  
243 - self.adv.advTeam.enemyId = self.enemy.id  
244 - return  
245 - end  
246 self.adv.advTeam.player = self.player:getDB() 158 self.adv.advTeam.player = self.player:getDB()
247 for _, enemy in ipairs(self.enemys) do 159 for _, enemy in ipairs(self.enemys) do
248 local block = self.adv.rooms[enemy.roomId].blocks[enemy.blockId] 160 local block = self.adv.rooms[enemy.roomId].blocks[enemy.blockId]
src/adv/AdvBuff.lua
@@ -15,7 +15,7 @@ Buff.IMMNUE_BUFF = 11 -- 免疫buff @@ -15,7 +15,7 @@ Buff.IMMNUE_BUFF = 11 -- 免疫buff
15 Buff.CLEAR_BUFF = 12 -- 清除buff 15 Buff.CLEAR_BUFF = 12 -- 清除buff
16 Buff.CANT_SKILL = 13 -- 禁止技能 16 Buff.CANT_SKILL = 13 -- 禁止技能
17 Buff.OPEN_BLOCK = 14 -- 翻开格子(每回合) 17 Buff.OPEN_BLOCK = 14 -- 翻开格子(每回合)
18 -Buff.POWER_CHANGE = 15 -- MP变化(每回合) 18 +Buff.SP_CHANGE = 15 -- sp变化(每回合)
19 Buff.HP_CHANGE_NOW = 16 -- 生命变化(每回合生效,立刻生效) 19 Buff.HP_CHANGE_NOW = 16 -- 生命变化(每回合生效,立刻生效)
20 20
21 --角色一些属性的变化 21 --角色一些属性的变化
@@ -59,14 +59,6 @@ local BuffFactory = { @@ -59,14 +59,6 @@ local BuffFactory = {
59 self.owner:hurt(-value, self.release, {hurtType = 2}) 59 self.owner:hurt(-value, self.release, {hurtType = 2})
60 end 60 end
61 end 61 end
62 - _Buff._afterTurn = function(self)  
63 - local value = self:effect()  
64 - if value > 0 then  
65 - self.owner:recover(value, self.release)  
66 - elseif value < 0 then  
67 - self.owner:hurt(-value, self.release, {hurtType = 2})  
68 - end  
69 - end  
70 _Buff._effectValue = function(self) 62 _Buff._effectValue = function(self)
71 return self._changeV 63 return self._changeV
72 end 64 end
@@ -177,24 +169,16 @@ local BuffFactory = { @@ -177,24 +169,16 @@ local BuffFactory = {
177 local roomNum = self:effect() 169 local roomNum = self:effect()
178 self.owner.battle.adv:openBlockRand(roomNum) 170 self.owner.battle.adv:openBlockRand(roomNum)
179 end 171 end
180 - _Buff._afterTurn = function(self)  
181 - local roomNum = self:effect()  
182 - self.owner.battle.adv:openBlockRand(roomNum)  
183 - end  
184 _Buff._effectValue = function(self) 172 _Buff._effectValue = function(self)
185 return self.buffData.effectValue1 173 return self.buffData.effectValue1
186 end 174 end
187 end, 175 end,
188 176
189 - [Buff.POWER_CHANGE] = function(_Buff) 177 + [Buff.SP_CHANGE] = function(_Buff)
190 --cType 0 or nil 值 1 百分比 178 --cType 0 or nil 值 1 百分比
191 _Buff._afterRound = function(self) 179 _Buff._afterRound = function(self)
192 local value, cType = self:effect() 180 local value, cType = self:effect()
193 - self.owner.battle.adv:changePower(value, cType)  
194 - end  
195 - _Buff._afterTurn = function(self)  
196 - local value, cType = self:effect()  
197 - self.owner.battle.adv:changePower(value, cType) 181 + self.owner:changeSp(value, cType)
198 end 182 end
199 _Buff._effectValue = function(self) 183 _Buff._effectValue = function(self)
200 return self.buffData.effectValue2, self.buffData.effectValue1 184 return self.buffData.effectValue2, self.buffData.effectValue1
@@ -213,7 +197,6 @@ local BuffFactory = { @@ -213,7 +197,6 @@ local BuffFactory = {
213 if self._changeV < 0 then 197 if self._changeV < 0 then
214 self._changeV = -self.release:getHurtValue(-self._changeV) 198 self._changeV = -self.release:getHurtValue(-self._changeV)
215 end 199 end
216 - self:afterTurn()  
217 end 200 end
218 _Buff._initDB = function(self, data) 201 _Buff._initDB = function(self, data)
219 self._changeV = data.cv 202 self._changeV = data.cv
@@ -226,14 +209,6 @@ local BuffFactory = { @@ -226,14 +209,6 @@ local BuffFactory = {
226 self.owner:hurt(-value, self.release, {hurtType = 2}) 209 self.owner:hurt(-value, self.release, {hurtType = 2})
227 end 210 end
228 end 211 end
229 - _Buff._afterTurn = function(self)  
230 - local value = self:effect()  
231 - if value > 0 then  
232 - self.owner:recover(value, self.release)  
233 - elseif value < 0 then  
234 - self.owner:hurt(-value, self.release, {hurtType = 2})  
235 - end  
236 - end  
237 _Buff._effectValue = function(self) 212 _Buff._effectValue = function(self)
238 return self._changeV 213 return self._changeV
239 end 214 end
@@ -246,7 +221,7 @@ local BuffFactory = { @@ -246,7 +221,7 @@ local BuffFactory = {
246 function Buff:ctor(owner, id) 221 function Buff:ctor(owner, id)
247 self.owner = owner 222 self.owner = owner
248 self.id = id 223 self.id = id
249 - self.buffData = csvdb["adv_buffCsv"][self.id] 224 + self.buffData = csvdb["adv_map_buffCsv"][self.id]
250 self.isDel = false 225 self.isDel = false
251 self.roundSpace = 0 --生效间隔 226 self.roundSpace = 0 --生效间隔
252 self.turnSpace = 0 --生效间隔 227 self.turnSpace = 0 --生效间隔
@@ -308,42 +283,6 @@ function Buff:battleEnd() @@ -308,42 +283,6 @@ function Buff:battleEnd()
308 end 283 end
309 end 284 end
310 285
311 -function Buff:beforeTurn()  
312 - if self.isDel or self.owner.isDead or self.buffData.turn == 0 then return end  
313 - if self.turnSpace > 0 then  
314 - return  
315 - end  
316 - if self._beforeTurn then  
317 - self:_beforeTurn()  
318 - end  
319 -end  
320 -  
321 -function Buff:afterTurn()  
322 - if self.isDel or self.owner.isDead or self.buffData.turn == 0 then return end  
323 - if self.turnSpace > 0 then  
324 - self.turnSpace = self.turnSpace - 1  
325 - self:decTurn()  
326 - return  
327 - end  
328 - if self._afterTurn then  
329 - self:_afterTurn()  
330 - end  
331 - if self.buffData.turnTime > 0 then  
332 - self.turnSpace = self.buffData.turnTime  
333 - end  
334 - self:decTurn()  
335 -end  
336 -  
337 -function Buff:decTurn()  
338 - if self.buffData.turn == 0 then  
339 - return  
340 - end  
341 - self.turn = self.turn - 1  
342 - if self.turn <= 0 then  
343 - self.isDel = true  
344 - end  
345 -end  
346 -  
347 function Buff:afterRound() 286 function Buff:afterRound()
348 if self.isDel or self.owner.isDead or self.buffData.round == 0 then return end 287 if self.isDel or self.owner.isDead or self.buffData.round == 0 then return end
349 if self.roundSpace > 0 then 288 if self.roundSpace > 0 then
src/adv/AdvPassive.lua
@@ -196,13 +196,11 @@ function Passive:ctor(owner, data) @@ -196,13 +196,11 @@ function Passive:ctor(owner, data)
196 self.owner = owner 196 self.owner = owner
197 self.id = data.id 197 self.id = data.id
198 self.level = data.level or 1 198 self.level = data.level or 1
199 - self.passiveData = csvdb["adv_skill_passiveCsv"][self.id][self.level] 199 + self.passiveData = csvdb["adv_map_passiveCsv"][self.id][self.level]
200 self.isDel = false 200 self.isDel = false
201 self.round = data.round or 0 --触发剩余回合数 201 self.round = data.round or 0 --触发剩余回合数
202 self.count = data.count or self.passiveData.count --触发剩余次数 202 self.count = data.count or self.passiveData.count --触发剩余次数
203 self.delay = data.delay or self.passiveData.delayRound --触发延迟回合数 203 self.delay = data.delay or self.passiveData.delayRound --触发延迟回合数
204 - self.turn = 0 --战斗内回合数  
205 - self.delayTurn = self.passiveData.delayTurn --战斗内延迟回合数  
206 204
207 self.effects = self.passiveData.effect:toTableArray(true) 205 self.effects = self.passiveData.effect:toTableArray(true)
208 self.filters = {} 206 self.filters = {}
@@ -257,25 +255,6 @@ function Passive:effect(trigger) @@ -257,25 +255,6 @@ function Passive:effect(trigger)
257 end 255 end
258 end 256 end
259 257
260 -function Passive:battleBegin()  
261 - if self.isDel or self.owner.isDead then return end  
262 - self.turn = 0  
263 - self.delayTurn = self.passiveData.delayTurn  
264 -end  
265 -  
266 -function Passive:afterTurn()  
267 - if self.isDel or self.owner.isDead then return end  
268 - if self._afterTurn then  
269 - self:_afterTurn() --有的触发自己检测在这里检查  
270 - end  
271 - if self.turn > 0 then --战斗内回合  
272 - self.turn = self.turn - 1  
273 - end  
274 - if self.delayTurn > 0 then  
275 - self.delayTurn = self.delayTurn - 1  
276 - end  
277 -end  
278 -  
279 function Passive:afterRound() 258 function Passive:afterRound()
280 if self.isDel or self.owner.isDead then return end 259 if self.isDel or self.owner.isDead then return end
281 if self._afterRound then 260 if self._afterRound then
@@ -291,7 +270,7 @@ end @@ -291,7 +270,7 @@ end
291 270
292 -- 可以触发 271 -- 可以触发
293 function Passive:canTrigger( ) 272 function Passive:canTrigger( )
294 - return self.count > 0 and self.delay <= 0 and self.delayTurn <= 0 273 + return self.count > 0 and self.delay <= 0
295 end 274 end
296 275
297 function Passive:trigger(condType, params) --触发检查 276 function Passive:trigger(condType, params) --触发检查
src/adv/AdvPlayer.lua
@@ -49,21 +49,6 @@ function BaseObject:reset(data) @@ -49,21 +49,6 @@ function BaseObject:reset(data)
49 self:initAfter(data) 49 self:initAfter(data)
50 end 50 end
51 51
52 -function BaseObject:beforeTurn()  
53 - for _, buff in ipairs(self.buffs) do  
54 - buff:beforeTurn()  
55 - end  
56 -end  
57 -  
58 -function BaseObject:afterTurn()  
59 - for _, passive in ipairs(self.passives) do  
60 - passive:afterTurn()  
61 - end  
62 - for _, buff in ipairs(self.buffs) do  
63 - buff:afterTurn()  
64 - end  
65 -end  
66 -  
67 function BaseObject:afterRound() 52 function BaseObject:afterRound()
68 for _, passive in ipairs(self.passives) do 53 for _, passive in ipairs(self.passives) do
69 passive:afterRound(self) 54 passive:afterRound(self)
@@ -73,15 +58,6 @@ function BaseObject:afterRound() @@ -73,15 +58,6 @@ function BaseObject:afterRound()
73 end 58 end
74 end 59 end
75 60
76 -function BaseObject:clearTurn()  
77 - for i = #self.buffs, 1, -1 do  
78 - if self.buffs[i].isDel then  
79 - self.battle.adv:backBuff(self.id, self.buffs[i].id, true)  
80 - self.buffs[i]:endBuff()  
81 - table.remove(self.buffs, i)  
82 - end  
83 - end  
84 -end  
85 61
86 function BaseObject:clearRound() 62 function BaseObject:clearRound()
87 for i = #self.passives, 1, -1 do 63 for i = #self.passives, 1, -1 do
@@ -117,7 +93,7 @@ end @@ -117,7 +93,7 @@ end
117 93
118 function BaseObject:addPassive(params) 94 function BaseObject:addPassive(params)
119 local skillId = params.id 95 local skillId = params.id
120 - local skillData = csvdb["adv_skill_passiveCsv"][skillId] 96 + local skillData = csvdb["adv_map_passiveCsv"][skillId]
121 if not skillData then return end 97 if not skillData then return end
122 local level = params.level or 1 98 local level = params.level or 1
123 if not skillData[level] then return end 99 if not skillData[level] then return end
@@ -127,7 +103,7 @@ function BaseObject:addPassive(params) @@ -127,7 +103,7 @@ function BaseObject:addPassive(params)
127 end 103 end
128 104
129 function BaseObject:addBuff(buffId, releaser) 105 function BaseObject:addBuff(buffId, releaser)
130 - local buffData = csvdb["adv_buffCsv"][buffId] 106 + local buffData = csvdb["adv_map_buffCsv"][buffId]
131 if not buffData then return end 107 if not buffData then return end
132 for _, buff in ipairs(self.buffs) do 108 for _, buff in ipairs(self.buffs) do
133 if not buff.isDel and (buff:getType() == Buff.CLEAR_BUFF or buff:getType() == Buff.IMMNUE_BUFF) then 109 if not buff.isDel and (buff:getType() == Buff.CLEAR_BUFF or buff:getType() == Buff.IMMNUE_BUFF) then
@@ -332,14 +308,6 @@ function BaseObject:addSpecialSkill(skillId, skillLevel, target) @@ -332,14 +308,6 @@ function BaseObject:addSpecialSkill(skillId, skillLevel, target)
332 table.insert(self.skillOrder, skillData) 308 table.insert(self.skillOrder, skillData)
333 end 309 end
334 310
335 -function BaseObject:releaseSpecialSkill()  
336 - local skillData = table.remove(self.skillOrder, 1)  
337 - local skillSet = csvdb["adv_skill_specialCsv"][skillData.id][skillData.level]  
338 - for _, skillId in ipairs(skillSet.skillId:toArray(true, "=")) do  
339 - self:releaseSkill(skillId, skillData.target)  
340 - end  
341 -end  
342 -  
343 function BaseObject:releaseSkill(skillId, target) 311 function BaseObject:releaseSkill(skillId, target)
344 if self:hadBuff(Buff.CANT_SKILL) then return end -- 针对 怪物 312 if self:hadBuff(Buff.CANT_SKILL) then return end -- 针对 怪物
345 local skill = Skill.new(self, {id = skillId, target = target}) 313 local skill = Skill.new(self, {id = skillId, target = target})
@@ -422,6 +390,9 @@ function BaseObject:triggerPassive(condType, params) @@ -422,6 +390,9 @@ function BaseObject:triggerPassive(condType, params)
422 end 390 end
423 end 391 end
424 392
  393 +function BaseObject:changeSp()
  394 +end
  395 +
425 local Enemy = class("Enemy", BaseObject) 396 local Enemy = class("Enemy", BaseObject)
426 function Enemy:ctor(battle, mId, monsterId, roomId, blockId, lock, enemy) 397 function Enemy:ctor(battle, mId, monsterId, roomId, blockId, lock, enemy)
427 Enemy.super.ctor(self, battle) 398 Enemy.super.ctor(self, battle)
@@ -452,18 +423,34 @@ function Player:initData(data) @@ -452,18 +423,34 @@ function Player:initData(data)
452 self.level = data.level or 1 --level 每增加1级 属性增长 growth * baseAttr 423 self.level = data.level or 1 --level 每增加1级 属性增长 growth * baseAttr
453 self.growth = data.growth or 0 424 self.growth = data.growth or 0
454 self.exp = data.exp or 0 425 self.exp = data.exp or 0
  426 + self.sp = data.sp or 100
455 end 427 end
456 428
457 function Player:addExp(value) 429 function Player:addExp(value)
458 -- todo 430 -- todo
459 end 431 end
460 432
  433 +--cType 0 or nil 值 1 百分比
  434 +function Player:changeSp(value, cType)
  435 + cType = cType or 0
  436 + if cType == 0 then
  437 + self.sp = self.sp + value
  438 + elseif cType == 1 then
  439 + self.sp = self.sp + self.sp * value / 100
  440 + end
  441 + self.sp = math.floor(math.max(0, self.sp))
  442 + self.battle.adv:pushBackEvent(AdvBackEventType.SpChange)
  443 +end
  444 +
  445 +
461 function Player:getDB() 446 function Player:getDB()
462 local db = Player.super.getDB(self) 447 local db = Player.super.getDB(self)
463 - for _ , field in pairs({"level", "exp", "growth"}) do 448 + for _ , field in pairs({"level", "exp", "growth", "sp"}) do
464 db[field] = self[field] 449 db[field] = self[field]
465 end 450 end
466 return db 451 return db
467 end 452 end
468 453
  454 +
  455 +
469 return table.pack(Player, Enemy) 456 return table.pack(Player, Enemy)
470 \ No newline at end of file 457 \ No newline at end of file
src/adv/AdvSkill.lua
@@ -5,7 +5,7 @@ function Skill:ctor(owner, data) @@ -5,7 +5,7 @@ function Skill:ctor(owner, data)
5 self.id = data.id 5 self.id = data.id
6 self.defaultTarget = data.target 6 self.defaultTarget = data.target
7 7
8 - self.skillData = csvdb["adv_skillCsv"][self.id] 8 + self.skillData = csvdb["adv_map_skillCsv"][self.id]
9 self.targets = self:initTargets() 9 self.targets = self:initTargets()
10 end 10 end
11 11