mirror of
https://github.com/ZZZure/ZZZ-Plugin.git
synced 2025-12-16 21:27:47 +00:00
feat: card
This commit is contained in:
parent
cd0793655d
commit
ce3c509cd9
43 changed files with 508 additions and 7 deletions
86
lib/convert/char.js
Normal file
86
lib/convert/char.js
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
import settings from '../settings.js';
|
||||
import PartnerId2SpriteId from '../../resources/map/PartnerId2SpriteId.json';
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} id
|
||||
* @param {boolean} full 显示全称
|
||||
* @param {boolean} en 是否为英文
|
||||
* @returns string
|
||||
*/
|
||||
export const IDToCharName = (id, full = true, en = false) => {
|
||||
const data = PartnerId2SpriteId?.[id];
|
||||
if (!data) return null;
|
||||
if (en) return data?.['en_name'];
|
||||
if (full) return data?.['full_name'];
|
||||
return data?.['name'];
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} id
|
||||
* @returns string
|
||||
*/
|
||||
export const IDToCharSprite = id => {
|
||||
const data = PartnerId2SpriteId?.[id];
|
||||
if (!data) return null;
|
||||
return data?.['sprite'];
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @returns string
|
||||
*/
|
||||
export const charNameToID = name => {
|
||||
for (const [id, data] of Object.entries(PartnerId2SpriteId)) {
|
||||
if (data['full_name'] === name) return id;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @returns string
|
||||
*/
|
||||
export const charNameToSprite = name => {
|
||||
for (const [_id, data] of Object.entries(PartnerId2SpriteId)) {
|
||||
if (data['full_name'] === name) return data['sprite'];
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} atlas
|
||||
* @returns string
|
||||
*/
|
||||
export const atlasToName = atlas => {
|
||||
const atlas = settings.getConfig('atlas');
|
||||
for (const [id, data] of Object.entries(atlas)) {
|
||||
if (data.includes(atlas)) return id;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} atlas
|
||||
* @returns string
|
||||
*/
|
||||
export const atlasToSprite = atlas => {
|
||||
const atlas = settings.getConfig('atlas');
|
||||
for (const [_id, data] of Object.entries(atlas)) {
|
||||
if (data.includes(atlas)) return data['sprite'];
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @returns string
|
||||
*/
|
||||
export const atlasToID = name => {
|
||||
const atlas = settings.getConfig('atlas');
|
||||
for (const [id, data] of Object.entries(atlas)) {
|
||||
if (data.includes(name)) return charNameToID(id);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
21
lib/convert/weapon.js
Normal file
21
lib/convert/weapon.js
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import WeaponId2Sprite from '../../resources/map/WeaponId2Sprite.json';
|
||||
|
||||
/**
|
||||
* @param {string} id
|
||||
* @returns string
|
||||
*/
|
||||
export const IDToWeaponName = id => {
|
||||
const data = WeaponId2Sprite?.[id];
|
||||
return data;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @returns string
|
||||
*/
|
||||
export const weaponNameToID = name => {
|
||||
for (const [id, data] of Object.entries(WeaponId2Sprite)) {
|
||||
if (data === name) return id;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue