mirror of
https://github.com/ZZZure/ZZZ-Plugin.git
synced 2025-12-16 13:17:32 +00:00
feat: panel
This commit is contained in:
parent
35c8c95b80
commit
27171c5727
77 changed files with 2126 additions and 312 deletions
118
model/avatar.js
118
model/avatar.js
|
|
@ -1,5 +1,5 @@
|
|||
import { element } from '../lib/convert.js';
|
||||
import { getSquareAvatar } from '../lib/download.js';
|
||||
import { getRoleImage, getSquareAvatar } from '../lib/download.js';
|
||||
import { Equip, Weapon } from './equip.js';
|
||||
import { Property } from './property.js';
|
||||
import { Skill } from './skill.js';
|
||||
|
|
@ -114,20 +114,40 @@ export class ZZZAvatarBasic {
|
|||
|
||||
this.element_str = element.IDToElement(element_type);
|
||||
}
|
||||
|
||||
async get_assets() {
|
||||
const result = await getSquareAvatar(this.id);
|
||||
this.square_icon = result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @class
|
||||
*/
|
||||
export class Rank {
|
||||
// 类型标注
|
||||
/** @type {number} */
|
||||
id;
|
||||
/** @type {string} */
|
||||
name;
|
||||
/** @type {string} */
|
||||
desc;
|
||||
/** @type {number} */
|
||||
pos;
|
||||
/** @type {boolean} */
|
||||
is_unlocked;
|
||||
|
||||
/**
|
||||
* @param {number} id
|
||||
* @param {string} name
|
||||
* @param {string} desc
|
||||
* @param {number} pos
|
||||
* @param {boolean} is_unlocked
|
||||
* @param {{
|
||||
* id: number;
|
||||
* name: string;
|
||||
* desc: string;
|
||||
* pos: number;
|
||||
* is_unlocked: boolean;
|
||||
* }} data
|
||||
*/
|
||||
constructor(id, name, desc, pos, is_unlocked) {
|
||||
constructor(data) {
|
||||
const { id, name, desc, pos, is_unlocked } = data;
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.desc = desc;
|
||||
|
|
@ -158,11 +178,46 @@ export class ZZZAvatarInfo {
|
|||
* skills: Skill[];
|
||||
* rank: number;
|
||||
* ranks: Rank[];
|
||||
*
|
||||
* isNew?: boolean;
|
||||
* }} data
|
||||
*/
|
||||
constructor(data) {
|
||||
// 类型标注
|
||||
/** @type {number} */
|
||||
this.id;
|
||||
/** @type {number} */
|
||||
this.level;
|
||||
/** @type {string} */
|
||||
this.name_mi18n;
|
||||
/** @type {string} */
|
||||
this.full_name_mi18n;
|
||||
/** @type {number} */
|
||||
this.element_type;
|
||||
/** @type {string} */
|
||||
this.camp_name_mi18n;
|
||||
/** @type {number} */
|
||||
this.avatar_profession;
|
||||
/** @type {string} */
|
||||
this.rarity;
|
||||
/** @type {string} */
|
||||
this.group_icon_path;
|
||||
/** @type {string} */
|
||||
this.hollow_icon_path;
|
||||
/** @type {Equip[]} */
|
||||
this.equip;
|
||||
/** @type {Weapon} */
|
||||
this.weapon;
|
||||
/** @type {Property[]} */
|
||||
this.properties;
|
||||
/** @type {Skill[]} */
|
||||
this.skills;
|
||||
/** @type {number} */
|
||||
this.rank;
|
||||
/** @type {Rank[]} */
|
||||
this.ranks;
|
||||
/** @type {boolean} */
|
||||
this.isNew;
|
||||
|
||||
const {
|
||||
id,
|
||||
level,
|
||||
|
|
@ -192,22 +247,59 @@ export class ZZZAvatarInfo {
|
|||
this.rarity = rarity;
|
||||
this.group_icon_path = group_icon_path;
|
||||
this.hollow_icon_path = hollow_icon_path;
|
||||
this.equip = equip;
|
||||
this.weapon = weapon;
|
||||
this.properties = properties;
|
||||
this.skills = skills;
|
||||
this.equip =
|
||||
equip &&
|
||||
(Array.isArray(equip)
|
||||
? equip.map(equip => new Equip(equip))
|
||||
: new Equip(equip));
|
||||
this.weapon = weapon ? new Weapon(weapon) : null;
|
||||
this.properties =
|
||||
properties && properties.map(property => new Property(property));
|
||||
this.skills = skills && skills.map(skill => new Skill(skill));
|
||||
this.rank = rank;
|
||||
this.ranks = ranks;
|
||||
this.ranks = ranks && ranks.map(rank => new Rank(rank));
|
||||
|
||||
this.ranks_num = this.ranks.filter(rank => rank.is_unlocked).length;
|
||||
|
||||
this.element_str = element.IDToElement(element_type);
|
||||
this.isNew = isNew;
|
||||
}
|
||||
|
||||
getProperty(name) {
|
||||
return this.properties.find(property => property.property_name === name);
|
||||
}
|
||||
|
||||
get basic_properties() {
|
||||
const data = {
|
||||
hpmax: this.getProperty('生命值'),
|
||||
attack: this.getProperty('攻击力'),
|
||||
def: this.getProperty('防御力'),
|
||||
breakstun: this.getProperty('冲击力'),
|
||||
crit: this.getProperty('暴击率'),
|
||||
critdam: this.getProperty('暴击伤害'),
|
||||
elementabnormalpower: this.getProperty('异常掌控'),
|
||||
elementmystery: this.getProperty('异常精通'),
|
||||
penratio: this.getProperty('穿透率'),
|
||||
sprecover: this.getProperty('能量自动回复'),
|
||||
};
|
||||
logger.debug('basic_properties', data);
|
||||
return data;
|
||||
}
|
||||
|
||||
async get_basic_assets() {
|
||||
const result = await getSquareAvatar(this.id);
|
||||
this.square_icon = result;
|
||||
}
|
||||
|
||||
async get_detail_assets() {
|
||||
const role_icon = await getRoleImage(this.id);
|
||||
this.role_icon = role_icon;
|
||||
await this.weapon.get_assets();
|
||||
for (const equip of this.equip) {
|
||||
await equip.get_assets();
|
||||
}
|
||||
}
|
||||
|
||||
async get_assets() {
|
||||
await this.get_basic_assets();
|
||||
}
|
||||
|
|
|
|||
209
model/equip.js
209
model/equip.js
|
|
@ -1,16 +1,34 @@
|
|||
import { property } from '../lib/convert.js';
|
||||
import { getSuitImage, getWeaponImage } from '../lib/download.js';
|
||||
|
||||
/**
|
||||
* @class
|
||||
*/
|
||||
export class EquipProperty {
|
||||
// 类型标注
|
||||
/** @type {string} */
|
||||
property_name;
|
||||
/** @type {number} */
|
||||
property_id;
|
||||
/** @type {string} */
|
||||
base;
|
||||
/** @type {string} */
|
||||
classname;
|
||||
|
||||
/**
|
||||
* @param {string} property_name
|
||||
* @param {number} property_id
|
||||
* @param {string} base
|
||||
* @param {{
|
||||
* property_name: string;
|
||||
* property_id: number;
|
||||
* base: string
|
||||
* }} data
|
||||
*/
|
||||
constructor(property_name, property_id, base) {
|
||||
constructor(data) {
|
||||
const { property_name, property_id, base } = data;
|
||||
this.property_name = property_name;
|
||||
this.property_id = property_id;
|
||||
this.base = base;
|
||||
|
||||
this.classname = property.idToClassName(property_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -18,15 +36,30 @@ export class EquipProperty {
|
|||
* @class
|
||||
*/
|
||||
export class EquipMainProperty {
|
||||
// 类型标注
|
||||
/** @type {string} */
|
||||
property_name;
|
||||
/** @type {number} */
|
||||
property_id;
|
||||
/** @type {string} */
|
||||
base;
|
||||
/** @type {string} */
|
||||
classname;
|
||||
|
||||
/**
|
||||
* @param {string} property_name
|
||||
* @param {number} property_id
|
||||
* @param {string} base
|
||||
* @param {{
|
||||
* property_name: string;
|
||||
* property_id: number;
|
||||
* base: string;
|
||||
* }} data
|
||||
*/
|
||||
constructor(property_name, property_id, base) {
|
||||
constructor(data) {
|
||||
const { property_name, property_id, base } = data;
|
||||
this.property_name = property_name;
|
||||
this.property_id = property_id;
|
||||
this.base = base;
|
||||
|
||||
this.classname = property.idToClassName(property_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -55,79 +88,143 @@ export class EquipSuit {
|
|||
*/
|
||||
export class Equip {
|
||||
/**
|
||||
* @param {number} id
|
||||
* @param {number} level
|
||||
* @param {string} name
|
||||
* @param {string} icon
|
||||
* @param {string} rarity
|
||||
* @param {EquipProperty[]} properties
|
||||
* @param {EquipMainProperty[]} main_properties
|
||||
* @param {EquipSuit} equip_suit
|
||||
* @param {number} equipment_type
|
||||
* @param {{
|
||||
* id: number;
|
||||
* level: number;
|
||||
* name: string;
|
||||
* icon: string;
|
||||
* rarity: string;
|
||||
* properties: EquipProperty[];
|
||||
* main_properties: EquipMainProperty[];
|
||||
* equip_suit: EquipSuit;
|
||||
* equipment_type: number;
|
||||
* }} data
|
||||
*/
|
||||
constructor(
|
||||
id,
|
||||
level,
|
||||
name,
|
||||
icon,
|
||||
rarity,
|
||||
properties,
|
||||
main_properties,
|
||||
equip_suit,
|
||||
equipment_type
|
||||
) {
|
||||
constructor(data) {
|
||||
// 类型标注
|
||||
/** @type {number} */
|
||||
this.id;
|
||||
/** @type {number} */
|
||||
this.level;
|
||||
/** @type {string} */
|
||||
this.name;
|
||||
/** @type {string} */
|
||||
this.icon;
|
||||
/** @type {string} */
|
||||
this.rarity;
|
||||
/** @type {EquipProperty[]} */
|
||||
this.properties;
|
||||
/** @type {EquipMainProperty[]} */
|
||||
this.main_properties;
|
||||
/** @type {EquipSuit} */
|
||||
this.equip_suit;
|
||||
/** @type {number} */
|
||||
this.equipment_type;
|
||||
|
||||
const {
|
||||
id,
|
||||
level,
|
||||
name,
|
||||
icon,
|
||||
rarity,
|
||||
properties,
|
||||
main_properties,
|
||||
equip_suit,
|
||||
equipment_type,
|
||||
} = data;
|
||||
this.id = id;
|
||||
this.level = level;
|
||||
this.name = name;
|
||||
this.icon = icon;
|
||||
this.rarity = rarity;
|
||||
this.properties = properties;
|
||||
this.main_properties = main_properties;
|
||||
this.properties = properties.map(item => new EquipProperty(item));
|
||||
this.main_properties = main_properties.map(
|
||||
item => new EquipMainProperty(item)
|
||||
);
|
||||
this.equip_suit = equip_suit;
|
||||
this.equipment_type = equipment_type;
|
||||
}
|
||||
|
||||
async get_assets() {
|
||||
const result = await getSuitImage(this.id);
|
||||
this.suit_icon = result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @class
|
||||
*/
|
||||
export class Weapon {
|
||||
// 类型标注
|
||||
/** @type {number} */
|
||||
id;
|
||||
/** @type {number} */
|
||||
level;
|
||||
/** @type {string} */
|
||||
name;
|
||||
/** @type {number} */
|
||||
star;
|
||||
/** @type {string} */
|
||||
icon;
|
||||
/** @type {string} */
|
||||
rarity;
|
||||
/** @type {EquipProperty[]} */
|
||||
properties;
|
||||
/** @type {EquipMainProperty[]} */
|
||||
main_properties;
|
||||
/** @type {string} */
|
||||
talent_title;
|
||||
/** @type {string} */
|
||||
talent_content;
|
||||
/** @type {number} */
|
||||
profession;
|
||||
|
||||
/**
|
||||
* @param {number} id
|
||||
* @param {number} level
|
||||
* @param {string} name
|
||||
* @param {number} star
|
||||
* @param {string} icon
|
||||
* @param {string} rarity
|
||||
* @param {EquipProperty[]} properties
|
||||
* @param {EquipMainProperty[]} main_properties
|
||||
* @param {string} talent_title
|
||||
* @param {string} talent_content
|
||||
* @param {number} profession
|
||||
* @param {{
|
||||
* id: number;
|
||||
* level: number;
|
||||
* name: string;
|
||||
* star: number;
|
||||
* icon: string;
|
||||
* rarity: string;
|
||||
* properties: EquipProperty[];
|
||||
* main_properties: EquipMainProperty[];
|
||||
* talent_title: string;
|
||||
* talent_content: string;
|
||||
* profession: number;
|
||||
* }} data
|
||||
*/
|
||||
constructor(
|
||||
id,
|
||||
level,
|
||||
name,
|
||||
star,
|
||||
icon,
|
||||
rarity,
|
||||
properties,
|
||||
main_properties,
|
||||
talent_title,
|
||||
talent_content,
|
||||
profession
|
||||
) {
|
||||
constructor(data) {
|
||||
const {
|
||||
id,
|
||||
level,
|
||||
name,
|
||||
star,
|
||||
icon,
|
||||
rarity,
|
||||
properties,
|
||||
main_properties,
|
||||
talent_title,
|
||||
talent_content,
|
||||
profession,
|
||||
} = data;
|
||||
this.id = id;
|
||||
this.level = level;
|
||||
this.name = name;
|
||||
this.star = star;
|
||||
this.icon = icon;
|
||||
this.rarity = rarity;
|
||||
this.properties = properties;
|
||||
this.main_properties = main_properties;
|
||||
this.properties = properties.map(item => new EquipProperty(item));
|
||||
this.main_properties = main_properties.map(
|
||||
item => new EquipMainProperty(item)
|
||||
);
|
||||
this.talent_title = talent_title;
|
||||
this.talent_content = talent_content;
|
||||
this.profession = profession;
|
||||
}
|
||||
|
||||
async get_assets() {
|
||||
const result = await getWeaponImage(this.id);
|
||||
this.square_icon = result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,32 +8,58 @@ import {
|
|||
* @class
|
||||
*/
|
||||
export class SingleGachaLog {
|
||||
// 类型标注
|
||||
/** @type {string} */
|
||||
uid;
|
||||
/** @type {string} */
|
||||
gacha_id;
|
||||
/** @type {string} */
|
||||
gacha_type;
|
||||
/** @type {string} */
|
||||
item_id;
|
||||
/** @type {string} */
|
||||
count;
|
||||
/** @type {string} */
|
||||
time;
|
||||
/** @type {string} */
|
||||
name;
|
||||
/** @type {string} */
|
||||
lang;
|
||||
/** @type {string} */
|
||||
item_type;
|
||||
/** @type {string} */
|
||||
rank_type;
|
||||
/** @type {string} */
|
||||
id;
|
||||
/**
|
||||
* @param {string} uid
|
||||
* @param {string} gacha_id
|
||||
* @param {string} gacha_type
|
||||
* @param {string} item_id
|
||||
* @param {string} count
|
||||
* @param {string} time
|
||||
* @param {string} name
|
||||
* @param {string} lang
|
||||
* @param {string} item_type
|
||||
* @param {string} rank_type
|
||||
* @param {string} id
|
||||
* @param {{
|
||||
* uid: string;
|
||||
* gacha_id: string;
|
||||
* gacha_type: string;
|
||||
* item_id: string;
|
||||
* count: string;
|
||||
* time: string;
|
||||
* name: string;
|
||||
* lang: string;
|
||||
* item_type: string;
|
||||
* rank_type: string;
|
||||
* id: string;
|
||||
* }} data
|
||||
*/
|
||||
constructor(
|
||||
uid,
|
||||
gacha_id,
|
||||
gacha_type,
|
||||
item_id,
|
||||
count,
|
||||
time,
|
||||
name,
|
||||
lang,
|
||||
item_type,
|
||||
rank_type,
|
||||
id
|
||||
) {
|
||||
constructor(data) {
|
||||
const {
|
||||
uid,
|
||||
gacha_id,
|
||||
gacha_type,
|
||||
item_id,
|
||||
count,
|
||||
time,
|
||||
name,
|
||||
lang,
|
||||
item_type,
|
||||
rank_type,
|
||||
id,
|
||||
} = data;
|
||||
this.uid = uid;
|
||||
this.gacha_id = gacha_id;
|
||||
this.gacha_type = gacha_type;
|
||||
|
|
@ -93,22 +119,7 @@ export class ZZZGachaLogResp {
|
|||
const { page, size, list, region, region_time_zone } = data;
|
||||
this.page = page;
|
||||
this.size = size;
|
||||
this.list = list.map(
|
||||
item =>
|
||||
new SingleGachaLog(
|
||||
item.uid,
|
||||
item.gacha_id,
|
||||
item.gacha_type,
|
||||
item.item_id,
|
||||
item.count,
|
||||
item.time,
|
||||
item.name,
|
||||
item.lang,
|
||||
item.item_type,
|
||||
item.rank_type,
|
||||
item.id
|
||||
)
|
||||
);
|
||||
this.list = list.map(item => new SingleGachaLog(item));
|
||||
this.region = region;
|
||||
this.region_time_zone = region_time_zone;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { ZZZAvatarInfo } from './avatar.js';
|
||||
import { ZZZAvatarBasic } from './avatar.js';
|
||||
import { Buddy } from './bangboo.js';
|
||||
|
||||
/**
|
||||
|
|
@ -34,7 +34,7 @@ export class ZZZIndexResp {
|
|||
/**
|
||||
* @param {{
|
||||
* stats: Stats;
|
||||
* avatar_list: ZZZAvatarInfo[];
|
||||
* avatar_list: ZZZAvatarBasic[];
|
||||
* cur_head_icon_url: string;
|
||||
* buddy_list: Buddy[];
|
||||
* }} data
|
||||
|
|
@ -42,7 +42,7 @@ export class ZZZIndexResp {
|
|||
constructor(data) {
|
||||
const { stats, avatar_list, cur_head_icon_url, buddy_list } = data;
|
||||
this.stats = stats;
|
||||
this.avatar_list = avatar_list.map(item => new ZZZAvatarInfo(item));
|
||||
this.avatar_list = avatar_list.map(item => new ZZZAvatarBasic(item));
|
||||
this.cur_head_icon_url = cur_head_icon_url;
|
||||
this.buddy_list = buddy_list.map(item => new Buddy(item));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,13 +3,21 @@
|
|||
*/
|
||||
export class Property {
|
||||
/**
|
||||
* @param {{
|
||||
* property_name: string,
|
||||
* property_id: number,
|
||||
* base: string,
|
||||
* add: string,
|
||||
* final: string
|
||||
* }} data
|
||||
* @param {string} property_name
|
||||
* @param {number} property_id
|
||||
* @param {string} base
|
||||
* @param {string} add
|
||||
* @param {string} final
|
||||
*/
|
||||
constructor(property_name, property_id, base, add, final) {
|
||||
constructor(data) {
|
||||
const { property_name, property_id, base, add, final } = data;
|
||||
this.property_name = property_name;
|
||||
this.property_id = property_id;
|
||||
this.base = base;
|
||||
|
|
|
|||
|
|
@ -17,11 +17,14 @@ export class SkillItem {
|
|||
*/
|
||||
export class Skill {
|
||||
/**
|
||||
* @param {number} level
|
||||
* @param {number} skill_type
|
||||
* @param {SkillItem[]} items
|
||||
* @param {{
|
||||
* level: number,
|
||||
* skill_type: number,
|
||||
* items: SkillItem[]
|
||||
* }} data
|
||||
*/
|
||||
constructor(level, skill_type, items) {
|
||||
constructor(data) {
|
||||
const { level, skill_type, items } = data;
|
||||
this.level = level;
|
||||
this.skill_type = skill_type;
|
||||
this.items = items;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue