fix:调整core.getEnemyValue逻辑,不填name返回该点完整metadata
This commit is contained in:
parent
a7ac6c2ae7
commit
6b5615fd4e
@ -167,17 +167,30 @@ enemys.prototype._calSpecialContent = function (enemy, content) {
|
||||
////// 获得某个点上某个怪物的某项属性 //////
|
||||
enemys.prototype.getEnemyValue = function (enemy, name, x, y, floorId) {
|
||||
floorId = floorId || core.status.floorId;
|
||||
if ((((flags.enemyOnPoint || {})[floorId] || {})[x + "," + y] || {})[name] != null) {
|
||||
return flags.enemyOnPoint[floorId][x + "," + y][name];
|
||||
|
||||
const pointInfo = (((flags.enemyOnPoint || {})[floorId] || {})[x + "," + y] || {});
|
||||
|
||||
if (core.isset(name) && pointInfo[name] != null) {
|
||||
return pointInfo[name];
|
||||
}
|
||||
if (enemy == null) {
|
||||
var block = core.getBlock(x, y, floorId);
|
||||
if (block == null) return null;
|
||||
if (block == null) return null; // 无enemy且无x,y时返回null,无enemy有x,y将读取该点信息
|
||||
enemy = core.material.enemys[block.event.id];
|
||||
}
|
||||
if (typeof enemy == 'string') enemy = core.material.enemys[enemy];
|
||||
if (enemy == null) return null;
|
||||
return enemy[name];
|
||||
else if (typeof enemy == 'string') {
|
||||
enemy = core.material.enemys[enemy];
|
||||
if (enemy == null) return null;
|
||||
}
|
||||
|
||||
if (!core.isset(name)) { // 仅name不填时返回该enemy的完整数据,有x,y将用该点信息覆盖core.material.enemys相应属性
|
||||
enemy = core.clone(enemy);
|
||||
for (let status in pointInfo) {
|
||||
if (pointInfo.hasOwnProperty(status)) enemy[status] = pointInfo[status];
|
||||
}
|
||||
return enemy;
|
||||
}
|
||||
else return enemy[name];
|
||||
}
|
||||
|
||||
////// 能否获胜 //////
|
||||
|
||||
@ -14,12 +14,12 @@ main.floors.MT0=
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[ 0, 0, 0, 0, 0, 0,201, 0, 0,201, 0, 0, 0],
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0, 0,201, 0, 0, 0],
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[ 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0],
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0, 0,201, 0, 0, 0],
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
@ -56,7 +56,19 @@ main.floors.MT0=
|
||||
"afterOpenDoor": {},
|
||||
"cannotMove": {},
|
||||
"bgmap": [
|
||||
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[167,167,167,167,167,167,167,167,167,167,167,167,167],
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||
],
|
||||
"fgmap": [
|
||||
|
||||
|
||||
@ -1967,7 +1967,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
function canBattle(enemy, x, y) {
|
||||
const loc = `${x},${y}`;
|
||||
const floor = core.floors[core.status.floorId];
|
||||
const e = core.material.enemys[enemy];
|
||||
const e = core.getEnemyValue(enemy, null, x, y);
|
||||
const hasEvent =
|
||||
has(floor.afterBattle[loc]) || has(floor.beforeBattle[loc])
|
||||
|| has(e.beforeBattle) || has(e.afterBattle)
|
||||
|
||||
11
runtime.d.ts
vendored
11
runtime.d.ts
vendored
@ -1426,8 +1426,15 @@ interface enemys {
|
||||
*/
|
||||
getSpecialHint(enemy: string | Enemy, special: number): string
|
||||
|
||||
/** 获得某个敌人的某项属性值 */
|
||||
getEnemyValue(enemy: string | Enemy, name: string, x?: number, y?: number, floorId?: string): any
|
||||
/**
|
||||
* 获得某个敌人的某项属性值
|
||||
* @param enemy 敌人id或敌人对象
|
||||
* @param name 要获取的属性名,不填时获取完整的该敌人数据
|
||||
* @param x 敌人的横坐标,可选,填写时该点属性覆盖core.material.enemys中相应属性
|
||||
* @param y 敌人的纵坐标,可选
|
||||
* @param floorId 敌人所在的地图,可选。
|
||||
*/
|
||||
getEnemyValue(enemy: string | Enemy, name?: string, x?: number, y?: number, floorId?: string): any
|
||||
|
||||
/**
|
||||
* 判定主角当前能否打败某只敌人
|
||||
|
||||
Loading…
Reference in New Issue
Block a user