local ServerChapterData = class("ServerChapterData", ServerBaseData) local MIN_CHAPTER_ID = 1 function ServerChapterData:init(data) self.data.chapterId = data and data.chapterId or MIN_CHAPTER_ID self.data.maxChapterId = data and data.maxChapterId or (self.data.chapterId - 1) self.data.chapterBoxInfo = data and data.chapterBoxInfo or {} self.data.chapterFightInfo = data and data.chapterBoxInfo or {} end function ServerChapterData:fightChapter(id, victory, wave) local idStr = tostring(id) if not self.data.chapterFightInfo[idStr] then self.data.chapterFightInfo[idStr] = { victory = false, maxWave = 0 } end local passBefore = self.data.chapterFightInfo[idStr].victory if victory then self.data.chapterFightInfo[idStr].victory = victory end if wave > self.data.chapterFightInfo[idStr].maxWave then self.data.chapterFightInfo[idStr].maxWave = wave end if not passBefore and victory then if id > self.data.maxChapterId then self.data.maxChapterId = id end end end return ServerChapterData