temporary accounts

This commit is contained in:
Jonas Weinz 2019-04-04 14:58:29 +02:00
parent ec8aed1f83
commit a8fb232643
3 changed files with 21 additions and 10 deletions

View File

@ -26,9 +26,9 @@ b_local_game = create_game_container.create_button("Local Game");
// register container: // register container:
register_container = main_menu.create_infocontainer("Login to play online"); register_container = main_menu.create_infocontainer("Login to play online");
i_register_username = register_container.create_input("username"); i_register_username = register_container.create_input("username");
i_register_pw = register_container.create_input("password", true); i_register_pw = register_container.create_input("pw (optional)", true);
b_register = register_container.create_button("register/login"); b_register = register_container.create_button("play online");
register_container.create_label("If the username does not exist yet, a new account is created automatically"); register_container.create_label("To play ranked matches you have to create an account. Login without an password will only create a temporary session");
register_container.create_label("Note that inactive accounts will be deleted after 45 days") register_container.create_label("Note that inactive accounts will be deleted after 45 days")
// logout TODO: rename container: // logout TODO: rename container:

View File

@ -1,6 +1,6 @@
class OnlineMatchManager class OnlineMatchManager
{ {
constructor(grid, info_func, matches_container, control_container, end_button, game_server_connection, match_id, match_state, revoke_time, player_name) constructor(grid, info_func, matches_container, control_container, end_button, game_server_connection, match_id, match_state, revoke_time, player_name, ranked)
{ {
this.grid = grid; this.grid = grid;
@ -10,6 +10,8 @@ class OnlineMatchManager
this.game_server_connection = game_server_connection; this.game_server_connection = game_server_connection;
this.ranked = ranked;
this.match_state = match_state; this.match_state = match_state;
this.revoke_time = Date.create_from_mysql(revoke_time); this.revoke_time = Date.create_from_mysql(revoke_time);
@ -32,7 +34,7 @@ class OnlineMatchManager
this.match_button_div = tmp[0]; this.match_button_div = tmp[0];
this.match_button_option = tmp[2]; this.match_button_option = tmp[2];
if (this.game_server_connection.is_friend(this.online_opponent.get_name())) if (this.game_server_connection.temporary_session || this.game_server_connection.is_friend(this.online_opponent.get_name()))
{ {
this.match_button_option.disabled = true; this.match_button_option.disabled = true;
} }
@ -244,7 +246,7 @@ class OnlineMatchManager
} }
} }
var control_head = ""; var control_head = this.ranked ? "Ranked Match<br>" : "Unranked_Match<br>";
this.control_container.clear_background_color(); this.control_container.clear_background_color();
this.update_button_text(); this.update_button_text();
@ -325,9 +327,9 @@ class OnlineMatchManager
this.control_container.blink(theme_color_highlight); this.control_container.blink(theme_color_highlight);
} }
control_head += "" + current_player_name + "'s move"; control_head += "" + encodeHTML(current_player_name) + "'s move";
this.control_container.update_head(encodeHTML(control_head)); this.control_container.update_head(control_head);

View File

@ -9,6 +9,8 @@ class WebsocketConnection
this.socket = null; this.socket = null;
this.registered = false; this.registered = false;
this.temporary_session = false;
this.info_func = info_func; this.info_func = info_func;
this.err_func = err_func; this.err_func = err_func;
@ -42,6 +44,8 @@ class WebsocketConnection
this.friend_name_divs = []; this.friend_name_divs = [];
matches_container.hide(); matches_container.hide();
} }
@ -245,6 +249,7 @@ class WebsocketConnection
var id = data.id var id = data.id
var match_state = data.match_state; var match_state = data.match_state;
var revoke_time = data.revoke_time; var revoke_time = data.revoke_time;
var ranked = data.ranked;
if (match_state == null) if (match_state == null)
{ {
@ -281,7 +286,7 @@ class WebsocketConnection
this.l_matches_container = null; this.l_matches_container = null;
} }
this.openmatches[id] = new OnlineMatchManager(this.grid, this.info_func, this.matches_container, this.control_container, this.end_button, this, id, match_state, revoke_time, this.player.get_name()); this.openmatches[id] = new OnlineMatchManager(this.grid, this.info_func, this.matches_container, this.control_container, this.end_button, this, id, match_state, revoke_time, this.player.get_name(), ranked);
if (match_state.last_move == null) if (match_state.last_move == null)
{ {
this.notify("new Game against " + encodeHTML(this.openmatches[id].online_opponent.get_name())); this.notify("new Game against " + encodeHTML(this.openmatches[id].online_opponent.get_name()));
@ -303,6 +308,7 @@ class WebsocketConnection
{ {
this.registered = true; this.registered = true;
this.session_id = data.id; this.session_id = data.id;
this.temporary_session = !data.registered;
this.login_callback_func(); this.login_callback_func();
this.info_func(data.msg); this.info_func(data.msg);
return; return;
@ -408,7 +414,10 @@ class WebsocketConnection
on_elo_update(data) on_elo_update(data)
{ {
console.log("received elo update: " + data.elo); console.log("received elo update: " + data.elo);
this.logout_container.update_head("logged in as: " + encodeHTML(connection.player.get_name()) + "<br>Score: " + encodeHTML("" + data.elo) + "<br>Rank: " + encodeHTML(""+data.rank)); if (data.elo != null && data.rank != null)
{
this.logout_container.update_head("logged in as: " + encodeHTML(connection.player.get_name()) + "<br>Score: " + encodeHTML("" + data.elo) + "<br>Rank: " + encodeHTML(""+data.rank));
}
this.top_names = data.top_names; this.top_names = data.top_names;
this.top_elos = data.top_elos; this.top_elos = data.top_elos;
this.logout_container.blink(theme_color_highlight); this.logout_container.blink(theme_color_highlight);