package skill // 本文件是支援兵(companion)移植的桥接层。 // // companion 模块从 Server-90 移植,引用 Skill.MaximumLevelForCharacterGrowth。 // 当前包的 MaximumLearnableLevel 会**同时**按角色等级收窄上限,而支援兵要的是 // 「只按成长类型算出的技能上限」——两者语义不同,不能互换,所以这个方法按 // Server-90 的原语义移植,只把它的两个内部辅助函数换成本包已有的等价写法。 // // MaximumLevelForCharacterGrowth resolves the packed grow_type's branch and // cumulative awakening stage. A positive awakening slot takes precedence; // otherwise the branch table applies. Missing tables use [maximum level]. func (s Skill) MaximumLevelForCharacterGrowth(growType int) int { first := growType & 0x0f awakening := (growType >> 4) & 0x0f maximum := s.MaximumLevel hasDirectionTables := len(s.GrowTypeMaximumLevels) > 0 || len(s.SecondGrowTypeMaximumLevels) > 0 if !hasDirectionTables { // Focused fixtures and older PVF rows may omit the maximum-level // tables. Preserve their established fitness semantics until a table is // present; a zero scalar means the old owner imposed no upper cap. if !s.SupportsGrowType(first) { return 0 } if len(s.SecondGrowTypes) > 0 { allowed := false for _, minimumStage := range s.SecondGrowTypes { if minimumStage >= 0 && awakening >= minimumStage { allowed = true break } } if !allowed { return 0 } } if maximum > 0 { return maximum } return -1 } // 当前 Skill 类型没有 Server-90 的那个 MaximumLevels 数组 —— 那一维在本树 // 由标量 MaximumLevel + GrowTypeMaximumLevels / SecondGrowTypeMaximumLevels // 表达。所以这里跳过那一步覆盖,直接用标量作为基准。 directionMaximum := maximum if awakening > 0 && len(s.SecondGrowTypeMaximumLevels) > 0 { directionMaximum = companionIndexedMaximum(s.SecondGrowTypeMaximumLevels, first*2+awakening-1) if directionMaximum > 0 { return companionMinimumMaximum(maximum, directionMaximum) } } if len(s.GrowTypeMaximumLevels) > 0 { directionMaximum = companionIndexedMaximum(s.GrowTypeMaximumLevels, first) } return companionMinimumMaximum(maximum, directionMaximum) } // companionIndexedMaximum 按下标取值;越界返回 0(与 Server-90 的 // indexedMaximum 同义:0 表示"这张表没给这一档定上限")。 func companionIndexedMaximum(values []int, index int) int { if index < 0 || index >= len(values) { return 0 } return values[index] } // companionMinimumMaximum 取两个上限里更严的那个,0 视为"无上限"。 // 与 Server-90 的 minimumMaximum 同义。 func companionMinimumMaximum(left, right int) int { if left <= 0 { return right } if right <= 0 { return left } if left < right { return left } return right }