mirror of
https://github.com/gooba42/adventureland.git
synced 2026-10-14 18:39:27 -05:00
use eslint's fixer
This commit is contained in:
+61
-61
@@ -4144,7 +4144,7 @@ function init_io() {
|
||||
} else {
|
||||
try {
|
||||
socket.emit("game_error", "ERROR!");
|
||||
} catch (e) { }
|
||||
} catch (e) {}
|
||||
}
|
||||
} catch (e) {
|
||||
log_trace("limit_calls", e);
|
||||
@@ -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,52 +8190,61 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
// Consume item check
|
||||
if (gSkill.consume) {
|
||||
let item;
|
||||
if(data.num === undefined || data.num === null) {
|
||||
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,
|
||||
};
|
||||
}
|
||||
@@ -9580,7 +9580,7 @@ function init_io() {
|
||||
}
|
||||
try {
|
||||
delete_observer(socket);
|
||||
} catch (e) { }
|
||||
} catch (e) {}
|
||||
|
||||
players[socket.id] = player;
|
||||
resume_instance(instances[player.in]);
|
||||
@@ -10358,7 +10358,7 @@ function init_io() {
|
||||
socket.emit("tavern", { event: "info", edge: house_edge(), max: parseInt((S.gold - house_debt()) * 0.4) });
|
||||
}
|
||||
});
|
||||
socket.on("play", function (data) { });
|
||||
socket.on("play", function (data) {});
|
||||
socket.on("pet", function (data) {
|
||||
var player = players[socket.id];
|
||||
if (!player) {
|
||||
@@ -10512,7 +10512,7 @@ function init_io() {
|
||||
var observer = observers[socket.id];
|
||||
try {
|
||||
delete sockets[socket.id];
|
||||
} catch (e) { }
|
||||
} catch (e) {}
|
||||
if (player) {
|
||||
player.dc = true;
|
||||
try {
|
||||
@@ -12454,7 +12454,7 @@ function update_instance(instance) {
|
||||
if (def.withdrawal) {
|
||||
add_condition(player, def.withdrawal);
|
||||
}
|
||||
} catch (e) { }
|
||||
} catch (e) {}
|
||||
player.slots.elixir = null;
|
||||
player.cslots.elixir = null;
|
||||
resend(player, "reopen+u+cid");
|
||||
@@ -13110,7 +13110,7 @@ setInterval(function () {
|
||||
retries: 5,
|
||||
item: mitem,
|
||||
},
|
||||
function (result) { },
|
||||
function (result) {},
|
||||
function () {
|
||||
console.log("#M unsent giveaway, lost item: " + mitem);
|
||||
},
|
||||
@@ -13468,7 +13468,7 @@ function sync_loop() {
|
||||
server_log("#X SEVERE: sync notingame disconnect for " + player.name, 1);
|
||||
try {
|
||||
player.socket.disconnect();
|
||||
} catch (e) { }
|
||||
} catch (e) {}
|
||||
}
|
||||
delete player.sync_call;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user