-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path.currency_build.ps1
94 lines (73 loc) · 2.15 KB
/
.currency_build.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
Set-Location $PSScriptRoot
$csv = (Test-Path ".\CurrencyTypes.csv") ? (Import-Csv ".\CurrencyTypes.csv") : (Invoke-WebRequest "https://wago.tools/db2/CurrencyTypes/csv" | ConvertFrom-Csv)
$currenciesToBlacklist = @(
2032 # Trader's Tender
)
$currenciesToWhitelist = @(
1540, # Wood
1541, # Iron
1559 # Essence of Storms
)
$categoriesToBlacklist = @(
3, # Unused
41, # Test
82, # Archaeology
89, # Meta
142, # Hidden
144, # Virtual
246, # Debug
248, # Torghast UI (Hidden)
251, # Dragon Racing UI (Hidden)
252, # Tuskarr - Fishing Nets (Hidden)
253, # Test Subcategory 1
254, # Test Subcategory 2
255, # Test Subcategory 3
256 # Test Subcategory 4
)
# convert IDs to int because sorting strings sucks ass
$ID = @{ l = "ID"; e = { $_.ID -as [int] } }
$blackist = $csv |
Where-Object {
($currenciesToBlacklist -contains $_.ID -or $categoriesToBlacklist -contains $_.CategoryID) -and $currenciesToWhitelist -notcontains $_.ID
} |
Select-Object $ID, Name_lang |
Sort-Object ID
# $blackist | ForEach-Object {
# Write-Host "[$($_.ID.ToString().PadLeft(4))] = true, -- $($_.Name_lang)"
# }
# 0x8 - 1/100 scalar for display
$mult = $csv |
Where-Object {
$_.Flags_0 -band 8 -and -not (($currenciesToBlacklist -contains $_.ID -or $categoriesToBlacklist -contains $_.CategoryID) -and $currenciesToWhitelist -notcontains $_.ID)
} |
Select-Object $ID, Name_lang |
Sort-Object ID
# $mult | ForEach-Object {
# Write-Host "[$($_.ID.ToString().PadLeft(4))] = 0.01, -- $($_.Name_lang)"
# }
$lua = ".\ls_Toasts\systems\loot_currency.lua"
$out = ""
foreach ($line in Get-Content $lua) {
$out += "$line`n"
if ($line -match "GENERATED-DATA-START") { break }
}
$out += "local BLACKLIST = {`n"
$blackist | ForEach-Object {
$out += "`t[$($_.ID.ToString().PadLeft(4))] = true, -- $($_.Name_lang)`n"
}
$out += "}`n`n"
$out += "local MULT = {`n"
$mult | ForEach-Object {
$out += "`t[$($_.ID.ToString().PadLeft(4))] = 0.01, -- $($_.Name_lang)`n"
}
$out += "}`n"
$canWrite = $false
foreach ($line in Get-Content $lua) {
if ($line -match "GENERATED-DATA-END") {
$canWrite = $true
}
if ($canWrite) {
$out += "$line`n"
}
}
Set-Content $lua -Value $out.TrimEnd()