-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #100 from InfSein/dev
Update to v2.1.7
- Loading branch information
Showing
58 changed files
with
38,796 additions
and
35,540 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"sponsors_gen1": [ | ||
"小密峰", | ||
"宁无恨", | ||
"四期重建用的翻车鱼", | ||
"·无言·", | ||
"漫才", | ||
"Sui", | ||
"被joker偷心了", | ||
"临渊羡鱼", | ||
"聪明", | ||
"江月渔火", | ||
"湿宝" | ||
], | ||
"sponsors_gen2": [] | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/* eslint-disable no-undef */ | ||
const fs = require('fs') | ||
const path = require('path') | ||
|
||
console.log('[scripts/compress-data.cjs] Starting data compression...') | ||
|
||
const placeNameFullPath = path.resolve(__dirname, '../src/assets/data/unpacks/raw/place-name.full.json') | ||
const placeNamePath = path.resolve(__dirname, '../src/assets/data/unpacks/place-name.json') | ||
const territoryFullPath = path.resolve(__dirname, '../src/assets/data/unpacks/raw/territory.full.json') | ||
const territoryPath = path.resolve(__dirname, '../src/assets/data/unpacks/territory.json') | ||
|
||
const placeNameFull = JSON.parse(fs.readFileSync(placeNameFullPath, 'utf8')) | ||
const territoryFull = JSON.parse(fs.readFileSync(territoryFullPath, 'utf8')) | ||
|
||
const gatheringItems = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../src/assets/data/unpacks/gathering-item.json'), 'utf8')) | ||
const maps = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../src/assets/data/unpacks/maps.json'), 'utf8')) | ||
|
||
console.log('[scripts/compress-data.cjs] Raw data have been loaded.') | ||
|
||
// 获取用到的 territories | ||
const territories = [] | ||
Object.values(gatheringItems).forEach(item => { | ||
if (item.territory && !territories.includes(item.territory)) { | ||
territories.push(item.territory) | ||
} | ||
}) | ||
|
||
// 获取用到的 place_ids | ||
const placeIds = [] | ||
territories.forEach(territory => { | ||
const territoryData = territoryFull[territory] | ||
if (territoryData?.length > 2) { | ||
const placeId = territoryFull[territory][2] | ||
if (!placeIds.includes(placeId)) { | ||
placeIds.push(placeId) | ||
} | ||
} | ||
}) | ||
Object.values(gatheringItems).forEach(item => { | ||
if (item.place && !placeIds.includes(item.place)) { | ||
placeIds.push(item.place) | ||
} | ||
}) | ||
Object.values(maps).forEach(map => { | ||
const keys = ['regionId', 'zoneId', 'placeId'] | ||
keys.forEach(key => { | ||
if (map?.[key] && !placeIds.includes(map[key])) { | ||
placeIds.push(map[key]) | ||
} | ||
}) | ||
map?.aetherytes?.forEach(aetheryte => { | ||
if (aetheryte?.placeId && !placeIds.includes(aetheryte.placeId)) { | ||
placeIds.push(aetheryte.placeId) | ||
} | ||
}) | ||
}) | ||
placeIds.sort((a, b) => a - b) | ||
|
||
// 组装压缩后的 territory.json | ||
const territory = {} | ||
for (const territoryId of territories) { | ||
if (!territoryFull[territoryId]) { | ||
console.error(`[scripts/compress-data.cjs] Missing territory for territoryId ${territoryId}`) | ||
} else { | ||
territory[territoryId] = territoryFull[territoryId] | ||
} | ||
} | ||
|
||
// 与现存的 territory.json 对比,有变化才执行写入 | ||
const originTerritory = JSON.parse(fs.readFileSync(territoryPath, 'utf8')) | ||
const territoryFileChanged = JSON.stringify(territory) !== JSON.stringify(originTerritory) | ||
if (territoryFileChanged) { | ||
console.log('[scripts/compress-data.cjs] territory.json has changed, writing to file...') | ||
fs.writeFileSync(territoryPath, customStringify(territory), 'utf8') | ||
} else { | ||
console.log('[scripts/compress-data.cjs] territory.json has not changed.') | ||
} | ||
|
||
// 组装压缩后的 place-name.json | ||
const placeName = {} | ||
for (const placeId of placeIds) { | ||
if (!placeNameFull[placeId]) { | ||
console.error(`[scripts/compress-data.cjs] Missing place name for placeId ${placeId}`) | ||
} else { | ||
placeName[placeId] = placeNameFull[placeId] | ||
} | ||
} | ||
|
||
// 与现存的 place-name.json 对比,有变化才执行写入 | ||
const originPlaceName = JSON.parse(fs.readFileSync(placeNamePath, 'utf8')) | ||
const placeFileChanged = JSON.stringify(placeName) !== JSON.stringify(originPlaceName) | ||
|
||
if (placeFileChanged) { | ||
console.log('[scripts/compress-data.cjs] place-name.json has changed, writing to file...') | ||
fs.writeFileSync(placeNamePath, customStringify(placeName), 'utf8') | ||
} else { | ||
console.log('[scripts/compress-data.cjs] place-name.json has not changed.') | ||
} | ||
|
||
/** 自定义输出模式 */ | ||
function customStringify(obj) { | ||
const kvps = [] | ||
for (const key in obj) { | ||
kvps.push(` "${key}": ${JSON.stringify(obj[key])}`) | ||
} | ||
return `{\n${kvps.join(',\n')}\n}` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"scripts": { | ||
"compress-data": "node compress-data.cjs" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.