cortico-world-fishx 0.7.2 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/assets/icon.png +0 -0
- package/describe.json +8 -0
- package/dist/webui.js +211 -11
- package/package.json +5 -1
- package/src/data/sports.json +54 -54
- package/src/definition.js +2 -0
- package/src/draw.js +84 -2
- package/src/state.js +135 -4
- package/src/tools.js +129 -16
- package/tools/check-name.mjs +1 -1
package/src/data/sports.json
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
"id": "skydiving",
|
|
4
4
|
"name": "跳伞",
|
|
5
5
|
"locations": [
|
|
6
|
-
{ "id": "skydive-dubai-palm", "name": "迪拜棕榈岛 Palm Jumeirah", "region": "阿联酋迪拜", "scenery": "俯瞰棕榈形海岸与波斯湾的蓝色海面,城市天际线在柔和日光中铺展。" },
|
|
7
|
-
{ "id": "skydive-interlaken", "name": "因特拉肯 Interlaken", "region": "瑞士伯尔尼州", "scenery": "碧绿湖泊、起伏草甸与白雪山峰在澄澈空气中层层相接。" },
|
|
8
|
-
{ "id": "skydive-queenstown", "name": "皇后镇 Lake Wakatipu", "region": "新西兰奥塔哥", "scenery": "瓦卡蒂普湖沿山谷泛着清亮蓝光,远处山脊被温暖晨光轻轻描亮。" }
|
|
6
|
+
{ "id": "skydive-dubai-palm", "name": "迪拜棕榈岛 Palm Jumeirah", "region": "阿联酋迪拜", "scenery": "俯瞰棕榈形海岸与波斯湾的蓝色海面,城市天际线在柔和日光中铺展。", "mapX": 65.3, "mapY": 36.1 },
|
|
7
|
+
{ "id": "skydive-interlaken", "name": "因特拉肯 Interlaken", "region": "瑞士伯尔尼州", "scenery": "碧绿湖泊、起伏草甸与白雪山峰在澄澈空气中层层相接。", "mapX": 52.2, "mapY": 24.1 },
|
|
8
|
+
{ "id": "skydive-queenstown", "name": "皇后镇 Lake Wakatipu", "region": "新西兰奥塔哥", "scenery": "瓦卡蒂普湖沿山谷泛着清亮蓝光,远处山脊被温暖晨光轻轻描亮。", "mapX": 96.9, "mapY": 75.0 }
|
|
9
9
|
],
|
|
10
10
|
"domain": "air",
|
|
11
11
|
"souvenirs": [
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
"id": "wingsuit",
|
|
41
41
|
"name": "翼装飞行",
|
|
42
42
|
"locations": [
|
|
43
|
-
{ "id": "wingsuit-lauterbrunnen", "name": "劳特布伦嫩 Lauterbrunnen 山谷", "region": "瑞士伯尔尼州", "scenery": "瀑布从高耸山壁间垂落,绿色山谷与云影构成开阔宁静的远景。" },
|
|
44
|
-
{ "id": "wingsuit-chamonix", "name": "霞慕尼勃朗峰 Mont Blanc", "region": "法国上萨瓦省", "scenery": "冰川与雪峰映着清澈天光,山麓小镇的暖色屋顶点缀在林间。" },
|
|
45
|
-
{ "id": "wingsuit-zhangjiajie", "name": "张家界武陵源", "region": "中国湖南", "scenery": "石英砂岩峰柱穿出薄雾与青翠林海,晨光为层叠山影染上淡金色。" }
|
|
43
|
+
{ "id": "wingsuit-lauterbrunnen", "name": "劳特布伦嫩 Lauterbrunnen 山谷", "region": "瑞士伯尔尼州", "scenery": "瀑布从高耸山壁间垂落,绿色山谷与云影构成开阔宁静的远景。", "mapX": 52.2, "mapY": 24.1 },
|
|
44
|
+
{ "id": "wingsuit-chamonix", "name": "霞慕尼勃朗峰 Mont Blanc", "region": "法国上萨瓦省", "scenery": "冰川与雪峰映着清澈天光,山麓小镇的暖色屋顶点缀在林间。", "mapX": 51.9, "mapY": 24.5 },
|
|
45
|
+
{ "id": "wingsuit-zhangjiajie", "name": "张家界武陵源", "region": "中国湖南", "scenery": "石英砂岩峰柱穿出薄雾与青翠林海,晨光为层叠山影染上淡金色。", "mapX": 80.7, "mapY": 33.8 }
|
|
46
46
|
],
|
|
47
47
|
"domain": "air",
|
|
48
48
|
"souvenirs": [
|
|
@@ -77,9 +77,9 @@
|
|
|
77
77
|
"id": "bungee",
|
|
78
78
|
"name": "蹦极",
|
|
79
79
|
"locations": [
|
|
80
|
-
{ "id": "bungee-kawarau", "name": "卡瓦劳大桥 Kawarau Bridge", "region": "新西兰皇后镇", "scenery": "历史石桥横跨清澈河谷,山坡草地与碧蓝水流在阳光下相映。" },
|
|
81
|
-
{ "id": "bungee-victoria-falls", "name": "维多利亚瀑布 Victoria Falls", "region": "赞比亚与津巴布韦边境", "scenery": "辽阔河谷间升起轻柔水雾,赞比西河与葱郁岸线铺成明亮背景。" },
|
|
82
|
-
{ "id": "bungee-macau-tower", "name": "澳门旅游塔 Macau Tower", "region": "中国澳门", "scenery": "珠江口的海天与城市天际线交织,塔下湾区水色在暮光中泛起微亮。" }
|
|
80
|
+
{ "id": "bungee-kawarau", "name": "卡瓦劳大桥 Kawarau Bridge", "region": "新西兰皇后镇", "scenery": "历史石桥横跨清澈河谷,山坡草地与碧蓝水流在阳光下相映。", "mapX": 96.9, "mapY": 75.0 },
|
|
81
|
+
{ "id": "bungee-victoria-falls", "name": "维多利亚瀑布 Victoria Falls", "region": "赞比亚与津巴布韦边境", "scenery": "辽阔河谷间升起轻柔水雾,赞比西河与葱郁岸线铺成明亮背景。", "mapX": 57.2, "mapY": 60.0 },
|
|
82
|
+
{ "id": "bungee-macau-tower", "name": "澳门旅游塔 Macau Tower", "region": "中国澳门", "scenery": "珠江口的海天与城市天际线交织,塔下湾区水色在暮光中泛起微亮。", "mapX": 81.5, "mapY": 37.7 }
|
|
83
83
|
],
|
|
84
84
|
"domain": "park",
|
|
85
85
|
"souvenirs": [
|
|
@@ -114,9 +114,9 @@
|
|
|
114
114
|
"id": "surfing",
|
|
115
115
|
"name": "冲浪",
|
|
116
116
|
"locations": [
|
|
117
|
-
{ "id": "surfing-banzai-pipeline", "name": "北岸班赛管浪 Banzai Pipeline", "region": "美国夏威夷瓦胡岛", "scenery": "清透海浪沿金色沙滩舒展,棕榈树与远方海平线映着午后暖光。" },
|
|
118
|
-
{ "id": "surfing-ujung-batu", "name": "乌鲁瓦图 Uluwatu", "region": "印度尼西亚巴厘岛", "scenery": "石灰岩海岬环抱碧蓝海湾,白色浪花与热带植被相映成清新画卷。" },
|
|
119
|
-
{ "id": "surfing-nazare", "name": "纳扎雷 Nazaré 海岸", "region": "葡萄牙莱里亚区", "scenery": "大西洋海岸在辽阔天空下闪着银蓝色光泽,彩色渔村沿着沙湾静静展开。" }
|
|
117
|
+
{ "id": "surfing-banzai-pipeline", "name": "北岸班赛管浪 Banzai Pipeline", "region": "美国夏威夷瓦胡岛", "scenery": "清透海浪沿金色沙滩舒展,棕榈树与远方海平线映着午后暖光。", "mapX": 6.1, "mapY": 37.9 },
|
|
118
|
+
{ "id": "surfing-ujung-batu", "name": "乌鲁瓦图 Uluwatu", "region": "印度尼西亚巴厘岛", "scenery": "石灰岩海岬环抱碧蓝海湾,白色浪花与热带植被相映成清新画卷。", "mapX": 82.0, "mapY": 54.9 },
|
|
119
|
+
{ "id": "surfing-nazare", "name": "纳扎雷 Nazaré 海岸", "region": "葡萄牙莱里亚区", "scenery": "大西洋海岸在辽阔天空下闪着银蓝色光泽,彩色渔村沿着沙湾静静展开。", "mapX": 47.5, "mapY": 28.0 }
|
|
120
120
|
],
|
|
121
121
|
"domain": "water",
|
|
122
122
|
"souvenirs": [
|
|
@@ -151,9 +151,9 @@
|
|
|
151
151
|
"id": "downhill-ski",
|
|
152
152
|
"name": "高山速降滑雪",
|
|
153
153
|
"locations": [
|
|
154
|
-
{ "id": "ski-zermatt", "name": "采尔马特 Zermatt", "region": "瑞士瓦莱州", "scenery": "马特洪峰映在洁白雪原上,木屋与松林在清冷晴空下显得格外温暖。" },
|
|
155
|
-
{ "id": "ski-whistler", "name": "惠斯勒黑梳山 Whistler Blackcomb", "region": "加拿大不列颠哥伦比亚省", "scenery": "雪松林与宽阔雪坡延向远处山脊,淡蓝天空映着柔和冬日阳光。" },
|
|
156
|
-
{ "id": "ski-val-gardena", "name": "加尔代纳山谷 Val Gardena", "region": "意大利南蒂罗尔", "scenery": "多洛米蒂粉色岩峰环抱银白山谷,山间村庄透出宁静的木屋灯火。" }
|
|
154
|
+
{ "id": "ski-zermatt", "name": "采尔马特 Zermatt", "region": "瑞士瓦莱州", "scenery": "马特洪峰映在洁白雪原上,木屋与松林在清冷晴空下显得格外温暖。", "mapX": 52.2, "mapY": 24.4 },
|
|
155
|
+
{ "id": "ski-whistler", "name": "惠斯勒黑梳山 Whistler Blackcomb", "region": "加拿大不列颠哥伦比亚省", "scenery": "雪松林与宽阔雪坡延向远处山脊,淡蓝天空映着柔和冬日阳光。", "mapX": 15.8, "mapY": 22.2 },
|
|
156
|
+
{ "id": "ski-val-gardena", "name": "加尔代纳山谷 Val Gardena", "region": "意大利南蒂罗尔", "scenery": "多洛米蒂粉色岩峰环抱银白山谷,山间村庄透出宁静的木屋灯火。", "mapX": 53.3, "mapY": 24.1 }
|
|
157
157
|
],
|
|
158
158
|
"domain": "snow",
|
|
159
159
|
"souvenirs": [
|
|
@@ -188,9 +188,9 @@
|
|
|
188
188
|
"id": "free-climbing",
|
|
189
189
|
"name": "自由攀岩",
|
|
190
190
|
"locations": [
|
|
191
|
-
{ "id": "climb-yosemite-el-capitan", "name": "酋长岩 El Capitan", "region": "美国加利福尼亚州优胜美地", "scenery": "浅金色花岗岩壁在阳光中显出细腻纹理,山谷松林与远山铺展开阔背景。" },
|
|
192
|
-
{ "id": "climb-kalymnos", "name": "卡林诺斯岛 Kalymnos", "region": "希腊南爱琴海", "scenery": "暖色石灰岩峭壁俯瞰爱琴海,白墙蓝顶村落点缀在明亮海岸线旁。" },
|
|
193
|
-
{ "id": "climb-el-chalten", "name": "菲茨罗伊峰 Fitz Roy", "region": "阿根廷圣克鲁斯省", "scenery": "锯齿状花岗岩峰映着巴塔哥尼亚澄澈云光,山脚湖泊倒映层层山色。" }
|
|
191
|
+
{ "id": "climb-yosemite-el-capitan", "name": "酋长岩 El Capitan", "region": "美国加利福尼亚州优胜美地", "scenery": "浅金色花岗岩壁在阳光中显出细腻纹理,山谷松林与远山铺展开阔背景。", "mapX": 16.8, "mapY": 29.1 },
|
|
192
|
+
{ "id": "climb-kalymnos", "name": "卡林诺斯岛 Kalymnos", "region": "希腊南爱琴海", "scenery": "暖色石灰岩峭壁俯瞰爱琴海,白墙蓝顶村落点缀在明亮海岸线旁。", "mapX": 57.5, "mapY": 29.5 },
|
|
193
|
+
{ "id": "climb-el-chalten", "name": "菲茨罗伊峰 Fitz Roy", "region": "阿根廷圣克鲁斯省", "scenery": "锯齿状花岗岩峰映着巴塔哥尼亚澄澈云光,山脚湖泊倒映层层山色。", "mapX": 29.7, "mapY": 77.4 }
|
|
194
194
|
],
|
|
195
195
|
"aliases": [
|
|
196
196
|
"徒手攀岩",
|
|
@@ -225,9 +225,9 @@
|
|
|
225
225
|
"id": "skate-halfpipe",
|
|
226
226
|
"name": "滑板U池",
|
|
227
227
|
"locations": [
|
|
228
|
-
{ "id": "skate-venice-beach", "name": "威尼斯海滩滑板公园 Venice Beach", "region": "美国加利福尼亚州洛杉矶", "scenery": "海边弧形滑板池与棕榈树相映,太平洋的蓝色在阳光下轻轻闪烁。" },
|
|
229
|
-
{ "id": "skate-barcelona-montjuic", "name": "蒙锥克山滑板场 Montjuïc", "region": "西班牙巴塞罗那", "scenery": "城市红瓦屋顶与地中海天际线铺展在开阔场地之外,午后光线温柔明亮。" },
|
|
230
|
-
{ "id": "skate-shanghai-jiangwan", "name": "江湾体育中心滑板场", "region": "中国上海", "scenery": "现代城市绿地环绕流畅的碗池,树影与浅蓝天色映在干净的场地边缘。" }
|
|
228
|
+
{ "id": "skate-venice-beach", "name": "威尼斯海滩滑板公园 Venice Beach", "region": "美国加利福尼亚州洛杉矶", "scenery": "海边弧形滑板池与棕榈树相映,太平洋的蓝色在阳光下轻轻闪烁。", "mapX": 17.1, "mapY": 31.1 },
|
|
229
|
+
{ "id": "skate-barcelona-montjuic", "name": "蒙锥克山滑板场 Montjuïc", "region": "西班牙巴塞罗那", "scenery": "城市红瓦屋顶与地中海天际线铺展在开阔场地之外,午后光线温柔明亮。", "mapX": 50.6, "mapY": 27.0 },
|
|
230
|
+
{ "id": "skate-shanghai-jiangwan", "name": "江湾体育中心滑板场", "region": "中国上海", "scenery": "现代城市绿地环绕流畅的碗池,树影与浅蓝天色映在干净的场地边缘。", "mapX": 83.8, "mapY": 32.6 }
|
|
231
231
|
],
|
|
232
232
|
"aliases": [
|
|
233
233
|
"滑板半管",
|
|
@@ -262,9 +262,9 @@
|
|
|
262
262
|
"id": "ice-climbing",
|
|
263
263
|
"name": "攀冰",
|
|
264
264
|
"locations": [
|
|
265
|
-
{ "id": "ice-climb-ouray", "name": "乌雷冰雪公园 Ouray Ice Park", "region": "美国科罗拉多州", "scenery": "峡谷冰瀑在冬日阳光下泛着晶莹蓝白光泽,针叶林与雪地安静相拥。" },
|
|
266
|
-
{ "id": "ice-climb-rjukan", "name": "尤坎 Rjukan 冰瀑谷", "region": "挪威泰勒马克郡", "scenery": "层叠冰瀑与深色岩壁形成清晰纹理,山谷薄雾在冷冽天光中缓缓流动。" },
|
|
267
|
-
{ "id": "ice-climb-cogne", "name": "科涅 Cogne 山谷", "region": "意大利瓦莱达奥斯塔", "scenery": "阿尔卑斯雪峰围绕静谧山谷,冰瀑边的松林覆着轻盈白雪。" }
|
|
265
|
+
{ "id": "ice-climb-ouray", "name": "乌雷冰雪公园 Ouray Ice Park", "region": "美国科罗拉多州", "scenery": "峡谷冰瀑在冬日阳光下泛着晶莹蓝白光泽,针叶林与雪地安静相拥。", "mapX": 20.1, "mapY": 28.9 },
|
|
266
|
+
{ "id": "ice-climb-rjukan", "name": "尤坎 Rjukan 冰瀑谷", "region": "挪威泰勒马克郡", "scenery": "层叠冰瀑与深色岩壁形成清晰纹理,山谷薄雾在冷冽天光中缓缓流动。", "mapX": 52.4, "mapY": 16.7 },
|
|
267
|
+
{ "id": "ice-climb-cogne", "name": "科涅 Cogne 山谷", "region": "意大利瓦莱达奥斯塔", "scenery": "阿尔卑斯雪峰围绕静谧山谷,冰瀑边的松林覆着轻盈白雪。", "mapX": 52.0, "mapY": 24.7 }
|
|
268
268
|
],
|
|
269
269
|
"aliases": [
|
|
270
270
|
"冰瀑攀登",
|
|
@@ -299,9 +299,9 @@
|
|
|
299
299
|
"id": "cave-diving",
|
|
300
300
|
"name": "洞穴潜水",
|
|
301
301
|
"locations": [
|
|
302
|
-
{ "id": "cave-yucatan-cenote", "name": "尤卡坦天然井 Cenote", "region": "墨西哥尤卡坦半岛", "scenery": "天光穿过岩顶洒入澄澈蓝绿水池,石灰岩洞壁与垂落藤蔓映出梦幻光影。" },
|
|
303
|
-
{ "id": "cave-blue-hole-palawan", "name": "科隆蓝洞 Blue Hole", "region": "菲律宾巴拉望", "scenery": "热带海岛的海水透出层层钴蓝,洞口光束在安静水下勾勒柔和轮廓。" },
|
|
304
|
-
{ "id": "cave-lake-mountain", "name": "萨尔茨卡默古特湖区洞穴", "region": "奥地利上奥地利州", "scenery": "清澈山湖与石灰岩洞窟相连,水下微光映出静谧的青蓝色纹理。" }
|
|
302
|
+
{ "id": "cave-yucatan-cenote", "name": "尤卡坦天然井 Cenote", "region": "墨西哥尤卡坦半岛", "scenery": "天光穿过岩顶洒入澄澈蓝绿水池,石灰岩洞壁与垂落藤蔓映出梦幻光影。", "mapX": 25.4, "mapY": 38.5 },
|
|
303
|
+
{ "id": "cave-blue-hole-palawan", "name": "科隆蓝洞 Blue Hole", "region": "菲律宾巴拉望", "scenery": "热带海岛的海水透出层层钴蓝,洞口光束在安静水下勾勒柔和轮廓。", "mapX": 83.4, "mapY": 43.4 },
|
|
304
|
+
{ "id": "cave-lake-mountain", "name": "萨尔茨卡默古特湖区洞穴", "region": "奥地利上奥地利州", "scenery": "清澈山湖与石灰岩洞窟相连,水下微光映出静谧的青蓝色纹理。", "mapX": 53.8, "mapY": 23.5 }
|
|
305
305
|
],
|
|
306
306
|
"aliases": [
|
|
307
307
|
"水下洞穴潜水",
|
|
@@ -336,9 +336,9 @@
|
|
|
336
336
|
"id": "mtb-downhill",
|
|
337
337
|
"name": "山地车速降",
|
|
338
338
|
"locations": [
|
|
339
|
-
{ "id": "mtb-whistler", "name": "惠斯勒山地车公园 Whistler Bike Park", "region": "加拿大不列颠哥伦比亚省", "scenery": "松林间的蜿蜒林道穿过高山草甸,远处云影掠过葱郁山坡。" },
|
|
340
|
-
{ "id": "mtb-finale-ligure", "name": "菲纳莱利古雷 Finale Ligure", "region": "意大利利古里亚", "scenery": "地中海海岸在山林小径尽头泛着蓝光,石砌村落藏在橄榄树与暖色岩壁间。" },
|
|
341
|
-
{ "id": "mtb-chengdu-xiling", "name": "西岭雪山山地公园", "region": "中国四川成都", "scenery": "竹林与高山草甸沿着柔和山势铺开,薄雾散去后露出清透的远山轮廓。" }
|
|
339
|
+
{ "id": "mtb-whistler", "name": "惠斯勒山地车公园 Whistler Bike Park", "region": "加拿大不列颠哥伦比亚省", "scenery": "松林间的蜿蜒林道穿过高山草甸,远处云影掠过葱郁山坡。", "mapX": 15.8, "mapY": 22.2 },
|
|
340
|
+
{ "id": "mtb-finale-ligure", "name": "菲纳莱利古雷 Finale Ligure", "region": "意大利利古里亚", "scenery": "地中海海岸在山林小径尽头泛着蓝光,石砌村落藏在橄榄树与暖色岩壁间。", "mapX": 52.3, "mapY": 25.5 },
|
|
341
|
+
{ "id": "mtb-chengdu-xiling", "name": "西岭雪山山地公园", "region": "中国四川成都", "scenery": "竹林与高山草甸沿着柔和山势铺开,薄雾散去后露出清透的远山轮廓。", "mapX": 78.7, "mapY": 33.0 }
|
|
342
342
|
],
|
|
343
343
|
"aliases": [
|
|
344
344
|
"山地自行车速降",
|
|
@@ -373,9 +373,9 @@
|
|
|
373
373
|
"id": "cliff-diving",
|
|
374
374
|
"name": "悬崖跳水",
|
|
375
375
|
"locations": [
|
|
376
|
-
{ "id": "cliff-diving-bay-malta", "name": "圣彼得池 St. Peter’s Pool", "region": "马耳他马尔萨什洛克", "scenery": "浅色石灰岩海岸环抱透明碧蓝水湾,地中海阳光在水面织出细碎光纹。" },
|
|
377
|
-
{ "id": "cliff-diving-ermita", "name": "拉埃尔米塔海湾 La Ermita", "region": "墨西哥阿卡普尔科", "scenery": "弧形海湾与远处港口在暖色日落中层层铺展,岸边灯火映亮平静海面。" },
|
|
378
|
-
{ "id": "cliff-diving-kauai", "name": "考艾岛海岸 Kauai Coast", "region": "美国夏威夷州", "scenery": "翠绿海岸山脉与深蓝太平洋相遇,白云倒映在阳光照亮的海湾中。" }
|
|
376
|
+
{ "id": "cliff-diving-bay-malta", "name": "圣彼得池 St. Peter’s Pool", "region": "马耳他马尔萨什洛克", "scenery": "浅色石灰岩海岸环抱透明碧蓝水湾,地中海阳光在水面织出细碎光纹。", "mapX": 54.0, "mapY": 30.1 },
|
|
377
|
+
{ "id": "cliff-diving-ermita", "name": "拉埃尔米塔海湾 La Ermita", "region": "墨西哥阿卡普尔科", "scenery": "弧形海湾与远处港口在暖色日落中层层铺展,岸边灯火映亮平静海面。", "mapX": 22.3, "mapY": 40.7 },
|
|
378
|
+
{ "id": "cliff-diving-kauai", "name": "考艾岛海岸 Kauai Coast", "region": "美国夏威夷州", "scenery": "翠绿海岸山脉与深蓝太平洋相遇,白云倒映在阳光照亮的海湾中。", "mapX": 5.7, "mapY": 37.8 }
|
|
379
379
|
],
|
|
380
380
|
"aliases": [
|
|
381
381
|
"高台跳水",
|
|
@@ -410,9 +410,9 @@
|
|
|
410
410
|
"id": "paragliding",
|
|
411
411
|
"name": "滑翔伞",
|
|
412
412
|
"locations": [
|
|
413
|
-
{ "id": "paraglide-interlaken", "name": "因特拉肯 Interlaken", "region": "瑞士伯尔尼州", "scenery": "两座碧绿湖泊之间的山谷沐浴在晨光中,阿尔卑斯雪峰清晰映入眼帘。" },
|
|
414
|
-
{ "id": "paraglide-oludeniz", "name": "厄吕代尼兹 Ölüdeniz", "region": "土耳其穆拉省", "scenery": "蓝色泻湖与白色沙滩映着托罗斯山脉,海天颜色在清风里渐次交融。" },
|
|
415
|
-
{ "id": "paraglide-queenstown", "name": "皇后镇 Queenstown", "region": "新西兰奥塔哥", "scenery": "湖泊和群山围成开阔山谷,云影轻轻掠过辽阔的草绿色坡地。" }
|
|
413
|
+
{ "id": "paraglide-interlaken", "name": "因特拉肯 Interlaken", "region": "瑞士伯尔尼州", "scenery": "两座碧绿湖泊之间的山谷沐浴在晨光中,阿尔卑斯雪峰清晰映入眼帘。", "mapX": 52.2, "mapY": 24.1 },
|
|
414
|
+
{ "id": "paraglide-oludeniz", "name": "厄吕代尼兹 Ölüdeniz", "region": "土耳其穆拉省", "scenery": "蓝色泻湖与白色沙滩映着托罗斯山脉,海天颜色在清风里渐次交融。", "mapX": 58.1, "mapY": 29.7 },
|
|
415
|
+
{ "id": "paraglide-queenstown", "name": "皇后镇 Queenstown", "region": "新西兰奥塔哥", "scenery": "湖泊和群山围成开阔山谷,云影轻轻掠过辽阔的草绿色坡地。", "mapX": 96.9, "mapY": 75.0 }
|
|
416
416
|
],
|
|
417
417
|
"aliases": [
|
|
418
418
|
"山地滑翔伞",
|
|
@@ -447,9 +447,9 @@
|
|
|
447
447
|
"id": "hang-gliding",
|
|
448
448
|
"name": "悬挂滑翔",
|
|
449
449
|
"locations": [
|
|
450
|
-
{ "id": "hang-glide-rio", "name": "佩德拉博尼塔 Pedra Bonita", "region": "巴西里约热内卢", "scenery": "热带山林与宽阔海湾相接,城市海岸线在明亮的南美天空下舒展开来。" },
|
|
451
|
-
{ "id": "hang-glide-krusevo", "name": "克鲁舍沃 Kruševo", "region": "北马其顿", "scenery": "起伏山丘围绕古朴石屋小镇,远处湖泊与淡紫色山脊相映成画。" },
|
|
452
|
-
{ "id": "hang-glide-berici", "name": "贝里奇山丘 Colli Berici", "region": "意大利威尼托", "scenery": "葡萄园、村庄与浅绿山丘在温暖天光中交织,远方阿尔卑斯山隐约可见。" }
|
|
450
|
+
{ "id": "hang-glide-rio", "name": "佩德拉博尼塔 Pedra Bonita", "region": "巴西里约热内卢", "scenery": "热带山林与宽阔海湾相接,城市海岸线在明亮的南美天空下舒展开来。", "mapX": 38.0, "mapY": 62.8 },
|
|
451
|
+
{ "id": "hang-glide-krusevo", "name": "克鲁舍沃 Kruševo", "region": "北马其顿", "scenery": "起伏山丘围绕古朴石屋小镇,远处湖泊与淡紫色山脊相映成画。", "mapX": 55.9, "mapY": 27.0 },
|
|
452
|
+
{ "id": "hang-glide-berici", "name": "贝里奇山丘 Colli Berici", "region": "意大利威尼托", "scenery": "葡萄园、村庄与浅绿山丘在温暖天光中交织,远方阿尔卑斯山隐约可见。", "mapX": 53.2, "mapY": 24.7 }
|
|
453
453
|
],
|
|
454
454
|
"aliases": ["三角翼滑翔", "滑翔翼"],
|
|
455
455
|
"tag": "空中",
|
|
@@ -469,9 +469,9 @@
|
|
|
469
469
|
"id": "kitesurfing",
|
|
470
470
|
"name": "风筝冲浪",
|
|
471
471
|
"locations": [
|
|
472
|
-
{ "id": "kite-le-morne", "name": "莫纳山 Le Morne", "region": "毛里求斯西南海岸", "scenery": "泻湖呈现由浅青至深蓝的层次,莫纳山在清透海风中静静守望海岸。" },
|
|
473
|
-
{ "id": "kite-tarifa", "name": "塔里法 Tarifa", "region": "西班牙安达卢西亚", "scenery": "大西洋与地中海在海峡相望,白色小镇和沙滩沐浴在柔和阳光里。" },
|
|
474
|
-
{ "id": "kite-hainan", "name": "万宁日月湾", "region": "中国海南", "scenery": "椰林沿着弧形海湾摇曳,清澈海水与明亮天空连成舒展的蓝色画面。" }
|
|
472
|
+
{ "id": "kite-le-morne", "name": "莫纳山 Le Morne", "region": "毛里求斯西南海岸", "scenery": "泻湖呈现由浅青至深蓝的层次,莫纳山在清透海风中静静守望海岸。", "mapX": 65.9, "mapY": 61.4 },
|
|
473
|
+
{ "id": "kite-tarifa", "name": "塔里法 Tarifa", "region": "西班牙安达卢西亚", "scenery": "大西洋与地中海在海峡相望,白色小镇和沙滩沐浴在柔和阳光里。", "mapX": 48.4, "mapY": 30.0 },
|
|
474
|
+
{ "id": "kite-hainan", "name": "万宁日月湾", "region": "中国海南", "scenery": "椰林沿着弧形海湾摇曳,清澈海水与明亮天空连成舒展的蓝色画面。", "mapX": 80.7, "mapY": 39.6 }
|
|
475
475
|
],
|
|
476
476
|
"aliases": ["风筝滑水", "海上风筝冲浪"],
|
|
477
477
|
"tag": "水上",
|
|
@@ -491,9 +491,9 @@
|
|
|
491
491
|
"id": "whitewater-kayaking",
|
|
492
492
|
"name": "激流皮划艇",
|
|
493
493
|
"locations": [
|
|
494
|
-
{ "id": "kayak-soca", "name": "索察河 Soča River", "region": "斯洛文尼亚朱利安阿尔卑斯", "scenery": "翡翠色河水绕过圆润白石,山谷森林与远处雪峰映在清亮水面。" },
|
|
495
|
-
{ "id": "kayak-rau", "name": "劳塔布河河谷 Rautas River", "region": "瑞典拉普兰", "scenery": "北境河流穿过松林与宽阔苔原,浅色山脉在柔和极昼天光下延伸。" },
|
|
496
|
-
{ "id": "kayak-yulong", "name": "遇龙河", "region": "中国广西阳朔", "scenery": "清澈河水缓缓绕过喀斯特峰林,田园竹筏与岸边翠竹映出诗意倒影。" }
|
|
494
|
+
{ "id": "kayak-soca", "name": "索察河 Soča River", "region": "斯洛文尼亚朱利安阿尔卑斯", "scenery": "翡翠色河水绕过圆润白石,山谷森林与远处雪峰映在清亮水面。", "mapX": 53.8, "mapY": 24.3 },
|
|
495
|
+
{ "id": "kayak-rau", "name": "劳塔布河河谷 Rautas River", "region": "瑞典拉普兰", "scenery": "北境河流穿过松林与宽阔苔原,浅色山脉在柔和极昼天光下延伸。", "mapX": 55.8, "mapY": 12.3 },
|
|
496
|
+
{ "id": "kayak-yulong", "name": "遇龙河", "region": "中国广西阳朔", "scenery": "清澈河水缓缓绕过喀斯特峰林,田园竹筏与岸边翠竹映出诗意倒影。", "mapX": 80.7, "mapY": 36.2 }
|
|
497
497
|
],
|
|
498
498
|
"aliases": ["溪流皮划艇", "白水皮划艇"],
|
|
499
499
|
"tag": "水上",
|
|
@@ -513,9 +513,9 @@
|
|
|
513
513
|
"id": "snowboarding",
|
|
514
514
|
"name": "单板自由式滑雪",
|
|
515
515
|
"locations": [
|
|
516
|
-
{ "id": "snowboard-niseko", "name": "二世古 Niseko", "region": "日本北海道", "scenery": "松林与细软雪原连成安静冬景,远处羊蹄山在淡蓝晨光中清晰可见。" },
|
|
517
|
-
{ "id": "snowboard-laax", "name": "莱克斯 Laax", "region": "瑞士格劳宾登州", "scenery": "开阔雪场与白色山峰映着晴朗天空,山谷木屋散发温暖的冬日气息。" },
|
|
518
|
-
{ "id": "snowboard-park-city", "name": "帕克城 Park City", "region": "美国犹他州", "scenery": "雪松林环绕着明亮山坡,历史小镇的彩色屋顶在洁净雪光中格外鲜明。" }
|
|
516
|
+
{ "id": "snowboard-niseko", "name": "二世古 Niseko", "region": "日本北海道", "scenery": "松林与细软雪原连成安静冬景,远处羊蹄山在淡蓝晨光中清晰可见。", "mapX": 89.1, "mapY": 26.2 },
|
|
517
|
+
{ "id": "snowboard-laax", "name": "莱克斯 Laax", "region": "瑞士格劳宾登州", "scenery": "开阔雪场与白色山峰映着晴朗天空,山谷木屋散发温暖的冬日气息。", "mapX": 52.6, "mapY": 24.0 },
|
|
518
|
+
{ "id": "snowboard-park-city", "name": "帕克城 Park City", "region": "美国犹他州", "scenery": "雪松林环绕着明亮山坡,历史小镇的彩色屋顶在洁净雪光中格外鲜明。", "mapX": 19.0, "mapY": 27.4 }
|
|
519
519
|
],
|
|
520
520
|
"aliases": ["单板滑雪", "粉雪单板"],
|
|
521
521
|
"tag": "雪地",
|
|
@@ -535,9 +535,9 @@
|
|
|
535
535
|
"id": "via-ferrata",
|
|
536
536
|
"name": "悬崖飞拉达",
|
|
537
537
|
"locations": [
|
|
538
|
-
{ "id": "ferrata-dolomites", "name": "多洛米蒂山脉 Dolomites", "region": "意大利南蒂罗尔", "scenery": "粉色岩峰与翠绿山谷相互映衬,云层在远山之间留下柔和明暗。" },
|
|
539
|
-
{ "id": "ferrata-garmisch", "name": "楚格峰 Zugspitze", "region": "德国巴伐利亚", "scenery": "高山平台俯瞰层叠森林与湛蓝湖泊,雪线在阳光中勾勒出清晰轮廓。" },
|
|
540
|
-
{ "id": "ferrata-huashan", "name": "华山西峰", "region": "中国陕西", "scenery": "花岗岩山脊在云海上方伸展,峰峦与晨曦共同构成辽阔的东方山景。" }
|
|
538
|
+
{ "id": "ferrata-dolomites", "name": "多洛米蒂山脉 Dolomites", "region": "意大利南蒂罗尔", "scenery": "粉色岩峰与翠绿山谷相互映衬,云层在远山之间留下柔和明暗。", "mapX": 53.3, "mapY": 24.2 },
|
|
539
|
+
{ "id": "ferrata-garmisch", "name": "楚格峰 Zugspitze", "region": "德国巴伐利亚", "scenery": "高山平台俯瞰层叠森林与湛蓝湖泊,雪线在阳光中勾勒出清晰轮廓。", "mapX": 53.1, "mapY": 23.7 },
|
|
540
|
+
{ "id": "ferrata-huashan", "name": "华山西峰", "region": "中国陕西", "scenery": "花岗岩山脊在云海上方伸展,峰峦与晨曦共同构成辽阔的东方山景。", "mapX": 80.6, "mapY": 30.8 }
|
|
541
541
|
],
|
|
542
542
|
"aliases": ["飞拉达", "铁道式攀登"],
|
|
543
543
|
"tag": "岩壁",
|
|
@@ -557,9 +557,9 @@
|
|
|
557
557
|
"id": "bmx-freestyle",
|
|
558
558
|
"name": "BMX 小轮车",
|
|
559
559
|
"locations": [
|
|
560
|
-
{ "id": "bmx-woodward", "name": "伍德沃德西部运动营 Woodward West", "region": "美国加利福尼亚州", "scenery": "明亮专业运动园区与远处山脉相连,绿树和宽阔天空让场地显得轻松开朗。" },
|
|
561
|
-
{ "id": "bmx-suzhou-park", "name": "苏州阳澄湖体育公园", "region": "中国江苏苏州", "scenery": "现代运动场地沿湖展开,水面、绿地与城市天际线在清朗天气里相映。" },
|
|
562
|
-
{ "id": "bmx-copenhagen", "name": "哥本哈根街头运动场", "region": "丹麦首都大区", "scenery": "北欧现代建筑与海港绿地围绕开放式运动空间,云影投下宁静的浅灰蓝色调。" }
|
|
560
|
+
{ "id": "bmx-woodward", "name": "伍德沃德西部运动营 Woodward West", "region": "美国加利福尼亚州", "scenery": "明亮专业运动园区与远处山脉相连,绿树和宽阔天空让场地显得轻松开朗。", "mapX": 17.1, "mapY": 30.6 },
|
|
561
|
+
{ "id": "bmx-suzhou-park", "name": "苏州阳澄湖体育公园", "region": "中国江苏苏州", "scenery": "现代运动场地沿湖展开,水面、绿地与城市天际线在清朗天气里相映。", "mapX": 83.5, "mapY": 32.6 },
|
|
562
|
+
{ "id": "bmx-copenhagen", "name": "哥本哈根街头运动场", "region": "丹麦首都大区", "scenery": "北欧现代建筑与海港绿地围绕开放式运动空间,云影投下宁静的浅灰蓝色调。", "mapX": 53.5, "mapY": 19.1 }
|
|
563
563
|
],
|
|
564
564
|
"aliases": ["自由式小轮车", "BMX"],
|
|
565
565
|
"tag": "场地",
|
package/src/definition.js
CHANGED
|
@@ -33,6 +33,8 @@ const TOOL_DECLS = Object.freeze([
|
|
|
33
33
|
weather: { type: 'string', description: '指定天气时段 id;省略则随机。' },
|
|
34
34
|
gear: { type: 'string', description: '指定已解锁装备 id;省略则随机。' },
|
|
35
35
|
locationId: { type: 'string', description: '指定地点 id;省略则随机。' },
|
|
36
|
+
expeditionId: { type: 'string', description: '沿已启动的远征路线前往下一站。' },
|
|
37
|
+
packItemId: { type: 'string', description: '随身小物 id;可从 state 的 packItems 目录选择。' },
|
|
36
38
|
},
|
|
37
39
|
required: [],
|
|
38
40
|
additionalProperties: false,
|
package/src/draw.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
2
|
import { mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises';
|
|
3
|
-
import { join } from 'node:path';
|
|
3
|
+
import { join, resolve } from 'node:path';
|
|
4
|
+
import { pathToFileURL } from 'node:url';
|
|
4
5
|
|
|
5
6
|
const DEFAULTS = Object.freeze({
|
|
6
7
|
mode: 'delegate', apiProtocol: 'openai-images', apiBaseUrl: '', apiKey: '', apiModel: '',
|
|
7
8
|
apiSize: '1024x1024', comfyUrl: 'http://127.0.0.1:8188', comfyWorkflow: '',
|
|
8
9
|
comfyNegative: 'lowres, bad anatomy, bad hands, text, watermark, error, blurry',
|
|
10
|
+
localProtocol: 'comfyui', sdwebuiUrl: 'http://127.0.0.1:7860', sdwebuiSampler: 'DPM++ 2M',
|
|
11
|
+
sdwebuiSteps: '24', sdwebuiCfg: '7', sdwebuiNegative: '',
|
|
9
12
|
});
|
|
10
13
|
|
|
11
14
|
export const DEFAULT_COMFY_WORKFLOW = Object.freeze({
|
|
@@ -27,6 +30,7 @@ function normalizeConfig(value = {}) {
|
|
|
27
30
|
delete config.delegateTool;
|
|
28
31
|
if (!['delegate', 'api', 'local', 'none'].includes(config.mode)) config.mode = DEFAULTS.mode;
|
|
29
32
|
if (!['openai-images', 'openai-chat', 'gemini'].includes(config.apiProtocol)) config.apiProtocol = DEFAULTS.apiProtocol;
|
|
33
|
+
if (!['comfyui', 'sdwebui'].includes(config.localProtocol)) config.localProtocol = DEFAULTS.localProtocol;
|
|
30
34
|
for (const key of Object.keys(DEFAULTS)) config[key] = asString(config[key], DEFAULTS[key]);
|
|
31
35
|
return config;
|
|
32
36
|
}
|
|
@@ -178,6 +182,50 @@ async function directApi(drawConfig, prompt, fetchImpl, timeoutMs) {
|
|
|
178
182
|
throw new Error('Gemini response contained no image');
|
|
179
183
|
}
|
|
180
184
|
|
|
185
|
+
function parseImageSize(size) {
|
|
186
|
+
const match = size.trim().match(/^(\d+)\s*[xX]\s*(\d+)$/u);
|
|
187
|
+
const width = Number(match?.[1]);
|
|
188
|
+
const height = Number(match?.[2]);
|
|
189
|
+
return Number.isSafeInteger(width) && width > 0 && Number.isSafeInteger(height) && height > 0
|
|
190
|
+
? { width, height } : { width: 1024, height: 1024 };
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function positiveNumber(value, fallback, maximum, integer = false) {
|
|
194
|
+
const parsed = Number(value);
|
|
195
|
+
const positive = Number.isFinite(parsed) && parsed > 0 ? parsed : Number(fallback);
|
|
196
|
+
return Math.min(maximum, Math.max(1, integer ? Math.floor(positive) : positive));
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
async function directSdWebui(drawConfig, prompt, fetchImpl, timeoutMs) {
|
|
200
|
+
const base = cleanBase(drawConfig.sdwebuiUrl);
|
|
201
|
+
if (!base) throw new Error('sdwebuiUrl is required');
|
|
202
|
+
try {
|
|
203
|
+
const response = await fetchImpl(`${base}/sdapi/v1/txt2img`, {
|
|
204
|
+
method: 'POST', headers: { 'Content-Type': 'application/json' }, signal: timeoutSignal(timeoutMs),
|
|
205
|
+
body: JSON.stringify({
|
|
206
|
+
prompt, negative_prompt: drawConfig.sdwebuiNegative || drawConfig.comfyNegative,
|
|
207
|
+
...parseImageSize(drawConfig.apiSize),
|
|
208
|
+
steps: positiveNumber(drawConfig.sdwebuiSteps, DEFAULTS.sdwebuiSteps, 150, true),
|
|
209
|
+
cfg_scale: positiveNumber(drawConfig.sdwebuiCfg, DEFAULTS.sdwebuiCfg, 30),
|
|
210
|
+
sampler_name: drawConfig.sdwebuiSampler || DEFAULTS.sdwebuiSampler, batch_size: 1,
|
|
211
|
+
}),
|
|
212
|
+
});
|
|
213
|
+
const json = await responseJson(response);
|
|
214
|
+
const image = Array.isArray(json?.images) ? json.images[0] : null;
|
|
215
|
+
if (typeof image !== 'string' || !image.trim()) throw new Error('response contained no image');
|
|
216
|
+
const encoded = image.trim().replace(/^data:image\/[^;,]+;base64,/iu, '').replace(/\s/gu, '');
|
|
217
|
+
if (!/^[A-Za-z0-9+/]+={0,2}$/u.test(encoded) || encoded.length % 4 === 1
|
|
218
|
+
|| (encoded.includes('=') && encoded.length % 4 !== 0)
|
|
219
|
+
|| decodeBase64(encoded).toString('base64').replace(/=+$/u, '') !== encoded.replace(/=+$/u, '')) {
|
|
220
|
+
throw new Error('response contained invalid base64 image');
|
|
221
|
+
}
|
|
222
|
+
return { ...imageFromData(encoded), mode: 'local', provider: 'sdwebui' };
|
|
223
|
+
} catch (error) {
|
|
224
|
+
if (error?.name === 'TimeoutError' || error?.name === 'AbortError') throw new Error('SD WebUI generation timed out');
|
|
225
|
+
throw new Error(`SD WebUI: ${error instanceof Error ? error.message : String(error)}`);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
181
229
|
async function directComfy(drawConfig, prompt, negative, fetchImpl, timeoutMs) {
|
|
182
230
|
const base = cleanBase(drawConfig.comfyUrl);
|
|
183
231
|
if (!base) throw new Error('comfyUrl is required');
|
|
@@ -204,17 +252,51 @@ export async function executeDirectDraw({ drawConfig = {}, prompt = '', negative
|
|
|
204
252
|
try {
|
|
205
253
|
if (typeof fetchImpl !== 'function') throw new Error('fetch is unavailable');
|
|
206
254
|
if (drawConfig.mode === 'api') return await directApi(normalizeConfig(drawConfig), prompt, fetchImpl, timeoutMs);
|
|
207
|
-
if (drawConfig.mode === 'local')
|
|
255
|
+
if (drawConfig.mode === 'local') {
|
|
256
|
+
const config = normalizeConfig(drawConfig);
|
|
257
|
+
return config.localProtocol === 'sdwebui'
|
|
258
|
+
? await directSdWebui(config, prompt, fetchImpl, timeoutMs)
|
|
259
|
+
: await directComfy(config, prompt, negative, fetchImpl, timeoutMs);
|
|
260
|
+
}
|
|
208
261
|
throw new Error('direct draw mode must be api or local');
|
|
209
262
|
} catch (error) { return { ok: false, error: error instanceof Error ? error.message : String(error) }; }
|
|
210
263
|
}
|
|
211
264
|
|
|
265
|
+
export async function generateImage({ dataDir, config = {}, drawConfig = config, ...options } = {}) {
|
|
266
|
+
if (typeof dataDir !== 'string' || !dataDir.trim()) throw new Error('dataDir is required');
|
|
267
|
+
const normalized = normalizeConfig(drawConfig);
|
|
268
|
+
const result = await executeDirectDraw({ ...options, drawConfig: normalized });
|
|
269
|
+
if (!result.ok) throw new Error(result.error);
|
|
270
|
+
const directory = resolve(dataDir, 'fish-x', 'images');
|
|
271
|
+
const imagePath = join(directory, `${randomUUID()}${result.extension}`);
|
|
272
|
+
await mkdir(directory, { recursive: true });
|
|
273
|
+
await writeFile(imagePath, result.buffer, { flag: 'wx' });
|
|
274
|
+
return {
|
|
275
|
+
imageUrl: pathToFileURL(imagePath).href, imagePath, mode: normalized.mode,
|
|
276
|
+
provider: normalized.mode === 'local' ? normalized.localProtocol : normalized.apiProtocol,
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
|
|
212
280
|
export async function testDrawConnection({ drawConfig = {}, fetchImpl = globalThis.fetch } = {}) {
|
|
213
281
|
try {
|
|
214
282
|
const config = normalizeConfig(drawConfig);
|
|
215
283
|
if (config.mode === 'delegate' || config.mode === 'none') return { ok: true, message: 'No direct connection required' };
|
|
216
284
|
if (typeof fetchImpl !== 'function') throw new Error('fetch is unavailable');
|
|
217
285
|
if (config.mode === 'local') {
|
|
286
|
+
if (config.localProtocol === 'sdwebui') {
|
|
287
|
+
const base = cleanBase(config.sdwebuiUrl);
|
|
288
|
+
if (!base) throw new Error('sdwebuiUrl is required');
|
|
289
|
+
const options = { method: 'GET', signal: timeoutSignal(10000) };
|
|
290
|
+
const response = await fetchImpl(`${base}/sdapi/v1/sd-models`, options);
|
|
291
|
+
if ([404, 405, 501].includes(response.status)) {
|
|
292
|
+
const settings = await responseJson(await fetchImpl(`${base}/sdapi/v1/options`, options));
|
|
293
|
+
if (!isRecord(settings)) throw new Error('SD WebUI returned invalid options');
|
|
294
|
+
return { ok: true, message: 'SD WebUI connection successful (options endpoint; model count unavailable)' };
|
|
295
|
+
}
|
|
296
|
+
const models = await responseJson(response);
|
|
297
|
+
if (!Array.isArray(models)) throw new Error('SD WebUI returned invalid model list');
|
|
298
|
+
return { ok: true, message: `SD WebUI connection successful (${models.length} models available)`, modelCount: models.length };
|
|
299
|
+
}
|
|
218
300
|
const response = await fetchImpl(`${cleanBase(config.comfyUrl)}/system_stats`, { signal: timeoutSignal(10000) });
|
|
219
301
|
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
220
302
|
return { ok: true, message: 'ComfyUI connection successful' };
|
package/src/state.js
CHANGED
|
@@ -9,6 +9,51 @@ const pendingPlays = new Map();
|
|
|
9
9
|
const pendingWrites = new Map();
|
|
10
10
|
const DOMAINS = ['air', 'water', 'snow', 'rock', 'park'];
|
|
11
11
|
|
|
12
|
+
export const EXPEDITIONS = Object.freeze([
|
|
13
|
+
{
|
|
14
|
+
id: 'pacific-wave', name: '环太平洋逐浪线', desc: '从太平洋岛屿海岸出发,循着浪花与海风一路向南。', badge: '🌊',
|
|
15
|
+
stops: [
|
|
16
|
+
{ sportId: 'cliff-diving', locationId: 'cliff-diving-kauai', label: '考艾岛海岸' },
|
|
17
|
+
{ sportId: 'surfing', locationId: 'surfing-banzai-pipeline', label: '北岸班赛管浪' },
|
|
18
|
+
{ sportId: 'bungee', locationId: 'bungee-kawarau', label: '卡瓦劳大桥' },
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
id: 'alpine-frost', name: '阿尔卑斯雪域三部曲', desc: '在阿尔卑斯雪峰间完成滑雪、冰瀑与山脊三站。', badge: '❄️',
|
|
23
|
+
stops: [
|
|
24
|
+
{ sportId: 'downhill-ski', locationId: 'ski-zermatt', label: '采尔马特' },
|
|
25
|
+
{ sportId: 'ice-climbing', locationId: 'ice-climb-cogne', label: '科涅山谷' },
|
|
26
|
+
{ sportId: 'via-ferrata', locationId: 'ferrata-dolomites', label: '多洛米蒂山脉' },
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: 'skyline-wind', name: '风洞与天际线穿行', desc: '从城市高塔一路追风,穿过山谷与北欧街区。', badge: '💨',
|
|
31
|
+
stops: [
|
|
32
|
+
{ sportId: 'bungee', locationId: 'bungee-macau-tower', label: '澳门塔湾区天际线' },
|
|
33
|
+
{ sportId: 'paragliding', locationId: 'paraglide-interlaken', label: '因特拉肯山谷' },
|
|
34
|
+
{ sportId: 'bmx-freestyle', locationId: 'bmx-copenhagen', label: '哥本哈根街头' },
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
id: 'aurora-abyss', name: '极光冰海探险线', desc: '沿北境河谷、冰瀑与雪原追寻极光下的蓝色回响。', badge: '🌌',
|
|
39
|
+
stops: [
|
|
40
|
+
{ sportId: 'whitewater-kayaking', locationId: 'kayak-rau', label: '拉普兰河谷' },
|
|
41
|
+
{ sportId: 'ice-climbing', locationId: 'ice-climb-rjukan', label: '尤坎冰瀑谷' },
|
|
42
|
+
{ sportId: 'snowboarding', locationId: 'snowboard-niseko', label: '二世古雪原' },
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
].map(route => Object.freeze({ ...route, stops: Object.freeze(route.stops.map(stop => Object.freeze(stop))) })));
|
|
46
|
+
|
|
47
|
+
export const PACK_ITEMS = Object.freeze([
|
|
48
|
+
{ id: 'sea-salt-candy', name: '海盐能量糖', desc: '活力补给,检定增加 2 点。', effects: { rollBonus: 2 }, bonusLine: '我把海盐糖纸叠成一朵小浪花,勇气也跟着回甘啦。' },
|
|
49
|
+
{ id: 'action-cam', name: '广角运动相机', desc: '纪念品发现率增加 15%,以广角记录风景。', effects: { souvenirBonus: 0.15 }, bonusLine: '相机里装下了整片风景,我想把这束光多看一遍。' },
|
|
50
|
+
{ id: 'waterproof-diary', name: '防水手账本', desc: '细腻记录灵感,本次熟练度额外增加 3 点。', effects: { xpBonus: 3 }, bonusLine: '我在防水手账上认真记下了这阵风的形状。' },
|
|
51
|
+
{ id: 'wind-goggles', name: '防风护目镜', desc: '薄雾或星夜时护航,检定增加 3 点。', effects: { lowVisibilityRollBonus: 3 }, bonusLine: '护目镜挡住了调皮的风,我看见你稳稳完成了这一段。' },
|
|
52
|
+
{ id: 'whale-charm', name: '幸运小鲸挂件', desc: '检定增加 1 点,纪念品发现率增加 10%,附赠鲸鱼彩蛋。', effects: { rollBonus: 1, souvenirBonus: 0.1 }, bonusLine: '小鲸挂件晃了一下——我听见海风在说今天有好运!' },
|
|
53
|
+
].map(item => Object.freeze({ ...item, effects: Object.freeze(item.effects) })));
|
|
54
|
+
|
|
55
|
+
const expeditionById = new Map(EXPEDITIONS.map(route => [route.id, route]));
|
|
56
|
+
|
|
12
57
|
function normalize(value) {
|
|
13
58
|
return String(value ?? '').trim().toLocaleLowerCase();
|
|
14
59
|
}
|
|
@@ -46,6 +91,8 @@ function emptyState() {
|
|
|
46
91
|
daily: { date: null, sportId: null, weatherId: null, completed: false, completedCount: 0 },
|
|
47
92
|
achievements: {},
|
|
48
93
|
nightPlays: 0,
|
|
94
|
+
expeditions: { activeId: null, progress: [], completedIds: [] },
|
|
95
|
+
personalityTendency: { warmth: 0, courage: 0, joy: 0 },
|
|
49
96
|
};
|
|
50
97
|
}
|
|
51
98
|
|
|
@@ -97,7 +144,15 @@ export function cleanLocation(value) {
|
|
|
97
144
|
const region = safeText(value.region, 80);
|
|
98
145
|
const scenery = safeText(value.scenery, 500);
|
|
99
146
|
if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/u.test(id) || !name || !region || !scenery) return null;
|
|
100
|
-
|
|
147
|
+
const mapCoordinate = key => value[key] === null ? null
|
|
148
|
+
: Number.isFinite(value[key]) && value[key] >= 0 && value[key] <= 100 ? value[key] : undefined;
|
|
149
|
+
const mapX = mapCoordinate('mapX');
|
|
150
|
+
const mapY = mapCoordinate('mapY');
|
|
151
|
+
return {
|
|
152
|
+
id, name, region, scenery,
|
|
153
|
+
...(mapX !== undefined ? { mapX } : {}),
|
|
154
|
+
...(mapY !== undefined ? { mapY } : {}),
|
|
155
|
+
};
|
|
101
156
|
}
|
|
102
157
|
|
|
103
158
|
function cleanCustomLocations(value) {
|
|
@@ -122,6 +177,8 @@ function cleanVisitedLocations(value) {
|
|
|
122
177
|
name: safeText(entry.name, 100),
|
|
123
178
|
region: safeText(entry.region, 80),
|
|
124
179
|
scenery: safeText(entry.scenery, 500),
|
|
180
|
+
...(Number.isFinite(entry.mapX) && entry.mapX >= 0 && entry.mapX <= 100 ? { mapX: entry.mapX } : {}),
|
|
181
|
+
...(Number.isFinite(entry.mapY) && entry.mapY >= 0 && entry.mapY <= 100 ? { mapY: entry.mapY } : {}),
|
|
125
182
|
sportId: safeText(entry.sportId, 80),
|
|
126
183
|
sportName: safeText(entry.sportName, 100),
|
|
127
184
|
count: Math.max(1, nonnegativeInteger(entry.count)),
|
|
@@ -130,6 +187,31 @@ function cleanVisitedLocations(value) {
|
|
|
130
187
|
}]));
|
|
131
188
|
}
|
|
132
189
|
|
|
190
|
+
function cleanExpeditions(value) {
|
|
191
|
+
const source = isRecord(value) ? value : {};
|
|
192
|
+
const activeId = typeof source.activeId === 'string' && expeditionById.has(source.activeId) ? source.activeId : null;
|
|
193
|
+
const route = activeId ? expeditionById.get(activeId) : null;
|
|
194
|
+
// Only an ordered prefix can describe a completed chain of stops.
|
|
195
|
+
const progress = [];
|
|
196
|
+
for (const stop of route?.stops ?? []) {
|
|
197
|
+
if (source.progress?.[progress.length] !== stop.locationId) break;
|
|
198
|
+
progress.push(stop.locationId);
|
|
199
|
+
}
|
|
200
|
+
const completedIds = Array.isArray(source.completedIds)
|
|
201
|
+
? [...new Set(source.completedIds.filter(id => typeof id === 'string' && expeditionById.has(id)))]
|
|
202
|
+
: [];
|
|
203
|
+
return { activeId, progress, completedIds };
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function cleanPersonalityTendency(value) {
|
|
207
|
+
const source = isRecord(value) ? value : {};
|
|
208
|
+
return {
|
|
209
|
+
warmth: nonnegativeInteger(source.warmth),
|
|
210
|
+
courage: nonnegativeInteger(source.courage),
|
|
211
|
+
joy: nonnegativeInteger(source.joy),
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
|
|
133
215
|
export function locationsForSport(sport, state = {}) {
|
|
134
216
|
const locations = new Map((Array.isArray(sport?.locations) ? sport.locations : [])
|
|
135
217
|
.map(cleanLocation).filter(Boolean).map(location => [location.id, location]));
|
|
@@ -198,11 +280,13 @@ export async function loadState(dataDir) {
|
|
|
198
280
|
if (!isRecord(parsed) || parsed.schemaVersion !== 3 || !Array.isArray(parsed.recent)) return emptyState();
|
|
199
281
|
const recent = parsed.recent
|
|
200
282
|
.filter(entry => entry && typeof entry.id === 'string' && typeof entry.at === 'string')
|
|
201
|
-
.map(entry => Object.fromEntries([
|
|
283
|
+
.map((entry, index) => Object.fromEntries([
|
|
202
284
|
['id', entry.id],
|
|
203
285
|
['at', entry.at],
|
|
204
286
|
['sportId', typeof entry.sportId === 'string' ? entry.sportId : entry.id],
|
|
205
|
-
|
|
287
|
+
['tripId', typeof entry.tripId === 'string' && entry.tripId ? entry.tripId
|
|
288
|
+
: `legacy-${createHash('sha256').update(JSON.stringify([entry.id, entry.at, entry.caption, index])).digest('hex').slice(0, 24)}`],
|
|
289
|
+
...['sportName', 'caption', 'prompt', 'image', 'weather', 'outcome', 'domain', 'domainLevel', 'leveledUp', 'souvenir', 'gear', 'location', 'storyContext', 'totalPlays', 'sportCount', 'packItem', 'companionNote', 'userReaction', 'expedition']
|
|
206
290
|
.filter(key => entry[key] !== undefined)
|
|
207
291
|
.map(key => [key, entry[key]]),
|
|
208
292
|
]))
|
|
@@ -244,6 +328,8 @@ export async function loadState(dataDir) {
|
|
|
244
328
|
unlockedGear: Array.isArray(parsed.unlockedGear)
|
|
245
329
|
? [...new Set(parsed.unlockedGear.filter(item => typeof item === 'string'))]
|
|
246
330
|
: ['basic-suit'],
|
|
331
|
+
expeditions: cleanExpeditions(parsed.expeditions),
|
|
332
|
+
personalityTendency: cleanPersonalityTendency(parsed.personalityTendency),
|
|
247
333
|
...cleanProgress(parsed),
|
|
248
334
|
};
|
|
249
335
|
} catch {
|
|
@@ -441,6 +527,48 @@ export function setSeasonOverride(dataDir, value) {
|
|
|
441
527
|
});
|
|
442
528
|
}
|
|
443
529
|
|
|
530
|
+
export function startExpedition(dataDir, expeditionId) {
|
|
531
|
+
return withLock(pendingWrites, dataDir, async () => {
|
|
532
|
+
const route = expeditionById.get(expeditionId);
|
|
533
|
+
if (!route) throw new TypeError('远征路线不存在');
|
|
534
|
+
const state = await loadState(dataDir);
|
|
535
|
+
if (state.expeditions.activeId === route.id) return state.expeditions;
|
|
536
|
+
if (state.expeditions.completedIds.includes(route.id)) throw new Error('这条远征路线已经完成');
|
|
537
|
+
state.expeditions = { ...state.expeditions, activeId: route.id, progress: [] };
|
|
538
|
+
await persistState(dataDir, state);
|
|
539
|
+
return state.expeditions;
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
export function abandonExpedition(dataDir) {
|
|
544
|
+
return withLock(pendingWrites, dataDir, async () => {
|
|
545
|
+
const state = await loadState(dataDir);
|
|
546
|
+
state.expeditions = { ...state.expeditions, activeId: null, progress: [] };
|
|
547
|
+
await persistState(dataDir, state);
|
|
548
|
+
return state.expeditions;
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
export function reactTrip(dataDir, tripId, reaction) {
|
|
553
|
+
return withLock(pendingWrites, dataDir, async () => {
|
|
554
|
+
if (typeof tripId !== 'string' || !tripId.trim()) throw new TypeError('tripId 必须是非空文本');
|
|
555
|
+
if (!['praise', 'encourage', 'highfive'].includes(reaction)) throw new TypeError('reaction 无效');
|
|
556
|
+
const state = await loadState(dataDir);
|
|
557
|
+
const index = state.recent.findIndex(entry => entry.tripId === tripId);
|
|
558
|
+
if (index < 0) throw new Error('未找到指定的运动记录');
|
|
559
|
+
if (state.recent[index].userReaction) throw new Error('这条运动记录已经互动过');
|
|
560
|
+
const updated = { ...state.recent[index], userReaction: reaction };
|
|
561
|
+
state.recent[index] = updated;
|
|
562
|
+
const tendencyKey = { praise: 'warmth', encourage: 'courage', highfive: 'joy' }[reaction];
|
|
563
|
+
state.personalityTendency = {
|
|
564
|
+
...state.personalityTendency,
|
|
565
|
+
[tendencyKey]: state.personalityTendency[tendencyKey] + 1,
|
|
566
|
+
};
|
|
567
|
+
await persistState(dataDir, state);
|
|
568
|
+
return { trip: updated, personalityTendency: state.personalityTendency };
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
|
|
444
572
|
export function saveSportPackImport(dataDir, pack, options = {}) {
|
|
445
573
|
return withLock(pendingWrites, dataDir, async () => {
|
|
446
574
|
const state = await loadState(dataDir);
|
|
@@ -482,11 +610,12 @@ async function writePlay(dataDir, id, caption, metadata = {}) {
|
|
|
482
610
|
const recentEntry = {
|
|
483
611
|
id: sportId,
|
|
484
612
|
sportId,
|
|
613
|
+
tripId: typeof metadata.tripId === 'string' ? metadata.tripId : randomUUID(),
|
|
485
614
|
at,
|
|
486
615
|
...(typeof metadata.sportName === 'string' ? { sportName: metadata.sportName } : {}),
|
|
487
616
|
...(typeof caption === 'string' ? { caption } : {}),
|
|
488
617
|
...(typeof metadata.prompt === 'string' ? { prompt: metadata.prompt } : {}),
|
|
489
|
-
...Object.fromEntries(['weather', 'outcome', 'domain', 'domainLevel', 'leveledUp', 'souvenir', 'gear', 'location', 'storyContext', 'totalPlays', 'sportCount']
|
|
618
|
+
...Object.fromEntries(['weather', 'outcome', 'domain', 'domainLevel', 'leveledUp', 'souvenir', 'gear', 'location', 'storyContext', 'totalPlays', 'sportCount', 'packItem', 'companionNote', 'expedition']
|
|
490
619
|
.filter(key => metadata[key] !== undefined)
|
|
491
620
|
.map(key => [key, metadata[key]])),
|
|
492
621
|
};
|
|
@@ -552,6 +681,8 @@ async function writePlay(dataDir, id, caption, metadata = {}) {
|
|
|
552
681
|
const next = {
|
|
553
682
|
...state,
|
|
554
683
|
...cleanProgress({ ...state, ...metadata }),
|
|
684
|
+
expeditions: cleanExpeditions(metadata.expeditions ?? state.expeditions),
|
|
685
|
+
personalityTendency: cleanPersonalityTendency(state.personalityTendency),
|
|
555
686
|
seasonsVisited: [...new Set([...(state.seasonsVisited ?? []), ...(Array.isArray(metadata.seasonsVisited) ? metadata.seasonsVisited : [])])],
|
|
556
687
|
recent: state.recent.slice(-HISTORY_LIMIT),
|
|
557
688
|
};
|