getStatusLabel

This commit is contained in:
ckcz123 2020-06-22 14:49:01 +08:00
parent 34080197f7
commit 942e256e0a
6 changed files with 55 additions and 18 deletions

View File

@ -2334,6 +2334,10 @@ var terndefs_f6783a0a_522d_417e_8407_94c67b692e50 = [
"!doc": "从status中获得实际属性增幅后的如果不存在则从勇士属性中获取",
"!type": "fn(status?: ?, name?: string)"
},
"getStatusLabel": {
"!doc": "获得某个状态的名字如atk->攻击def->防御等",
"!type": "fn(name: string) -> string"
},
"removeSave": {
"!doc": "删除某个存档",
"!type": "fn(index?: number, callback?: fn())"

View File

@ -135,6 +135,12 @@ var functions_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
"_lint": true,
"_data": "读档操作"
},
"getStatusLabel": {
"_leaf": true,
"_type": "textarea",
"_lint": true,
"_data": "状态名定义"
},
"triggerDebuff": {
"_leaf": true,
"_type": "textarea",

View File

@ -2080,6 +2080,17 @@ control.prototype.getNakedStatus = function (name) {
return value;
}
////// 获得某个属性的名字 //////
control.prototype.getStatusLabel = function (name) {
if (this.controldata.getStatusLabel) {
return this.controldata.getStatusLabel(name) || name;
}
return {
name: "名称", lv: "等级", hpmax: "生命上限", hp: "生命", manamax: "魔力上限", mana: "魔力",
atk: "攻击", def: "防御", mdef: "护盾", money: "金币", exp: "经验", point: "加点", steps: "步数"
}[name] || name;
}
////// 设置某个属性的增幅值 //////
control.prototype.setBuff = function (name, value) {
// 仅保留三位有效buff值

View File

@ -1992,11 +1992,11 @@ ui.prototype._drawBook_drawRow1 = function (index, enemy, top, left, width, posi
core.setTextAlign('ui', 'left');
var b13 = this._buildFont(13, true), f13 = this._buildFont(13, false);
var col1 = left, col2 = left + width * 9 / 25, col3 = left + width * 17 / 25;
core.fillText('ui', '生命', col1, position, '#DDDDDD', f13);
core.fillText('ui', core.getStatusLabel('hp'), col1, position, '#DDDDDD', f13);
core.fillText('ui', core.formatBigNumber(enemy.hp||0), col1 + 30, position, null, b13);
core.fillText('ui', '攻击', col2, position, null, f13);
core.fillText('ui', core.getStatusLabel('atk'), col2, position, null, f13);
core.fillText('ui', core.formatBigNumber(enemy.atk||0), col2 + 30, position, null, b13);
core.fillText('ui', '防御', col3, position, null, f13);
core.fillText('ui', core.getStatusLabel('def'), col3, position, null, f13);
core.fillText('ui', core.formatBigNumber(enemy.def||0), col3 + 30, position, null, b13);
}
@ -2007,9 +2007,9 @@ ui.prototype._drawBook_drawRow2 = function (index, enemy, top, left, width, posi
var col1 = left, col2 = left + width * 9 / 25, col3 = left + width * 17 / 25;
// 获得第二行绘制的内容
var second_line = [];
if (core.flags.statusBarItems.indexOf('enableMoney')>=0) second_line.push(["金币", core.formatBigNumber(enemy.money || 0)]);
if (core.flags.enableAddPoint) second_line.push(["加点", core.formatBigNumber(enemy.point || 0)]);
if (core.flags.statusBarItems.indexOf('enableExp')>=0) second_line.push(["经验", core.formatBigNumber(enemy.exp || 0)]);
if (core.flags.statusBarItems.indexOf('enableMoney')>=0) second_line.push([core.getStatusLabel('money'), core.formatBigNumber(enemy.money || 0)]);
if (core.flags.enableAddPoint) second_line.push([core.getStatusLabel('point'), core.formatBigNumber(enemy.point || 0)]);
if (core.flags.statusBarItems.indexOf('enableExp')>=0) second_line.push([core.getStatusLabel('exp'), core.formatBigNumber(enemy.exp || 0)]);
var damage_offset = col1 + (this.PIXEL - col1) / 2 - 12;
// 第一列
@ -2600,7 +2600,7 @@ ui.prototype._drawEquipbox_drawStatusChanged = function (info, y, equip, equipTy
var newValue = Math.floor((core.getStatus(name) + (compare.value[name] || 0))
* (core.getBuff(name) * 100 + (compare.percentage[name] || 0)) / 100);
if (nowValue == newValue) continue;
var text = this._drawEquipbox_getStatusName(name);
var text = core.getStatusLabel(name);
this._drawEquipbox_drawStatusChanged_draw(text + " ", '#CCCCCC', obj);
var color = newValue>nowValue?'#00FF00':'#FF0000';
nowValue = core.formatBigNumber(nowValue);
@ -2611,14 +2611,6 @@ ui.prototype._drawEquipbox_drawStatusChanged = function (info, y, equip, equipTy
}
}
ui.prototype._drawEquipbox_getStatusName = function (name) {
var map = {
name: "名称", lv: "等级", hpmax: "生命上限", hp: "生命", manamax: "魔力上限", mana: "魔力",
atk: "攻击", def: "防御", mdef: "护盾", money: "金币", exp: "经验", exp: "经验", steps: "步数"
};
return map[name] || name;
}
ui.prototype._drawEquipbox_drawStatusChanged_draw = function (text, color, obj) {
var len = core.calWidth('ui', text);
if (obj.drawOffset + len >= core.__PIXELS__) { // 换行
@ -2978,9 +2970,9 @@ ui.prototype._drawStatistics_items = function (floorId, floor, id, obj) {
}
if (id.indexOf('sword')==0 || id.indexOf('shield')==0 || obj.cls[id]=='equips') {
var t = "";
if (atk > 0) t += atk + "攻";
if (def > 0) t += def + "防";
if (mdef > 0) t += mdef + "护盾";
if (atk > 0) t += atk + core.getStatusLabel('atk');
if (def > 0) t += def + core.getStatusLabel('def');
if (mdef > 0) t += mdef + core.getStatusLabel('mdef');
if (t != "") obj.ext[id] = t;
}
this._drawStatistics_add(floorId, obj, 'count', id, 1);

View File

@ -992,6 +992,27 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
core.removeFlag('__fromLoad__');
if (callback) callback();
});
},
"getStatusLabel": function (name) {
// 返回某个状态英文名的对应中文标签如atk -> 攻击def -> 防御等。
// 请注意此项仅影响 libs/ 下的内容(如绘制怪物手册、数据统计等)
// 自行定义的(比如获得道具效果)中用到的“攻击+3”等需要自己去对应地方修改
return {
name: "名称",
lv: "等级",
hpmax: "生命上限",
hp: "生命",
manamax: "魔力上限",
mana: "魔力",
atk: "攻击",
def: "防御",
mdef: "护盾",
money: "金币",
exp: "经验",
point: "加点",
steps: "步数",
} [name] || name;
},
"triggerDebuff": function (action, type) {
// 毒衰咒效果的获得与解除

3
runtime.d.ts vendored
View File

@ -430,6 +430,9 @@ declare class control {
* @param name NaN
*/
getRealStatus(name: string): any
/** 获得某个状态的名字 */
getStatusLabel(name: string): string
/**
* 1