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;
if (gSkill.share) {
// This skill shares a cooldown with another skill, use that skill's cooldown
cooldown = G.skills[gSkill.share].cooldown * (gSkill.cooldown_multiplier || 1)
lastUse = player.last[gSkill.share]
cooldown = G.skills[gSkill.share].cooldown * (gSkill.cooldown_multiplier || 1);
lastUse = player.last[gSkill.share];
} else {
cooldown = gSkill.cooldown || gSkill.reuse_cooldown;
lastUse = player.last[data.name];
@@ -8092,25 +8092,21 @@ function init_io() {
});
}
if (
gSkill.class &&
!in_arr(player.type, gSkill.class)
&& player.role != "gm"
) {
if (gSkill.class && !in_arr(player.type, gSkill.class) && player.role != "gm") {
return fail_response("skill_cant_use", data.name);
}
if (gSkill.wtype && player.role != "gm") {
let canUse;
if (!player.slots.mainhand) {
canUse = false
canUse = false;
} 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 {
canUse = G.items[player.slots.mainhand.name].wtype == gSkill.wtype
canUse = G.items[player.slots.mainhand.name].wtype == gSkill.wtype;
}
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;
if (gSkill.target) {
const isMonster = "" + parseInt(data.id) === "" + data.id
const isPlayer = !isMonster
const canTargetMonster = gSkill.target == "monster" || gSkill.target === true
const canTargetPlayer = gSkill.target == "player" || gSkill.target === true
const isMonster = "" + parseInt(data.id) === "" + data.id;
const isPlayer = !isMonster;
const canTargetMonster = gSkill.target == "monster" || gSkill.target === true;
const canTargetPlayer = gSkill.target == "player" || gSkill.target === true;
if ((isMonster && !canTargetMonster) || (isPlayer && !canTargetPlayer)) {
return fail_response("invalid_target", data.name, { id: data.id });
}
@@ -8132,7 +8128,7 @@ function init_io() {
target = players[id_to_id[data.id]];
if (gSkill.hostile && target.name == player.name) {
// 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]) {
target = instances[player.in].monsters[data.id];
@@ -8140,10 +8136,7 @@ function init_io() {
// TODO: Consider adding game_response, too
return socket.emit("disappear", { id: data.id, place: data.name, reason: "not_there" });
}
if (
is_invis(target) ||
(!gSkill.global && distance(target, player) > B.max_vision)
) {
if (is_invis(target) || (!gSkill.global && distance(target, player) > B.max_vision)) {
// TODO: Consider adding game_response, too
return socket.emit("disappear", { id: data.id, place: data.name, reason: "not_there" });
}
@@ -8151,10 +8144,7 @@ function init_io() {
if (gSkill.requirements) {
for (const requirement in gSkill.requirements) {
if (
!player[requirement] ||
player[requirement] < gSkill.requirements[requirement]
) {
if (!player[requirement] || player[requirement] < gSkill.requirements[requirement]) {
return fail_response("skill_cant_requirements", data.name);
}
}
@@ -8164,12 +8154,16 @@ function init_io() {
let found = false;
let noCharge = false;
for (const [slotName, itemName] of gSkill.slot) {
const slotItem = player.slots[slotName]
if (!slotItem || slotItem.name !== itemName) continue;
const slotItem = player.slots[slotName];
if (!slotItem || slotItem.name !== itemName) {
continue;
}
found = true;
const gItem = G.items[itemName]
if (!gItem.charge) continue;
const gItem = G.items[itemName];
if (!gItem.charge) {
continue;
}
// This skill requires a charge, check the charge level
if ((slotItem.charges || 0) < gItem.charge) {
noCharge = true;
@@ -8196,21 +8190,25 @@ function init_io() {
// Range check
if (target && (gSkill.range || gSkill.use_range)) {
let range = gSkill.range || player.range
if (gSkill.range_multiplier) range *= gSkill.range_multiplier
if (gSkill.range_bonus) range += gSkill.range_bonus
if (data.name == "throw") {
range += player.level
let range = gSkill.range || player.range;
if (gSkill.range_multiplier) {
range *= gSkill.range_multiplier;
}
if (gSkill.range_bonus) {
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) {
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) {
// 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) {
// No item was provided, search for one
for (let i = player.isize - 1; i >= 0; i--) {
const potentialItem = player.items[i]
if(!potentialItem) continue
if(potentialItem.name !== gSkill.consume) continue
const potentialItem = player.items[i];
if (!potentialItem) {
continue;
}
if (potentialItem.name !== gSkill.consume) {
continue;
}
// We found the item
data.num = i
item = potentialItem
break
data.num = i;
item = potentialItem;
break;
}
} else {
item = player.items[data.num]
item = player.items[data.num];
}
if (!item || item.name != gSkill.consume) {
return fail_response("skill_cant_item", data.name);
}
// Consume the item
consume_one(player, data.num)
consume_one(player, data.num);
player.to_resend = "u+cid+reopen";
}
if ([
if (
[
"attack",
"burst",
"heal",
@@ -8257,7 +8260,8 @@ function init_io() {
"supershot",
"taunt",
"zapperzap",
].includes(data.name)) {
].includes(data.name)
) {
const attack = commence_attack(player, target, data.name);
if (!attack.failed) {
resolve = attack;
@@ -8275,9 +8279,7 @@ function init_io() {
} else if (data.name == "pickpocket") {
consume_mp(player, gSkill.mp);
player.c[data.name] = {
ms:
gSkill.duration_min +
Math.random() * (gSkill.duration_max - gSkill.duration_min),
ms: gSkill.duration_min + Math.random() * (gSkill.duration_max - gSkill.duration_min),
target: target.name,
};
player.to_resend = "u+cid";
@@ -8308,9 +8310,7 @@ function init_io() {
} else {
xy_emit(player, "ui", { type: data.name + "_start", name: player.name, direction: direction });
player.c[data.name] = {
ms:
gSkill.duration_min +
Math.random() * (gSkill.duration_max - gSkill.duration_min),
ms: gSkill.duration_min + Math.random() * (gSkill.duration_max - gSkill.duration_min),
drop: the_zone.drop,
};
}