use eslint's fixer

This commit is contained in:
Kent Rasmussen
2023-11-22 13:21:39 +09:00
parent 4aba162c5d
commit 5c4b468465
+53 -53
View File
@@ -8078,8 +8078,8 @@ function init_io() {
let lastUse; let lastUse;
if (gSkill.share) { if (gSkill.share) {
// This skill shares a cooldown with another skill, use that skill's cooldown // This skill shares a cooldown with another skill, use that skill's cooldown
cooldown = G.skills[gSkill.share].cooldown * (gSkill.cooldown_multiplier || 1) cooldown = G.skills[gSkill.share].cooldown * (gSkill.cooldown_multiplier || 1);
lastUse = player.last[gSkill.share] lastUse = player.last[gSkill.share];
} else { } else {
cooldown = gSkill.cooldown || gSkill.reuse_cooldown; cooldown = gSkill.cooldown || gSkill.reuse_cooldown;
lastUse = player.last[data.name]; lastUse = player.last[data.name];
@@ -8092,25 +8092,21 @@ function init_io() {
}); });
} }
if ( if (gSkill.class && !in_arr(player.type, gSkill.class) && player.role != "gm") {
gSkill.class &&
!in_arr(player.type, gSkill.class)
&& player.role != "gm"
) {
return fail_response("skill_cant_use", data.name); return fail_response("skill_cant_use", data.name);
} }
if (gSkill.wtype && player.role != "gm") { if (gSkill.wtype && player.role != "gm") {
let canUse; let canUse;
if (!player.slots.mainhand) { if (!player.slots.mainhand) {
canUse = false canUse = false;
} else if (is_array(gSkill.wtype)) { } else if (is_array(gSkill.wtype)) {
canUse = in_arr(G.items[player.slots.mainhand.name].wtype, gSkill.wtype) canUse = in_arr(G.items[player.slots.mainhand.name].wtype, gSkill.wtype);
} else { } else {
canUse = G.items[player.slots.mainhand.name].wtype == gSkill.wtype canUse = G.items[player.slots.mainhand.name].wtype == gSkill.wtype;
} }
if (!canUse) { if (!canUse) {
return fail_response("skill_cant_wtype", data.name) return fail_response("skill_cant_wtype", data.name);
} }
} }
@@ -8121,10 +8117,10 @@ function init_io() {
var target; var target;
if (gSkill.target) { if (gSkill.target) {
const isMonster = "" + parseInt(data.id) === "" + data.id const isMonster = "" + parseInt(data.id) === "" + data.id;
const isPlayer = !isMonster const isPlayer = !isMonster;
const canTargetMonster = gSkill.target == "monster" || gSkill.target === true const canTargetMonster = gSkill.target == "monster" || gSkill.target === true;
const canTargetPlayer = gSkill.target == "player" || gSkill.target === true const canTargetPlayer = gSkill.target == "player" || gSkill.target === true;
if ((isMonster && !canTargetMonster) || (isPlayer && !canTargetPlayer)) { if ((isMonster && !canTargetMonster) || (isPlayer && !canTargetPlayer)) {
return fail_response("invalid_target", data.name, { id: data.id }); return fail_response("invalid_target", data.name, { id: data.id });
} }
@@ -8132,7 +8128,7 @@ function init_io() {
target = players[id_to_id[data.id]]; target = players[id_to_id[data.id]];
if (gSkill.hostile && target.name == player.name) { if (gSkill.hostile && target.name == player.name) {
// Prevent casting the skill on oneself // Prevent casting the skill on oneself
return fail_response("no_target", data.name) return fail_response("no_target", data.name);
} }
} else if (isMonster && instances[player.in].monsters[data.id]) { } else if (isMonster && instances[player.in].monsters[data.id]) {
target = instances[player.in].monsters[data.id]; target = instances[player.in].monsters[data.id];
@@ -8140,10 +8136,7 @@ function init_io() {
// TODO: Consider adding game_response, too // TODO: Consider adding game_response, too
return socket.emit("disappear", { id: data.id, place: data.name, reason: "not_there" }); return socket.emit("disappear", { id: data.id, place: data.name, reason: "not_there" });
} }
if ( if (is_invis(target) || (!gSkill.global && distance(target, player) > B.max_vision)) {
is_invis(target) ||
(!gSkill.global && distance(target, player) > B.max_vision)
) {
// TODO: Consider adding game_response, too // TODO: Consider adding game_response, too
return socket.emit("disappear", { id: data.id, place: data.name, reason: "not_there" }); return socket.emit("disappear", { id: data.id, place: data.name, reason: "not_there" });
} }
@@ -8151,10 +8144,7 @@ function init_io() {
if (gSkill.requirements) { if (gSkill.requirements) {
for (const requirement in gSkill.requirements) { for (const requirement in gSkill.requirements) {
if ( if (!player[requirement] || player[requirement] < gSkill.requirements[requirement]) {
!player[requirement] ||
player[requirement] < gSkill.requirements[requirement]
) {
return fail_response("skill_cant_requirements", data.name); return fail_response("skill_cant_requirements", data.name);
} }
} }
@@ -8164,12 +8154,16 @@ function init_io() {
let found = false; let found = false;
let noCharge = false; let noCharge = false;
for (const [slotName, itemName] of gSkill.slot) { for (const [slotName, itemName] of gSkill.slot) {
const slotItem = player.slots[slotName] const slotItem = player.slots[slotName];
if (!slotItem || slotItem.name !== itemName) continue; if (!slotItem || slotItem.name !== itemName) {
continue;
}
found = true; found = true;
const gItem = G.items[itemName] const gItem = G.items[itemName];
if (!gItem.charge) continue; if (!gItem.charge) {
continue;
}
// This skill requires a charge, check the charge level // This skill requires a charge, check the charge level
if ((slotItem.charges || 0) < gItem.charge) { if ((slotItem.charges || 0) < gItem.charge) {
noCharge = true; noCharge = true;
@@ -8196,21 +8190,25 @@ function init_io() {
// Range check // Range check
if (target && (gSkill.range || gSkill.use_range)) { if (target && (gSkill.range || gSkill.use_range)) {
let range = gSkill.range || player.range let range = gSkill.range || player.range;
if (gSkill.range_multiplier) range *= gSkill.range_multiplier if (gSkill.range_multiplier) {
if (gSkill.range_bonus) range += gSkill.range_bonus range *= gSkill.range_multiplier;
}
if (data.name == "throw") { if (gSkill.range_bonus) {
range += player.level range += gSkill.range_bonus;
} }
const dist = distance(player, target) if (data.name == "throw") {
range += player.level;
}
const dist = distance(player, target);
if (dist > range + player.xrange) { if (dist > range + player.xrange) {
return fail_response("too_far", data.name, { dist: dist, id: target.id, place: data.name }) return fail_response("too_far", data.name, { dist: dist, id: target.id, place: data.name });
} }
if (dist > range) { if (dist > range) {
// xrange was used, reduce it by however much we used // xrange was used, reduce it by however much we used
player.xrange -= dist - range player.xrange -= dist - range;
} }
} }
@@ -8220,28 +8218,33 @@ function init_io() {
if (data.num === undefined || data.num === null) { if (data.num === undefined || data.num === null) {
// No item was provided, search for one // No item was provided, search for one
for (let i = player.isize - 1; i >= 0; i--) { for (let i = player.isize - 1; i >= 0; i--) {
const potentialItem = player.items[i] const potentialItem = player.items[i];
if(!potentialItem) continue if (!potentialItem) {
if(potentialItem.name !== gSkill.consume) continue continue;
}
if (potentialItem.name !== gSkill.consume) {
continue;
}
// We found the item // We found the item
data.num = i data.num = i;
item = potentialItem item = potentialItem;
break break;
} }
} else { } else {
item = player.items[data.num] item = player.items[data.num];
} }
if (!item || item.name != gSkill.consume) { if (!item || item.name != gSkill.consume) {
return fail_response("skill_cant_item", data.name); return fail_response("skill_cant_item", data.name);
} }
// Consume the item // Consume the item
consume_one(player, data.num) consume_one(player, data.num);
player.to_resend = "u+cid+reopen"; player.to_resend = "u+cid+reopen";
} }
if ([ if (
[
"attack", "attack",
"burst", "burst",
"heal", "heal",
@@ -8257,7 +8260,8 @@ function init_io() {
"supershot", "supershot",
"taunt", "taunt",
"zapperzap", "zapperzap",
].includes(data.name)) { ].includes(data.name)
) {
const attack = commence_attack(player, target, data.name); const attack = commence_attack(player, target, data.name);
if (!attack.failed) { if (!attack.failed) {
resolve = attack; resolve = attack;
@@ -8275,9 +8279,7 @@ function init_io() {
} else if (data.name == "pickpocket") { } else if (data.name == "pickpocket") {
consume_mp(player, gSkill.mp); consume_mp(player, gSkill.mp);
player.c[data.name] = { player.c[data.name] = {
ms: ms: gSkill.duration_min + Math.random() * (gSkill.duration_max - gSkill.duration_min),
gSkill.duration_min +
Math.random() * (gSkill.duration_max - gSkill.duration_min),
target: target.name, target: target.name,
}; };
player.to_resend = "u+cid"; player.to_resend = "u+cid";
@@ -8308,9 +8310,7 @@ function init_io() {
} else { } else {
xy_emit(player, "ui", { type: data.name + "_start", name: player.name, direction: direction }); xy_emit(player, "ui", { type: data.name + "_start", name: player.name, direction: direction });
player.c[data.name] = { player.c[data.name] = {
ms: ms: gSkill.duration_min + Math.random() * (gSkill.duration_max - gSkill.duration_min),
gSkill.duration_min +
Math.random() * (gSkill.duration_max - gSkill.duration_min),
drop: the_zone.drop, drop: the_zone.drop,
}; };
} }