Skip to content

Commit

Permalink
fix path to race and gender (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
Miorey authored Jan 3, 2024
1 parent 4a21111 commit af9ebdd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 20 deletions.
21 changes: 3 additions & 18 deletions character_modeling.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,6 @@ const NOT_DISPLAYED_SLOTS = [
14, // trinket2
]

const RACES = {
1: `human`,
2: `orc`,
3: `dwarf`,
4: `nightelf`,
5: `scourge`,
6: `tauren`,
7: `gnome`,
8: `troll`,
10: `bloodelf`,
11: `draenei`
}

const CHARACTER_PART = {
Face: `face`,
"Skin Color": `skin`,
Expand Down Expand Up @@ -106,16 +93,14 @@ function optionsFromModel(model, fullOptions) {
const characterItems = (model.items) ? model.items.filter(e => !NOT_DISPLAYED_SLOTS.includes(e[0])) : []
const options = getCharacterOptions(model, fullOptions)

const retGender = (gender === 1) ? `female` : `male`
const raceToModelId = RACES[race] + retGender

return {
items: characterItems,
charCustomization: {
options: options
},
models: {
id: raceToModelId,
id: race*2-1+gender,
type: 16
},
}
Expand Down Expand Up @@ -229,7 +214,8 @@ async function findItemsInEquipments(equipments) {
* @returns {Promise<Object>}
*/
async function findRaceGenderOptions(race, gender) {
const options = await fetch(`${window.CONTENT_PATH}meta/charactercustomization2/${race}_${gender}.json`)
const raceGender = race * 2 - 1 + gender
const options = await fetch(`${window.CONTENT_PATH}meta/charactercustomization/${raceGender}.json`)
.then(
(response) => response.json()
)
Expand All @@ -243,7 +229,6 @@ async function findRaceGenderOptions(race, gender) {
export {
optionsFromModel,
findRaceGenderOptions,
RACES,
findItemsInEquipments,
getDisplaySlot,
getCharacterOptions
Expand Down
2 changes: 1 addition & 1 deletion tests/character_modeling.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe(`Character Modeling functions`, () => {
expect(result).toEqual({
items: [],
charCustomization: { options: [] },
models: { id: `humanfemale`, type: 16 }
models: { id: 2, type: 16 }
})
})

Expand Down
2 changes: 1 addition & 1 deletion tests/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ describe(`findRaceGenderOptions`, () => {
const result = await findRaceGenderOptions(2, 1)

expect(fetch).toHaveBeenCalledTimes(1)
expect(fetch).toHaveBeenCalledWith(`http://localhost:3001/modelviewer/live/meta/charactercustomization2/2_1.json`)
expect(fetch).toHaveBeenCalledWith(`http://localhost:3001/modelviewer/live/meta/charactercustomization/4.json`)
expect(result).toEqual(mockResponse)
})
})
Expand Down

0 comments on commit af9ebdd

Please sign in to comment.