星见凛的代码笔记

Hoshimi RIN`s CodeNote

关于如何计算Chunithm New在Verse中引入的新版Rating机制的N20理论最高Rating

PowerShell脚本

# 获取当前目录
$currentDir = Get-Location

# 定义一个列表来存储所有音乐的定数
$musicConstants = @()

# 获取所有以A开头的文件夹
$dirs = Get-ChildItem -Path $currentDir -Directory | Where-Object { $_.Name -like 'A*' }

# 遍历所有文件夹
foreach ($dir in $dirs) {
    $musicFolder = Join-Path -Path $dir.FullName -ChildPath "music"
    if (Test-Path -Path $musicFolder) {
        $musicSubDirs = Get-ChildItem -Path $musicFolder -Directory | Where-Object { $_.Name -like 'music*' }

        # 遍历所有以music开头的文件夹
        foreach ($musicSubDir in $musicSubDirs) {
            $xmlFilePath = Join-Path -Path $musicSubDir.FullName -ChildPath "Music.xml"
            if (Test-Path -Path $xmlFilePath) {
                try {
                    # 读取XML文件
                    [xml]$xmlContent = Get-Content -Path $xmlFilePath

                    # 检查releaseTagName.id是否为18 (18为Verse,其他版本需要对应修改)
                    $releaseTagId = $xmlContent.MusicData.releaseTagName.id
                    
                    if ($releaseTagId -eq 18) {
                        # 遍历fumens列表
                        $fumens = $xmlContent.MusicData.fumens.MusicFumenData
                        foreach ($fumen in $fumens) {
                            $level = [float]$fumen.level
                            $levelDecimal = [float]$fumen.levelDecimal
                            $constant = $level + ($levelDecimal / 100)

                            # 将定数添加到列表
                            $musicConstants += [pscustomobject]@{
                                Id = [int]$xmlContent.MusicData.name.id
                                Name = $xmlContent.MusicData.name.str
                                Diff = $fumen.type.data
                                Constant = $constant
                                MaxRa = $constant + 2.15
                            }
                        }
                    }
                } catch {
                    Write-Warning "无法处理文件 $xmlFilePath"
                }
            }
        }
    }
}

# 按照定数降序排列
$sortedMusicConstants = $musicConstants | Sort-Object -Property Constant -Descending

# 获取定数最大的前20项
$top20 = $sortedMusicConstants | Select-Object -First 20

# 打印前20项的定数
Write-Output "定数最大的前20项:"
$top20 | ForEach-Object {
    Write-Output "ID: $($_.Id), Name: $($_.Name), Diff: $($_.Diff), Constant: $($_.Constant), MaxRa: $($_.MaxRa)"
}

# 计算定数平均值
$averageConstant = ($top20 | Measure-Object -Property Constant -Average).Average

# 输出定数最大的前20项的平均值
Write-Output "定数最大的前20项的平均值: $averageConstant, 理论N20: $($averageConstant + 2.15)"

文章评论已关闭