Merge pull request #90 from OpzekerIT/dev

fix
This commit is contained in:
Lanta 2023-11-12 11:03:47 +01:00 committed by GitHub
commit 0ae5df1364
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 21 deletions

View file

@ -1,3 +1,4 @@
Start-Transcript -Path '/var/log/dtch/matchparser.log' -Append
. .\..\includes\ps1\lockfile.ps1
new-lock
@ -20,6 +21,19 @@ function Get-Change {
return [math]::Round($change, 2)
}
function Get-winratio {
param (
[int]$player_wins,
[int]$player_matches
)
if ($player_wins -eq 0 -or $player_matches -eq 0) {
$winratio = 0
}
else {
$winratio = ($player_wins / $player_matches) * 100
}
return $winratio
}
function get-killstats {
param (
$player_name,
@ -184,11 +198,8 @@ foreach ($player in $all_player_matches.playername) {
$kills = (($killstats.stats | where-object { $_.playername -eq $player -and $_.gameMode -eq 'ibr' -and $_.matchType -eq 'event' }).kills | Measure-Object -sum).sum
$dbno = (($killstats.stats | where-object { $_.playername -eq $player -and $_.gameMode -eq 'ibr' -and $_.matchType -eq 'event' }).dbno | Measure-Object -sum).sum
$humankills = (($killstats.stats | where-object { $_.playername -eq $player -and $_.gameMode -eq 'ibr' -and $_.matchType -eq 'event' }).humankills | Measure-Object -sum).sum
$player_matches = ($killstats.stats | where-object { $_.playername -eq $player -and $_.gameMode -eq 'ibr' -and $_.matchType -eq 'event' }).count
$player_wins = ($killstats | where-object { $_.stats.playername -eq $player -and $_.winplace -eq 1 -and $_.stats.gameMode -eq 'ibr' -and $_.stats.matchType -eq 'event' }).count
$winratio = ($player_wins / $player_matches) * 100
$winratio_old = (($oldstats.Intense | Where-Object { $_.playername -eq $player }).winratio)
$change = get-change -OldWinRatio $winratio_old -NewWinRatio $winratio
@ -206,7 +217,7 @@ foreach ($player in $all_player_matches.playername) {
matches = $player_matches
KD_H = $humankills / $deaths
KD_ALL = $kills / $deaths
winratio = ($player_wins / $player_matches) * 100
winratio = Get-winratio -player_wins $player_wins -player_matches $player_matches
wins = $player_wins
dbno = $dbno
change = $change
@ -226,7 +237,6 @@ foreach ($player in $all_player_matches.playername) {
$humankills = (($killstats.stats | where-object { $_.playername -eq $player -and $_.matchType -eq 'airoyale' }).humankills | Measure-Object -sum).sum
$player_matches = ($killstats.stats | where-object { $_.playername -eq $player -and $_.matchType -eq 'airoyale' }).count
$player_wins = ($killstats | where-object { $_.stats.playername -eq $player -and $_.winplace -eq 1 -and $_.stats.matchType -eq 'airoyale' }).count
$winratio = ($player_wins / $player_matches) * 100
$winratio_old = (($oldstats.Casual | Where-Object { $_.playername -eq $player }).winratio)
$change = get-change -OldWinRatio $winratio_old -NewWinRatio $winratio
@ -245,7 +255,7 @@ foreach ($player in $all_player_matches.playername) {
matches = $player_matches
KD_H = $humankills / $deaths
KD_ALL = $kills / $deaths
winratio = ($player_wins / $player_matches) * 100
winratio = Get-winratio -player_wins $player_wins -player_matches $player_matches
wins = $player_wins
dbno = $dbno
change = $change
@ -264,7 +274,6 @@ foreach ($player in $all_player_matches.playername) {
$humankills = (($killstats.stats | where-object { $_.playername -eq $player -and $_.matchType -eq 'official' }).humankills | Measure-Object -sum).sum
$player_matches = ($killstats.stats | where-object { $_.playername -eq $player -and $_.matchType -eq 'official' }).count
$player_wins = ($killstats | where-object { $_.stats.playername -eq $player -and $_.winplace -eq 1 -and $_.stats.matchType -eq 'official' }).count
$winratio = ($player_wins / $player_matches) * 100
$winratio_old = (($oldstats.official | Where-Object { $_.playername -eq $player }).winratio)
$change = get-change -OldWinRatio $winratio_old -NewWinRatio $winratio
write-output 'official'
@ -281,7 +290,7 @@ foreach ($player in $all_player_matches.playername) {
matches = $player_matches
KD_H = $humankills / $deaths
KD_ALL = $kills / $deaths
winratio = ($player_wins / $player_matches) * 100
winratio = Get-winratio -player_wins $player_wins -player_matches $player_matches
wins = $player_wins
dbno = $dbno
change = $change
@ -302,7 +311,6 @@ foreach ($player in $all_player_matches.playername) {
$humankills = (($killstats.stats | where-object { $_.playername -eq $player -and $_.matchType -eq 'custom' }).humankills | Measure-Object -sum).sum
$player_matches = ($killstats.stats | where-object { $_.playername -eq $player -and $_.matchType -eq 'custom' }).count
$player_wins = ($killstats | where-object { $_.stats.playername -eq $player -and $_.winplace -eq 1 -and $_.stats.matchType -eq 'custom' }).count
$winratio = ($player_wins / $player_matches) * 100
$winratio_old = (($oldstats.custom | Where-Object { $_.playername -eq $player }).winratio)
$change = get-change -OldWinRatio $winratio_old -NewWinRatio $winratio
write-output 'custom'
@ -319,7 +327,7 @@ foreach ($player in $all_player_matches.playername) {
matches = $player_matches
KD_H = $humankills / $deaths
KD_ALL = $kills / $deaths
winratio = ($player_wins / $player_matches) * 100
winratio = Get-winratio -player_wins $player_wins -player_matches $player_matches
wins = $player_wins
dbno = $dbno
change = $change
@ -368,3 +376,5 @@ foreach ($file in $difference) {
}
write-output "Operation complete"
remove-lock
$Error
Stop-Transcript

View file

@ -1,4 +1,6 @@
. .\..\includes\ps1\lockfile.ps1
Start-Transcript -Path '/var/log/dtch/update_clan_members.log' -Append
. .\..\includes\ps1\lockfile.ps1
new-lock
if ($PSScriptRoot.length -eq 0) {
@ -126,3 +128,5 @@ $lifetimestats['updated'] = $formattedString
$lifetimestats | convertto-json -Depth 100 | out-file "$scriptroot/../data/player_lifetime_data.json"
remove-lock
$Error
Stop-Transcript