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