Skip to content

Commit

Permalink
Added new scripts
Browse files Browse the repository at this point in the history
Updated README
  • Loading branch information
arghblargh committed Feb 9, 2020
1 parent 47a214c commit 45f55c2
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 4 deletions.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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).
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`
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand All @@ -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%",
Expand Down
4 changes: 3 additions & 1 deletion src/scripts/portraits.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
22 changes: 22 additions & 0 deletions src/scripts/templates.ps1
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 45f55c2

Please sign in to comment.