删除getDamageString函数

This commit is contained in:
unanmed 2023-07-30 17:33:46 +08:00
parent ef7215a2b0
commit dae43498ca
5 changed files with 86 additions and 24 deletions

View File

@ -1501,7 +1501,7 @@ control.prototype.drawDamage = function (ctx, floorId = core.status.floorId) {
}; };
control.prototype._drawDamage_draw = function (ctx, onMap) { control.prototype._drawDamage_draw = function (ctx, onMap) {
// Deprecated. See src/plugin/game/popup.js // Deprecated. See src/plugin/game/fx/checkblock.js
}; };
// ------ 录像相关 ------ // // ------ 录像相关 ------ //

View File

@ -207,29 +207,7 @@ enemys.prototype.canBattle = function (enemy, x, y, floorId) {
}; };
enemys.prototype.getDamageString = function (enemy, x, y, floorId, hero) { enemys.prototype.getDamageString = function (enemy, x, y, floorId, hero) {
// todo: 删除 // Deprecated.
if (typeof enemy == 'string') enemy = core.material.enemys[enemy];
var damage = this.getDamage(enemy, x, y, floorId, hero);
var color = '#000000';
if (damage == null) {
damage = '???';
color = '#FF2222';
} else {
if (damage <= 0) color = '#11FF11';
else if (damage < core.status.hero.hp / 3) color = '#FFFFFF';
else if (damage < (core.status.hero.hp * 2) / 3) color = '#FFFF00';
else if (damage < core.status.hero.hp) color = '#FF9933';
else color = '#FF2222';
damage = core.formatBigNumber(damage, true);
}
return {
damage: damage,
color: color
};
}; };
////// 接下来N个临界值和临界减伤计算 ////// ////// 接下来N个临界值和临界减伤计算 //////

View File

@ -0,0 +1,70 @@
import { getEnemy } from '../enemy/battle';
import { DamageDir, getNeedCalDir } from '../enemy/damage';
import { formatDamage } from '../utils';
export {};
core.maps._initDetachedBlock = function (
info: BlockInfo,
x: number,
y: number,
displayDamage: boolean = false
) {
let headCanvas = null,
bodyCanvas = '__body_' + x + '_' + y,
damageCanvas = null;
// head
if (!info.bigImage && info.height > 32) {
headCanvas = '__head_' + x + '_' + y;
core.createCanvas(headCanvas, 0, 0, 32, info.height - 32, 55);
}
// body
if (info.bigImage) {
var bigImageInfo = this._getBigImageInfo(
info.bigImage,
info.face,
info.posX
);
const { per_width, per_height } = bigImageInfo;
core.createCanvas(bodyCanvas, 0, 0, per_width, per_height, 35);
} else {
core.createCanvas(bodyCanvas, 0, 0, 32, 32, 35);
}
// 伤害
if (
info.cls.indexOf('enemy') == 0 &&
core.hasItem('book') &&
displayDamage
) {
const enemy = getEnemy(x, y);
const dam = enemy.calEnemyDamage(core.status.hero, getNeedCalDir(x, y));
let min = Infinity;
let minDir: DamageDir = 'none';
for (const d of dam) {
if (d.damage < min) {
min = d.damage;
minDir = d.dir;
}
}
const { damage, color } = formatDamage(min);
damageCanvas = '__damage_' + x + '_' + y;
const ctx = core.createCanvas(damageCanvas, 0, 0, 32, 32, 65);
ctx.textAlign = 'left';
ctx.font = '14px normal';
core.fillBoldText(ctx, damage, 1, 31, color as string);
if (core.flags.displayCritical) {
const critical = enemy.calCritical(1, minDir)[0];
const atk = core.formatBigNumber(critical[0].dirDelta, true);
const display = atk === '???' ? '?' : atk;
core.fillBoldText(ctx, display, 1, 21, '#FFFFFF');
}
}
return {
headCanvas,
bodyCanvas,
damageCanvas
};
};

View File

@ -5,6 +5,7 @@ import './fx/itemDetail';
import './enemy/checkblock'; import './enemy/checkblock';
import './replay'; import './replay';
import './ui'; import './ui';
import './fx/rewrite';
import * as halo from './fx/halo'; import * as halo from './fx/halo';
import * as hero from './hero'; import * as hero from './hero';
import * as loopMap from './loopMap'; import * as loopMap from './loopMap';

13
src/types/map.d.ts vendored
View File

@ -1380,6 +1380,19 @@ interface Maps {
stopAnimate(id?: number, doCallback?: boolean): void; stopAnimate(id?: number, doCallback?: boolean): void;
_makeAutotileEdges(): void; _makeAutotileEdges(): void;
_initDetachedBlock(
info: BlockInfo,
x: number,
y: number,
displayDamage: boolean
): {
headCanvas: string | null;
bodyCanvas: string;
damageCanvas: string | null;
};
_getBigImageInfo(bigImage: HTMLImageElement, face: Dir, posX: number): any;
} }
declare const maps: new () => Maps; declare const maps: new () => Maps;