dev
This commit is contained in:
@@ -449,6 +449,8 @@ class Character:
|
||||
suits = []
|
||||
stones = []
|
||||
for i in equInfos.equs:
|
||||
if i.itemType == '武器' and i.itemDetailType not in self.武器选项:
|
||||
continue
|
||||
equs.append(i.__dict__)
|
||||
for i in equInfos.suits:
|
||||
suits.append(i.__dict__)
|
||||
@@ -460,6 +462,7 @@ class Character:
|
||||
info['enchants'] = equInfos.enchants
|
||||
info['emblems'] = equInfos.emblems
|
||||
info["avatar"] = equInfos.funs.get_dress_list(skill_clothes)
|
||||
info['jades'] = equInfos.jades
|
||||
for skill in platinum:
|
||||
info['emblems'].append({
|
||||
'id': skill,
|
||||
@@ -726,6 +729,7 @@ class Character:
|
||||
# 角色基础属性
|
||||
self.SetBaseStatus()
|
||||
# 辟邪玉计算
|
||||
self.calc_jade(setInfo.get('jades', []))
|
||||
# 时装计算
|
||||
self.calc_avatar(setInfo.get('avatar', {}))
|
||||
# 精通、增幅、强化计算
|
||||
|
||||
@@ -73,6 +73,7 @@ class Equipments:
|
||||
self.funs = self.init_func()
|
||||
self.equ_dict: dict[str, Equ] = {}
|
||||
self.stone_dict: dict[str, Equ] = {}
|
||||
self.jades = []
|
||||
self.enchants = []
|
||||
self.emblems = []
|
||||
self.suits: list[Suit] = []
|
||||
@@ -82,6 +83,7 @@ class Equipments:
|
||||
self.init_enchants()
|
||||
self.init_stones()
|
||||
self.init_emblem()
|
||||
self.init_jades()
|
||||
self.engine.dispose()
|
||||
|
||||
def init_equs(self):
|
||||
@@ -170,9 +172,6 @@ class Equipments:
|
||||
db_list = session.query(JadeData).all()
|
||||
for item in db_list:
|
||||
jade = {k: v for k, v in item.__dict__.items() if not k.startswith('_')}
|
||||
jade['position'] = [] if jade['itemType'] is None else jade['itemType'].split(',')
|
||||
jade['categorize'] = [] if jade['categorize'] is None else jade['categorize'].split(',')
|
||||
del jade['itemType']
|
||||
self.jades.append(jade)
|
||||
pass
|
||||
pass
|
||||
|
||||
@@ -33,6 +33,7 @@ export interface ICharacterInfo {
|
||||
skills: ISkill[]
|
||||
suits: ISuit[]
|
||||
avatar: Record<string, IAvatarInfo[]>
|
||||
jades:IJade[]
|
||||
}
|
||||
|
||||
export interface IEquipment {
|
||||
@@ -82,3 +83,12 @@ export interface IAvatarInfo {
|
||||
suit?: string
|
||||
name: string
|
||||
}
|
||||
|
||||
export interface IJade {
|
||||
name:string
|
||||
id:number
|
||||
max:number
|
||||
min:number
|
||||
pre:number
|
||||
unit:string
|
||||
}
|
||||
|
||||
@@ -3,53 +3,58 @@
|
||||
<template v-for="key in ['0','1','2','3']" :key="key">
|
||||
<div class="flex gap-2 mt-5px">
|
||||
<calc-select class="flex-1 !h-20px" v-model="configStore.config.jades[key].id">
|
||||
<calc-option v-for="(item, index) in ['0','1']" :key="index" :value="item">
|
||||
{{item}}
|
||||
<calc-option v-for="(item, index) in infoStore.jades" :key="item.id" :value="item.id">
|
||||
{{item.name}}
|
||||
</calc-option>
|
||||
</calc-select>
|
||||
<calc-select class="flex-1 !h-20px" v-model="configStore.config.jades[key].value">
|
||||
<calc-option v-for="(item, index) in valueList(configStore.config.jades[key].id)" :key="item.id" :value="item.id">
|
||||
{{item.value}}
|
||||
</calc-option>
|
||||
</calc-select>
|
||||
<calc-select class="flex-1 !h-20px" v-model="configStore.config.jades[key].value"></calc-select>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { IJade } from '@/api/info/type'
|
||||
import { useConfigStore } from '@/stores'
|
||||
import { useInfoStore } from '@/stores'
|
||||
import { getFloat } from '@/utils'
|
||||
|
||||
const configStore = useConfigStore()
|
||||
const infoStore = useInfoStore()
|
||||
|
||||
// const valueList = computed(() => {
|
||||
// return function (id: number = -1) {
|
||||
// if (id == -1) {
|
||||
// return undefined
|
||||
// } else {
|
||||
// const res = []
|
||||
// const cur = infoStore.jade?.find(e => e.id == id) as IJadeInfo
|
||||
// if (cur) {
|
||||
// const { max, min, unit, pre } = cur
|
||||
// //
|
||||
// if (pre == 0) {
|
||||
// res.push({
|
||||
// id: 1,
|
||||
// value: unit
|
||||
// })
|
||||
// } else {
|
||||
// for (let i = Number(max) as number; i >= Number(min);) {
|
||||
// if (i != 0) {
|
||||
// res.push({
|
||||
// id: getFloat(i, 1),
|
||||
// value: (i > 0 ? "+" : "") + getFloat(i, 1) + unit
|
||||
// })
|
||||
// }
|
||||
// i = Number((i - Number(pre)).toFixed(1))
|
||||
// }
|
||||
// }
|
||||
// return res
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
const valueList = computed(() => {
|
||||
return function (id: number = -1) {
|
||||
if (id == -1) {
|
||||
return undefined
|
||||
} else {
|
||||
const res = []
|
||||
const cur = infoStore.jades?.find(e => e.id == id) as IJade
|
||||
if (cur) {
|
||||
const { max, min, unit, pre } = cur
|
||||
//
|
||||
if (pre == 0) {
|
||||
res.push({
|
||||
id: 1,
|
||||
value: unit
|
||||
})
|
||||
} else {
|
||||
for (let i = Number(max) as number; i >= Number(min);) {
|
||||
if (i != 0) {
|
||||
res.push({
|
||||
id: i,
|
||||
value: (i > 0 ? "+" : "") + getFloat(i, 1) + unit
|
||||
})
|
||||
}
|
||||
i = Number((i - Number(pre)).toFixed(1))
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -32,7 +32,7 @@ export interface IConfig {
|
||||
}
|
||||
>
|
||||
jades: Record<string, {
|
||||
id:string
|
||||
id:number
|
||||
value: number
|
||||
}>
|
||||
avatar: Record<
|
||||
@@ -124,7 +124,7 @@ export const useConfigStore = defineStore('configStore', () => {
|
||||
|
||||
(["0", "1", "2", "3"].filter((key) => !Object.keys(config.value.jades).includes(key)) ?? []).forEach((key) => {
|
||||
config.value.jades[key] = {
|
||||
id: '',
|
||||
id: -1,
|
||||
value: 0,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ export const useInfoStore = defineStore('infoStore', () => {
|
||||
|
||||
const avatars = computed(() => infos.value?.avatar ?? {})
|
||||
|
||||
// const jades = computed(() => infos.value?.jades ?? [])
|
||||
const jades = computed(() => infos.value?.jades ?? [])
|
||||
|
||||
const parts = [
|
||||
'头肩',
|
||||
@@ -78,5 +78,6 @@ export const useInfoStore = defineStore('infoStore', () => {
|
||||
stones,
|
||||
avatarParts,
|
||||
avatars,
|
||||
jades
|
||||
}
|
||||
})
|
||||
|
||||
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
interface Number {
|
||||
plus(value: number): number
|
||||
|
||||
minus(value: number): number
|
||||
|
||||
multiply(value: number): number
|
||||
|
||||
divide(value: number): number
|
||||
|
||||
perMulti(value: number): number
|
||||
|
||||
round(digit?: number): number
|
||||
|
||||
floor(digit?: number): number
|
||||
|
||||
exactlyDivide(value: number): number
|
||||
}
|
||||
|
||||
interface Array<T> {
|
||||
min(callback: (t: T) => number): [number, T | undefined]
|
||||
max(callback: (t: T) => number): [number, T | undefined]
|
||||
}
|
||||
@@ -0,0 +1,330 @@
|
||||
export function in_range(num: number, start: number, end: number) {
|
||||
return start <= num && num <= end
|
||||
}
|
||||
|
||||
export function to_percent(num?: number, defaultValue: number = 0, suffix = "", withPlus = false) {
|
||||
num = num ?? defaultValue
|
||||
return (num > 0 && withPlus ? "+" : "") + num?.multiply(100).round(2).toString().concat(suffix)
|
||||
}
|
||||
|
||||
export function get_num(num?: number, defaultValue: number = 0) {
|
||||
return num ?? defaultValue
|
||||
}
|
||||
|
||||
export function format_string(str: string, params: any = {}, ...args: any[]) {
|
||||
let num = 0
|
||||
str = str.replace(/{}/g, match => {
|
||||
return args[num++] ?? match
|
||||
})
|
||||
str = str.replace(/{\d+}/g, match => {
|
||||
const i = Number.parseInt(match.slice(1, -1))
|
||||
return args[i] ?? match
|
||||
})
|
||||
str = str.replace(/{\w+}/g, match => {
|
||||
const name = match.slice(1, -1)
|
||||
return params[name] ?? match
|
||||
})
|
||||
return str
|
||||
}
|
||||
|
||||
export function format_bytes(bytes: number, decimals = 2) {
|
||||
if (bytes === 0) {
|
||||
return "0 Bytes"
|
||||
}
|
||||
const k = 1024
|
||||
const dm = decimals < 0 ? 0 : decimals
|
||||
const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]
|
||||
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k))
|
||||
|
||||
return `${Number.parseFloat((bytes / k ** i).toFixed(dm))} ${sizes[i]}`
|
||||
}
|
||||
|
||||
export function getFloat(value: any, n: any) {
|
||||
value = Number(value)
|
||||
n = n ? Number.parseInt(n) : 0
|
||||
if (n <= 0) {
|
||||
return Math.round(value)
|
||||
}
|
||||
value = Math.round(value * 10 ** n) / 10 ** n
|
||||
value = Number(value).toFixed(n)
|
||||
return value
|
||||
}
|
||||
|
||||
export function cartesian<T = any>(...arr: T[][]): T[][] {
|
||||
if (arr.length < 2) {
|
||||
return arr
|
||||
}
|
||||
return arr.reduce(
|
||||
(a, b) => {
|
||||
const ret: T[][] = []
|
||||
a.forEach(a => {
|
||||
b.forEach(b => {
|
||||
ret.push(a.concat([b]))
|
||||
})
|
||||
})
|
||||
return ret
|
||||
},
|
||||
[[]] as T[][]
|
||||
)
|
||||
}
|
||||
|
||||
export function groupBy<T, K>(array: T[], callback: (t: T) => K) {
|
||||
const map = new Map<K, T[]>()
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
const t = array[i]
|
||||
const key = callback(t)
|
||||
const temp: T[] = map.get(key) || []
|
||||
if (!map.has(key)) {
|
||||
map.set(key, temp)
|
||||
}
|
||||
temp.push(t)
|
||||
}
|
||||
|
||||
return Array.from(map.values())
|
||||
}
|
||||
|
||||
export function debounce_last(func: Function, wait: number) {
|
||||
let timer = Number.NaN
|
||||
return function () {
|
||||
if (timer) {
|
||||
clearTimeout(timer)
|
||||
}
|
||||
timer = setTimeout(func, wait)
|
||||
}
|
||||
}
|
||||
|
||||
export function padding(num: number | string, length: number): string {
|
||||
if ((`${num}`).length >= length) {
|
||||
return `${num}`
|
||||
}
|
||||
return padding(`0${num}`, length)
|
||||
}
|
||||
|
||||
export function format_float(f: number, digit: number = 2) {
|
||||
const m = 10 ** digit
|
||||
return (f * m).round(10) / m
|
||||
}
|
||||
|
||||
export function mapRecord<T extends keyof any, K>(status: Record<T, K>, callback: (value: K, key: T) => K) {
|
||||
const new_status = {} as Record<T, K>
|
||||
for (const key in status) {
|
||||
const value = callback(status[key], key)
|
||||
if (value) {
|
||||
new_status[key] = value
|
||||
}
|
||||
}
|
||||
return new_status
|
||||
}
|
||||
|
||||
Array.prototype.max = function<T>(callback: (t: T) => number): [number, T | undefined] {
|
||||
let rs: [number, T | undefined] = [-1, undefined]
|
||||
let max = -1
|
||||
for (let i = 0; i < this.length; i++) {
|
||||
const item = this.at(i) as T
|
||||
const count = callback(item)
|
||||
if (count > max) {
|
||||
max = count
|
||||
rs = [i, item]
|
||||
}
|
||||
}
|
||||
return rs
|
||||
}
|
||||
|
||||
Array.prototype.min = function<T>(callback: (t: T) => number): [number, T | undefined] {
|
||||
let rs: [number, T | undefined] = [-1, undefined]
|
||||
let min = -1
|
||||
for (let i = 0; i < this.length; i++) {
|
||||
const item = this.at(i) as T
|
||||
const count = callback(item)
|
||||
if (count < min) {
|
||||
min = count
|
||||
rs = [i, item]
|
||||
}
|
||||
}
|
||||
return rs
|
||||
}
|
||||
|
||||
Number.prototype.multiply = function (value: number) {
|
||||
return Number(this) * value
|
||||
}
|
||||
|
||||
Number.prototype.round = function (digit?: number) {
|
||||
const m = 10 ** (digit ?? 0)
|
||||
return Math.round(Number(this) * m) / m
|
||||
}
|
||||
|
||||
export function formatStr(template: string, ...params: any) {
|
||||
let str = template
|
||||
|
||||
if (params.length == 1 && params[0].length > 0) {
|
||||
params = params[0]
|
||||
}
|
||||
|
||||
for (let i = 0; i < params.length; i++) {
|
||||
str = str.replaceAll(`{${i}}`, params[i])
|
||||
}
|
||||
|
||||
return str
|
||||
}
|
||||
|
||||
export function toObj(data: any): any {
|
||||
const temp = {}
|
||||
for (const key in data) {
|
||||
try {
|
||||
if (typeof data[key] === "number" || typeof data[key] === "string") {
|
||||
Object.defineProperty(temp, key, {
|
||||
value: data[key],
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
})
|
||||
} else {
|
||||
Object.defineProperty(temp, key, {
|
||||
value: RecordToObj(data[key]),
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
})
|
||||
}
|
||||
} catch {
|
||||
Object.defineProperty(temp, key, {
|
||||
value: data[key],
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
})
|
||||
}
|
||||
}
|
||||
return temp
|
||||
}
|
||||
|
||||
export function toMap(data: any, except: string[] = []) {
|
||||
const temp = {}
|
||||
for (const key in data) {
|
||||
if (typeof data[key] === "object" && data[key].constructor != Array && !except.includes(key)) {
|
||||
// 需要转换部分,不能是Array,也会被转换
|
||||
const sub = {}
|
||||
for (const subkey in data[key]) {
|
||||
Object.defineProperty(sub, subkey, {
|
||||
value: new Map(Object.entries(data[key][subkey])),
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
})
|
||||
}
|
||||
Object.defineProperty(temp, key, {
|
||||
value: sub,
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
})
|
||||
} else {
|
||||
Object.defineProperty(temp, key, {
|
||||
value: data[key],
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
})
|
||||
}
|
||||
}
|
||||
return temp
|
||||
}
|
||||
|
||||
export function RecordToObj(todo: Record<string, Map<any, any>>) {
|
||||
const temp = {}
|
||||
for (const key in todo) {
|
||||
Object.defineProperty(temp, key, {
|
||||
value: Object.fromEntries(todo[key]),
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
})
|
||||
}
|
||||
return temp
|
||||
}
|
||||
|
||||
export function getUuid() {
|
||||
if (typeof crypto === "object") {
|
||||
if (typeof crypto.randomUUID === "function") {
|
||||
return crypto.randomUUID()
|
||||
}
|
||||
if (typeof crypto.getRandomValues === "function" && typeof Uint8Array === "function") {
|
||||
const callback = (c: any) => {
|
||||
const num = Number(c)
|
||||
return (num ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (num / 4)))).toString(16)
|
||||
}
|
||||
return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, callback)
|
||||
}
|
||||
}
|
||||
let timestamp = new Date().getTime()
|
||||
let perforNow = (typeof performance !== "undefined" && performance.now && performance.now() * 1000) || 0
|
||||
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, c => {
|
||||
let random = Math.random() * 16
|
||||
if (timestamp > 0) {
|
||||
random = Math.trunc((timestamp + random) % 16)
|
||||
timestamp = Math.floor(timestamp / 16)
|
||||
} else {
|
||||
random = Math.trunc((perforNow + random) % 16)
|
||||
perforNow = Math.floor(perforNow / 16)
|
||||
}
|
||||
return (c === "x" ? random : (random & 0x3) | 0x8).toString(16)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
export function rarityClass(type: string) {
|
||||
switch (type) {
|
||||
case "太初":
|
||||
return "primeval"
|
||||
case "史诗":
|
||||
return "epic"
|
||||
case "神话":
|
||||
return "myth"
|
||||
case "智慧产物":
|
||||
return "epic"
|
||||
case "神器":
|
||||
return "artifact"
|
||||
case "稀有":
|
||||
return "rare"
|
||||
case "传说":
|
||||
return "legend"
|
||||
case "勇者":
|
||||
return "chronicle"
|
||||
case "高级":
|
||||
return "advanced"
|
||||
default:
|
||||
return "epic"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const decrypt = (encryptedData:string)=>{
|
||||
try{
|
||||
encryptedData = decodeURIComponent(encryptedData).split("").map(a=>{
|
||||
if(a=='='){
|
||||
return a
|
||||
}
|
||||
else{
|
||||
return String.fromCharCode(a.charCodeAt(0) - 1)
|
||||
}
|
||||
}).join("")
|
||||
const decryptedData = atob(encryptedData);
|
||||
|
||||
const len = decryptedData.length;
|
||||
const decryptedBinaryOffset = decryptedData.slice(0, len-13);
|
||||
const decryptedTimestamp = decryptedData.slice(len-13, len);
|
||||
|
||||
return {
|
||||
uid:parseInt(decryptedBinaryOffset,2),
|
||||
time:parseInt(decryptedTimestamp)
|
||||
}
|
||||
}
|
||||
catch(e){
|
||||
console.log(e)
|
||||
return {
|
||||
uid:-1,
|
||||
time:0
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user