Commit 3b0526d2fbca515f69fd15311d075cf04aefce88
1 parent
9407543b
冒险demo
Showing
9 changed files
with
31 additions
and
303 deletions
Show diff stats
src/GlobalVar.lua
src/ProtocolCode.lua
src/actions/AdvAction.lua
... | ... | @@ -90,17 +90,6 @@ function _M.usePotionRpc(agent, data) |
90 | 90 | return true |
91 | 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 | 94 | function _M.exitAdvRpc(agent, data) |
106 | 95 | local role = agent.role |
... | ... | @@ -111,18 +100,5 @@ function _M.exitAdvRpc(agent, data) |
111 | 100 | return true |
112 | 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 | 104 | return _M |
129 | 105 | \ No newline at end of file | ... | ... |
src/adv/Adv.lua
... | ... | @@ -112,7 +112,6 @@ local function randomAdvMap(role, chapterId, level, notNotify) |
112 | 112 | local lastMapId = advInfo.mapId --非同一层不连续随出同一张类似的地图 |
113 | 113 | local lastChapterId = advInfo.chapter |
114 | 114 | local lastScore = advInfo.score or {} -- 分数 |
115 | - local power = advInfo.power or 100 --MP | |
116 | 115 | |
117 | 116 | local pool = {} |
118 | 117 | for _, mapId in ipairs(raw_pool) do |
... | ... | @@ -139,7 +138,6 @@ local function randomAdvMap(role, chapterId, level, notNotify) |
139 | 138 | advInfo.chapter = chapterId |
140 | 139 | advInfo.level = level |
141 | 140 | advInfo.mapId = mapId |
142 | - advInfo.power = power | |
143 | 141 | advInfo.score = lastScore |
144 | 142 | advInfo.enemyId = 1 --怪递增的索引 |
145 | 143 | advInfo.rooms = {} -- {[roomId] = {event = {}, open = {}},} -- event 事件信息(具体信息查看randomEvent), open 是否解锁 |
... | ... | @@ -947,22 +945,6 @@ function Adv:clickBlock(roomId, blockId, params) |
947 | 945 | return status |
948 | 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 | 949 | function Adv:useItem(itemId, count, target) |
968 | 950 | count = count or 1 |
... | ... | @@ -994,9 +976,6 @@ end |
994 | 976 | function Adv:usePotion(potionId, potionLevel, target) |
995 | 977 | -- cost |
996 | 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 | 979 | local enemy = self.battle:getEnemy(target.roomId, target.blockId) |
1001 | 980 | if not enemy then return end |
1002 | 981 | --生效 |
... | ... | @@ -1013,29 +992,6 @@ function Adv:usePotion(potionId, potionLevel, target) |
1013 | 992 | return true |
1014 | 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 | 996 | function Adv:enemyDead(roomId, blockId, escape) |
1041 | 997 | local room = self.rooms[roomId] |
... | ... | @@ -1072,17 +1028,6 @@ function Adv:enemyDead(roomId, blockId, escape) |
1072 | 1028 | self:backBlockChange(roomId, blockId) |
1073 | 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 | 1032 | function Adv:pushBackEvent(btype, params) |
1088 | 1033 | table.insert(self.backEvents, {btype = btype, params = params}) |
... | ... | @@ -1144,14 +1089,6 @@ function Adv:backDead(enemyId) |
1144 | 1089 | self:pushBackEvent(AdvBackEventType.Dead, {enemyId = enemyId}) |
1145 | 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 | 1092 | function Adv:backTrap() |
1156 | 1093 | self:pushBackEvent(AdvBackEventType.Trap, {}) |
1157 | 1094 | end | ... | ... |
src/adv/AdvBattle.lua
... | ... | @@ -6,7 +6,6 @@ function Battle:ctor(adv) |
6 | 6 | self.adv = adv |
7 | 7 | self.player = nil --玩家 |
8 | 8 | self.isNewPlayer = false |
9 | - self.enemy = nil | |
10 | 9 | self.enemys = {} --怪 |
11 | 10 | self.tempData = {} -- 临时回合数据 |
12 | 11 | self:initPlayer() |
... | ... | @@ -22,10 +21,6 @@ function Battle:initAfter() |
22 | 21 | for _, enemy in pairs(self.enemys) do |
23 | 22 | enemy:initAfter(self.adv.rooms[enemy.roomId].blocks[enemy.blockId].event.enemy) |
24 | 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 | 24 | end |
30 | 25 | --[[ |
31 | 26 | 队伍总属性 = 基础属性 + 等级 × 成长率 |
... | ... | @@ -56,6 +51,7 @@ function Battle:initPlayer() |
56 | 51 | player.growth = (self.adv.owner:getRealBattleValue(self.adv.advTeam.heros) / 80) ^ 0.52 + math.floor(heroLevel / 50) / 50 |
57 | 52 | player.level = 1 |
58 | 53 | player.exp = 0 |
54 | + player.sp = 100 | |
59 | 55 | local activeRelation = self.adv.owner:getHeroActiveRelation() |
60 | 56 | local baseAttr = csvdb["adv_unitCsv"][math.floor(self.adv.advInfo.chapter / 100)] |
61 | 57 | for _, attr in pairs(AttsEnumEx) do |
... | ... | @@ -121,75 +117,6 @@ function Battle:getRBByEnemyId(enemyId) |
121 | 117 | return enemy.roomId, enemy.blockId |
122 | 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 | 122 | function Battle:triggerPassive(condType, params) |
... | ... | @@ -225,24 +152,9 @@ function Battle:afterRound() |
225 | 152 | end |
226 | 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 | 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 | 158 | self.adv.advTeam.player = self.player:getDB() |
247 | 159 | for _, enemy in ipairs(self.enemys) do |
248 | 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 | 15 | Buff.CLEAR_BUFF = 12 -- 清除buff |
16 | 16 | Buff.CANT_SKILL = 13 -- 禁止技能 |
17 | 17 | Buff.OPEN_BLOCK = 14 -- 翻开格子(每回合) |
18 | -Buff.POWER_CHANGE = 15 -- MP变化(每回合) | |
18 | +Buff.SP_CHANGE = 15 -- sp变化(每回合) | |
19 | 19 | Buff.HP_CHANGE_NOW = 16 -- 生命变化(每回合生效,立刻生效) |
20 | 20 | |
21 | 21 | --角色一些属性的变化 |
... | ... | @@ -59,14 +59,6 @@ local BuffFactory = { |
59 | 59 | self.owner:hurt(-value, self.release, {hurtType = 2}) |
60 | 60 | end |
61 | 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 | 62 | _Buff._effectValue = function(self) |
71 | 63 | return self._changeV |
72 | 64 | end |
... | ... | @@ -177,24 +169,16 @@ local BuffFactory = { |
177 | 169 | local roomNum = self:effect() |
178 | 170 | self.owner.battle.adv:openBlockRand(roomNum) |
179 | 171 | end |
180 | - _Buff._afterTurn = function(self) | |
181 | - local roomNum = self:effect() | |
182 | - self.owner.battle.adv:openBlockRand(roomNum) | |
183 | - end | |
184 | 172 | _Buff._effectValue = function(self) |
185 | 173 | return self.buffData.effectValue1 |
186 | 174 | end |
187 | 175 | end, |
188 | 176 | |
189 | - [Buff.POWER_CHANGE] = function(_Buff) | |
177 | + [Buff.SP_CHANGE] = function(_Buff) | |
190 | 178 | --cType 0 or nil 值 1 百分比 |
191 | 179 | _Buff._afterRound = function(self) |
192 | 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 | 182 | end |
199 | 183 | _Buff._effectValue = function(self) |
200 | 184 | return self.buffData.effectValue2, self.buffData.effectValue1 |
... | ... | @@ -213,7 +197,6 @@ local BuffFactory = { |
213 | 197 | if self._changeV < 0 then |
214 | 198 | self._changeV = -self.release:getHurtValue(-self._changeV) |
215 | 199 | end |
216 | - self:afterTurn() | |
217 | 200 | end |
218 | 201 | _Buff._initDB = function(self, data) |
219 | 202 | self._changeV = data.cv |
... | ... | @@ -226,14 +209,6 @@ local BuffFactory = { |
226 | 209 | self.owner:hurt(-value, self.release, {hurtType = 2}) |
227 | 210 | end |
228 | 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 | 212 | _Buff._effectValue = function(self) |
238 | 213 | return self._changeV |
239 | 214 | end |
... | ... | @@ -246,7 +221,7 @@ local BuffFactory = { |
246 | 221 | function Buff:ctor(owner, id) |
247 | 222 | self.owner = owner |
248 | 223 | self.id = id |
249 | - self.buffData = csvdb["adv_buffCsv"][self.id] | |
224 | + self.buffData = csvdb["adv_map_buffCsv"][self.id] | |
250 | 225 | self.isDel = false |
251 | 226 | self.roundSpace = 0 --生效间隔 |
252 | 227 | self.turnSpace = 0 --生效间隔 |
... | ... | @@ -308,42 +283,6 @@ function Buff:battleEnd() |
308 | 283 | end |
309 | 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 | 286 | function Buff:afterRound() |
348 | 287 | if self.isDel or self.owner.isDead or self.buffData.round == 0 then return end |
349 | 288 | if self.roundSpace > 0 then | ... | ... |
src/adv/AdvPassive.lua
... | ... | @@ -196,13 +196,11 @@ function Passive:ctor(owner, data) |
196 | 196 | self.owner = owner |
197 | 197 | self.id = data.id |
198 | 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 | 200 | self.isDel = false |
201 | 201 | self.round = data.round or 0 --触发剩余回合数 |
202 | 202 | self.count = data.count or self.passiveData.count --触发剩余次数 |
203 | 203 | self.delay = data.delay or self.passiveData.delayRound --触发延迟回合数 |
204 | - self.turn = 0 --战斗内回合数 | |
205 | - self.delayTurn = self.passiveData.delayTurn --战斗内延迟回合数 | |
206 | 204 | |
207 | 205 | self.effects = self.passiveData.effect:toTableArray(true) |
208 | 206 | self.filters = {} |
... | ... | @@ -257,25 +255,6 @@ function Passive:effect(trigger) |
257 | 255 | end |
258 | 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 | 258 | function Passive:afterRound() |
280 | 259 | if self.isDel or self.owner.isDead then return end |
281 | 260 | if self._afterRound then |
... | ... | @@ -291,7 +270,7 @@ end |
291 | 270 | |
292 | 271 | -- 可以触发 |
293 | 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 | 274 | end |
296 | 275 | |
297 | 276 | function Passive:trigger(condType, params) --触发检查 | ... | ... |
src/adv/AdvPlayer.lua
... | ... | @@ -49,21 +49,6 @@ function BaseObject:reset(data) |
49 | 49 | self:initAfter(data) |
50 | 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 | 52 | function BaseObject:afterRound() |
68 | 53 | for _, passive in ipairs(self.passives) do |
69 | 54 | passive:afterRound(self) |
... | ... | @@ -73,15 +58,6 @@ function BaseObject:afterRound() |
73 | 58 | end |
74 | 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 | 62 | function BaseObject:clearRound() |
87 | 63 | for i = #self.passives, 1, -1 do |
... | ... | @@ -117,7 +93,7 @@ end |
117 | 93 | |
118 | 94 | function BaseObject:addPassive(params) |
119 | 95 | local skillId = params.id |
120 | - local skillData = csvdb["adv_skill_passiveCsv"][skillId] | |
96 | + local skillData = csvdb["adv_map_passiveCsv"][skillId] | |
121 | 97 | if not skillData then return end |
122 | 98 | local level = params.level or 1 |
123 | 99 | if not skillData[level] then return end |
... | ... | @@ -127,7 +103,7 @@ function BaseObject:addPassive(params) |
127 | 103 | end |
128 | 104 | |
129 | 105 | function BaseObject:addBuff(buffId, releaser) |
130 | - local buffData = csvdb["adv_buffCsv"][buffId] | |
106 | + local buffData = csvdb["adv_map_buffCsv"][buffId] | |
131 | 107 | if not buffData then return end |
132 | 108 | for _, buff in ipairs(self.buffs) do |
133 | 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 | 308 | table.insert(self.skillOrder, skillData) |
333 | 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 | 311 | function BaseObject:releaseSkill(skillId, target) |
344 | 312 | if self:hadBuff(Buff.CANT_SKILL) then return end -- 针对 怪物 |
345 | 313 | local skill = Skill.new(self, {id = skillId, target = target}) |
... | ... | @@ -422,6 +390,9 @@ function BaseObject:triggerPassive(condType, params) |
422 | 390 | end |
423 | 391 | end |
424 | 392 | |
393 | +function BaseObject:changeSp() | |
394 | +end | |
395 | + | |
425 | 396 | local Enemy = class("Enemy", BaseObject) |
426 | 397 | function Enemy:ctor(battle, mId, monsterId, roomId, blockId, lock, enemy) |
427 | 398 | Enemy.super.ctor(self, battle) |
... | ... | @@ -452,18 +423,34 @@ function Player:initData(data) |
452 | 423 | self.level = data.level or 1 --level 每增加1级 属性增长 growth * baseAttr |
453 | 424 | self.growth = data.growth or 0 |
454 | 425 | self.exp = data.exp or 0 |
426 | + self.sp = data.sp or 100 | |
455 | 427 | end |
456 | 428 | |
457 | 429 | function Player:addExp(value) |
458 | 430 | -- todo |
459 | 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 | 446 | function Player:getDB() |
462 | 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 | 449 | db[field] = self[field] |
465 | 450 | end |
466 | 451 | return db |
467 | 452 | end |
468 | 453 | |
454 | + | |
455 | + | |
469 | 456 | return table.pack(Player, Enemy) |
470 | 457 | \ No newline at end of file | ... | ... |
src/adv/AdvSkill.lua