Fixed bug with faction invitations not getting deleted

This commit is contained in:
Daniel Ferri 2021-05-06 21:49:20 +02:00 committed by hydroflame
parent 68eb68a89e
commit 62e2f0582a
3 changed files with 9 additions and 8 deletions

@ -56,6 +56,15 @@ export function joinFaction(faction) {
Factions[enemy].isBanned = true; Factions[enemy].isBanned = true;
} }
} }
for (var i = 0; i < Player.factionInvitations.length; ++i) {
if (Player.factionInvitations[i] == faction.name || Factions[Player.factionInvitations[i]].isBanned) {
Player.factionInvitations.splice(i, 1);
i--;
}
}
if (routing.isOn(Page.Factions)) {
Engine.loadFactionsContent();
}
} }
export function startHackingMission(faction) { export function startHackingMission(faction) {

@ -643,12 +643,6 @@ const Engine = {
clickListener: (e) => { clickListener: (e) => {
if (!e.isTrusted) { return false; } if (!e.isTrusted) { return false; }
joinFaction(Factions[factionName]); joinFaction(Factions[factionName]);
for (var i = 0; i < Player.factionInvitations.length; ++i) {
if (Player.factionInvitations[i] == factionName || Factions[Player.factionInvitations[i]].isBanned) {
Player.factionInvitations.splice(i, 1);
i--;
}
}
Engine.displayFactionsInfo(); Engine.displayFactionsInfo();
return false; return false;
}, },

@ -36,8 +36,6 @@ function factionInvitationBoxCreate(faction) {
var i = Player.factionInvitations.findIndex((facName)=>{return facName === faction.name}); var i = Player.factionInvitations.findIndex((facName)=>{return facName === faction.name});
if (i === -1) { if (i === -1) {
console.error("Could not find faction in Player.factionInvitations"); console.error("Could not find faction in Player.factionInvitations");
} else {
Player.factionInvitations.splice(i, 1);
} }
joinFaction(faction); joinFaction(faction);
factionInvitationBoxClose(); factionInvitationBoxClose();