@@ -141,9 +141,14 @@ object RoleCache {
141141 /* *
142142 * @return 长度为 `n` 的列表
143143 */
144- fun getRandomRoles (n : Int ): List <RoleSkillsData > = runBlocking {
144+ fun getRandomRoles (n : Int , extension : Int ): List <RoleSkillsData > = runBlocking {
145145 mu.withLock {
146- val indexList = cache.indices.shuffled()
146+ // TODO: 禁用角色再解禁的情况下会导致限制扩展包排序不对
147+ val indexList = when (extension) {
148+ 2 -> 1 .. cache.indexOfFirst { it.role == sp_duan_mu_jing }
149+ 1 -> 1 .. cache.indexOfFirst { it.role == sp_li_ning_yu }
150+ else -> cache.indices
151+ }.shuffled()
147152 List (n) { i -> if (i < indexList.size) cache[indexList[i]] else RoleSkillsData () }
148153 }
149154 }
@@ -152,10 +157,15 @@ object RoleCache {
152157 * @param except 排除的角色
153158 * @return 长度为 `n` 的列表
154159 */
155- fun getRandomRoles (n : Int , except : Set <role>): List <RoleSkillsData > = runBlocking {
160+ fun getRandomRoles (n : Int , except : Set <role>, extension : Int ): List <RoleSkillsData > = runBlocking {
156161 mu.withLock {
162+ // TODO: 禁用角色再解禁的情况下会导致限制扩展包排序不对
157163 val cache = this @RoleCache.cache.filterNot { it.role in except }
158- val indexList = cache.indices.shuffled()
164+ val indexList = when (extension) {
165+ 2 -> 1 .. cache.indexOfFirst { it.role == sp_duan_mu_jing }
166+ 1 -> 1 .. cache.indexOfFirst { it.role == sp_li_ning_yu }
167+ else -> cache.indices
168+ }.shuffled()
159169 List (n) { i -> if (i < indexList.size) cache[indexList[i]] else RoleSkillsData () }
160170 }
161171 }
@@ -164,8 +174,8 @@ object RoleCache {
164174 * @param roles 返回数组的前几个角色强行指定
165175 * @return 长度为 `n` 的列表
166176 */
167- fun getRandomRolesWithSpecific (n : Int , roles : List <role>): List <RoleSkillsData > {
168- val roleSkillsDataList = getRandomRoles(n).toMutableList()
177+ fun getRandomRolesWithSpecific (n : Int , roles : List <role>, extension : Int ): List <RoleSkillsData > {
178+ val roleSkillsDataList = getRandomRoles(n, extension ).toMutableList()
169179 var roleIndex = 0
170180 while (roleIndex < roles.size && roleIndex < n) {
171181 val index = roleSkillsDataList.indexOfFirst { it.role == roles[roleIndex] }
0 commit comments