cc2190-buddy 1.0.1 → 1.0.2

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.
Files changed (2) hide show
  1. package/fast_buddy.mjs +8 -5
  2. package/package.json +1 -1
package/fast_buddy.mjs CHANGED
@@ -62,9 +62,9 @@ async function select(title, items, allowSkip=false){
62
62
  items.forEach((it,i) => console.log(` ${c(E.c,`[${i+1}]`)} ${it}`))
63
63
  if(allowSkip) console.log(` ${c(E.d,`[0] 不限制`)}`)
64
64
  const a = await ask(`\n ${c(E.c,'>')} `)
65
+ if(allowSkip && a==='0') return -1
65
66
  const idx = parseInt(a)-1
66
- if(allowSkip && a==='0') return null
67
- return idx>=0&&idx<items.length ? items[idx] : (allowSkip?null:items[0])
67
+ return idx>=0&&idx<items.length ? idx : (allowSkip?-1:0)
68
68
  }
69
69
 
70
70
  async function main(){
@@ -73,17 +73,20 @@ async function main(){
73
73
 
74
74
  // 选择物种
75
75
  const speciesList = SPECIES.map(s => `${SP_E[s]} ${s}`)
76
- const species = await select('选择物种 (可选)', speciesList, true)
76
+ const spIdx = await select('选择物种 (可选)', speciesList, true)
77
+ const species = spIdx>=0 ? SPECIES[spIdx] : null
77
78
  console.log(species ? ` ✓ 物种: ${SP_E[species]} ${species}` : ` ✓ 物种: 不限制`)
78
79
 
79
80
  // 选择眼睛
80
81
  const eyeList = EYES.map(e => ` ${e}`)
81
- const eye = await select('选择眼睛 (可选)', eyeList, true)
82
+ const eyeIdx = await select('选择眼睛 (可选)', eyeList, true)
83
+ const eye = eyeIdx>=0 ? EYES[eyeIdx] : null
82
84
  console.log(eye ? ` ✓ 眼睛: ${eye}` : ` ✓ 眼睛: 不限制`)
83
85
 
84
86
  // 选择帽子
85
87
  const hatList = HATS.map(h => `${HAT_E[h]} ${h}`)
86
- const hat = await select('选择帽子 (可选)', hatList, true)
88
+ const hatIdx = await select('选择帽子 (可选)', hatList, true)
89
+ const hat = hatIdx>=0 ? HATS[hatIdx] : null
87
90
  console.log(hat ? ` ✓ 帽子: ${HAT_E[hat]} ${hat}` : ` ✓ 帽子: 不限制`)
88
91
 
89
92
  // 输入名字
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cc2190-buddy",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "快速搜索 legendary + shiny 宠物,支持自定义物种、眼睛、帽子选项",
5
5
  "type": "module",
6
6
  "bin": {