-
Notifications
You must be signed in to change notification settings - Fork 0
Util
A module holding several functions and variables used on most of the other modules.
Type: Dict (String, String)
A dictionnary holding every string used by the game, except unit's lines and scenarios, in english.
Indexed by their internal tag, which used to begin with MID_
.
Type: String
A special string equals to TODO:
, with specials characters which should display the string on a yellow background on a terminal.
Type: String
A special string equals to ERROR:
, with specials characters which should display the string on a red background on a terminal.
Type: String
The time format to use on datetime's methods.
Corresponds to the UTC ISO 8601 format, which is the one used on the wiki.
Type: String
The minimum possible datetime (Epoch), on ISO 8601 format.
Type: String
The maximum possible datetime that can fit on a signed 32-bit integer (Epochalypse), on ISO 8601 format.
Type: List (String)
The list of difficulties used on FeH, in increasing difficulties order.
Type: List (String)
A list of roman numbers, from 0 to 10. 0 is set as the empty-string.
Type: Dict (String, BGM object)
A dictionnary holding informations about the background musics used on maps.
Indexed by the map tag (usually a letter and four digits).
Type: Dict (String, Sound object)
A dictionnary holding every sounds used by the game (Background music, sound effect, voice lines).
Indexed by their internal tag.
Type: String
The endpoint of the Fire Emblem Heroes' Wiki's API.
PersonalData's globals
Variables extracted from module PersonalData
, which are also made accessible here.
Type: String
Absolute path to the assets
directory containing the unaltered binaries of the FeH assets.
Type: String
Absolute path to the assets
directory containing the original files of the FeH assets. While these files may be named as .png
, most of them are actually .webp
.
Currently unused.
Type: String
Absolute path to the assets
directory containing the converted version of the FeH assets into json.
Type: String
Absolute path to the assets
directory containing the unaltered binaries of the FeH Apk.
Currently unused.
Type: String
The name of the user whose hold the bot. It is the name of the user which will be displayed as performing the action.
Type: String
The name of the bot which will be used to perform action on the wiki.
Type: String
The password of the bot. This is NOT the user password, but the password of the bot. See Special:BotPasswords.
cleanStr(string)
Parameter | Type |
---|---|
string | String |
Return: String
For a given string, convert any letter with a diacritic to the basic letter, then keep only alpha-numeric letter, regular space (
), dot (.
), hyphen (-
) and underscore (_
).
timeDiff(time, diff)
Parameter | Type | Default |
---|---|---|
time | String | |
diff | Integer | 1 |
Return: String
For a given datetime, remove diff
seconds and return the new datetime. Input and output datetimes must follow the ISO 8601 format (TIME_FORMAT
).
Positive diff
values will substract seconds, while negative values will add seconds to the given time.
fehBotLogin()
Return: HTTP Session
When call the first time, create a new HTTP Session logged to the FeH Wiki's API as the bot specified by the user.
Otherwise, return the already logged Session object, stored in SESSION
. However, do not use the SESSION
object directly.
readFehData(path, isFull)
Parameter | Type | Default |
---|---|---|
path | String | |
isFull | Boolean | False |
Return: Object (Json)
Read the JSON file present at path
and return it. If isFull
is False
, prepend the user-defined JSON_ASSETS_DIR_PATH
variable to the path.
In case of error, write a message on the error output and return an empty object ({}
).
fetchFehData(path, easySort)
Parameter | Type | Default |
---|---|---|
path | String | |
easySort | String | "id_tag" |
Return: List (Object) OR Dict (*, Object)
Read every JSON files present on the directory specified as path
. path
MUST be relative to the user-defined [JSON_ASSETS_DIR_PATH
] folder.
If easySort
is a string which is present as a key on the json objects, return an object with each objects indexed by the value of easySort
.
Otherwise, return the list of objects.
getName(id, complete)
Parameter | Type | Default |
---|---|---|
id | String | |
complete | Boolean | True |
Return: String
Given an id_tag, return the string associated to it on DATA
. If the string can't be found, try to prepend M
—which is always present on messages—or MID_STAGE_
, or MID_CHAPTER_
. If no name in found, return id
.
If complete
is True
and a name is found while prepending M
or MID_STAGE_
, return the concatenation of the name and the HONOR
name, if any, separated by a colon.
If complete
is True
and a name is found while prepending MID_CHAPTER_
, return the concatenation of the TITLE
name and the name, separated by a colon.
Example:
>>> getName('PID_アルフォンス')
'Alfonse: Prince of Askr'
>>> getName('PID_アルフォンス', complete=False)
'Alfonse'
>>> getName('MID_CHAPTER_C0002')
'World of Mystery'
>>> getName('MID_CHAPTER_TITLE_C0002')
'Chapter 1'
>>> getName('C0002')
'Chapter 1: World of Mystery'
>>> getName('C0002', complete=False)
'World of Mystery'
getBgm(mapId)
Parameter | Type |
---|---|
mapId | String |
Return: List (String)
Return the list of background musics play for a given stage. mapId
use to be a letter followed by four digits.
The background musics are retrieve from json files which are not present on feh-assets-json
by default. You have to add them yourself, using RevBGM
to create these files. More information here.
cargoQuery(tables, fields, where, join, group, order, limit)
Parameter | Type | Default |
---|---|---|
tables | String | |
fields | String | "_pageName=Page" |
where | String | "1" |
join | String | None |
group | String | None |
order | String | "_pageID" |
limit | Integer / "max" | "max" |
Return: List (Dict (String, String))
Perform a cargo query. See the official page for more information. Return a list of objects, with the differents fields as key, and the result as value.
Note that you can't query fields beginning with an underscore (_
) without renaming them.
Using the special string "max"
on limit
will end in performing as many query as needed in order to retrieve every results.
If several tables are specified, it is necessary to change the fields
and order
fields, otherwise exceptions will occur.
askFor(pattern, intro, ignoreCase)
Parameter | Type | Default |
---|---|---|
pattern | String | None |
intro | String | None |
ignoreCase | Boolean | False |
Return: String OR None
Pause the program and wait for a user response.
If intro
is given, it is print on the standard error output before waiting the user response.
If pattern
is given, it is used as a regex pattern to check the user response. Return the response if it match, None
otherwise.
Otherwise, return the user response.
askAgreed(intro, askTrue, askFalse, defaultTrue, defaultFalse, useTrueDefault)
Parameter | Type | Default |
---|---|---|
intro | String | |
askTrue | String | None |
askFalse | String | None |
defaultTrue | * | None |
defaultFalse | * | None |
useTrueDefault | Boolean | True |
Return: String OR *
Print intro
on the standard error output, then pause the program and wait for a user response.
- If the user does not respond (press only Enter), return
defaultTrue
ordefaultFalse
depending onuseTrueDefault
. - If the user respond
Yes
ory
- If
askTrue
is not null, callaskFor
with it as intro, and return the value. - Otherwise return
defaultTrue
.
- If
- If the user respond
No
orn
- If
askFalse
is not null, callaskFor
with it as intro, and return the value. - Otherwise return
defaultFalse
.
- If
- Otherwise, return the user answer.
getToken()
:
Return: String
Call the API to retrieve a CSRF token, which is necessary in order to perform POST request to the API.
otherLanguages()
Return: Dict (String, Language object)
Return a dictionnary holding every string used by the game, except unit's lines and scenarios.
Keys or the internal tag of messages, while values are objects holding the message in all languages supported by FeH.
python3 util.py
Create two jsons files (./jsons/data.json
and ./jsons/otherLanguages.json
) holding respectively the DATA
variable and the result of calling otherLanguages
.
Type: HTTP Session
The internal session object return by fehBotLogin
).
Setting this variable at None
will force FehBotLogin
to recreate a new session, which may resolve some errors. Apart from that, do NOT use this variable.
Type: Dict (String, String)
Some non-ascii letters with an ascii equivalent, used by cleanStr
).
- Util
- Maps
- StoryParalogue.py
- TD.py (Tactics Drills)
- HO.py (Heroic Ordeal)
- DerivedMap.py
- HB.py (* Hero Battle)
- RD.py (Rival Domains)
- EventMap.py
- Events
- Others
- REUtil.py
- Reverse.py
- Events
- RevVG.py
- RevTT.py
- RevTB.py
- RevGC.py
- RevFB.py
- RevRS.py
- RevLL.py
- RevHoF.py
- RevMS.py
- RevFP.py
- RevPoL.py
- Others
- RevData.py
- RevMap.py
- RevQuests.py
- RevSound.py
- RevUnit.py