2020-01-10 08:36:57 +01:00
|
|
|
import * as Dom from UnitJS.Dom;
|
|
|
|
import I18n;
|
2020-01-11 19:46:41 +01:00
|
|
|
import * as Players from GUI.Screen.Hall.Players;
|
|
|
|
import * as Games from GUI.Screen.Hall.Games;
|
2020-01-10 08:36:57 +01:00
|
|
|
import Messaging;
|
2020-01-11 19:46:41 +01:00
|
|
|
import opponent from Room;
|
2020-01-10 08:36:57 +01:00
|
|
|
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-13 08:39:32 +01:00
|
|
|
Games.entries.insert(o.from, {vs: opponent(o.from), yourTurn: true});
|
2020-01-11 19:46:41 +01:00
|
|
|
Games.refresh();
|
2020-01-10 08:36:57 +01:00
|
|
|
});
|
|
|
|
Messaging.addEventListener(["Relay", "Answer"], function(o) {
|
2020-01-13 08:39:32 +01:00
|
|
|
Games.entries.remove(o.from);
|
2020-01-11 19:46:41 +01:00
|
|
|
Games.refresh();
|
2020-01-10 08:36:57 +01:00
|
|
|
});
|
|
|
|
Messaging.addEventListener(["Game"], function(o) {
|
2020-01-11 19:46:41 +01:00
|
|
|
Games.refresh();
|
2020-01-10 08:36:57 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function refresh() {
|
2020-01-11 19:46:41 +01:00
|
|
|
Players.refresh();
|
|
|
|
Games.refresh();
|
2020-01-10 08:36:57 +01:00
|
|
|
}
|