2020-01-10 08:36:57 +01:00
|
|
|
import * as Dom from UnitJS.Dom;
|
2020-01-13 18:05:11 +01:00
|
|
|
import Games;
|
2020-01-10 08:36:57 +01:00
|
|
|
import I18n;
|
2020-01-11 19:46:41 +01:00
|
|
|
import * as Players from GUI.Screen.Hall.Players;
|
2020-01-13 18:05:11 +01:00
|
|
|
import * as GamesGUI from GUI.Screen.Hall.Games;
|
2020-01-10 08:36:57 +01:00
|
|
|
import Messaging;
|
|
|
|
import StatusHandler;
|
|
|
|
|
|
|
|
return {
|
|
|
|
init: init
|
|
|
|
};
|
|
|
|
|
|
|
|
function init() {
|
|
|
|
Messaging.addEventListener(["Okaeri"], function(o) {
|
|
|
|
refresh();
|
|
|
|
});
|
|
|
|
Messaging.addEventListener(["Welcome"], function(o) {
|
|
|
|
refresh();
|
|
|
|
});
|
|
|
|
Messaging.addEventListener(["LogIn"], function(o) {
|
2020-01-11 19:46:41 +01:00
|
|
|
refresh();
|
2020-01-10 08:36:57 +01:00
|
|
|
});
|
|
|
|
Messaging.addEventListener(["LogOut"], function(o) {
|
2020-01-11 19:46:41 +01:00
|
|
|
// Just in case there was a game proposal from that player, in which case the game proposal's ID is the player's ID
|
2020-01-13 08:39:32 +01:00
|
|
|
Games.entries.remove(o.from);
|
2020-01-10 08:36:57 +01:00
|
|
|
refresh();
|
|
|
|
});
|
|
|
|
Messaging.addEventListener(["Relay", "Invitation"], function(o) {
|
2020-01-11 19:46:41 +01:00
|
|
|
StatusHandler.set("🎴");
|
2020-01-14 09:55:04 +01:00
|
|
|
Games.proposal(o.from, true);
|
2020-01-13 18:05:11 +01:00
|
|
|
GamesGUI.refresh();
|
2020-01-10 08:36:57 +01:00
|
|
|
});
|
|
|
|
Messaging.addEventListener(["Relay", "Answer"], function(o) {
|
2020-01-14 11:19:03 +01:00
|
|
|
var gameEntry = Games.entries.get(o.from);
|
|
|
|
if(gameEntry != undefined) {
|
|
|
|
if(!o.message.accept) {
|
|
|
|
gameEntry.answer = false;
|
|
|
|
} else {
|
|
|
|
Games.entries.remove(o.from);
|
|
|
|
}
|
|
|
|
GamesGUI.refresh();
|
|
|
|
}
|
2020-01-10 08:36:57 +01:00
|
|
|
});
|
|
|
|
Messaging.addEventListener(["Game"], function(o) {
|
2020-01-13 18:05:11 +01:00
|
|
|
GamesGUI.refresh();
|
2020-01-10 08:36:57 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function refresh() {
|
2020-01-11 19:46:41 +01:00
|
|
|
Players.refresh();
|
2020-01-13 18:05:11 +01:00
|
|
|
GamesGUI.refresh();
|
2020-01-10 08:36:57 +01:00
|
|
|
}
|