From ed6cd5a80ed9bc062d069c0c4e018aaa4c88f60e Mon Sep 17 00:00:00 2001 From: SirPython Date: Sun, 26 Jul 2015 20:22:20 -0400 Subject: [PATCH 01/24] initial format of login page --- login.html | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 login.html diff --git a/login.html b/login.html new file mode 100644 index 0000000..ebc582b --- /dev/null +++ b/login.html @@ -0,0 +1,17 @@ + + + + + +
+ Server: + +
+ Port: + +
+ Username: + +
+ + From fea0e199bcc0d20e8716530256c536457364290a Mon Sep 17 00:00:00 2001 From: SirPython Date: Sun, 26 Jul 2015 20:23:15 -0400 Subject: [PATCH 02/24] move here --- login/login.html | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 login/login.html diff --git a/login/login.html b/login/login.html new file mode 100644 index 0000000..ebc582b --- /dev/null +++ b/login/login.html @@ -0,0 +1,17 @@ + + + + + +
+ Server: + +
+ Port: + +
+ Username: + +
+ + From 673bcfcde2f8b9b9ea7889caa24aabd91ed16959 Mon Sep 17 00:00:00 2001 From: SirPython Date: Sun, 26 Jul 2015 20:23:24 -0400 Subject: [PATCH 03/24] moved --- login.html | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 login.html diff --git a/login.html b/login.html deleted file mode 100644 index ebc582b..0000000 --- a/login.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - -
- Server: - -
- Port: - -
- Username: - -
- - From 9e5377d5a7e395817b4eaa046a1d399cacc2e4b7 Mon Sep 17 00:00:00 2001 From: SirPython Date: Sun, 26 Jul 2015 20:41:54 -0400 Subject: [PATCH 04/24] added submit button --- login/login.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/login/login.html b/login/login.html index ebc582b..2e9dc44 100644 --- a/login/login.html +++ b/login/login.html @@ -3,7 +3,8 @@ -
+ + Server:
@@ -12,6 +13,8 @@
Username: +
+
From ccfd4e783ba47b5deca4075d5b7a955fb27c860a Mon Sep 17 00:00:00 2001 From: SirPython Date: Sun, 26 Jul 2015 20:42:18 -0400 Subject: [PATCH 05/24] initial --- login/login.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 login/login.js diff --git a/login/login.js b/login/login.js new file mode 100644 index 0000000..55362d0 --- /dev/null +++ b/login/login.js @@ -0,0 +1,14 @@ +(function(window, undefined) { + var login_information = document.login_information; + + var server = login_information.server; + var port = login_information.port; + var username = login_information.username; + + login_information.submit.onclick = function() { + console.log("Server: " + server.value); + console.log("Port: " + port.value); + console.log("Username: " + username.value); + } + +})(Function("return this")); From be9b5f3b8bceaf8b20af87d61151e10035ce702d Mon Sep 17 00:00:00 2001 From: SirPython Date: Sun, 26 Jul 2015 21:34:05 -0400 Subject: [PATCH 06/24] initial --- server_interface.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 server_interface.js diff --git a/server_interface.js b/server_interface.js new file mode 100644 index 0000000..80afc24 --- /dev/null +++ b/server_interface.js @@ -0,0 +1,23 @@ +(function(window, undefined) { + function Message(command) { + this.command = command; + } + window.CardshifterServerInterface = { + types: { + LoginMessage: function(username) { + this.username = username; + }, + RequestTargetsMessage: function(gameId, id, action) { + this.gamdId = gameId; + this.id = id; + this.action = action; + } + }, + init: function() { + var tyeps = this.types; + + types.LoginMessage.prototype = new Message("login"); + types.RequestTargetsMessage.prototype = new Message("requestTargets"); + } + } +})(Function("return this")); From cceaf985f56b420b539bfb76b9fdec949cd6fc9f Mon Sep 17 00:00:00 2001 From: SirPython Date: Sun, 26 Jul 2015 21:34:41 -0400 Subject: [PATCH 07/24] moving file to own folder --- server_interface/server_interface.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 server_interface/server_interface.js diff --git a/server_interface/server_interface.js b/server_interface/server_interface.js new file mode 100644 index 0000000..80afc24 --- /dev/null +++ b/server_interface/server_interface.js @@ -0,0 +1,23 @@ +(function(window, undefined) { + function Message(command) { + this.command = command; + } + window.CardshifterServerInterface = { + types: { + LoginMessage: function(username) { + this.username = username; + }, + RequestTargetsMessage: function(gameId, id, action) { + this.gamdId = gameId; + this.id = id; + this.action = action; + } + }, + init: function() { + var tyeps = this.types; + + types.LoginMessage.prototype = new Message("login"); + types.RequestTargetsMessage.prototype = new Message("requestTargets"); + } + } +})(Function("return this")); From b77793358455d23e44c25b21e033e9512aa753ad Mon Sep 17 00:00:00 2001 From: SirPython Date: Sun, 26 Jul 2015 21:35:01 -0400 Subject: [PATCH 08/24] moved --- server_interface.js | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 server_interface.js diff --git a/server_interface.js b/server_interface.js deleted file mode 100644 index 80afc24..0000000 --- a/server_interface.js +++ /dev/null @@ -1,23 +0,0 @@ -(function(window, undefined) { - function Message(command) { - this.command = command; - } - window.CardshifterServerInterface = { - types: { - LoginMessage: function(username) { - this.username = username; - }, - RequestTargetsMessage: function(gameId, id, action) { - this.gamdId = gameId; - this.id = id; - this.action = action; - } - }, - init: function() { - var tyeps = this.types; - - types.LoginMessage.prototype = new Message("login"); - types.RequestTargetsMessage.prototype = new Message("requestTargets"); - } - } -})(Function("return this")); From 94f4d13ba877623bfe559e3b8829b6f2bdd16191 Mon Sep 17 00:00:00 2001 From: SirPython Date: Sun, 26 Jul 2015 21:37:23 -0400 Subject: [PATCH 09/24] thanks Phrancis; fixed typo --- server_interface/server_interface.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server_interface/server_interface.js b/server_interface/server_interface.js index 80afc24..7b89473 100644 --- a/server_interface/server_interface.js +++ b/server_interface/server_interface.js @@ -14,7 +14,7 @@ } }, init: function() { - var tyeps = this.types; + var types = this.types; types.LoginMessage.prototype = new Message("login"); types.RequestTargetsMessage.prototype = new Message("requestTargets"); From 8e71d8cf48be33e87f5e11247130344e612d33b6 Mon Sep 17 00:00:00 2001 From: SirPython Date: Sun, 26 Jul 2015 22:05:46 -0400 Subject: [PATCH 10/24] having trouble with global, will set inheritance using for loop tomorrow --- server_interface/server_interface.js | 32 +++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/server_interface/server_interface.js b/server_interface/server_interface.js index 7b89473..0f8065b 100644 --- a/server_interface/server_interface.js +++ b/server_interface/server_interface.js @@ -11,6 +11,32 @@ this.gamdId = gameId; this.id = id; this.action = action; + }, + ServerQueryMessage: function(request, message) { + this.request = request; + this.message = message; + + this.toString = function() { + return "ServerQueryMessage: Request" + this.request + " message: " + this.message; + } + }, + StartGameRequest: function(opponent, gameType) { + this.opponent = opponent; + this.gameType = gameType; + }, + TransformerMessage: function(type) { + this.type = type; + }, + UseAbilityMessage: function(gameId, id, action, targets) { + this.gameId = gameId; + this.id = id; + this.action = action; + this.targets = targets; + + this.toString = function() { + return "UseAbilityMessage [id=" + this.id + ", action=" + this.action + + ", gameId=" + this.gameId + ", targets=" + this.targets.toString() + "]"; + } } }, init: function() { @@ -18,6 +44,10 @@ types.LoginMessage.prototype = new Message("login"); types.RequestTargetsMessage.prototype = new Message("requestTargets"); + types.ServerQueryMessage.prototype = new Message("query"); + types.StartGameRequest.prototype = new Message("startgame"); + types.TransformerMessage.prototype = new Message("serial"); + types.UseAbilityMessage.prototype = new Message("use"); } } -})(Function("return this")); +})(Function("return this")()); From 53affb9f24bde2ca2a17930c71ca5a2c3b69a6d9 Mon Sep 17 00:00:00 2001 From: SirPython Date: Mon, 27 Jul 2015 15:13:20 -0400 Subject: [PATCH 11/24] port not needed --- login/login.html | 3 --- 1 file changed, 3 deletions(-) diff --git a/login/login.html b/login/login.html index 2e9dc44..4bc09d6 100644 --- a/login/login.html +++ b/login/login.html @@ -8,9 +8,6 @@ Server:
- Port: - -
Username:
From 6f7c923fbfadadb3e6e637d805b2757f611a4c67 Mon Sep 17 00:00:00 2001 From: SirPython Date: Mon, 27 Jul 2015 15:13:47 -0400 Subject: [PATCH 12/24] port not needed --- login/login.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/login/login.js b/login/login.js index 55362d0..9934ff7 100644 --- a/login/login.js +++ b/login/login.js @@ -2,12 +2,10 @@ var login_information = document.login_information; var server = login_information.server; - var port = login_information.port; var username = login_information.username; login_information.submit.onclick = function() { console.log("Server: " + server.value); - console.log("Port: " + port.value); console.log("Username: " + username.value); } From 8466a3ff3d63983d76a1405a9c3951fcb7be7bf6 Mon Sep 17 00:00:00 2001 From: SirPython Date: Mon, 27 Jul 2015 15:14:15 -0400 Subject: [PATCH 13/24] need to call the return this function --- login/login.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/login/login.js b/login/login.js index 9934ff7..6a6d027 100644 --- a/login/login.js +++ b/login/login.js @@ -9,4 +9,4 @@ console.log("Username: " + username.value); } -})(Function("return this")); +})(Function("return this")()); From afa2b6b2c226f8cb0d43edc442511d25c2886192 Mon Sep 17 00:00:00 2001 From: SirPython Date: Mon, 27 Jul 2015 15:16:33 -0400 Subject: [PATCH 14/24] fixed formatting, added semicolons. --- server_interface/server_interface.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/server_interface/server_interface.js b/server_interface/server_interface.js index 0f8065b..355e856 100644 --- a/server_interface/server_interface.js +++ b/server_interface/server_interface.js @@ -18,7 +18,7 @@ this.toString = function() { return "ServerQueryMessage: Request" + this.request + " message: " + this.message; - } + }; }, StartGameRequest: function(opponent, gameType) { this.opponent = opponent; @@ -34,9 +34,8 @@ this.targets = targets; this.toString = function() { - return "UseAbilityMessage [id=" + this.id + ", action=" + this.action - + ", gameId=" + this.gameId + ", targets=" + this.targets.toString() + "]"; - } + return "UseAbilityMessage [id=" + this.id + ", action=" + this.action + ", gameId=" + this.gameId + ", targets=" + this.targets.toString() + "]"; + }; } }, init: function() { @@ -49,5 +48,5 @@ types.TransformerMessage.prototype = new Message("serial"); types.UseAbilityMessage.prototype = new Message("use"); } - } + }; })(Function("return this")()); From ca7a7b400a51679f9ac1de39b364767ad16767d7 Mon Sep 17 00:00:00 2001 From: SirPython Date: Mon, 27 Jul 2015 16:55:41 -0400 Subject: [PATCH 15/24] added a primitive sendMessage method --- server_interface/server_interface.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/server_interface/server_interface.js b/server_interface/server_interface.js index 355e856..04e8261 100644 --- a/server_interface/server_interface.js +++ b/server_interface/server_interface.js @@ -3,6 +3,7 @@ this.command = command; } window.CardshifterServerInterface = { + ws: null, types: { LoginMessage: function(username) { this.username = username; @@ -38,7 +39,7 @@ }; } }, - init: function() { + init: function(server, isSecure) { var types = this.types; types.LoginMessage.prototype = new Message("login"); @@ -47,6 +48,12 @@ types.StartGameRequest.prototype = new Message("startgame"); types.TransformerMessage.prototype = new Message("serial"); types.UseAbilityMessage.prototype = new Message("use"); + + var ws = new WebSocket("ws" + (isSecure ? "s" : "") + "://" + server); + this.ws = ws; + }, + sendMessage: function(message) { + this.ws.send(JSON.stringify(message)); } }; })(Function("return this")()); From f260556c5cf4f25f7e52e0fb299823752a26bd7a Mon Sep 17 00:00:00 2001 From: SirPython Date: Mon, 27 Jul 2015 16:59:06 -0400 Subject: [PATCH 16/24] added a secure server option --- login/login.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/login/login.js b/login/login.js index 6a6d027..eb9ce38 100644 --- a/login/login.js +++ b/login/login.js @@ -3,10 +3,12 @@ var server = login_information.server; var username = login_information.username; + var isSecure = login_information.secure; login_information.submit.onclick = function() { console.log("Server: " + server.value); console.log("Username: " + username.value); + console.log("Is secure: " + isSecure.value); } })(Function("return this")()); From 4d0d83411a7534a55e0b5befefda452b93c50754 Mon Sep 17 00:00:00 2001 From: SirPython Date: Mon, 27 Jul 2015 16:59:26 -0400 Subject: [PATCH 17/24] added a secure server option --- login/login.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/login/login.html b/login/login.html index 4bc09d6..a9bc606 100644 --- a/login/login.html +++ b/login/login.html @@ -11,6 +11,9 @@ Username:
+ Is secure server: + +
From 62bf949b202c882eeef4bfc36d410d3bfbd3a0f2 Mon Sep 17 00:00:00 2001 From: SirPython Date: Mon, 27 Jul 2015 17:02:12 -0400 Subject: [PATCH 18/24] changed name to CardshifterServerAPI --- server_interface/server_interface.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server_interface/server_interface.js b/server_interface/server_interface.js index 04e8261..6214a10 100644 --- a/server_interface/server_interface.js +++ b/server_interface/server_interface.js @@ -2,7 +2,7 @@ function Message(command) { this.command = command; } - window.CardshifterServerInterface = { + window.CardshifterServerAPI = { ws: null, types: { LoginMessage: function(username) { From a9166e5a0ac65bf6d14c36c7c8d5562b6bbea784 Mon Sep 17 00:00:00 2001 From: SirPython Date: Mon, 27 Jul 2015 17:05:29 -0400 Subject: [PATCH 19/24] types renamed to messageTypes --- server_interface/server_interface.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server_interface/server_interface.js b/server_interface/server_interface.js index 6214a10..2f89851 100644 --- a/server_interface/server_interface.js +++ b/server_interface/server_interface.js @@ -4,7 +4,7 @@ } window.CardshifterServerAPI = { ws: null, - types: { + messageTypes: { LoginMessage: function(username) { this.username = username; }, From 24ba581d4d2119fd5843534879e262a95c0697bc Mon Sep 17 00:00:00 2001 From: SirPython Date: Mon, 27 Jul 2015 17:13:43 -0400 Subject: [PATCH 20/24] added all "both" message types --- server_interface/server_interface.js | 31 ++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/server_interface/server_interface.js b/server_interface/server_interface.js index 2f89851..0938909 100644 --- a/server_interface/server_interface.js +++ b/server_interface/server_interface.js @@ -37,6 +37,33 @@ this.toString = function() { return "UseAbilityMessage [id=" + this.id + ", action=" + this.action + ", gameId=" + this.gameId + ", targets=" + this.targets.toString() + "]"; }; + }, + ChatMessage: function(chatId, from, message) { + this.chatId = chatId; + this.from = from; + this.message = message; + + this.toString = function() { + return "ChatMessage [chatId=" + chatId + ", message=" + message + ", from=" + from + "]"; + }; + }, + InviteRequest: function(id, name, gameType) { + this.id = id; + this.name = name; + this.gameType = gameType; + }, + InviteResponse: function(inviteId, accepted) { + this.inviteId = inviteId; + this.accepted = accepted; + }, + PlayerConfigMessage: function(gameId, modName, configs) { + this.gameId = gameId; + this.modName = modName; + this.configs = configs; + + this.toString = function() { + return "PlayerConfigMessage{ configs=" + configs + ", gameId=" + gameId + ", modName='" + modName + '\'' + '}'; + }; } }, init: function(server, isSecure) { @@ -48,6 +75,10 @@ types.StartGameRequest.prototype = new Message("startgame"); types.TransformerMessage.prototype = new Message("serial"); types.UseAbilityMessage.prototype = new Message("use"); + types.ChatMessage.prototype = new Message("chat"); + types.InviteRequest.prototype = new Message("inviteRequest"); + types.InviteResponse.prototype = new Message("inviteResponse"); + types.PlayerConfigMessage = new Message("playerconfig"); var ws = new WebSocket("ws" + (isSecure ? "s" : "") + "://" + server); this.ws = ws; From 34df9ffa8f93e89e150faff11ea9462b57a06857 Mon Sep 17 00:00:00 2001 From: SirPython Date: Mon, 27 Jul 2015 17:25:25 -0400 Subject: [PATCH 21/24] changed ws to socket --- server_interface/server_interface.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server_interface/server_interface.js b/server_interface/server_interface.js index 0938909..9ce3cd4 100644 --- a/server_interface/server_interface.js +++ b/server_interface/server_interface.js @@ -3,7 +3,7 @@ this.command = command; } window.CardshifterServerAPI = { - ws: null, + socket: null, messageTypes: { LoginMessage: function(username) { this.username = username; @@ -80,11 +80,11 @@ types.InviteResponse.prototype = new Message("inviteResponse"); types.PlayerConfigMessage = new Message("playerconfig"); - var ws = new WebSocket("ws" + (isSecure ? "s" : "") + "://" + server); - this.ws = ws; + var socket = new WebSocket("ws" + (isSecure ? "s" : "") + "://" + server); + this.socket = socket; }, sendMessage: function(message) { - this.ws.send(JSON.stringify(message)); + this.socket.send(JSON.stringify(message)); } }; })(Function("return this")()); From 520c684d232ed919a8745e1d98245b478b350b64 Mon Sep 17 00:00:00 2001 From: SirPython Date: Mon, 27 Jul 2015 17:32:51 -0400 Subject: [PATCH 22/24] changed placholder, planning select The place holder for server used to be `dwardtowers.com`, now it is local host. Simon suggested that I add a select option for some of the most common servers. I am planning the best way to do this now. --- login/login.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/login/login.html b/login/login.html index a9bc606..b1994dc 100644 --- a/login/login.html +++ b/login/login.html @@ -6,7 +6,7 @@
Server: - +
Username: From b6b7c4db667399d1b0fca6b18134370bd5b8dbed Mon Sep 17 00:00:00 2001 From: SirPython Date: Mon, 27 Jul 2015 20:36:31 -0400 Subject: [PATCH 23/24] new select feature --- login/login.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/login/login.js b/login/login.js index eb9ce38..0c17ad7 100644 --- a/login/login.js +++ b/login/login.js @@ -2,13 +2,27 @@ var login_information = document.login_information; var server = login_information.server; + var serverOther = login_information.server_other; + var serverOtherContainer = document.getElementById("server_other"); var username = login_information.username; var isSecure = login_information.secure; + var submit = login_information.submit; + var isOther = false; - login_information.submit.onclick = function() { - console.log("Server: " + server.value); - console.log("Username: " + username.value); - console.log("Is secure: " + isSecure.value); + submit.onclick = function() { + var finalServer = (isOther ? serverOther.value : server.value); + console.log(finalServer); + } + + server.onclick = function() { + console.log(this.value); + if(this.value === "other") { + serverOtherContainer.style.display = "block"; + isOther = true; + } else { + serverOtherContainer.style.display = "none"; + isOther = false; + } } })(Function("return this")()); From b5a5773cbbee76f81cda7748c4f89fc8459ec9e0 Mon Sep 17 00:00:00 2001 From: SirPython Date: Mon, 27 Jul 2015 20:36:56 -0400 Subject: [PATCH 24/24] added select feature --- login/login.html | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/login/login.html b/login/login.html index b1994dc..c5258bd 100644 --- a/login/login.html +++ b/login/login.html @@ -6,8 +6,17 @@ Server: - +
+
+ Other Server: + +
+
Username: