summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LICENSE191
-rw-r--r--Makefile36
-rw-r--r--elm-package.json19
-rw-r--r--images/to-favicon.svg511
-rw-r--r--manifest.json23
-rw-r--r--src/Comm/GetBattles.elm41
-rw-r--r--src/Comm/GetID.elm43
-rw-r--r--src/Comm/Okay.elm21
-rw-r--r--src/Comm/Send.elm67
-rw-r--r--src/Comm/SetPlayer.elm26
-rw-r--r--src/ElmModule/Init.elm18
-rw-r--r--src/ElmModule/Subscriptions.elm17
-rw-r--r--src/ElmModule/Update.elm38
-rw-r--r--src/ElmModule/View.elm64
-rw-r--r--src/Main.elm23
-rw-r--r--src/Struct/BattleSummary.elm65
-rw-r--r--src/Struct/Error.elm45
-rw-r--r--src/Struct/Event.elm25
-rw-r--r--src/Struct/Model.elm64
-rw-r--r--src/Struct/Player.elm107
-rw-r--r--src/Struct/ServerReply.elm23
-rw-r--r--src/Struct/UI.elm62
-rw-r--r--src/Update/HandleServerReply.elm104
-rw-r--r--src/View/BattleListing.elm92
-rw-r--r--src/View/Header.elm79
-rw-r--r--www/index.html12
26 files changed, 1816 insertions, 0 deletions
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..bdaf40e
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,191 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ Copyright 2018 Nathanael Sensfelder
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..3b58a08
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,36 @@
+################################################################################
+## CONFIG ######################################################################
+################################################################################
+SRC_DIR ?= src
+WWW_DIR ?= www
+WWW_SCRIPT_DIR ?= $(WWW_DIR)/script
+
+ELM_CC ?= elm-make --warn
+
+MAIN_MODULE ?= $(SRC_DIR)/Main.elm
+
+################################################################################
+## MAKEFILE MAGIC ##############################################################
+################################################################################
+SUB_MODULES = $(shell find $(SRC_DIR) -type f | grep "elm$$")
+
+################################################################################
+## SANITY CHECKS ###############################################################
+################################################################################
+
+################################################################################
+## TARGET RULES ################################################################
+################################################################################
+build: $(WWW_SCRIPT_DIR)/main.js
+
+clean:
+ rm -f $(WWW_SCRIPT_DIR)/main.js
+
+reset:
+ rm -rf elm-stuff
+
+################################################################################
+## INTERNAL RULES ##############################################################
+################################################################################
+$(WWW_SCRIPT_DIR)/main.js: $(MAIN_MODULE) $(SUB_MODULES)
+ $(ELM_CC) $(MAIN_MODULE) --output $@
diff --git a/elm-package.json b/elm-package.json
new file mode 100644
index 0000000..a8b8580
--- /dev/null
+++ b/elm-package.json
@@ -0,0 +1,19 @@
+{
+ "version": "1.0.0",
+ "summary": "helpful summary of your project, less than 80 characters",
+ "repository": "https://github.com/nsensfel/tacticians-extension.git",
+ "license": "Apache 2.0",
+ "source-directories": [
+ "src"
+ ],
+ "exposed-modules": [],
+ "dependencies": {
+ "NoRedInk/elm-decode-pipeline": "3.0.0 <= v < 4.0.0",
+ "andrewMacmurray/elm-delay": "2.0.3 <= v < 3.0.0",
+ "elm-lang/core": "5.1.1 <= v < 6.0.0",
+ "elm-lang/dom": "1.1.1 <= v < 2.0.0",
+ "elm-lang/html": "2.0.0 <= v < 3.0.0",
+ "elm-lang/http": "1.0.0 <= v < 2.0.0"
+ },
+ "elm-version": "0.18.0 <= v < 0.19.0"
+}
diff --git a/images/to-favicon.svg b/images/to-favicon.svg
new file mode 100644
index 0000000..6757b03
--- /dev/null
+++ b/images/to-favicon.svg
@@ -0,0 +1,511 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="42mm"
+ height="42mm"
+ viewBox="0 0 42 42"
+ version="1.1"
+ id="svg8"
+ inkscape:version="0.92.2 5c3e80d, 2017-08-06"
+ sodipodi:docname="to-favicon.svg"
+ inkscape:export-filename="/home/nsensfel/to-logo.png"
+ inkscape:export-xdpi="24.5634"
+ inkscape:export-ydpi="24.5634">
+ <defs
+ id="defs2" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="1.41421"
+ inkscape:cx="35.5077"
+ inkscape:cy="150.206"
+ inkscape:document-units="mm"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:snap-global="false"
+ showguides="false"
+ inkscape:window-width="1678"
+ inkscape:window-height="1029"
+ inkscape:window-x="1"
+ inkscape:window-y="516"
+ inkscape:window-maximized="0"
+ fit-margin-top="0"
+ fit-margin-left="0"
+ fit-margin-right="0"
+ fit-margin-bottom="0" />
+ <metadata
+ id="metadata5">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(-0.765209,-49.6575)">
+ <g
+ id="g1230"
+ transform="translate(7.96196,-0.001457)">
+ <g
+ inkscape:export-ydpi="105.84057"
+ inkscape:export-xdpi="105.84057"
+ inkscape:export-filename="/home/nsensfel/to-logo.png"
+ style="fill:#e9ddaf;stroke:#483e37"
+ id="g1022">
+ <path
+ style="stroke-width:0.5"
+ d="M 25.8655,74.956 A 8.23368,8.23368 65.7815 0 1 21.7341,85.8426 8.23368,8.23368 65.7815 0 1 10.8475,81.7112 8.23368,8.23368 65.7815 0 1 14.9789,70.8246 8.23368,8.23368 65.7815 0 1 25.8655,74.956 Z"
+ id="path922"
+ inkscape:connector-curvature="0" />
+ <path
+ style="stroke-width:0.1"
+ d="M 24.9805,75.3541 A 7.26322,7.26322 65.7815 0 1 21.336,84.9576 7.26322,7.26322 65.7815 0 1 11.7326,81.3131 7.26322,7.26322 65.7815 0 1 15.377,71.7096 7.26322,7.26322 65.7815 0 1 24.9805,75.3541 Z"
+ id="path922-6"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill-rule:evenodd;stroke-width:0.1"
+ d="M 11.267,76.6753 14.8686,84.6824"
+ id="path945"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cc" />
+ <use
+ x="0"
+ y="0"
+ xlink:href="#path945"
+ id="use947"
+ transform="matrix(0.998771,-0.002732,-0.002732,0.993927,10.8154,-4.19754)"
+ width="100%"
+ height="100%"
+ style="stroke-width:0.100367" />
+ <path
+ style="fill-rule:evenodd;stroke-width:0.1"
+ d="M 12.2142,74.4725 13.7955,77.9881"
+ id="path945-7"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cc" />
+ <use
+ x="0"
+ y="0"
+ xlink:href="#path945-7"
+ id="use964"
+ transform="translate(7.3407,-3.3019)"
+ width="100%"
+ height="100%"
+ style="stroke-width:0.1" />
+ <path
+ style="fill-rule:evenodd;stroke-width:0.100725"
+ d="M 13.6805,72.7924 19.4026,85.5138"
+ id="path945-7-3"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cc" />
+ <use
+ x="0"
+ y="0"
+ xlink:href="#path945-7-3"
+ id="use4555"
+ transform="translate(3.61138,-1.62442)"
+ width="100%"
+ height="100%"
+ style="stroke-width:0.1" />
+ <use
+ x="0"
+ y="0"
+ xlink:href="#path945-7-3"
+ id="use4555-6"
+ transform="matrix(0.838763,-0.356215,-0.356215,0.207063,35.516,74.1467)"
+ width="100%"
+ height="100%"
+ style="stroke-width:0.46231" />
+ <path
+ style="stroke-width:0.1"
+ d="M 20.0595,77.5008 A 1.89475,1.89475 65.7815 0 1 19.1088,80.006 1.89475,1.89475 65.7815 0 1 16.6035,79.0553 1.89475,1.89475 65.7815 0 1 17.5543,76.55 1.89475,1.89475 65.7815 0 1 20.0595,77.5008 Z"
+ id="path922-3"
+ inkscape:connector-curvature="0" />
+ <path
+ inkscape:connector-curvature="0"
+ id="use4597"
+ d="M 25.5865,74.8736 A 0.316587,0.316587 65.7815 0 1 25.4277,75.2922 0.316587,0.316587 65.7815 0 1 25.0091,75.1334 0.316587,0.316587 65.7815 0 1 25.1679,74.7148 0.316587,0.316587 65.7815 0 1 25.5865,74.8736 Z"
+ style="stroke-width:0.1" />
+ <path
+ inkscape:connector-curvature="0"
+ id="use4599"
+ d="M 15.4923,71.1942 A 0.316587,0.316587 65.7815 0 1 15.3334,71.6128 0.316587,0.316587 65.7815 0 1 14.9148,71.4539 0.316587,0.316587 65.7815 0 1 15.0737,71.0353 0.316587,0.316587 65.7815 0 1 15.4923,71.1942 Z"
+ style="stroke-width:0.1" />
+ <use
+ x="0"
+ y="0"
+ xlink:href="#use4599"
+ id="use4601"
+ transform="translate(6.31649,14.0427)"
+ width="100%"
+ height="100%"
+ style="stroke-width:0.1" />
+ <use
+ x="0"
+ y="0"
+ xlink:href="#use4601"
+ id="use4603"
+ transform="translate(-6.18533,0.015093)"
+ width="100%"
+ height="100%"
+ style="stroke-width:0.1" />
+ <use
+ x="0"
+ y="0"
+ xlink:href="#use4603"
+ id="use4605"
+ transform="translate(-4.25392,-9.45721)"
+ width="100%"
+ height="100%"
+ style="stroke-width:0.1" />
+ <use
+ x="0"
+ y="0"
+ xlink:href="#use4605"
+ id="use4607"
+ transform="translate(10.3357,-4.64909)"
+ width="100%"
+ height="100%"
+ style="stroke-width:0.1" />
+ <use
+ x="0"
+ y="0"
+ xlink:href="#use4607"
+ id="use4609"
+ transform="translate(4.25286,9.45486)"
+ width="100%"
+ height="100%"
+ style="stroke-width:0.1" />
+ <path
+ style="stroke-width:0.1"
+ d="M 19.1977,77.8884 A 0.94976,0.94976 0 0 1 18.7211,79.1442 0.94976,0.94976 0 0 1 17.4653,78.6676 0.94976,0.94976 0 0 1 17.9419,77.4119 0.94976,0.94976 0 0 1 19.1977,77.8884 Z"
+ id="path922-3-5"
+ inkscape:connector-curvature="0" />
+ <use
+ x="0"
+ y="0"
+ xlink:href="#use964"
+ id="use5318"
+ transform="translate(3.38109,7.51676)"
+ width="100%"
+ height="100%"
+ style="stroke-width:0.1" />
+ <path
+ inkscape:connector-curvature="0"
+ style="stroke-width:0.1"
+ d="M 20.5395,74.3183 C 19.9855,75.087 19.7004,76.5892 20.0495,77.3653 20.4057,78.1573 21.7335,79.1134 22.6545,79.0201 23.7901,78.3799 24.6144,76.416 24.7315,75.2593 23.7583,74.5579 21.8147,74.1113 20.5395,74.3183 Z M 20.7662,75.1426 C 21.6199,75.004 22.9211,75.303 23.5726,75.7725 23.4942,76.5469 22.9423,77.8616 22.182,78.2903 21.5655,78.3527 20.6768,77.7126 20.4383,77.1824 20.2046,76.6628 20.3953,75.6572 20.7662,75.1426 Z"
+ id="path4515" />
+ <use
+ x="0"
+ y="0"
+ xlink:href="#path4515"
+ id="use5298"
+ transform="matrix(-0.663442,0.748228,0.748228,0.663442,-28.0637,12.6232)"
+ width="100%"
+ height="100%"
+ style="stroke-width:0.1" />
+ <use
+ x="0"
+ y="0"
+ xlink:href="#path4515"
+ id="use5300"
+ transform="rotate(90,18.2449,78.2498)"
+ width="100%"
+ height="100%"
+ style="stroke-width:0.1" />
+ <use
+ x="0"
+ y="0"
+ xlink:href="#use5300"
+ id="use5302"
+ transform="matrix(0.663442,-0.748228,-0.748228,-0.663442,64.7501,143.951)"
+ width="100%"
+ height="100%"
+ style="stroke-width:0.1" />
+ <use
+ x="0"
+ y="0"
+ xlink:href="#use4555-6"
+ id="use5320"
+ transform="translate(-5.697,-12.6654)"
+ width="100%"
+ height="100%"
+ style="stroke-width:0.1" />
+ <use
+ x="0"
+ y="0"
+ xlink:href="#use5302"
+ id="use5304"
+ width="100%"
+ height="100%"
+ style="stroke-width:0.1" />
+ <use
+ x="0"
+ y="0"
+ xlink:href="#path945-7"
+ id="use5316"
+ transform="translate(3.38109,7.51676)"
+ width="100%"
+ height="100%"
+ style="stroke-width:0.1" />
+ <use
+ x="0"
+ y="0"
+ xlink:href="#use5298"
+ id="use5312"
+ width="100%"
+ height="100%"
+ style="stroke-width:0.1" />
+ <path
+ inkscape:connector-curvature="0"
+ id="use5330"
+ d="M 18.6202,78.1482 A 0.316587,0.316587 65.7815 0 1 18.4614,78.5668 0.316587,0.316587 65.7815 0 1 18.0428,78.4079 0.316587,0.316587 65.7815 0 1 18.2016,77.9893 0.316587,0.316587 65.7815 0 1 18.6202,78.1482 Z"
+ style="stroke-width:0.1" />
+ <use
+ x="0"
+ y="0"
+ xlink:href="#use4597"
+ id="use1241"
+ transform="translate(-13.9952,6.29513)"
+ width="100%"
+ height="100%" />
+ </g>
+ <path
+ inkscape:export-ydpi="105.84057"
+ inkscape:export-xdpi="105.84057"
+ inkscape:export-filename="/home/nsensfel/to-logo.png"
+ sodipodi:nodetypes="ccccccccccccccc"
+ inkscape:connector-curvature="0"
+ d="M 24.2172,91.3106 C 22.7779,81.0634 18.8389,81.4851 13.3558,61.0857 14.4997,59.1718 19.3261,59.4097 21.0781,59.0713 18.644,58.8611 15.9915,58.8101 14.9749,57.5635 13.8334,57.9832 12.3265,58.6546 11.1557,59.4869 9.9924,56.0745 9.30559,54.2587 7.839,52.1345 9.26206,49.6789 6.57668,49.696 5.65755,50.1674 L 5.56442,50.2094 C 4.60266,50.5864 2.81307,52.588 5.59578,53.1464 6.21755,55.6517 7.12424,57.3684 8.91243,60.4988 7.5136,60.8257 6.01251,61.5112 4.94234,62.0892 5.20405,63.6763 3.48678,65.6985 2.03339,67.6624 3.44656,66.5729 6.46248,62.7974 8.65436,63.2065 20.3178,80.8179 17.3948,83.4917 24.124,91.3526 Z"
+ style="fill:#e9ddaf;fill-rule:evenodd;stroke:#483e37;stroke-width:0.5;stroke-miterlimit:88.800003"
+ id="path4526" />
+ <path
+ inkscape:export-ydpi="105.84057"
+ inkscape:export-xdpi="105.84057"
+ inkscape:export-filename="/home/nsensfel/to-logo.png"
+ sodipodi:nodetypes="cc"
+ inkscape:connector-curvature="0"
+ id="path4547"
+ d="M 8.86646,60.6297 C 9.95389,60.3226 10.6623,59.8943 11.3659,59.4644"
+ style="fill:#e9ddaf;fill-opacity:0;fill-rule:evenodd;stroke:#483e37;stroke-width:0.1" />
+ <use
+ inkscape:export-ydpi="105.84057"
+ inkscape:export-xdpi="105.84057"
+ inkscape:export-filename="/home/nsensfel/to-logo.png"
+ height="100%"
+ width="100%"
+ transform="translate(-0.28115,-0.493305)"
+ id="use4564"
+ xlink:href="#path4547"
+ y="0"
+ x="0"
+ style="fill:#e9ddaf;stroke:#483e37" />
+ <use
+ inkscape:export-ydpi="105.84057"
+ inkscape:export-xdpi="105.84057"
+ inkscape:export-filename="/home/nsensfel/to-logo.png"
+ height="100%"
+ width="100%"
+ transform="translate(-0.23254,-0.515498)"
+ id="use4566"
+ xlink:href="#use4564"
+ y="0"
+ x="0"
+ style="fill:#e9ddaf;stroke:#483e37" />
+ <use
+ inkscape:export-ydpi="105.84057"
+ inkscape:export-xdpi="105.84057"
+ inkscape:export-filename="/home/nsensfel/to-logo.png"
+ height="100%"
+ width="100%"
+ transform="translate(-0.23254,-0.515498)"
+ id="use4568"
+ xlink:href="#use4566"
+ y="0"
+ x="0"
+ style="fill:#e9ddaf;stroke:#483e37" />
+ <use
+ inkscape:export-ydpi="105.84057"
+ inkscape:export-xdpi="105.84057"
+ inkscape:export-filename="/home/nsensfel/to-logo.png"
+ height="100%"
+ width="100%"
+ transform="translate(-0.23254,-0.515498)"
+ id="use4570"
+ xlink:href="#use4568"
+ y="0"
+ x="0"
+ style="fill:#e9ddaf;stroke:#483e37" />
+ <use
+ inkscape:export-ydpi="105.84057"
+ inkscape:export-xdpi="105.84057"
+ inkscape:export-filename="/home/nsensfel/to-logo.png"
+ height="100%"
+ width="100%"
+ transform="translate(-0.23254,-0.515498)"
+ id="use4572"
+ xlink:href="#use4570"
+ y="0"
+ x="0"
+ style="fill:#e9ddaf;stroke:#483e37" />
+ <use
+ inkscape:export-ydpi="105.84057"
+ inkscape:export-xdpi="105.84057"
+ inkscape:export-filename="/home/nsensfel/to-logo.png"
+ height="100%"
+ width="100%"
+ transform="translate(-0.23254,-0.515498)"
+ id="use4574"
+ xlink:href="#use4572"
+ y="0"
+ x="0"
+ style="fill:#e9ddaf;stroke:#483e37" />
+ <use
+ inkscape:export-ydpi="105.84057"
+ inkscape:export-xdpi="105.84057"
+ inkscape:export-filename="/home/nsensfel/to-logo.png"
+ height="100%"
+ width="100%"
+ transform="translate(-0.23254,-0.515498)"
+ id="use4576"
+ xlink:href="#use4574"
+ y="0"
+ x="0"
+ style="fill:#e9ddaf;stroke:#483e37" />
+ <use
+ inkscape:export-ydpi="105.84057"
+ inkscape:export-xdpi="105.84057"
+ inkscape:export-filename="/home/nsensfel/to-logo.png"
+ height="100%"
+ width="100%"
+ transform="translate(-0.23254,-0.515498)"
+ id="use4578"
+ xlink:href="#use4576"
+ y="0"
+ x="0"
+ style="fill:#e9ddaf;stroke:#483e37" />
+ <use
+ inkscape:export-ydpi="105.84057"
+ inkscape:export-xdpi="105.84057"
+ inkscape:export-filename="/home/nsensfel/to-logo.png"
+ height="100%"
+ width="100%"
+ transform="translate(-0.23254,-0.515498)"
+ id="use4580"
+ xlink:href="#use4578"
+ y="0"
+ x="0"
+ style="fill:#e9ddaf;stroke:#483e37" />
+ <use
+ inkscape:export-ydpi="105.84057"
+ inkscape:export-xdpi="105.84057"
+ inkscape:export-filename="/home/nsensfel/to-logo.png"
+ height="100%"
+ width="100%"
+ transform="translate(-0.23254,-0.515498)"
+ id="use4582"
+ xlink:href="#use4580"
+ y="0"
+ x="0"
+ style="fill:#e9ddaf;stroke:#483e37" />
+ <use
+ inkscape:export-ydpi="105.84057"
+ inkscape:export-xdpi="105.84057"
+ inkscape:export-filename="/home/nsensfel/to-logo.png"
+ height="100%"
+ width="100%"
+ transform="translate(-0.23254,-0.515498)"
+ id="use4584"
+ xlink:href="#use4582"
+ y="0"
+ x="0"
+ style="fill:#e9ddaf;stroke:#483e37" />
+ <use
+ inkscape:export-ydpi="105.84057"
+ inkscape:export-xdpi="105.84057"
+ inkscape:export-filename="/home/nsensfel/to-logo.png"
+ height="100%"
+ width="100%"
+ transform="translate(-0.23254,-0.515498)"
+ id="use4586"
+ xlink:href="#use4584"
+ y="0"
+ x="0"
+ style="fill:#e9ddaf;stroke:#483e37" />
+ <use
+ inkscape:export-ydpi="105.84057"
+ inkscape:export-xdpi="105.84057"
+ inkscape:export-filename="/home/nsensfel/to-logo.png"
+ height="100%"
+ width="100%"
+ transform="translate(-0.23254,-0.515498)"
+ id="use4588"
+ xlink:href="#use4586"
+ y="0"
+ x="0"
+ style="fill:#e9ddaf;stroke:#483e37" />
+ <use
+ inkscape:export-ydpi="105.84057"
+ inkscape:export-xdpi="105.84057"
+ inkscape:export-filename="/home/nsensfel/to-logo.png"
+ height="100%"
+ width="100%"
+ transform="translate(-0.188539,-0.417955)"
+ id="use4590"
+ xlink:href="#use4588"
+ y="0"
+ x="0"
+ style="fill:#e9ddaf;stroke:#483e37" />
+ <use
+ inkscape:export-ydpi="105.84057"
+ inkscape:export-xdpi="105.84057"
+ inkscape:export-filename="/home/nsensfel/to-logo.png"
+ transform="translate(-0.188523,-0.417919)"
+ height="100%"
+ width="100%"
+ id="use4592"
+ xlink:href="#use4590"
+ y="0"
+ x="0"
+ style="fill:#e9ddaf;stroke:#483e37" />
+ <path
+ inkscape:export-ydpi="105.84057"
+ inkscape:export-xdpi="105.84057"
+ inkscape:export-filename="/home/nsensfel/to-logo.png"
+ sodipodi:nodetypes="cc"
+ inkscape:connector-curvature="0"
+ id="path4547-3"
+ d="M 8.69475,63.1703 C 10.181,63.5831 12.8752,62.0343 13.2687,61.0382"
+ style="fill:#e9ddaf;fill-opacity:0;fill-rule:evenodd;stroke:#483e37;stroke-width:0.1" />
+ <path
+ inkscape:export-ydpi="105.84057"
+ inkscape:export-xdpi="105.84057"
+ inkscape:export-filename="/home/nsensfel/to-logo.png"
+ sodipodi:nodetypes="cc"
+ inkscape:connector-curvature="0"
+ id="path4609"
+ d="M 11.2144,62.7344 24.1379,91.2554"
+ style="fill:#e9ddaf;fill-rule:evenodd;stroke:#483e37;stroke-width:0.05" />
+ </g>
+ </g>
+</svg>
diff --git a/manifest.json b/manifest.json
new file mode 100644
index 0000000..f9fb2e6
--- /dev/null
+++ b/manifest.json
@@ -0,0 +1,23 @@
+{
+
+ "name": "Tacticians Online - Active Battles",
+
+ "manifest_version": 1,
+ "version": "0.1",
+
+ "description":
+ "Regularly checks if it's your turn to play on Tacticians Online.",
+
+ "icons": {
+ "48": "images/to-favicon.svg",
+ "96": "images/to-favicon.svg"
+ },
+
+ "permissions": [ ],
+
+ "browser_action": {
+ "default_icon": "images/to-favicon.svg",
+ "default_title": "TO - Active Battles",
+ "default_popup": "www/index.html"
+ }
+}
diff --git a/src/Comm/GetBattles.elm b/src/Comm/GetBattles.elm
new file mode 100644
index 0000000..59b8d1d
--- /dev/null
+++ b/src/Comm/GetBattles.elm
@@ -0,0 +1,41 @@
+module Comm.GetBattles exposing (try)
+
+-- Elm -------------------------------------------------------------------------
+import Json.Encode
+
+-- Extension -------------------------------------------------------------------
+import Comm.Send
+import Struct.Event
+import Struct.Model
+
+--------------------------------------------------------------------------------
+-- TYPES ------------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+try_encoding : String -> Struct.Model.Type -> (Maybe Json.Encode.Value)
+try_encoding player_id model =
+ let
+ encoded_player_id = (Json.Encode.string player_id)
+ in
+ (Just
+ (Json.Encode.object
+ [
+ ("id", encoded_player_id)
+ ]
+ )
+ )
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+try : Struct.Model.Type -> String -> (Maybe (Cmd Struct.Event.Type))
+try model player_id =
+ (Comm.Send.try_sending
+ model
+ -- FIXME: this is a param now...
+ Constants.IO.get_battles_handler
+ (try_encoding player_id)
+ )
diff --git a/src/Comm/GetID.elm b/src/Comm/GetID.elm
new file mode 100644
index 0000000..14d668c
--- /dev/null
+++ b/src/Comm/GetID.elm
@@ -0,0 +1,43 @@
+module Comm.GetID exposing (try)
+
+-- Elm -------------------------------------------------------------------------
+import Json.Encode
+
+-- Extension -------------------------------------------------------------------
+import Comm.Send
+
+import Constants.IO
+
+import Struct.Event
+import Struct.Model
+
+--------------------------------------------------------------------------------
+-- TYPES ------------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+try_encoding : String -> Struct.Model.Type -> (Maybe Json.Encode.Value)
+try_encoding player_id model =
+ let
+ encoded_player_id = (Json.Encode.string player_id)
+ in
+ (Just
+ (Json.Encode.object
+ [
+ ("id", encoded_player_id)
+ ]
+ )
+ )
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+try : Struct.Model.Type -> String -> (Maybe (Cmd Struct.Event.Type))
+try model =
+ (Comm.Send.try_sending
+ model
+ Constants.IO.get_battles_handler
+ (try_encoding player_id)
+ )
diff --git a/src/Comm/Okay.elm b/src/Comm/Okay.elm
new file mode 100644
index 0000000..ca7a2eb
--- /dev/null
+++ b/src/Comm/Okay.elm
@@ -0,0 +1,21 @@
+module Comm.Okay exposing (decode)
+
+-- Elm -------------------------------------------------------------------------
+import Json.Decode
+
+-- Battlemap -------------------------------------------------------------------
+import Struct.ServerReply
+
+--------------------------------------------------------------------------------
+-- TYPES -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+decode : (Json.Decode.Decoder Struct.ServerReply.Type)
+decode = (Json.Decode.succeed Struct.ServerReply.Okay)
diff --git a/src/Comm/Send.elm b/src/Comm/Send.elm
new file mode 100644
index 0000000..dd9dc28
--- /dev/null
+++ b/src/Comm/Send.elm
@@ -0,0 +1,67 @@
+module Comm.Send exposing (try_sending)
+
+-- Elm -------------------------------------------------------------------------
+import Http
+
+import Json.Decode
+import Json.Encode
+
+-- Extension -------------------------------------------------------------------
+import Comm.Okay
+import Comm.SetBattles
+
+import Struct.Event
+import Struct.ServerReply
+import Struct.Model
+
+--------------------------------------------------------------------------------
+-- TYPES -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+internal_decoder : String -> (Json.Decode.Decoder Struct.ServerReply.Type)
+internal_decoder reply_type =
+ case reply_type of
+ "okay" -> (Comm.Okay.decode)
+ "set_battles" -> (Comm.SetBattles.decode)
+ other ->
+ (Json.Decode.fail
+ (
+ "Unknown server command \""
+ ++ other
+ ++ "\""
+ )
+ )
+
+decode : (Json.Decode.Decoder Struct.ServerReply.Type)
+decode =
+ (Json.Decode.field "msg" Json.Decode.string)
+ |> (Json.Decode.andThen (internal_decoder))
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+-- TODO: turn this into a multi-server version.
+try_sending : (
+ Struct.Model.Type ->
+ String ->
+ (Struct.Model.Type -> (Maybe Json.Encode.Value)) ->
+ (Maybe (Cmd Struct.Event.Type))
+ )
+try_sending model recipient try_encoding_fun =
+ case (try_encoding_fun model) of
+ (Just serial) ->
+ (Just
+ (Http.send
+ Struct.Event.ServerReplied
+ (Http.post
+ recipient
+ (Http.jsonBody serial)
+ (Json.Decode.list (decode))
+ )
+ )
+ )
+
+ Nothing -> Nothing
diff --git a/src/Comm/SetPlayer.elm b/src/Comm/SetPlayer.elm
new file mode 100644
index 0000000..a595777
--- /dev/null
+++ b/src/Comm/SetPlayer.elm
@@ -0,0 +1,26 @@
+module Comm.SetPlayer exposing (decode)
+
+-- Elm -------------------------------------------------------------------------
+import Json.Decode
+
+-- Map -------------------------------------------------------------------------
+import Struct.Player
+import Struct.ServerReply
+
+--------------------------------------------------------------------------------
+-- TYPES -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+internal_decoder : Struct.Player.Type -> Struct.ServerReply.Type
+internal_decoder player =
+ (Struct.ServerReply.SetPlayer player)
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+decode : (Json.Decode.Decoder Struct.ServerReply.Type)
+decode =
+ (Json.Decode.map (internal_decoder) (Struct.Player.decoder))
diff --git a/src/ElmModule/Init.elm b/src/ElmModule/Init.elm
new file mode 100644
index 0000000..705cff7
--- /dev/null
+++ b/src/ElmModule/Init.elm
@@ -0,0 +1,18 @@
+module ElmModule.Init exposing (init)
+
+-- Elm -------------------------------------------------------------------------
+
+-- Main Menu -------------------------------------------------------------------
+import Struct.Event
+import Struct.Flags
+import Struct.Model
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+init : Struct.Flags.Type -> (Struct.Model.Type, (Cmd Struct.Event.Type))
+init flags = (Struct.Model.new flags)
diff --git a/src/ElmModule/Subscriptions.elm b/src/ElmModule/Subscriptions.elm
new file mode 100644
index 0000000..e9b557e
--- /dev/null
+++ b/src/ElmModule/Subscriptions.elm
@@ -0,0 +1,17 @@
+module ElmModule.Subscriptions exposing (..)
+
+-- Elm -------------------------------------------------------------------------
+
+-- Main Menu -------------------------------------------------------------------
+import Struct.Model
+import Struct.Event
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+subscriptions : Struct.Model.Type -> (Sub Struct.Event.Type)
+subscriptions model = Sub.none
diff --git a/src/ElmModule/Update.elm b/src/ElmModule/Update.elm
new file mode 100644
index 0000000..18b2077
--- /dev/null
+++ b/src/ElmModule/Update.elm
@@ -0,0 +1,38 @@
+module ElmModule.Update exposing (update)
+
+-- Elm -------------------------------------------------------------------------
+
+-- Main Menu -------------------------------------------------------------------
+import Struct.Event
+import Struct.Model
+
+import Update.HandleServerReply
+import Update.SelectTab
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+update : (
+ Struct.Event.Type ->
+ Struct.Model.Type ->
+ (Struct.Model.Type, (Cmd Struct.Event.Type))
+ )
+update event model =
+ let
+ new_model = (Struct.Model.clear_error model)
+ in
+ case event of
+ Struct.Event.None -> (model, Cmd.none)
+
+ (Struct.Event.Failed err) ->
+ (
+ (Struct.Model.invalidate err new_model),
+ Cmd.none
+ )
+
+ (Struct.Event.ServerReplied result) ->
+ (Update.HandleServerReply.apply_to model result)
diff --git a/src/ElmModule/View.elm b/src/ElmModule/View.elm
new file mode 100644
index 0000000..0d6a321
--- /dev/null
+++ b/src/ElmModule/View.elm
@@ -0,0 +1,64 @@
+module ElmModule.View exposing (view)
+
+-- Elm -------------------------------------------------------------------------
+import Html
+import Html.Attributes
+
+-- Shared ----------------------------------------------------------------------
+import Util.Html
+
+-- Main Menu -------------------------------------------------------------------
+import Struct.Error
+import Struct.Event
+import Struct.Model
+import Struct.Player
+
+import View.BattleListing
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+view : Struct.Model.Type -> (Html.Html Struct.Event.Type)
+view model =
+ (Html.div
+ [
+ (Html.Attributes.class "fullscreen-module")
+ ]
+ [
+ (Html.main_
+ [
+ ]
+ [
+ (View.BattleListing.get_html
+ "Campaigns"
+ "main-menu-campaigns"
+ (Struct.Player.get_campaigns model.player)
+ ),
+ (View.BattleListing.get_html
+ "Invasions"
+ "main-menu-invasions"
+ (Struct.Player.get_invasions model.player)
+ ),
+ (View.BattleListing.get_html
+ "Events"
+ "main-menu-events"
+ (Struct.Player.get_events model.player)
+ )
+ ]
+ ),
+ (
+ case model.error of
+ Nothing -> (Util.Html.nothing)
+ (Just err) ->
+ (Html.div
+ []
+ [
+ (Html.text (Struct.Error.to_string err))
+ ]
+ )
+ )
+ ]
+ )
diff --git a/src/Main.elm b/src/Main.elm
new file mode 100644
index 0000000..8140041
--- /dev/null
+++ b/src/Main.elm
@@ -0,0 +1,23 @@
+-- Elm ------------------------------------------------------------------------
+import Html
+
+-- Map -------------------------------------------------------------------
+import Struct.Model
+import Struct.Event
+import Struct.Flags
+
+import ElmModule.Init
+import ElmModule.Subscriptions
+import ElmModule.View
+import ElmModule.Update
+
+main : (Program Struct.Flags.Type Struct.Model.Type Struct.Event.Type)
+main =
+ (Html.programWithFlags
+ {
+ init = ElmModule.Init.init,
+ view = ElmModule.View.view,
+ update = ElmModule.Update.update,
+ subscriptions = ElmModule.Subscriptions.subscriptions
+ }
+ )
diff --git a/src/Struct/BattleSummary.elm b/src/Struct/BattleSummary.elm
new file mode 100644
index 0000000..adab965
--- /dev/null
+++ b/src/Struct/BattleSummary.elm
@@ -0,0 +1,65 @@
+module Struct.BattleSummary exposing
+ (
+ Type,
+ get_id,
+ get_name,
+ get_last_edit,
+ is_players_turn,
+ decoder,
+ none
+ )
+
+-- Elm -------------------------------------------------------------------------
+import Json.Decode
+import Json.Decode.Pipeline
+
+-- Main Menu -------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- TYPES -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+type alias Type =
+ {
+ id : String,
+ name : String,
+ last_edit : String,
+ is_players_turn : Bool
+ }
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+get_id : Type -> String
+get_id t = t.id
+
+get_name : Type -> String
+get_name t = t.name
+
+get_last_edit : Type -> String
+get_last_edit t = t.last_edit
+
+is_players_turn : Type -> Bool
+is_players_turn t = t.is_players_turn
+
+decoder : (Json.Decode.Decoder Type)
+decoder =
+ (Json.Decode.Pipeline.decode
+ Type
+ |> (Json.Decode.Pipeline.required "id" Json.Decode.string)
+ |> (Json.Decode.Pipeline.required "nme" Json.Decode.string)
+ |> (Json.Decode.Pipeline.required "ldt" Json.Decode.string)
+ |> (Json.Decode.Pipeline.required "ipt" Json.Decode.bool)
+ )
+
+none : Type
+none =
+ {
+ id = "",
+ name = "Unknown",
+ last_edit = "Never",
+ is_players_turn = False
+ }
diff --git a/src/Struct/Error.elm b/src/Struct/Error.elm
new file mode 100644
index 0000000..5f40c09
--- /dev/null
+++ b/src/Struct/Error.elm
@@ -0,0 +1,45 @@
+module Struct.Error exposing (Type, Mode(..), new, to_string)
+
+--------------------------------------------------------------------------------
+-- TYPES -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+type Mode =
+ IllegalAction
+ | Programming
+ | Unimplemented
+ | Networking
+ | Failure
+
+type alias Type =
+ {
+ mode: Mode,
+ message: String
+ }
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+new : Mode -> String -> Type
+new mode str =
+ {
+ mode = mode,
+ message = str
+ }
+
+to_string : Type -> String
+to_string e =
+ (
+ (case e.mode of
+ Failure -> "The action failed: "
+ IllegalAction -> "Request discarded: "
+ Programming -> "Error in the program (please report): "
+ Unimplemented -> "Update discarded due to unimplemented feature: "
+ Networking -> "Error while conversing with the server: "
+ )
+ ++ e.message
+ )
+
diff --git a/src/Struct/Event.elm b/src/Struct/Event.elm
new file mode 100644
index 0000000..419ef51
--- /dev/null
+++ b/src/Struct/Event.elm
@@ -0,0 +1,25 @@
+module Struct.Event exposing (Type(..), attempted)
+
+-- Elm -------------------------------------------------------------------------
+import Http
+
+-- Main Menu -------------------------------------------------------------------
+import Struct.Error
+import Struct.ServerReply
+import Struct.UI
+
+--------------------------------------------------------------------------------
+-- TYPES -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+type Type =
+ None
+ | Failed Struct.Error.Type
+ | ServerReplied (Result Http.Error (List Struct.ServerReply.Type))
+ | TabSelected Struct.UI.Tab
+
+attempted : (Result.Result err val) -> Type
+attempted act =
+ case act of
+ (Result.Ok _) -> None
+ (Result.Err msg) ->
+ (Failed (Struct.Error.new Struct.Error.Failure (toString msg)))
diff --git a/src/Struct/Model.elm b/src/Struct/Model.elm
new file mode 100644
index 0000000..747a39e
--- /dev/null
+++ b/src/Struct/Model.elm
@@ -0,0 +1,64 @@
+module Struct.Model exposing
+ (
+ Type,
+ new,
+ invalidate,
+ reset,
+ clear_error
+ )
+
+-- Elm -------------------------------------------------------------------------
+
+-- Shared ----------------------------------------------------------------------
+import Struct.Flags
+
+-- Main Menu -------------------------------------------------------------------
+import Struct.Error
+import Struct.Player
+import Struct.UI
+
+--------------------------------------------------------------------------------
+-- TYPES -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+type alias Type =
+ {
+ flags: Struct.Flags.Type,
+ error: (Maybe Struct.Error.Type),
+ player_id: String,
+ session_token: String,
+ player: Struct.Player.Type,
+ ui: Struct.UI.Type
+ }
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+new : Struct.Flags.Type -> Type
+new flags =
+ {
+ flags = flags,
+ error = Nothing,
+ player_id = flags.user_id,
+ session_token = flags.token,
+ player = (Struct.Player.none),
+ ui = (Struct.UI.default)
+ }
+
+reset : Type -> Type
+reset model =
+ {model |
+ error = Nothing
+ }
+
+invalidate : Struct.Error.Type -> Type -> Type
+invalidate err model =
+ {model |
+ error = (Just err)
+ }
+
+clear_error : Type -> Type
+clear_error model = {model | error = Nothing}
diff --git a/src/Struct/Player.elm b/src/Struct/Player.elm
new file mode 100644
index 0000000..73fbdb3
--- /dev/null
+++ b/src/Struct/Player.elm
@@ -0,0 +1,107 @@
+module Struct.Player exposing
+ (
+ Type,
+ get_id,
+ get_username,
+ get_maps,
+ get_campaigns,
+ get_invasions,
+ get_events,
+ get_roster_id,
+ get_inventory_id,
+ decoder,
+ none
+ )
+
+-- Elm -------------------------------------------------------------------------
+import Json.Decode
+import Json.Decode.Pipeline
+
+-- Main Menu -------------------------------------------------------------------
+import Struct.BattleSummary
+import Struct.MapSummary
+
+--------------------------------------------------------------------------------
+-- TYPES -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+type alias Type =
+ {
+ id : String,
+ name : String,
+ maps : (List Struct.MapSummary.Type),
+ campaigns : (List Struct.BattleSummary.Type),
+ invasions : (List Struct.BattleSummary.Type),
+ events : (List Struct.BattleSummary.Type),
+ roster_id : String,
+ inventory_id : String
+ }
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+get_id : Type -> String
+get_id t = t.id
+
+get_username : Type -> String
+get_username t = t.name
+
+get_maps : Type -> (List Struct.MapSummary.Type)
+get_maps t = t.maps
+
+get_campaigns : Type -> (List Struct.BattleSummary.Type)
+get_campaigns t = t.campaigns
+
+get_invasions : Type -> (List Struct.BattleSummary.Type)
+get_invasions t = t.invasions
+
+get_events : Type -> (List Struct.BattleSummary.Type)
+get_events t = t.events
+
+get_roster_id : Type -> String
+get_roster_id t = t.roster_id
+
+get_inventory_id : Type -> String
+get_inventory_id t = t.inventory_id
+
+decoder : (Json.Decode.Decoder Type)
+decoder =
+ (Json.Decode.Pipeline.decode
+ Type
+ |> (Json.Decode.Pipeline.required "id" Json.Decode.string)
+ |> (Json.Decode.Pipeline.required "nme" Json.Decode.string)
+ |> (Json.Decode.Pipeline.required
+ "maps"
+ (Json.Decode.list Struct.MapSummary.decoder)
+ )
+ |> (Json.Decode.Pipeline.required
+ "cmps"
+ (Json.Decode.list Struct.BattleSummary.decoder)
+ )
+ |> (Json.Decode.Pipeline.required
+ "invs"
+ (Json.Decode.list Struct.BattleSummary.decoder)
+ )
+ |> (Json.Decode.Pipeline.required
+ "evts"
+ (Json.Decode.list Struct.BattleSummary.decoder)
+ )
+ |> (Json.Decode.Pipeline.required "rtid" Json.Decode.string)
+ |> (Json.Decode.Pipeline.required "ivid" Json.Decode.string)
+ )
+
+none : Type
+none =
+ {
+ id = "",
+ name = "Unknown",
+ maps = [],
+ campaigns = [],
+ invasions = [],
+ events = [],
+ roster_id = "",
+ inventory_id = ""
+ }
diff --git a/src/Struct/ServerReply.elm b/src/Struct/ServerReply.elm
new file mode 100644
index 0000000..fb4967b
--- /dev/null
+++ b/src/Struct/ServerReply.elm
@@ -0,0 +1,23 @@
+module Struct.ServerReply exposing (Type(..))
+
+-- Elm -------------------------------------------------------------------------
+
+-- Main Menu -------------------------------------------------------------------
+import Struct.Player
+
+--------------------------------------------------------------------------------
+-- TYPES -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+type Type =
+ Okay
+ | Disconnected
+ | SetPlayer Struct.Player.Type
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
diff --git a/src/Struct/UI.elm b/src/Struct/UI.elm
new file mode 100644
index 0000000..6cf853c
--- /dev/null
+++ b/src/Struct/UI.elm
@@ -0,0 +1,62 @@
+module Struct.UI exposing
+ (
+ Type,
+ Tab(..),
+ default,
+ -- Tab
+ try_getting_displayed_tab,
+ set_displayed_tab,
+ reset_displayed_tab,
+ to_string
+ )
+
+-- Main Menu -------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- TYPES -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+type Tab =
+ CampaignsTab
+ | InvasionsTab
+ | EventsTab
+ | CharactersTab
+ | MapsEditorTab
+ | AccountTab
+
+type alias Type =
+ {
+ displayed_tab : (Maybe Tab)
+ }
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+default : Type
+default =
+ {
+ displayed_tab = Nothing
+ }
+
+-- Tab -------------------------------------------------------------------------
+try_getting_displayed_tab : Type -> (Maybe Tab)
+try_getting_displayed_tab ui = ui.displayed_tab
+
+set_displayed_tab : Tab -> Type -> Type
+set_displayed_tab tab ui = {ui | displayed_tab = (Just tab)}
+
+reset_displayed_tab : Type -> Type
+reset_displayed_tab ui = {ui | displayed_tab = Nothing}
+
+to_string : Tab -> String
+to_string tab =
+ case tab of
+ CampaignsTab -> "Campaigns"
+ InvasionsTab -> "Invasions"
+ EventsTab -> "Events"
+ CharactersTab -> "Character Editor"
+ MapsEditorTab -> "Map Editor"
+ AccountTab -> "Account Settings"
diff --git a/src/Update/HandleServerReply.elm b/src/Update/HandleServerReply.elm
new file mode 100644
index 0000000..d68496c
--- /dev/null
+++ b/src/Update/HandleServerReply.elm
@@ -0,0 +1,104 @@
+module Update.HandleServerReply exposing (apply_to)
+
+-- Elm -------------------------------------------------------------------------
+import Http
+
+-- Shared ----------------------------------------------------------------------
+import Action.Ports
+
+import Struct.Flags
+
+-- Main Menu -------------------------------------------------------------------
+import Constants.IO
+
+import Struct.Error
+import Struct.Event
+import Struct.Model
+import Struct.Player
+import Struct.ServerReply
+
+--------------------------------------------------------------------------------
+-- TYPES -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+disconnected : (
+ (Struct.Model.Type, (List (Cmd Struct.Event.Type))) ->
+ (Struct.Model.Type, (List (Cmd Struct.Event.Type)))
+ )
+disconnected current_state =
+ let (model, cmds) = current_state in
+ (
+ model,
+ [
+ (Action.Ports.go_to
+ (
+ Constants.IO.base_url
+ ++ "/login/?action=disconnect&goto="
+ ++
+ (Http.encodeUri
+ (
+ "/main-menu/?"
+ ++ (Struct.Flags.get_params_as_url model.flags)
+ )
+ )
+ )
+ )
+ ]
+ )
+
+set_player : (
+ Struct.Player.Type ->
+ (Struct.Model.Type, (List (Cmd Struct.Event.Type))) ->
+ (Struct.Model.Type, (List (Cmd Struct.Event.Type)))
+ )
+set_player player current_state =
+ let (model, cmds) = current_state in
+ ({model | player = player}, cmds)
+
+apply_command : (
+ Struct.ServerReply.Type ->
+ (Struct.Model.Type, (List (Cmd Struct.Event.Type))) ->
+ (Struct.Model.Type, (List (Cmd Struct.Event.Type)))
+ )
+apply_command command current_state =
+ case command of
+ Struct.ServerReply.Disconnected -> (disconnected current_state)
+ (Struct.ServerReply.SetPlayer player) -> (set_player player current_state)
+ Struct.ServerReply.Okay -> current_state
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+apply_to : (
+ Struct.Model.Type ->
+ (Result Http.Error (List Struct.ServerReply.Type)) ->
+ (Struct.Model.Type, (Cmd Struct.Event.Type))
+ )
+apply_to model query_result =
+ case query_result of
+ (Result.Err error) ->
+ (
+ (Struct.Model.invalidate
+ (Struct.Error.new Struct.Error.Networking (toString error))
+ model
+ ),
+ Cmd.none
+ )
+
+ (Result.Ok commands) ->
+ let
+ (new_model, elm_commands) =
+ (List.foldl (apply_command) (model, [Cmd.none]) commands)
+ in
+ (
+ new_model,
+ (
+ case elm_commands of
+ [] -> Cmd.none
+ [cmd] -> cmd
+ _ -> (Cmd.batch elm_commands)
+ )
+ )
diff --git a/src/View/BattleListing.elm b/src/View/BattleListing.elm
new file mode 100644
index 0000000..9b667ac
--- /dev/null
+++ b/src/View/BattleListing.elm
@@ -0,0 +1,92 @@
+module View.BattleListing exposing (get_html)
+
+-- Elm -------------------------------------------------------------------------
+import Html
+import Html.Attributes
+-- import Html.Events
+
+-- Map -------------------------------------------------------------------
+import Struct.BattleSummary
+import Struct.Event
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+get_item_html : Struct.BattleSummary.Type -> (Html.Html Struct.Event.Type)
+get_item_html item =
+ (Html.a
+ [
+ (Html.Attributes.href
+ (
+ "/battle/?id="
+ ++ (Struct.BattleSummary.get_id item)
+ )
+ ),
+ (
+ if (Struct.BattleSummary.is_players_turn item)
+ then
+ (Html.Attributes.class "main-menu-battle-summary-is-active")
+ else
+ (Html.Attributes.class "main-menu-battle-summary-is-inactive")
+ )
+ ]
+ [
+ (Html.div
+ [
+ (Html.Attributes.class "main-menu-battle-summary-name")
+ ]
+ [
+ (Html.text (Struct.BattleSummary.get_name item))
+ ]
+ ),
+ (Html.div
+ [
+ (Html.Attributes.class "main-menu-battle-summary-date")
+ ]
+ [
+ (Html.text (Struct.BattleSummary.get_last_edit item))
+ ]
+ )
+ ]
+ )
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+get_html : (
+ String ->
+ String ->
+ (List Struct.BattleSummary.Type) ->
+ (Html.Html Struct.Event.Type)
+ )
+get_html name class battle_summaries =
+ (Html.div
+ [
+ (Html.Attributes.class class),
+ (Html.Attributes.class "main-menu-battle-listing")
+ ]
+ [
+ (Html.div
+ [
+ (Html.Attributes.class "main-menu-battle-listing-header")
+ ]
+ [
+ (Html.text name)
+ ]
+ ),
+ (Html.div
+ [
+ (Html.Attributes.class "main-menu-battle-listing-body")
+ ]
+ (List.map (get_item_html) battle_summaries)
+ ),
+ (Html.div
+ [
+ (Html.Attributes.class "main-menu-battle-listing-add-new")
+ ]
+ [
+ (Html.text "New")
+ ]
+ )
+ ]
+ )
diff --git a/src/View/Header.elm b/src/View/Header.elm
new file mode 100644
index 0000000..fd8e693
--- /dev/null
+++ b/src/View/Header.elm
@@ -0,0 +1,79 @@
+module View.Header exposing (get_html)
+
+-- Elm -------------------------------------------------------------------------
+import Html
+import Html.Attributes
+
+-- Map -------------------------------------------------------------------
+import Struct.Event
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+link_html : String -> String -> Bool -> (Html.Html Struct.Event.Type)
+link_html src label is_active =
+ (Html.a
+ [
+ (Html.Attributes.href src)
+ ]
+ [
+ (
+ if (is_active)
+ then (Html.text label)
+ else (Html.s [] [(Html.text label)])
+ )
+ ]
+ )
+
+navigation_html : (Html.Html Struct.Event.Type)
+navigation_html =
+ (Html.nav
+ []
+ [
+ (link_html "/about.html" "About" True),
+ (link_html "/news/" "News" False),
+ (link_html "/community/" "Community" False),
+ (link_html "/login/?action=disconnect" "Disconnect" True)
+ ]
+ )
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+get_html : (Html.Html Struct.Event.Type)
+get_html =
+ (Html.header
+ []
+ [
+ (Html.div
+ [
+ (Html.Attributes.class "main-server-logo")
+ ]
+ [
+ (Html.a
+ [
+ (Html.Attributes.href "http://127.0.0.1")
+ ]
+ [
+ (Html.img
+ [
+ (Html.Attributes.src "/asset/svg/to-logo-no-bg.svg")
+ ]
+ [
+ ]
+ )
+ ]
+ )
+ ]
+ ),
+ (Html.div
+ [
+ (Html.Attributes.class "main-server-version")
+ ]
+ [
+ (Html.text "Latest Dev. Build (Mon, 10 Sep 2018 10:30:17 +0000)")
+ ]
+ ),
+ (navigation_html)
+ ]
+ )
diff --git a/www/index.html b/www/index.html
new file mode 100644
index 0000000..f0fc53c
--- /dev/null
+++ b/www/index.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <link rel="stylesheet" type="text/css" href="/style.css">
+ </head>
+ <body>
+ <script src="script/main.js"></script>
+ <script>
+ tacticians_online_app = Elm.Main.fullscreen();
+ </script>
+ </body>
+</html>