Update deadly.js (#140) fix #139

修复危局查询中无邦布信息导致的报错,为其追加空白默认值
This commit is contained in:
AthenaHibou 2025-07-28 20:54:04 +08:00 committed by GitHub
parent 0c53e71af6
commit b2c93724b3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -71,6 +71,10 @@ import { Buffer } from 'node:buffer';
* @property {DeadlyList[]} list * @property {DeadlyList[]} list
*/ */
// 1x1像素透明用于填充无图情况
const BLANK_IMAGE = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=';
/** /**
* @class Deadly. * @class Deadly.
*/ */
@ -169,6 +173,15 @@ export class Buddy {
* @param {Buddy} data * @param {Buddy} data
*/ */
constructor(data) { constructor(data) {
//无邦布信息的时候使用默认空值
if (!data) {
this.id = 0;
this.rarity = '';
this.level = 0;
//邦布使用透明图
this.bangboo_rectangle_url = BLANK_IMAGE;
return;
}
this.id = data.id; this.id = data.id;
this.rarity = data.rarity; this.rarity = data.rarity;
this.level = data.level; this.level = data.level;