new:添加从助手导入打造功能
This commit is contained in:
@@ -10,6 +10,7 @@ from api.dp import RedisDep,AltersDep
|
||||
from core.character.adventure import get_adv_list
|
||||
from core.basic.character import createCharacter
|
||||
from core.open.helper import get_user_info_by_id
|
||||
from api.core.exception import ResponseException
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@@ -96,10 +97,11 @@ async def get_skill_info(
|
||||
|
||||
|
||||
@router.get("/dnfhelper/{uid}/")
|
||||
async def get_info_by_dnfhelper(uid: str, redis: RedisDep):
|
||||
async def get_info_by_dnfhelper(uid: str, state: AltersDep, redis: RedisDep):
|
||||
try:
|
||||
result = await get_user_info_by_id(uid,'')
|
||||
result = await get_user_info_by_id(uid,state)
|
||||
return response(data=result)
|
||||
except Exception as e:
|
||||
print(f"Error fetching DNFHelper info: {e}")
|
||||
if isinstance(e, ResponseException):
|
||||
return response(code=500, message=str(e), data=None)
|
||||
return response(code=500, message="Failed to fetch DNFHelper info", data=None)
|
||||
@@ -55,6 +55,16 @@ def enchant_5(char: CharacterProperty):
|
||||
char.SetStatus(三攻=20, 四维=75, 技攻=0.07)
|
||||
pass
|
||||
|
||||
@register
|
||||
def enchant_6(char: CharacterProperty):
|
||||
"""
|
||||
DCALC_REMOVE: enchant_6
|
||||
四维(75)|Lv1~50主动+1
|
||||
"""
|
||||
char.SetStatus(四维=75)
|
||||
char.AddSkillLv(1, 50, 1, 1)
|
||||
pass
|
||||
|
||||
|
||||
# endregion
|
||||
# region 上衣
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
from openapi.dnfhelper.public import get_main_user_info_by_id
|
||||
from core.basic.equipment import get_equipment
|
||||
from api.dp import AltersDep
|
||||
from api.core.exception import ResponseException
|
||||
import re
|
||||
|
||||
job_mapping = {
|
||||
'极诣·剑魂': 'weapon_master',
|
||||
@@ -74,18 +77,22 @@ job_mapping = {
|
||||
}
|
||||
|
||||
|
||||
async def get_user_info_by_id(user_id: str, alter: str):
|
||||
async def get_user_info_by_id(user_id: str, alter: AltersDep):
|
||||
if alter is None:
|
||||
raise ResponseException("登录过期或无效Token,请刷新后重试")
|
||||
# 通过OCR助手获取用户信息
|
||||
helper_info = await get_main_user_info_by_id(user_id)
|
||||
if helper_info is None:
|
||||
return None
|
||||
raise ResponseException("当前助手ID不存在或已隐藏,请确认后重试")
|
||||
else:
|
||||
return trans_to_dcalc_set(helper_info)
|
||||
return trans_to_dcalc_set(helper_info, alter)
|
||||
pass
|
||||
|
||||
|
||||
def trans_to_dcalc_set(detail):
|
||||
def trans_to_dcalc_set(detail, alter: AltersDep):
|
||||
job = job_mapping.get(detail.get('job', ''), '')
|
||||
if job != alter.origin:
|
||||
raise ResponseException(f"职业不匹配,请切换到{detail.get('job', '')}后或修改助手的默认角色后重试")
|
||||
basic = get_equipment('0')
|
||||
basicAvatars = basic.funs.get_dress_list([])
|
||||
equs = detail.get('equs', [])
|
||||
@@ -114,7 +121,7 @@ def trans_to_dcalc_set(detail):
|
||||
'precision': 100,
|
||||
}
|
||||
# 装备
|
||||
dcalcEqu = next((item for item in basic.equs if item.name == equ['name']), None)
|
||||
dcalcEqu = next((item for item in basic.equs if item.name == equ['name'].replace('(黑雨) ', '')), None)
|
||||
# 贴膜
|
||||
if dcalcEqu:
|
||||
info['id'] = dcalcEqu.id
|
||||
@@ -143,8 +150,31 @@ def trans_to_dcalc_set(detail):
|
||||
info['option'] = item.get('attr', '')
|
||||
avatar[item['posName']] = info
|
||||
else:
|
||||
# TODO: 处理没有找到对应时装的情况 即光环、皮肤、武器装扮
|
||||
print(item)
|
||||
if item.get('posName', '') in ['光环', '皮肤', '武器装扮']:
|
||||
# TODO: 处理没有找到对应时装的情况 即光环、皮肤、武器
|
||||
# 装扮
|
||||
if item.get('posName', '') == '武器装扮':
|
||||
if item.get('name', '') == '神器克隆武器装扮':
|
||||
item['enchant'] = '技攻(3%)|增益量(1%)|四维(65)'
|
||||
match = re.search(r'\[(\d+)级\]', item.get('name', ''))
|
||||
lv = int(match.group(1)) if match else None
|
||||
if lv:
|
||||
item['enchant'] = f'Lv{lv}主动+1|四维(55)'
|
||||
else:
|
||||
item['enchant'] = '全属强(6)'
|
||||
if item.get('posName', '') == '皮肤':
|
||||
match = re.search(r'\[(\d+)级\]', item.get('name', ''))
|
||||
lv = int(match.group(1)) if match else None
|
||||
if lv :
|
||||
item['enchant'] = f'Lv{lv}主动+1|全属强(12)|四维(55)'
|
||||
if item.get('posName', '') == '光环':
|
||||
# 先默认这个了 不管了
|
||||
item['enchant'] = 'Lv1~95+1|攻击强化(12%)|增益量(7%)'
|
||||
info['enchant'] = getEnchatIdByName(item.get('enchant', ''), item.get('posName', ''), basic.enchants)
|
||||
emblems = [getEmblemIdByName(i.get('detail', ''), i.get('categorize', ''), i.get('rarity', ''), basic.emblems) for i in item.get('emblems', [])]
|
||||
info['emblem_0'] = emblems[0] if len(emblems) > 0 else 0
|
||||
info['emblem_1'] = emblems[1] if len(emblems) > 1 else 0
|
||||
avatar[item['posName']] = info
|
||||
return {
|
||||
'job': job,
|
||||
'equips': equips,
|
||||
|
||||
Binary file not shown.
+1
-1
Submodule backend/openapi updated: d374db49af...fed2b6423e
@@ -18,6 +18,10 @@ export default defineRequest((request) => {
|
||||
async skillDetail(skillId: string, level: number) {
|
||||
const res = await request.get<ISkillInfo>(`/skill/${skillId}/${level}`)
|
||||
return res.data
|
||||
},
|
||||
async getConfigFromHelper(uid: string) {
|
||||
const res = await request.get(`/dnfhelper/${uid}/`)
|
||||
return res.data
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
<script lang="tsx">
|
||||
import { useAsyncState } from '@vueuse/core'
|
||||
import { computed, defineComponent, ref, renderList } from 'vue'
|
||||
import api from '@/api'
|
||||
import { useDialog } from '@/components/hooks/dialog'
|
||||
import { isShow, onShow } from '@/components/hooks/show'
|
||||
import { useConfigStore } from '@/stores'
|
||||
|
||||
export default defineComponent({
|
||||
setup() {
|
||||
const configStore = useConfigStore()
|
||||
const uid = ref('')
|
||||
|
||||
const { state, execute } = useAsyncState(
|
||||
async () => {
|
||||
const res = await api.getConfigFromHelper(uid.value)
|
||||
configStore.config.equips = res.equips
|
||||
configStore.config.avatar = res.avatars
|
||||
await alert({
|
||||
content: '导入成功',
|
||||
})
|
||||
visible.value = false
|
||||
return res
|
||||
},
|
||||
undefined,
|
||||
{
|
||||
resetOnExecute: false,
|
||||
immediate: false,
|
||||
onError: Promise.reject,
|
||||
},
|
||||
)
|
||||
|
||||
onShow(
|
||||
() => {
|
||||
uid.value = ''
|
||||
state.value = undefined
|
||||
},
|
||||
{ immediate: true },
|
||||
)
|
||||
|
||||
const visible = isShow()
|
||||
|
||||
const configList = computed(() => {
|
||||
return Object.keys(state.value ?? {}).sort()
|
||||
})
|
||||
|
||||
async function importConfigs() {
|
||||
// if (window.pywebview) {
|
||||
// const configs = {}
|
||||
// cacheList.value.forEach(key => {
|
||||
// configs[key] = state.value?.[key]
|
||||
// })
|
||||
// await api.importConfigs(configs)
|
||||
// } else {
|
||||
// cacheList.value.forEach(key => {
|
||||
// localStorage.setItem(key, JSON.stringify(state.value?.[key]))
|
||||
// })
|
||||
// }
|
||||
// const { alert } = useDialog()
|
||||
// await alert({
|
||||
// content: "导入成功"
|
||||
// })
|
||||
// visible.value = false
|
||||
// await configStore.load()
|
||||
}
|
||||
|
||||
return () => {
|
||||
return (
|
||||
<>
|
||||
<div class="h-40 w-80 py-2 px-4 text-hex-e9c556">
|
||||
<div class="flex justify-around items-center">
|
||||
助手社区ID
|
||||
<calc-input class="!w-60" v-model={uid.value} />
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-hex-e9c556/80">
|
||||
* 请输入助手社区ID,点击导入后会从助手社区通过OCR获取主角色打造
|
||||
</p>
|
||||
<p class="text-hex-e9c556/80">
|
||||
* 由于通过文字识别,部分打造无法完全获取,此处仅做快捷导入
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex justify-around items-center">
|
||||
<calc-button onClick={execute}>导入</calc-button>
|
||||
<calc-button onClick={() => (visible.value = false)}>取消</calc-button>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
},
|
||||
})
|
||||
</script>
|
||||
@@ -21,21 +21,28 @@
|
||||
<div class="footer flex">
|
||||
<calc-checkbox round v-model="configStore.config.DSB">系统奶</calc-checkbox>
|
||||
<calc-checkbox round v-model="configStore.config.BUFF">组队</calc-checkbox>
|
||||
<calc-button title="打造导入" @click="showImport" class="ml-1" icon="import"></calc-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<calc-dialog lazy header="存档导入" v-model:visible="importVisible">
|
||||
<ImportVue></ImportVue>
|
||||
</calc-dialog>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup name="Index">
|
||||
import { useInfoStore } from '@/stores/info'
|
||||
import { useConfigStore } from '@/stores'
|
||||
import ImportVue from './Config/import.vue';
|
||||
import Result from './Result/Index.vue'
|
||||
const props = defineProps<{
|
||||
alter: string
|
||||
}>()
|
||||
const infoStore = useInfoStore()
|
||||
const configStore = useConfigStore()
|
||||
const importVisible = ref(false)
|
||||
|
||||
const stopWatch = watch<any>(
|
||||
const stopWatch = watch(
|
||||
() => {
|
||||
return JSON.stringify(configStore.config)
|
||||
},
|
||||
@@ -44,6 +51,10 @@ const stopWatch = watch<any>(
|
||||
}, 800),
|
||||
)
|
||||
|
||||
const showImport = () => {
|
||||
importVisible.value = true
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await infoStore.createCharacter(props.alter, '0')
|
||||
window.addEventListener('beforeunload', () => {
|
||||
|
||||
Reference in New Issue
Block a user