old, new winratio

This commit is contained in:
Lanta 2023-10-05 11:29:03 +02:00
parent f03b6ec714
commit 2f02f44de1

View file

@ -9,24 +9,17 @@ else {
$scriptroot = $PSScriptRoot $scriptroot = $PSScriptRoot
} }
function get-change { function Get-Change {
param ( param (
$winratio_old, [double]$OldWinRatio,
$winratio [double]$NewWinRatio
) )
if ($winratio_old -eq 0) {
if ($winratio -eq 0) {
$change = 0
} else {
$change = [math]::Round(($winratio), 2)
}
} else {
$change = [math]::Round(($winratio - $winratio_old) , 2)
}
return $change $change = ($OldWinRatio -eq 0) ? (($NewWinRatio -eq 0) ? 0 : $NewWinRatio) : ($NewWinRatio - $OldWinRatio)
return [math]::Round($change, 2)
} }
function get-killstats { function get-killstats {
param ( param (
$player_name, $player_name,
@ -121,7 +114,7 @@ foreach ($player in $all_player_matches.playername) {
$player_wins = ($all_player_matches | where-object { $_.playername -eq $player } | ForEach-Object { $_.player_matches } | where-object { $_.stats.winPlace -eq 1 }).count $player_wins = ($all_player_matches | where-object { $_.playername -eq $player } | ForEach-Object { $_.player_matches } | where-object { $_.stats.winPlace -eq 1 }).count
$winratio = ($player_wins / $player_matches) * 100 $winratio = ($player_wins / $player_matches) * 100
$winratio_old = (($oldstats.all | Where-Object { $_.playername -eq $player }).winratio) $winratio_old = (($oldstats.all | Where-Object { $_.playername -eq $player }).winratio)
$change = get-change -winratio_old $winratio_old -winratio $winratio $change = get-change -OldWinRatio $winratio_old -NewWinRatio $winratio
write-output 'all' write-output 'all'
write-output "Calculating for player $player" write-output "Calculating for player $player"
write-output "new winratio $winratio" write-output "new winratio $winratio"
@ -159,7 +152,7 @@ foreach ($player in $all_player_matches.playername) {
$player_wins = ($all_player_matches | where-object { $_.playername -eq $player } | ForEach-Object { $_.player_matches } | where-object { $_.stats.winPlace -eq 1 } | Where-Object { $_.matchType -eq 'event' -and $_.gameMode -eq 'ibr' }).count $player_wins = ($all_player_matches | where-object { $_.playername -eq $player } | ForEach-Object { $_.player_matches } | where-object { $_.stats.winPlace -eq 1 } | Where-Object { $_.matchType -eq 'event' -and $_.gameMode -eq 'ibr' }).count
$winratio = ($player_wins / $player_matches) * 100 $winratio = ($player_wins / $player_matches) * 100
$winratio_old = (($oldstats.Intense | Where-Object { $_.playername -eq $player }).winratio) $winratio_old = (($oldstats.Intense | Where-Object { $_.playername -eq $player }).winratio)
$change = get-change -winratio_old $winratio_old -winratio $winratio $change = get-change -OldWinRatio $winratio_old -NewWinRatio $winratio
write-output 'event' write-output 'event'
write-output "Calculating for player $player" write-output "Calculating for player $player"
@ -195,7 +188,7 @@ foreach ($player in $all_player_matches.playername) {
$player_wins = ($all_player_matches | where-object { $_.playername -eq $player } | ForEach-Object { $_.player_matches } | where-object { $_.stats.winPlace -eq 1 } | Where-Object { $_.matchType -eq 'airoyale' }).count $player_wins = ($all_player_matches | where-object { $_.playername -eq $player } | ForEach-Object { $_.player_matches } | where-object { $_.stats.winPlace -eq 1 } | Where-Object { $_.matchType -eq 'airoyale' }).count
$winratio = ($player_wins / $player_matches) * 100 $winratio = ($player_wins / $player_matches) * 100
$winratio_old = (($oldstats.Casual | Where-Object { $_.playername -eq $player }).winratio) $winratio_old = (($oldstats.Casual | Where-Object { $_.playername -eq $player }).winratio)
$change = get-change -winratio_old $winratio_old -winratio $winratio $change = get-change -OldWinRatio $winratio_old -NewWinRatio $winratio
write-output 'airoyale' write-output 'airoyale'
write-output "Calculating for player $player" write-output "Calculating for player $player"
@ -231,7 +224,7 @@ foreach ($player in $all_player_matches.playername) {
$player_wins = ($all_player_matches | where-object { $_.playername -eq $player } | ForEach-Object { $_.player_matches } | where-object { $_.stats.winPlace -eq 1 } | Where-Object { $_.matchType -eq 'official' }).count $player_wins = ($all_player_matches | where-object { $_.playername -eq $player } | ForEach-Object { $_.player_matches } | where-object { $_.stats.winPlace -eq 1 } | Where-Object { $_.matchType -eq 'official' }).count
$winratio = ($player_wins / $player_matches) * 100 $winratio = ($player_wins / $player_matches) * 100
$winratio_old = (($oldstats.official | Where-Object { $_.playername -eq $player }).winratio) $winratio_old = (($oldstats.official | Where-Object { $_.playername -eq $player }).winratio)
$change = get-change -winratio_old $winratio_old -winratio $winratio $change = get-change -OldWinRatio $winratio_old -NewWinRatio $winratio
write-output 'official' write-output 'official'
write-output "Calculating for player $player" write-output "Calculating for player $player"
write-output "new winratio $winratio" write-output "new winratio $winratio"