From ffad2cee344229c7aceb7a2c8ce509583a041b84 Mon Sep 17 00:00:00 2001 From: Stanislas Dolcini Date: Thu, 4 Oct 2018 17:14:22 +0200 Subject: [PATCH] Use correct OOP --- assets/Scripts/Models/nel_login_message.gd | 32 ++++++++++++++++++++++ gui_scene/GUI/login/login_menu.gd | 5 ++-- 2 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 assets/Scripts/Models/nel_login_message.gd diff --git a/assets/Scripts/Models/nel_login_message.gd b/assets/Scripts/Models/nel_login_message.gd new file mode 100644 index 0000000..358f06e --- /dev/null +++ b/assets/Scripts/Models/nel_login_message.gd @@ -0,0 +1,32 @@ +class nel_login_message: + var _cmd; + var _login; + var _password; + var _clientApplication; + var _cp; + var _lg; + + func _init(cmd, login, password, clientApplication, cp, lg): + self._cmd = cmd; + self._login = login; + self._password = password; + self._clientApplication = clientApplication; + self._cp = cp; + self._lg = lg; + + func get_request_string(): + var request_string = "cmd=" + self._cmd; + if self._login != "": + request_string += "&login=" + self._login; + if self._password != "": + request_string += "&password=" + self._password; + if self._clientApplication != "": + request_string += "&clientApplication=" + self._clientApplication + if self._cp != "": + request_string += "&cp=" + self._cp + if self._lg != "": + request_string += "&lg=" + self._lg + + return request_string; + + diff --git a/gui_scene/GUI/login/login_menu.gd b/gui_scene/GUI/login/login_menu.gd index 8f068b7..c2e8d2e 100644 --- a/gui_scene/GUI/login/login_menu.gd +++ b/gui_scene/GUI/login/login_menu.gd @@ -18,9 +18,8 @@ func _on_quit_button_pressed(): func do_request(username): - var headers = ["Content-Type: application/json"] - #$HTTPRequest.request("http://lirria.khaganat.net/login/r2_login.php?cmd=ask&login=" + username) - $HTTPRequest.request("http://lirria.khaganat.net/login/r2_login.php?cmd=ask", headers, true, HTTPClient.METHOD_GET, "&login=" + username) + var message = load("res://assets/Scripts/Models/nel_login_message.gd").nel_login_message.new("ask", username, "", "", "", ""); + $HTTPRequest.request("http://lirria.khaganat.net/login/r2_login.php?" + message.get_request_string()); func _on_HTTPRequest_request_completed(result, response_code, headers, body):