/** C 老彩虹只选完整方块;禁止属性优先,允许的复合属性取靠后的池。 */ export function oldRainbowPool(info: any, buttonColors: number[] = [], type: number = info && info.type, color: number = info && info.color): number { if (!info || info.block === 23 || color === 11 || [1, 9, 10, 11, 16, 18, 19, 20, 22].indexOf(type) >= 0 || info.colorChange != null || info.colorArray != null || info.floor != null || info.floorMove === true || info.flowerReceive || buttonColors.indexOf(color) >= 0) return 0; if ([3, 4, 12].indexOf(type) >= 0) return 3; if ([2, 5, 6, 7, 8, 13, 14, 17, 21].indexOf(type) >= 0 || info.flowerSend || info.lock != null || info.horizontal || info.vertical) return 2; return type === 0 ? 1 : 0; } export function chooseOldRainbowTarget( candidates: T[], random: () => number = Math.random): T | null { const available = candidates.filter(candidate => candidate.pool > 0); if (!available.length) return null; const priority = Math.min(...available.map(candidate => candidate.pool)); const pool = available.filter(candidate => candidate.pool === priority); return pool[Math.floor(random() * pool.length)]; }