Commit b0fe18174e4bb2b89ae0668e044b9cb8d41ca952

Authored by zhouahaihai
1 parent bedca62d

冒险分数

@@ -99,4 +99,12 @@ AdvBackEventType = { @@ -99,4 +99,12 @@ AdvBackEventType = {
99 BlockChange = 9, -- 块改变 99 BlockChange = 9, -- 块改变
100 PowerChange = 10, --体力改变 100 PowerChange = 10, --体力改变
101 Dead = 11, --怪死亡 101 Dead = 11, --怪死亡
  102 +}
  103 +
  104 +AdvScoreType = {
  105 + Level = 1,
  106 + Kill = 2,
  107 + Item = 3,
  108 + Hurt = 4,
  109 + Block = 5,
102 } 110 }
103 \ No newline at end of file 111 \ No newline at end of file
@@ -104,9 +104,12 @@ local function randomAdvMap(role, chapterId, level, notNotify) @@ -104,9 +104,12 @@ local function randomAdvMap(role, chapterId, level, notNotify)
104 --随出地图 104 --随出地图
105 local raw_pool = chapterData.mapid:toArray(true, "=") 105 local raw_pool = chapterData.mapid:toArray(true, "=")
106 local advInfo = role:getProperty("advInfo") 106 local advInfo = role:getProperty("advInfo")
  107 +
107 local lastMapId = advInfo.mapId --非同一层不连续随出同一张类似的地图 108 local lastMapId = advInfo.mapId --非同一层不连续随出同一张类似的地图
108 local lastChapterId = advInfo.chapter 109 local lastChapterId = advInfo.chapter
  110 + local lastScore = advInfo.score or {} -- 分数
109 local power = advInfo.power or 100 --体力 111 local power = advInfo.power or 100 --体力
  112 +
110 local pool = {} 113 local pool = {}
111 for _, mapId in ipairs(raw_pool) do 114 for _, mapId in ipairs(raw_pool) do
112 local temp = csvdb["mapCsv"][mapId] 115 local temp = csvdb["mapCsv"][mapId]
@@ -128,12 +131,12 @@ local function randomAdvMap(role, chapterId, level, notNotify) @@ -128,12 +131,12 @@ local function randomAdvMap(role, chapterId, level, notNotify)
128 return 131 return
129 end 132 end
130 133
131 -  
132 table.clear(advInfo) 134 table.clear(advInfo)
133 advInfo.chapter = chapterId 135 advInfo.chapter = chapterId
134 advInfo.level = level 136 advInfo.level = level
135 advInfo.mapId = mapId 137 advInfo.mapId = mapId
136 advInfo.power = power 138 advInfo.power = power
  139 + advInfo.score = lastScore
137 advInfo.enemyId = 1 --怪递增的索引 140 advInfo.enemyId = 1 --怪递增的索引
138 advInfo.rooms = {} -- {[roomId] = {event = {}, open = {}},} -- event 事件信息(具体信息查看randomEvent), open 是否解锁 141 advInfo.rooms = {} -- {[roomId] = {event = {}, open = {}},} -- event 事件信息(具体信息查看randomEvent), open 是否解锁
139 --事件随机 142 --事件随机
@@ -425,6 +428,8 @@ function Room:openBlock(block, adv) @@ -425,6 +428,8 @@ function Room:openBlock(block, adv)
425 self.info.open[block.blockId] = 1 428 self.info.open[block.blockId] = 1
426 end 429 end
427 430
  431 + adv:scoreChange(AdvScoreType.Block)
  432 +
428 if not self.isShow then 433 if not self.isShow then
429 self.isShow = true 434 self.isShow = true
430 --首次展示房间 435 --首次展示房间
@@ -459,11 +464,10 @@ end @@ -459,11 +464,10 @@ end
459 464
460 --关卡通关,非层 score < 0 失败 465 --关卡通关,非层 score < 0 失败
461 function Adv:over(success) 466 function Adv:over(success)
462 - local score = -1 467 + local score = self:getScore()
  468 + local scoreInfo = self.advInfo.score
463 local reward 469 local reward
464 if success then 470 if success then
465 - -- todo success 计算分数  
466 - score = 1  
467 self.owner:updateProperty({field = "advPass", self.owner:getProperty("advPass"):setv(self.advInfo.chapter, score)}) 471 self.owner:updateProperty({field = "advPass", self.owner:getProperty("advPass"):setv(self.advInfo.chapter, score)})
468 reward = self.owner:award(self.owner:getProperty("advItems"):toNumMap(), {}) 472 reward = self.owner:award(self.owner:getProperty("advItems"):toNumMap(), {})
469 end 473 end
@@ -473,7 +477,7 @@ function Adv:over(success) @@ -473,7 +477,7 @@ function Adv:over(success)
473 477
474 self.owner:updateProperty({field = "advItems", value = ""}) 478 self.owner:updateProperty({field = "advItems", value = ""})
475 479
476 - self:backEnd(score, reward) 480 + self:backEnd(success, score, scoreInfo, reward)
477 end 481 end
478 482
479 function Adv:exit() 483 function Adv:exit()
@@ -531,6 +535,10 @@ end @@ -531,6 +535,10 @@ end
531 function Adv:initByChapter(chapterId, level, notNotify) 535 function Adv:initByChapter(chapterId, level, notNotify)
532 level = level or 1 536 level = level or 1
533 randomAdvMap(self.owner, chapterId, level, notNotify) 537 randomAdvMap(self.owner, chapterId, level, notNotify)
  538 + if not next(self.advInfo) then return end
  539 + if level > 1 then
  540 + self:scoreChange(AdvScoreType.Level)
  541 + end
534 self:initByInfo() --初始化 542 self:initByInfo() --初始化
535 self.owner:updateProperties({advInfo = self.advInfo, advTeam = self.advTeam}, notNotify) 543 self.owner:updateProperties({advInfo = self.advInfo, advTeam = self.advTeam}, notNotify)
536 end 544 end
@@ -645,6 +653,9 @@ function Adv:award(gift, params) @@ -645,6 +653,9 @@ function Adv:award(gift, params)
645 end 653 end
646 local items = self.owner:getProperty("advItems") 654 local items = self.owner:getProperty("advItems")
647 for itemId, count in pairs(tgift) do 655 for itemId, count in pairs(tgift) do
  656 + if count > 0 then
  657 + self:scoreChange(AdvScoreType.Item, {itemId, count})
  658 + end
648 local origin = items:getv(itemId, 0) 659 local origin = items:getv(itemId, 0)
649 local nums = origin + count 660 local nums = origin + count
650 if nums <= 0 then 661 if nums <= 0 then
@@ -947,12 +958,14 @@ function Adv:enemyDead(roomId, blockId, escape) @@ -947,12 +958,14 @@ function Adv:enemyDead(roomId, blockId, escape)
947 if escape then 958 if escape then
948 room:clearBEvent(block) 959 room:clearBEvent(block)
949 else 960 else
  961 + local monsterData = csvdb["event_monsterCsv"][block.event.id]
  962 + self:scoreChange(AdvScoreType.Kill, monsterData.type)
  963 +
950 local item = block.event.item 964 local item = block.event.item
951 if not item then 965 if not item then
952 if block.event.etype == AdvEventType.BOSS then 966 if block.event.etype == AdvEventType.BOSS then
953 item = {ItemId.AdvKey, 1} 967 item = {ItemId.AdvKey, 1}
954 else 968 else
955 - local monsterData = csvdb["event_monsterCsv"][block.event.id]  
956 local dropData = csvdb["event_dropCsv"][monsterData.dropid] 969 local dropData = csvdb["event_dropCsv"][monsterData.dropid]
957 item = dropData["range"]:randWeight(true) 970 item = dropData["range"]:randWeight(true)
958 end 971 end
@@ -1010,8 +1023,8 @@ function Adv:backNext() @@ -1010,8 +1023,8 @@ function Adv:backNext()
1010 self:pushBackEvent(AdvBackEventType.Next, {}) 1023 self:pushBackEvent(AdvBackEventType.Next, {})
1011 end 1024 end
1012 1025
1013 -function Adv:backEnd(score, reward)  
1014 - self:pushBackEvent(AdvBackEventType.End, {score = score, reward = reward}) 1026 +function Adv:backEnd(success, score, scoreInfo, reward)
  1027 + self:pushBackEvent(AdvBackEventType.End, {success = success, score = score, scoreInfo = scoreInfo, reward = reward})
1015 end 1028 end
1016 1029
1017 function Adv:backBlockChange(roomId, blockId) 1030 function Adv:backBlockChange(roomId, blockId)
@@ -1027,6 +1040,43 @@ function Adv:backDead(enemyId) @@ -1027,6 +1040,43 @@ function Adv:backDead(enemyId)
1027 end 1040 end
1028 1041
1029 1042
  1043 +function Adv:scoreChange(scoreType, pms)
  1044 + local cutTypes = {}
  1045 + local score = 0
  1046 + cutTypes[AdvScoreType.Level] = function()
  1047 + score = globalCsv.adv_score_floor
  1048 + end
  1049 + cutTypes[AdvScoreType.Kill] = function()
  1050 + local chapterData = csvdb["adv_chapterCsv"][self.advInfo.chapter]
  1051 + score = globalCsv.adv_score_monster[pms] * chapterData["monRatio"]
  1052 + end
  1053 + cutTypes[AdvScoreType.Item] = function()
  1054 + score = csvdb["itemCsv"][pms[1]].adv_score_item * pms[2]
  1055 + end
  1056 + cutTypes[AdvScoreType.Hurt] = function()
  1057 + score = globalCsv.adv_score_hurt * pms
  1058 + end
  1059 + cutTypes[AdvScoreType.Block] = function()
  1060 + score = globalCsv.adv_score_block
  1061 + end
  1062 + if cutTypes[scoreType] then
  1063 + cutTypes[scoreType]()
  1064 + else
  1065 + return
  1066 + end
  1067 + self.advInfo.score[scoreType] = self.advInfo.score[scoreType] or 0
  1068 + self.advInfo.score[scoreType] = self.advInfo.score[scoreType] + score
  1069 +end
  1070 +
  1071 +function Adv:getScore()
  1072 + return math.floor(math.max(
  1073 + (self.advInfo.score[AdvScoreType.Level] or 0) +
  1074 + (self.advInfo.score[AdvScoreType.Block] or 0) +
  1075 + (self.advInfo.score[AdvScoreType.Hurt] or 0),
  1076 + 0) + (self.advInfo.score[AdvScoreType.Kill] or 0) +
  1077 + (self.advInfo.score[AdvScoreType.Item] or 0))
  1078 +end
  1079 +
1030 function Adv:popBackEvents() 1080 function Adv:popBackEvents()
1031 local events = self.backEvents 1081 local events = self.backEvents
1032 self.backEvents = {} 1082 self.backEvents = {}
src/adv/AdvPlayer.lua
@@ -230,6 +230,11 @@ function BaseObject:hurt(value, releaser, params) @@ -230,6 +230,11 @@ function BaseObject:hurt(value, releaser, params)
230 --受伤了~ 230 --受伤了~
231 self.battle.adv:backHpChange(self.id, -value) 231 self.battle.adv:backHpChange(self.id, -value)
232 self.hp = math.max(0, self.hp - value) 232 self.hp = math.max(0, self.hp - value)
  233 +
  234 + if self.cutHp then
  235 + self:cutHp(value)
  236 + end
  237 +
233 if self.hp == 0 then 238 if self.hp == 0 then
234 self:triggerPassive(Passive.SELF_DEAD) 239 self:triggerPassive(Passive.SELF_DEAD)
235 for _, team in ipairs(self:getTeam(1, true)) do 240 for _, team in ipairs(self:getTeam(1, true)) do
@@ -432,4 +437,8 @@ function Player:ctor(battle, data) @@ -432,4 +437,8 @@ function Player:ctor(battle, data)
432 self:initData(data) 437 self:initData(data)
433 end 438 end
434 439
  440 +function Player:cutHp(value)
  441 + self.battle.adv:scoreChange(AdvScoreType.Hurt, value)
  442 +end
  443 +
435 return table.pack(Player, Enemy) 444 return table.pack(Player, Enemy)
436 \ No newline at end of file 445 \ No newline at end of file