From 45f55c256f076e8fc93b2b6110c63a556b975635 Mon Sep 17 00:00:00 2001 From: arghblargh Date: Sat, 8 Feb 2020 16:13:58 -0800 Subject: [PATCH] Added new scripts Updated README --- README.md | 16 +++++++++++++++- package.json | 5 +++-- src/scripts/portraits.ps1 | 4 +++- src/scripts/templates.ps1 | 22 ++++++++++++++++++++++ 4 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 src/scripts/templates.ps1 diff --git a/README.md b/README.md index 851c6b8..6d58467 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,17 @@ ## Fire Emblem: Heroes Skill Inheritance Tool -This project was bootstrapped with [Create React App](https://github.com/facebookincubator/create-react-app). \ No newline at end of file +This project was bootstrapped with [Create React App](https://github.com/facebookincubator/create-react-app). + + +### Data Entry +Scripts are provided to simplify data entry: + * `npm run stats` - Sends web requests to https://feh-stat-pull.herokuapp.com/, which hosts my [stats API](https://github.com/arghblargh/feh-stat-pull). + * `npm run templates` - Generates blank entries in the JSON files for missing data (currently only unit templates). + * `npm run portraits` - Sends web requests to the [Fire Emblem Heroes Wiki](https://feheroes.gamepedia.com/) to retrieve and convert missing unit portrait images. Requires [ImageMagick](https://imagemagick.org/) installed with `magick convert` available from the command line. + + To add new units from the wiki: + 1. Run the `stats` script. + 2. Run the `templates` script. + 2a. If units were missed by the script (usually some wiki data is incorrect/missing), add those manually. + 3. Run the `portraits` script. + 4. Manually fill in data in the JSON files: `units`, `weapons`, `passives`, `specials`, `assists`, `seals`, `upgrades` \ No newline at end of file diff --git a/package.json b/package.json index dffc58b..a7861be 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "feh-inheritance-tool", - "version": "1.8.3", + "version": "1.8.4", "homepage": "https://arghblargh.github.io/feh-inheritance-tool", "private": true, "dependencies": { @@ -19,7 +19,8 @@ "predeploy": "npm run build", "deploy": "gh-pages -d build", "stats": "curl https://feh-stat-pull.herokuapp.com/stats -o \"src/data/stats/5_1.json\" https://feh-stat-pull.herokuapp.com/stats/growths -o \"src/data/stats/growths.json\" https://feh-stat-pull.herokuapp.com/units/rarity -o \"src/data/stats/rarity.json\"", - "portraits": "pwsh src/scripts/portraits.ps1" + "portraits": "pwsh src/scripts/portraits.ps1", + "templates": "pwsh src/scripts/templates.ps1" }, "browserslist": [ ">0.2%", diff --git a/src/scripts/portraits.ps1 b/src/scripts/portraits.ps1 index f84eb2c..9635978 100644 --- a/src/scripts/portraits.ps1 +++ b/src/scripts/portraits.ps1 @@ -7,7 +7,9 @@ function Remove-StringNormalize [Text.Encoding]::ASCII.GetString([Text.Encoding]::GetEncoding("Cyrillic").GetBytes($String)) } -$FullList = (Get-Content src/data/units.json) -join "`n" | ConvertFrom-Json | ForEach-Object { $_.PSObject.Properties | Select-Object -Expand Name } | ForEach-Object { Remove-StringNormalize -String $_ } +$StatList = Get-Content src/data/stats/rarity.json -raw | ConvertFrom-Json | ForEach-Object { $_.PSObject.Properties | Select-Object -Expand Name } | ForEach-Object { Remove-StringNormalize -String $_ } +$UnitList = Get-Content src/data/units.json -raw | ConvertFrom-Json | ForEach-Object { $_.PSObject.Properties | Select-Object -Expand Name } | ForEach-Object { Remove-StringNormalize -String $_ } +$FullList = $StatList + $UnitList | Select -uniq $CurrentList = Get-ChildItem -Path src/img/portrait/* | ForEach-Object { [io.path]::GetFileNameWithoutExtension($_) } $DiffList = $FullList | Where-Object { $CurrentList -notcontains $_ } | ForEach-Object { "https://feheroes.gamepedia.com/File:" + $_ + "_Face_FC.webp" } | ForEach-Object { (Invoke-WebRequest $_).Links | Where-Object { $_.href -match "Face_FC.webp" } | Select-Object href -First 1 -ExpandProperty href } diff --git a/src/scripts/templates.ps1 b/src/scripts/templates.ps1 new file mode 100644 index 0000000..20832fe --- /dev/null +++ b/src/scripts/templates.ps1 @@ -0,0 +1,22 @@ +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + +# function Remove-StringNormalize +# { +# PARAM ([string]$String) +# $String = $String -Replace ":","" -Replace " ","_" -Replace '"',"" -Replace "'","" +# [Text.Encoding]::ASCII.GetString([Text.Encoding]::GetEncoding("Cyrillic").GetBytes($String)) +# } +$weapon = @([psobject][ordered]@{name="";unlock=1},[psobject][ordered]@{name="";unlock=2},[psobject][ordered]@{name="";unlock=3},[psobject][ordered]@{name=""}) +$skill = @([psobject][ordered]@{name="";unlock=1}) + +$Units = Get-Content src/data/units.json -raw | ConvertFrom-Json +$FullList = Get-Content src/data/stats/rarity.json -raw | ConvertFrom-Json | ForEach-Object { $_.PSObject.Properties | Select-Object -Expand Name } +$CurrentList = $Units | ForEach-Object { $_.PSObject.Properties | Select-Object -Expand Name } +$DiffList = $FullList | Where-Object { $CurrentList -notcontains $_ } + +$DiffList.foreach({ + $name = $_.Split(": ") + $unit = [psobject][ordered]@{name=$name[0];title=$name[1];color="";wpnType="";movType="";skills=[psobject][ordered]@{weapon=$weapon;assist=$skill;special=$skill;passiveA=$skill;passiveB=$skill;passiveC=$skill}} + $Units | Add-Member -TypeName PSObject -NotePropertyName $_ -NotePropertyValue $unit +}) +$Units | ConvertTo-Json -depth 32 | Set-Content src/data/units.json