2017-08-30 19:44:29 +02:00
|
|
|
import {Faction, joinFaction} from "../src/Faction.js";
|
|
|
|
import {Player} from "../src/Player.js";
|
|
|
|
import {clearEventListeners} from "./HelperFunctions.js";
|
|
|
|
|
2017-02-16 19:52:11 +01:00
|
|
|
/* Faction Invitation Pop-up box */
|
2017-08-30 19:44:29 +02:00
|
|
|
function factionInvitationBoxClose() {
|
2017-02-16 19:52:11 +01:00
|
|
|
var factionInvitationBox = document.getElementById("faction-invitation-box-container");
|
|
|
|
factionInvitationBox.style.display = "none";
|
|
|
|
}
|
|
|
|
|
2017-08-30 19:44:29 +02:00
|
|
|
function factionInvitationBoxOpen() {
|
2017-02-16 19:52:11 +01:00
|
|
|
var factionInvitationBox = document.getElementById("faction-invitation-box-container");
|
|
|
|
factionInvitationBox.style.display = "block";
|
|
|
|
}
|
|
|
|
|
2017-08-30 19:44:29 +02:00
|
|
|
function factionInvitationSetText(txt) {
|
2017-02-16 19:52:11 +01:00
|
|
|
var textBox = document.getElementById("faction-invitation-box-text");
|
|
|
|
textBox.innerHTML = txt;
|
|
|
|
}
|
|
|
|
|
2017-08-30 19:44:29 +02:00
|
|
|
function factionInvitationSetMessage(msg) {
|
2017-02-16 19:52:11 +01:00
|
|
|
var msgBox = document.getElementById("faction-invitation-box-message");
|
|
|
|
msgBox.innerHTML = msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
//ram argument is in GB
|
2017-08-30 19:44:29 +02:00
|
|
|
function factionInvitationBoxCreate(faction) {
|
2017-02-16 19:52:11 +01:00
|
|
|
factionInvitationSetText("You have received a faction invitation from " + faction.name);
|
|
|
|
//TODO Faction invitation message
|
2017-07-27 04:56:14 +02:00
|
|
|
|
2017-05-05 23:27:35 +02:00
|
|
|
var newYesButton = clearEventListeners("faction-invitation-box-yes");
|
2017-04-17 14:26:54 +02:00
|
|
|
newYesButton.addEventListener("click", function() {
|
2017-02-16 19:52:11 +01:00
|
|
|
joinFaction(faction);
|
|
|
|
factionInvitationBoxClose();
|
|
|
|
return false;
|
|
|
|
});
|
2017-07-27 04:56:14 +02:00
|
|
|
|
2017-06-08 01:35:56 +02:00
|
|
|
var noButton = clearEventListeners("faction-invitation-box-no");
|
|
|
|
noButton.addEventListener("click", function() {
|
|
|
|
factionInvitationBoxClose();
|
|
|
|
faction.alreadyInvited = true;
|
2017-07-27 04:56:14 +02:00
|
|
|
Player.factionInvitations.push(faction.name);
|
2017-06-08 01:35:56 +02:00
|
|
|
return false;
|
|
|
|
});
|
2017-07-27 04:56:14 +02:00
|
|
|
|
2017-02-16 19:52:11 +01:00
|
|
|
factionInvitationBoxOpen();
|
2017-07-27 04:56:14 +02:00
|
|
|
}
|
2017-08-30 19:44:29 +02:00
|
|
|
|
|
|
|
export {factionInvitationBoxCreate};
|