Merge branch 'feature/spells-officialJSON' into feature/spells
# Conflicts: # .vscode/spells-schemas.json
This commit is contained in:
commit
07009a1f98
6 changed files with 41586 additions and 41 deletions
7
.issuetracker
Normal file
7
.issuetracker
Normal file
|
@ -0,0 +1,7 @@
|
|||
# Integration with Issue Tracker
|
||||
#
|
||||
# (note that '\' need to be escaped).
|
||||
|
||||
[issuetracker "Issue Tracker Rule"]
|
||||
regex = "((?<=#)[0-9]+)"
|
||||
url = "http://185.216.25.221:3000/lucastucious/fateforge-tool/issues/$1"
|
46
.vscode/spells-schemas.json
vendored
46
.vscode/spells-schemas.json
vendored
|
@ -21,7 +21,7 @@
|
|||
"name",
|
||||
"source",
|
||||
"page",
|
||||
"srd",
|
||||
"fateforge_exclusive",
|
||||
"level",
|
||||
"school",
|
||||
"time",
|
||||
|
@ -67,10 +67,10 @@
|
|||
"examples": [110],
|
||||
"default": 0
|
||||
},
|
||||
"srd": {
|
||||
"$id": "#root/spells/items/srd",
|
||||
"fateforge_exclusive": {
|
||||
"$id": "#root/spells/items/fateforge_exclusive",
|
||||
"description": "is srd or a creation",
|
||||
"title": "Srd",
|
||||
"title": "fateforge_exclusive",
|
||||
"type": "boolean",
|
||||
"examples": [true],
|
||||
"default": true
|
||||
|
@ -126,43 +126,7 @@
|
|||
"range": {
|
||||
"$id": "#root/spells/items/range",
|
||||
"title": "Range",
|
||||
"type": "object",
|
||||
"required": ["type", "distance"],
|
||||
"properties": {
|
||||
"type": {
|
||||
"$id": "#root/spells/items/range/type",
|
||||
"title": "Type",
|
||||
"type": "string",
|
||||
"default": "point",
|
||||
"examples": ["point"],
|
||||
"pattern": "^.*$",
|
||||
"enum": ["point", "cone", "sphere", "cylinder", "special"],
|
||||
"description": "point by default, but can be cone, sphere, cylinder, special "
|
||||
},
|
||||
"distance": {
|
||||
"$id": "#root/spells/items/range/distance",
|
||||
"title": "Distance",
|
||||
"type": "object",
|
||||
"required": ["type", "amount"],
|
||||
"properties": {
|
||||
"type": {
|
||||
"$id": "#root/spells/items/range/distance/type",
|
||||
"title": "Type",
|
||||
"type": "string",
|
||||
"default": "",
|
||||
"examples": ["feet"],
|
||||
"pattern": "^.*$"
|
||||
},
|
||||
"amount": {
|
||||
"$id": "#root/spells/items/range/distance/amount",
|
||||
"title": "Amount",
|
||||
"type": "integer",
|
||||
"examples": [90],
|
||||
"default": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"type": "string"
|
||||
},
|
||||
"components": {
|
||||
"$id": "#root/spells/items/components",
|
||||
|
|
16042
data/spells/fateforge_spells_all.json
Normal file
16042
data/spells/fateforge_spells_all.json
Normal file
File diff suppressed because one or more lines are too long
12686
data/spells/fateforge_spells_en.json
Normal file
12686
data/spells/fateforge_spells_en.json
Normal file
File diff suppressed because one or more lines are too long
12686
data/spells/fateforge_spells_fr.json
Normal file
12686
data/spells/fateforge_spells_fr.json
Normal file
File diff suppressed because one or more lines are too long
160
data/spells/notes.md
Normal file
160
data/spells/notes.md
Normal file
|
@ -0,0 +1,160 @@
|
|||
# Notes
|
||||
Pour transformer le json d'origine, on itérera sur le fichier pour le scinder en deux
|
||||
on utilise le tools ici : https://jsoneditoronline.org/#right=cloud.f0a19b92543d4c7fa1bdb58a913707e8&left=local.xoliwi
|
||||
|
||||
##### Pour avoir le json en francais:
|
||||
*Cette version de la fonction query utilise une récursion pour explorer les sous-objets de chaque objet dans la liste data. La fonction checkKey transforme les clés se terminant par "_fr" en supprimant cette terminaison, et elle vérifie si la clé contient un nombre avant de traiter ses sous-objets. Si la clé ne contient pas de nombre, la fonction ne traite pas les sous-objets de cette clé.*
|
||||
```js
|
||||
function query(data) {
|
||||
function checkKey(obj) {
|
||||
obj = _.mapKeys(obj, (value, key) => {
|
||||
|
||||
if (_.endsWith(key, "_fr") ) {
|
||||
return key.slice(0, -3);
|
||||
}
|
||||
return key;
|
||||
});
|
||||
for (const [key, value] of Object.entries(obj)) {
|
||||
if (_.isObject(value) && isNaN(value) ) {
|
||||
obj[key] = checkKey(value);
|
||||
}
|
||||
}
|
||||
return _.pickBy(obj, (value, key) => !_.endsWith(key, "_en"));
|
||||
}
|
||||
|
||||
return _.chain(data)
|
||||
.map(obj => checkKey(obj))
|
||||
.value();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
```
|
||||
|
||||
##### Pour deplacer les classes dans un objet "classes"
|
||||
```js
|
||||
function query(data) {
|
||||
return _.chain(data)
|
||||
.map(item => {
|
||||
const {
|
||||
bard = "",
|
||||
cleric = "",
|
||||
druid = "",
|
||||
paladin = "",
|
||||
ranger = "",
|
||||
scholar = "",
|
||||
sorcerer = "",
|
||||
warlock = "",
|
||||
wizard = "",
|
||||
...rest
|
||||
} = item;
|
||||
return {
|
||||
...rest,
|
||||
classes: {
|
||||
bard,
|
||||
cleric,
|
||||
druid,
|
||||
paladin,
|
||||
ranger,
|
||||
scholar,
|
||||
sorcerer,
|
||||
warlock,
|
||||
wizard
|
||||
}
|
||||
};
|
||||
})
|
||||
.value();
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
##### pour renommer les components :
|
||||
```js
|
||||
function query(data) {
|
||||
return _.chain(data)
|
||||
.map(obj => {
|
||||
// Renommer les clés spécifiées
|
||||
obj = _.mapKeys(obj, (value, key) => {
|
||||
switch(key) {
|
||||
case "composite_oral":
|
||||
return "v";
|
||||
case "composite_moves":
|
||||
return "s";
|
||||
case "composite_material":
|
||||
return "m";
|
||||
case "material_components_fr":
|
||||
return "m_fr";
|
||||
case "material_components_en":
|
||||
return "m_en";
|
||||
case "composite_material_destroyed":
|
||||
return "m_destroyed"
|
||||
default:
|
||||
return key;
|
||||
}
|
||||
});
|
||||
return obj;
|
||||
})
|
||||
.value();
|
||||
}
|
||||
```
|
||||
|
||||
##### Pour deplacer les components dans un objet "components"
|
||||
```js
|
||||
function query(data) {
|
||||
return _.chain(data)
|
||||
.map(item => {
|
||||
const {
|
||||
m_destroyed = "",
|
||||
v = "",
|
||||
s= "",
|
||||
m= "",
|
||||
m_fr= "",
|
||||
m_en= "",
|
||||
...rest
|
||||
} = item;
|
||||
return {
|
||||
...rest,
|
||||
components: {
|
||||
m_destroyed,
|
||||
v,
|
||||
s,
|
||||
m,
|
||||
m_fr,
|
||||
m_en,
|
||||
}
|
||||
};
|
||||
})
|
||||
.value();
|
||||
}
|
||||
```
|
||||
|
||||
##### Pour ajouter recid et source
|
||||
```js
|
||||
function query(data) {
|
||||
return _.chain(data)
|
||||
.map((item, index) => _.merge({ recid: index }, item))
|
||||
.map((item, index) => _.merge({ source: "GRI01" }, item))
|
||||
.value();
|
||||
}
|
||||
```
|
||||
|
||||
##### Pour transformer les clé 0/1 en true/false
|
||||
```js
|
||||
function query(data) {
|
||||
return _.chain(data)
|
||||
.map((item) => ({
|
||||
...item,
|
||||
composite_material_destroyed: item.composite_material_destroyed = "x"? true : false,
|
||||
composite_oral: item.composite_oral == 1? true : false,
|
||||
has_higher_level_details: item.has_higher_level_details == 1? true : false,
|
||||
ritual: item.ritual == 1? true : false,
|
||||
dragons_exclusive: item.dragons_exclusive == 1? true : false,
|
||||
composite_moves: item.composite_moves == 1? true : false,
|
||||
composite_material: item.composite_material == 1? true : false,
|
||||
corrupted: item.corrupted == 1? true : false,
|
||||
concentration: item.concentration == 1? true : false,
|
||||
}))
|
||||
.value();
|
||||
}
|
||||
```
|
Loading…
Reference in a new issue