2018-12-07 02:54:26 -08:00
|
|
|
import {joinFaction} from "../src/Faction/FactionHelpers";
|
2018-06-26 12:34:11 -04:00
|
|
|
import {Engine} from "../src/engine";
|
|
|
|
import {Player} from "../src/Player";
|
2018-07-07 23:19:19 -04:00
|
|
|
import {clearEventListeners} from "./uiHelpers/clearEventListeners";
|
2018-07-19 21:51:18 -04:00
|
|
|
import {Page, routing} from "../src/ui/navigationTracking";
|
2017-08-30 12:44:29 -05:00
|
|
|
|
2017-02-16 12:52:11 -06:00
|
|
|
/* Faction Invitation Pop-up box */
|
2017-08-30 12:44:29 -05:00
|
|
|
function factionInvitationBoxClose() {
|
2017-02-16 12:52:11 -06:00
|
|
|
var factionInvitationBox = document.getElementById("faction-invitation-box-container");
|
|
|
|
factionInvitationBox.style.display = "none";
|
|
|
|
}
|
|
|
|
|
2017-08-30 12:44:29 -05:00
|
|
|
function factionInvitationBoxOpen() {
|
2017-02-16 12:52:11 -06:00
|
|
|
var factionInvitationBox = document.getElementById("faction-invitation-box-container");
|
2018-08-17 15:06:18 -05:00
|
|
|
factionInvitationBox.style.display = "flex";
|
2017-02-16 12:52:11 -06:00
|
|
|
}
|
|
|
|
|
2017-08-30 12:44:29 -05:00
|
|
|
function factionInvitationSetText(txt) {
|
2017-02-16 12:52:11 -06:00
|
|
|
var textBox = document.getElementById("faction-invitation-box-text");
|
|
|
|
textBox.innerHTML = txt;
|
|
|
|
}
|
|
|
|
|
|
|
|
//ram argument is in GB
|
2017-08-30 12:44:29 -05:00
|
|
|
function factionInvitationBoxCreate(faction) {
|
2017-02-16 12:52:11 -06:00
|
|
|
factionInvitationSetText("You have received a faction invitation from " + faction.name);
|
2018-03-03 15:05:33 -06:00
|
|
|
faction.alreadyInvited = true;
|
|
|
|
Player.factionInvitations.push(faction.name);
|
|
|
|
|
2018-07-19 21:51:18 -04:00
|
|
|
if (routing.isOn(Page.Factions)) {
|
2018-03-03 15:05:33 -06:00
|
|
|
Engine.loadFactionsContent();
|
|
|
|
}
|
2017-07-26 21:56:14 -05:00
|
|
|
|
2017-05-05 16:27:35 -05:00
|
|
|
var newYesButton = clearEventListeners("faction-invitation-box-yes");
|
2017-04-17 07:26:54 -05:00
|
|
|
newYesButton.addEventListener("click", function() {
|
2018-03-03 15:05:33 -06:00
|
|
|
//Remove from invited factions
|
|
|
|
var i = Player.factionInvitations.findIndex((facName)=>{return facName === faction.name});
|
|
|
|
if (i === -1) {
|
2018-11-30 04:19:51 -08:00
|
|
|
console.error("Could not find faction in Player.factionInvitations");
|
2018-03-03 15:05:33 -06:00
|
|
|
}
|
2017-02-16 12:52:11 -06:00
|
|
|
joinFaction(faction);
|
|
|
|
factionInvitationBoxClose();
|
2018-07-19 21:51:18 -04:00
|
|
|
if (routing.isOn(Page.Factions)) {
|
2018-03-03 15:05:33 -06:00
|
|
|
Engine.loadFactionsContent();
|
|
|
|
}
|
2017-02-16 12:52:11 -06:00
|
|
|
return false;
|
|
|
|
});
|
2017-07-26 21:56:14 -05:00
|
|
|
|
2017-06-07 18:35:56 -05:00
|
|
|
var noButton = clearEventListeners("faction-invitation-box-no");
|
|
|
|
noButton.addEventListener("click", function() {
|
|
|
|
factionInvitationBoxClose();
|
|
|
|
return false;
|
|
|
|
});
|
2017-07-26 21:56:14 -05:00
|
|
|
|
2017-02-16 12:52:11 -06:00
|
|
|
factionInvitationBoxOpen();
|
2017-07-26 21:56:14 -05:00
|
|
|
}
|
2017-08-30 12:44:29 -05:00
|
|
|
|
|
|
|
export {factionInvitationBoxCreate};
|