├── com.tsatsatzu.subwar ├── .gitignore ├── src │ ├── .gitignore │ ├── com │ │ ├── history.index │ │ └── tsatsatzu │ │ │ ├── subwar │ │ │ ├── audio │ │ │ │ ├── logic │ │ │ │ │ ├── PlayLogic.java │ │ │ │ │ ├── FrameworkLogic.java │ │ │ │ │ ├── SWAudioException.java │ │ │ │ │ ├── ResponseLogic.java │ │ │ │ │ ├── AudioConstLogic.java │ │ │ │ │ ├── InvocationLogic.java │ │ │ │ │ └── ScanLogic.java │ │ │ │ ├── api │ │ │ │ │ └── ISubWarAudioLogger.java │ │ │ │ └── data │ │ │ │ │ └── SWSessionBean.java │ │ │ ├── alexa │ │ │ │ ├── api │ │ │ │ │ ├── TYPE_DIRECTION.txt │ │ │ │ │ ├── subwar.baf │ │ │ │ │ └── subwar.json │ │ │ │ └── service │ │ │ │ │ └── SubWarSpeechlet.java │ │ │ └── game │ │ │ │ ├── api │ │ │ │ └── ISubWarGameLogger.java │ │ │ │ ├── logic │ │ │ │ ├── IIODriver.java │ │ │ │ ├── ai │ │ │ │ │ └── IComputerPlayer.java │ │ │ │ ├── SWGameException.java │ │ │ │ ├── GameConstLogic.java │ │ │ │ ├── UserLogic.java │ │ │ │ ├── IOLogic.java │ │ │ │ ├── mem │ │ │ │ │ └── MemIODriver.java │ │ │ │ ├── dynamo │ │ │ │ │ └── DynamoUtils.java │ │ │ │ └── CredentialsLogic.java │ │ │ │ └── data │ │ │ │ ├── SWContextBean.java │ │ │ │ ├── SWGameDetailsBean.java │ │ │ │ ├── SWGameBean.java │ │ │ │ └── SWPositionBean.java │ │ │ └── utils │ │ │ └── obj │ │ │ └── StringUtils.java │ └── AwsCredentialsSample.properties ├── .settings │ ├── org.eclipse.wst.jsdt.ui.superType.name │ ├── org.eclipse.wst.jsdt.ui.superType.container │ ├── org.eclipse.jdt.core.prefs │ ├── org.eclipse.wst.common.project.facet.core.xml │ ├── org.eclipse.wst.common.component │ └── .jsdtscope ├── WebContent │ ├── META-INF │ │ └── MANIFEST.MF │ ├── images │ │ ├── drive.png │ │ ├── database.png │ │ ├── server.png │ │ └── README │ ├── WEB-INF │ │ ├── lib │ │ │ ├── joda-time-2.0.jar │ │ │ ├── log4j-1.2.17.jar │ │ │ ├── commons-io-2.4.jar │ │ │ ├── slf4j-api-1.7.0.jar │ │ │ ├── commons-codec-1.6.jar │ │ │ ├── commons-lang3-3.0.jar │ │ │ ├── jackson-core-2.3.2.jar │ │ │ ├── slf4j-log4j12-1.7.0.jar │ │ │ ├── alexa-skills-kit-1.1.3.jar │ │ │ ├── jackson-databind-2.3.2.jar │ │ │ ├── javax.servlet-api-3.0.1.jar │ │ │ ├── jackson-annotations-2.3.2.jar │ │ │ └── aws-lambda-java-core-1.0.0.jar │ │ └── web.xml │ ├── doc │ │ ├── package-list │ │ ├── com │ │ │ └── tsatsatzu │ │ │ │ ├── utils │ │ │ │ └── obj │ │ │ │ │ ├── package-frame.html │ │ │ │ │ ├── package-use.html │ │ │ │ │ └── class-use │ │ │ │ │ └── StringUtils.html │ │ │ │ └── subwar │ │ │ │ ├── alexa │ │ │ │ ├── api │ │ │ │ │ ├── package-frame.html │ │ │ │ │ └── package-use.html │ │ │ │ └── service │ │ │ │ │ ├── package-frame.html │ │ │ │ │ └── package-use.html │ │ │ │ ├── game │ │ │ │ ├── logic │ │ │ │ │ ├── mem │ │ │ │ │ │ ├── package-frame.html │ │ │ │ │ │ └── package-use.html │ │ │ │ │ ├── dynamo │ │ │ │ │ │ ├── package-frame.html │ │ │ │ │ │ └── package-use.html │ │ │ │ │ ├── ai │ │ │ │ │ │ └── package-frame.html │ │ │ │ │ ├── package-frame.html │ │ │ │ │ └── class-use │ │ │ │ │ │ ├── IOLogic.html │ │ │ │ │ │ ├── GameLogic.html │ │ │ │ │ │ └── UserLogic.html │ │ │ │ ├── api │ │ │ │ │ └── package-frame.html │ │ │ │ └── data │ │ │ │ │ └── package-frame.html │ │ │ │ └── audio │ │ │ │ ├── api │ │ │ │ └── package-frame.html │ │ │ │ ├── data │ │ │ │ └── package-frame.html │ │ │ │ └── logic │ │ │ │ ├── package-frame.html │ │ │ │ └── class-use │ │ │ │ └── MoveLogic.html │ │ ├── script.js │ │ ├── overview-frame.html │ │ ├── index.html │ │ └── deprecated-list.html │ ├── styles │ │ └── styles.css │ ├── index.jsp │ └── index.html ├── .classpath └── .project ├── com.tsatsatzu.subwar.test ├── .gitignore ├── .classpath ├── .project ├── README.md └── src │ └── com │ └── tsatsatzu │ └── subwar │ └── test │ ├── audio │ ├── AllAudioTests.java │ ├── PreGameTest.java │ ├── Launch4Test.java │ ├── GameTest.java │ ├── Launch2Test.java │ └── Launch1Test.java │ └── game │ ├── AllGameTests.java │ ├── CredentialTest.java │ ├── AITest.java │ ├── BaseTest.java │ ├── ObserveTest.java │ └── UserTest.java ├── Launch1.png ├── Launch2.png ├── Launch3.png ├── subwar108.png ├── subwar512.png ├── subwar_icon.jpg └── README.md /com.tsatsatzu.subwar/.gitignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar.test/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/src/.gitignore: -------------------------------------------------------------------------------- 1 | /AwsCredentials.properties 2 | -------------------------------------------------------------------------------- /Launch1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjaquinta/EchoSubWar/HEAD/Launch1.png -------------------------------------------------------------------------------- /Launch2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjaquinta/EchoSubWar/HEAD/Launch2.png -------------------------------------------------------------------------------- /Launch3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjaquinta/EchoSubWar/HEAD/Launch3.png -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/.settings/org.eclipse.wst.jsdt.ui.superType.name: -------------------------------------------------------------------------------- 1 | Window -------------------------------------------------------------------------------- /subwar108.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjaquinta/EchoSubWar/HEAD/subwar108.png -------------------------------------------------------------------------------- /subwar512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjaquinta/EchoSubWar/HEAD/subwar512.png -------------------------------------------------------------------------------- /subwar_icon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjaquinta/EchoSubWar/HEAD/subwar_icon.jpg -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Class-Path: 3 | 4 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/.settings/org.eclipse.wst.jsdt.ui.superType.container: -------------------------------------------------------------------------------- 1 | org.eclipse.wst.jsdt.launching.baseBrowserLibrary -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/src/com/history.index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjaquinta/EchoSubWar/HEAD/com.tsatsatzu.subwar/src/com/history.index -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/images/drive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjaquinta/EchoSubWar/HEAD/com.tsatsatzu.subwar/WebContent/images/drive.png -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/images/database.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjaquinta/EchoSubWar/HEAD/com.tsatsatzu.subwar/WebContent/images/database.png -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/images/server.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjaquinta/EchoSubWar/HEAD/com.tsatsatzu.subwar/WebContent/images/server.png -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/WEB-INF/lib/joda-time-2.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjaquinta/EchoSubWar/HEAD/com.tsatsatzu.subwar/WebContent/WEB-INF/lib/joda-time-2.0.jar -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/WEB-INF/lib/log4j-1.2.17.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjaquinta/EchoSubWar/HEAD/com.tsatsatzu.subwar/WebContent/WEB-INF/lib/log4j-1.2.17.jar -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/WEB-INF/lib/commons-io-2.4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjaquinta/EchoSubWar/HEAD/com.tsatsatzu.subwar/WebContent/WEB-INF/lib/commons-io-2.4.jar -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/WEB-INF/lib/slf4j-api-1.7.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjaquinta/EchoSubWar/HEAD/com.tsatsatzu.subwar/WebContent/WEB-INF/lib/slf4j-api-1.7.0.jar -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/WEB-INF/lib/commons-codec-1.6.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjaquinta/EchoSubWar/HEAD/com.tsatsatzu.subwar/WebContent/WEB-INF/lib/commons-codec-1.6.jar -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/WEB-INF/lib/commons-lang3-3.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjaquinta/EchoSubWar/HEAD/com.tsatsatzu.subwar/WebContent/WEB-INF/lib/commons-lang3-3.0.jar -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/WEB-INF/lib/jackson-core-2.3.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjaquinta/EchoSubWar/HEAD/com.tsatsatzu.subwar/WebContent/WEB-INF/lib/jackson-core-2.3.2.jar -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/WEB-INF/lib/slf4j-log4j12-1.7.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjaquinta/EchoSubWar/HEAD/com.tsatsatzu.subwar/WebContent/WEB-INF/lib/slf4j-log4j12-1.7.0.jar -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/WEB-INF/lib/alexa-skills-kit-1.1.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjaquinta/EchoSubWar/HEAD/com.tsatsatzu.subwar/WebContent/WEB-INF/lib/alexa-skills-kit-1.1.3.jar -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/WEB-INF/lib/jackson-databind-2.3.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjaquinta/EchoSubWar/HEAD/com.tsatsatzu.subwar/WebContent/WEB-INF/lib/jackson-databind-2.3.2.jar -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/WEB-INF/lib/javax.servlet-api-3.0.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjaquinta/EchoSubWar/HEAD/com.tsatsatzu.subwar/WebContent/WEB-INF/lib/javax.servlet-api-3.0.1.jar -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/WEB-INF/lib/jackson-annotations-2.3.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjaquinta/EchoSubWar/HEAD/com.tsatsatzu.subwar/WebContent/WEB-INF/lib/jackson-annotations-2.3.2.jar -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/src/com/tsatsatzu/subwar/audio/logic/PlayLogic.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjaquinta/EchoSubWar/HEAD/com.tsatsatzu.subwar/src/com/tsatsatzu/subwar/audio/logic/PlayLogic.java -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/WEB-INF/lib/aws-lambda-java-core-1.0.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjaquinta/EchoSubWar/HEAD/com.tsatsatzu.subwar/WebContent/WEB-INF/lib/aws-lambda-java-core-1.0.0.jar -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/src/com/tsatsatzu/subwar/audio/logic/FrameworkLogic.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjaquinta/EchoSubWar/HEAD/com.tsatsatzu.subwar/src/com/tsatsatzu/subwar/audio/logic/FrameworkLogic.java -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/images/README: -------------------------------------------------------------------------------- 1 | Icons Copyright (c) Yusuke Kamiyamane. 2 | Licensed under a Creative Commons Attribution 3.0 license. 3 | 4 | http://p.yusukekamiyamane.com 5 | http://creativecommons.org/licenses/by/3.0/ 6 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.compliance=1.8 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 7 | org.eclipse.jdt.core.compiler.source=1.8 8 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar.test/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/src/AwsCredentialsSample.properties: -------------------------------------------------------------------------------- 1 | # This file is for containing system secrets 2 | # It should be filled in with your accounts secrets 3 | # and renamed to AwsCredentials.propertes. 4 | # The renamed file should not be checked into source control! 5 | userName={AWS user name} 6 | accessKey={AWS access key} 7 | secretKey={Password for AWS access key} 8 | apiKeys={comma delimited list of valid API keys that are allowed to use this program's API} -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/.settings/org.eclipse.wst.common.project.facet.core.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/doc/package-list: -------------------------------------------------------------------------------- 1 | com.tsatsatzu.subwar.alexa.api 2 | com.tsatsatzu.subwar.alexa.service 3 | com.tsatsatzu.subwar.audio.api 4 | com.tsatsatzu.subwar.audio.data 5 | com.tsatsatzu.subwar.audio.logic 6 | com.tsatsatzu.subwar.game.api 7 | com.tsatsatzu.subwar.game.data 8 | com.tsatsatzu.subwar.game.logic 9 | com.tsatsatzu.subwar.game.logic.ai 10 | com.tsatsatzu.subwar.game.logic.dynamo 11 | com.tsatsatzu.subwar.game.logic.mem 12 | com.tsatsatzu.utils.obj 13 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar.test/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.tsatsatzu.subwar.test 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/.settings/org.eclipse.wst.common.component: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/src/com/tsatsatzu/subwar/alexa/api/TYPE_DIRECTION.txt: -------------------------------------------------------------------------------- 1 | north 2 | north northeast 3 | north north east 4 | northeast 5 | north east 6 | east northeast 7 | east north east 8 | east 9 | east southeast 10 | east south east 11 | southeast 12 | south east 13 | south southeast 14 | south south east 15 | south 16 | south southwest 17 | south south west 18 | southwest 19 | south west 20 | west southwest 21 | west south west 22 | west 23 | west northwest 24 | west north west 25 | northwest 26 | north west 27 | north northwest 28 | north north west 29 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/.settings/.jsdtscope: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar.test/README.md: -------------------------------------------------------------------------------- 1 | # Test Suite 2 | 3 | This project contains the JUnit tests that verify the functionality of the different layers of SubWar. 4 | Although not explicitly using Test Driven Development, the aim here is to validate functionality as it is added. 5 | Collectively the tests provide a regression suite to ensure that subsequent features do not break any existing functionality. 6 | 7 | When a test is launched, it institutes the in-memory storage model, and adds an override to specify a unique API key. 8 | This means that the Dynamo storage is not changed by testing, and that any amount of constructive or destructive tesing can be done. 9 | It also means that the credentials file does not need to be changed. I.e. a special test key and secret do not have 10 | to be maintained to validate the test routines with. -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/doc/com/tsatsatzu/utils/obj/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | com.tsatsatzu.utils.obj 7 | 8 | 9 | 10 | 11 | 12 |

com.tsatsatzu.utils.obj

13 |
14 |

Classes

15 | 18 |
19 | 20 | 21 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/doc/script.js: -------------------------------------------------------------------------------- 1 | function show(type) 2 | { 3 | count = 0; 4 | for (var key in methods) { 5 | var row = document.getElementById(key); 6 | if ((methods[key] & type) != 0) { 7 | row.style.display = ''; 8 | row.className = (count++ % 2) ? rowColor : altColor; 9 | } 10 | else 11 | row.style.display = 'none'; 12 | } 13 | updateTabs(type); 14 | } 15 | 16 | function updateTabs(type) 17 | { 18 | for (var value in tabs) { 19 | var sNode = document.getElementById(tabs[value][0]); 20 | var spanNode = sNode.firstChild; 21 | if (value == type) { 22 | sNode.className = activeTableTab; 23 | spanNode.innerHTML = tabs[value][1]; 24 | } 25 | else { 26 | sNode.className = tableTab; 27 | spanNode.innerHTML = "" + tabs[value][1] + ""; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/doc/com/tsatsatzu/subwar/alexa/api/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | com.tsatsatzu.subwar.alexa.api 7 | 8 | 9 | 10 | 11 | 12 |

com.tsatsatzu.subwar.alexa.api

13 |
14 |

Classes

15 | 18 |
19 | 20 | 21 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Sub War 4 | 5 | SubWarAlexaServlet 6 | com.tsatsatzu.subwar.alexa.service.SubWarServlet 7 | 8 | 9 | SubWarAlexaServlet 10 | /alexa/v1 11 | 12 | 13 | index.html 14 | index.htm 15 | index.jsp 16 | default.html 17 | default.htm 18 | default.jsp 19 | 20 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/doc/com/tsatsatzu/subwar/game/logic/mem/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | com.tsatsatzu.subwar.game.logic.mem 7 | 8 | 9 | 10 | 11 | 12 |

com.tsatsatzu.subwar.game.logic.mem

13 |
14 |

Classes

15 | 18 |
19 | 20 | 21 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/doc/com/tsatsatzu/subwar/alexa/service/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | com.tsatsatzu.subwar.alexa.service 7 | 8 | 9 | 10 | 11 | 12 |

com.tsatsatzu.subwar.alexa.service

13 |
14 |

Classes

15 | 19 |
20 | 21 | 22 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.tsatsatzu.subwar 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.wst.jsdt.core.javascriptValidator 10 | 11 | 12 | 13 | 14 | org.eclipse.jdt.core.javabuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.wst.common.project.facet.core.builder 20 | 21 | 22 | 23 | 24 | org.eclipse.wst.validation.validationbuilder 25 | 26 | 27 | 28 | 29 | 30 | org.eclipse.jem.workbench.JavaEMFNature 31 | org.eclipse.wst.common.modulecore.ModuleCoreNature 32 | org.eclipse.wst.common.project.facet.core.nature 33 | org.eclipse.jdt.core.javanature 34 | org.eclipse.wst.jsdt.core.jsNature 35 | 36 | 37 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/doc/com/tsatsatzu/subwar/game/logic/dynamo/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | com.tsatsatzu.subwar.game.logic.dynamo 7 | 8 | 9 | 10 | 11 | 12 |

com.tsatsatzu.subwar.game.logic.dynamo

13 |
14 |

Classes

15 | 19 |
20 | 21 | 22 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/doc/com/tsatsatzu/subwar/game/api/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | com.tsatsatzu.subwar.game.api 7 | 8 | 9 | 10 | 11 | 12 |

com.tsatsatzu.subwar.game.api

13 |
14 |

Interfaces

15 | 18 |

Classes

19 | 22 |
23 | 24 | 25 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/src/com/tsatsatzu/subwar/audio/api/ISubWarAudioLogger.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Jo Jaquinta, TsaTsaTzu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.tsatsatzu.subwar.audio.api; 17 | 18 | /** 19 | * The Interface ISubWarAudioLogger. 20 | * This allows for the debug messages of the audio layer to be trapped by a higher layer. 21 | */ 22 | public interface ISubWarAudioLogger 23 | { 24 | 25 | /** 26 | * Debug. 27 | * 28 | * @param msg the msg 29 | */ 30 | public void debug(String msg); 31 | 32 | /** 33 | * Debug. 34 | * 35 | * @param t the t 36 | */ 37 | public void debug(Throwable t); 38 | } 39 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar.test/src/com/tsatsatzu/subwar/test/audio/AllAudioTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Jo Jaquinta, TsaTsaTzu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.tsatsatzu.subwar.test.audio; 17 | 18 | import org.junit.runner.RunWith; 19 | import org.junit.runners.Suite; 20 | import org.junit.runners.Suite.SuiteClasses; 21 | 22 | /** 23 | * The Class AllAudioTests. 24 | * This is the test suite comprising all audio layer tests. 25 | */ 26 | @RunWith(Suite.class) 27 | @SuiteClasses({ Launch1Test.class, Launch2Test.class, Launch3Test.class, 28 | Launch4Test.class, GameTest.class, PreGameTest.class, RandomTest.class }) 29 | public class AllAudioTests 30 | { 31 | 32 | } 33 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar.test/src/com/tsatsatzu/subwar/test/game/AllGameTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Jo Jaquinta, TsaTsaTzu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.tsatsatzu.subwar.test.game; 17 | 18 | import org.junit.runner.RunWith; 19 | import org.junit.runners.Suite; 20 | import org.junit.runners.Suite.SuiteClasses; 21 | 22 | /** 23 | * The Class AllGameTests. 24 | * This is the test suite for running all the game tests. 25 | */ 26 | @RunWith(Suite.class) 27 | @SuiteClasses({ AITest.class, AngleTest.class, AttackTest.class, 28 | CredentialTest.class, MoveTest.class, ObserveTest.class, 29 | UserTest.class }) 30 | public class AllGameTests 31 | { 32 | 33 | } 34 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/src/com/tsatsatzu/subwar/game/api/ISubWarGameLogger.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Jo Jaquinta, TsaTsaTzu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.tsatsatzu.subwar.game.api; 17 | 18 | /** 19 | * The Interface ISubWarGameLogger. 20 | * An interface so that higher levels can plug themselves into the logging mechanism. 21 | */ 22 | public interface ISubWarGameLogger 23 | { 24 | 25 | /** 26 | * Debug. 27 | * 28 | * @param msg the message 29 | */ 30 | public void debug(String msg); 31 | 32 | /** 33 | * Debug. 34 | * 35 | * @param t the throwable 36 | */ 37 | public void debug(Throwable t); 38 | } 39 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/doc/com/tsatsatzu/subwar/audio/api/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | com.tsatsatzu.subwar.audio.api 7 | 8 | 9 | 10 | 11 | 12 |

com.tsatsatzu.subwar.audio.api

13 |
14 |

Interfaces

15 | 18 |

Classes

19 | 22 |
23 | 24 | 25 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/doc/com/tsatsatzu/subwar/audio/data/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | com.tsatsatzu.subwar.audio.data 7 | 8 | 9 | 10 | 11 | 12 |

com.tsatsatzu.subwar.audio.data

13 |
14 |

Classes

15 | 20 |
21 | 22 | 23 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/doc/com/tsatsatzu/subwar/game/logic/ai/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | com.tsatsatzu.subwar.game.logic.ai 7 | 8 | 9 | 10 | 11 | 12 |

com.tsatsatzu.subwar.game.logic.ai

13 |
14 |

Interfaces

15 | 18 |

Classes

19 | 22 |
23 | 24 | 25 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/src/com/tsatsatzu/subwar/audio/data/SWSessionBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Jo Jaquinta, TsaTsaTzu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.tsatsatzu.subwar.audio.data; 17 | 18 | /** 19 | * The Class SWSessionBean. 20 | * This contains the raw data from the invoking context. 21 | * Right now this is just a user ID. It is assumed to be maintianed by the invoking context. 22 | * All that is required by this layer is that it is unique and unchanging per user. 23 | */ 24 | public class SWSessionBean 25 | { 26 | 27 | /** The User id. */ 28 | private String mUserID; 29 | 30 | /** 31 | * Gets the user id. 32 | * 33 | * @return the user id 34 | */ 35 | public String getUserID() 36 | { 37 | return mUserID; 38 | } 39 | 40 | /** 41 | * Sets the user id. 42 | * 43 | * @param userID the new user id 44 | */ 45 | public void setUserID(String userID) 46 | { 47 | mUserID = userID; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar.test/src/com/tsatsatzu/subwar/test/game/CredentialTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Jo Jaquinta, TsaTsaTzu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.tsatsatzu.subwar.test.game; 17 | 18 | import static org.junit.Assert.*; 19 | 20 | import org.junit.Test; 21 | 22 | import com.tsatsatzu.subwar.game.logic.CredentialsLogic; 23 | 24 | /** 25 | * The Class CredentialTest. 26 | * Check that mandatory values are set in the credentials file. 27 | * Note: this file is not checked into source code. So you are going to 28 | * need to make one for your own version of the project. That's why this 29 | * test is handy. 30 | */ 31 | public class CredentialTest 32 | { 33 | 34 | /** 35 | * Test. 36 | */ 37 | @Test 38 | public void test() 39 | { 40 | assertNotNull("secretKey not set in system secrets", CredentialsLogic.getProperty("secretKey")); 41 | assertNotNull("accessKey not set in system secrets", CredentialsLogic.getProperty("accessKey")); 42 | assertNotNull("apiKeys not set in system secrets", CredentialsLogic.getProperty("apiKeys")); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/doc/com/tsatsatzu/subwar/game/data/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | com.tsatsatzu.subwar.game.data 7 | 8 | 9 | 10 | 11 | 12 |

com.tsatsatzu.subwar.game.data

13 |
14 |

Classes

15 | 24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/src/com/tsatsatzu/utils/obj/StringUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Jo Jaquinta, TsaTsaTzu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.tsatsatzu.utils.obj; 17 | 18 | /** 19 | * The Class StringUtils. 20 | * Some general string utilities. Sure, Apache has a library 21 | * that does a wider job, but I don't want to bloat the code 22 | * unnecessarily for just a few functions. 23 | */ 24 | public class StringUtils 25 | { 26 | 27 | /** 28 | * This is a convenience function to test for both null and zero length. 29 | * 30 | * @param title the text to test 31 | * @return true, if null or zero lenght 32 | */ 33 | public static boolean trivial(String title) 34 | { 35 | return (title == null) || (title.length() == 0); 36 | } 37 | 38 | /** 39 | * This trims *only* spaces from the ends of a string. 40 | * 41 | * @param txt the txt 42 | * @return the trimmed string 43 | */ 44 | public static String trimSpaces(String txt) 45 | { 46 | while (txt.startsWith(" ")) 47 | txt = txt.substring(1); 48 | while (txt.endsWith(" ")) 49 | txt = txt.substring(0, txt.length() - 1); 50 | return txt; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/src/com/tsatsatzu/subwar/game/logic/IIODriver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Jo Jaquinta, TsaTsaTzu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.tsatsatzu.subwar.game.logic; 17 | 18 | import java.util.List; 19 | 20 | import com.tsatsatzu.subwar.game.data.SWUserBean; 21 | 22 | /** 23 | * The Interface IIODriver. 24 | * Any storage mechanism needs to implement a drive to access it. 25 | */ 26 | public interface IIODriver 27 | { 28 | 29 | /** 30 | * Clear caches. 31 | * If any caches are maintained, this clears them out. 32 | */ 33 | public void clearCaches(); 34 | 35 | /** 36 | * Gets the user from the store. 37 | * 38 | * @param id the id 39 | * @return the user 40 | */ 41 | public SWUserBean getUser(String id); 42 | 43 | /** 44 | * Save user to store. 45 | * 46 | * @param user the user 47 | */ 48 | public void saveUser(SWUserBean user); 49 | 50 | /** 51 | * Delete user from store. 52 | * 53 | * @param id the id 54 | */ 55 | public void deleteUser(String id); 56 | 57 | /** 58 | * Gets the top users from the store. 59 | * 60 | * @param total the total 61 | * @return the top users 62 | */ 63 | public List getTopUsers(int total); 64 | } 65 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/doc/com/tsatsatzu/subwar/game/logic/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | com.tsatsatzu.subwar.game.logic 7 | 8 | 9 | 10 | 11 | 12 |

com.tsatsatzu.subwar.game.logic

13 |
14 |

Interfaces

15 | 18 |

Classes

19 | 26 |

Exceptions

27 | 30 |
31 | 32 | 33 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/src/com/tsatsatzu/subwar/alexa/api/subwar.baf: -------------------------------------------------------------------------------- 1 | NORTH north 2 | SOUTH south 3 | EAST east 4 | WEST west 5 | NORTHWEST northwest 6 | NORTHWEST north west 7 | NORTHEAST northeast 8 | NORTHEAST north east 9 | SOUTHWEST southwest 10 | SOUTHWEST south west 11 | SOUTHEAST southeast 12 | SOUTHEAST south east 13 | NORTH go north 14 | SOUTH go south 15 | EAST go east 16 | WEST go west 17 | NORTHWEST go northwest 18 | NORTHWEST go north west 19 | NORTHEAST go northeast 20 | NORTHEAST go north east 21 | SOUTHWEST go southwest 22 | SOUTHWEST go south west 23 | SOUTHEAST go southeast 24 | SOUTHEAST go south east 25 | NORTH move north 26 | SOUTH move south 27 | EAST move east 28 | WEST move west 29 | NORTHWEST move northwest 30 | NORTHWEST move north west 31 | NORTHEAST move northeast 32 | NORTHEAST move north east 33 | SOUTHWEST move southwest 34 | SOUTHWEST move south west 35 | SOUTHEAST move southeast 36 | SOUTHEAST move south east 37 | DIVE dive 38 | DIVE sink 39 | DIVE down 40 | RISE surface 41 | RISE rise 42 | RISE up 43 | RISE blow ballast 44 | LISTEN wait 45 | LISTEN listen 46 | LISTEN microphone 47 | LISTEN silent running 48 | SONAR sonar 49 | SONAR ping 50 | SONAR activate sonar 51 | SONAR use sonar 52 | FIRE fire 53 | FIRE fire torpedo 54 | FIRE launch torpedo 55 | FIRE fire {dir} 56 | FIRE fire torpedo {dir} 57 | FIRE launch torpedo {dir} 58 | CALLME call me {name} 59 | CALLME name me {name} 60 | CALLME set my name to {name} 61 | CALLSHIP call my ship {shipname} 62 | CALLSHIP name my ship {shipname} 63 | LAUNCH launch 64 | LAUNCH launch ship 65 | LAUNCH launch sub 66 | LAUNCH launch submarine 67 | LAUNCH launch me 68 | DOCK dock 69 | DOCK dock ship 70 | DOCK dock sub 71 | DOCK dock me 72 | DOCK back to dock 73 | DOCK return to dock 74 | DOCK back to port 75 | DOCK return to port 76 | LEADERS leaders 77 | LEADERS leader board 78 | LEADERS leaderboard 79 | LEADERS who are the leaders 80 | LEADERS score 81 | LEADERS score board 82 | LEADERS scoreboard 83 | LEADERS board 84 | SHIP ship 85 | SHIP tell me about my ship 86 | COMBAT combat 87 | COMBAT tell me about combat 88 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/src/com/tsatsatzu/subwar/game/logic/ai/IComputerPlayer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Jo Jaquinta, TsaTsaTzu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.tsatsatzu.subwar.game.logic.ai; 17 | 18 | import com.tsatsatzu.subwar.game.data.SWGameBean; 19 | 20 | /** 21 | * The Interface IComputerPlayer. 22 | * This encapsulates the functionality necessary to make the game moves for 23 | * computer based players. For each strategy, a new subclass of this can be 24 | * created and registered with the system. 25 | */ 26 | public interface IComputerPlayer 27 | { 28 | 29 | /** 30 | * Initializes the robotic system. 31 | * If there is any setup to do for a new robotic player, 32 | * this is the place to do it. 33 | * 34 | * @param game the game object 35 | * @param id the robot's id 36 | */ 37 | public void init(SWGameBean game, String id); 38 | 39 | /** 40 | * Move the robot. 41 | * Whatever logic is necessary to choose what a robot can do, should be done here. 42 | * 43 | * @param game the game object 44 | * @param id the robot's id 45 | * @param tick the elapsed time 46 | */ 47 | public void move(SWGameBean game, String id, long tick); 48 | 49 | /** 50 | * Terminates the robotic system's connection to this robot player. 51 | * If there is any 52 | * cleanup to do for a new robotic player, this is the place to do it. 53 | * 54 | * @param game the game object 55 | * @param id the robot's id 56 | */ 57 | public void term(SWGameBean game, String id); 58 | } 59 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/doc/com/tsatsatzu/subwar/audio/logic/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | com.tsatsatzu.subwar.audio.logic 7 | 8 | 9 | 10 | 11 | 12 |

com.tsatsatzu.subwar.audio.logic

13 |
14 |

Classes

15 | 26 |

Exceptions

27 | 30 |
31 | 32 | 33 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar.test/src/com/tsatsatzu/subwar/test/game/AITest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Jo Jaquinta, TsaTsaTzu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.tsatsatzu.subwar.test.game; 17 | 18 | import static org.junit.Assert.assertNotNull; 19 | import static org.junit.Assert.assertNull; 20 | 21 | import org.junit.Test; 22 | 23 | import com.tsatsatzu.subwar.game.api.SubWarGameAPI; 24 | import com.tsatsatzu.subwar.game.data.SWContextBean; 25 | import com.tsatsatzu.subwar.game.data.SWOperationBean; 26 | 27 | /** 28 | * The Class AITest. 29 | * Tests the AI logic for gameplay. 30 | */ 31 | public class AITest extends BaseTest 32 | { 33 | 34 | /** 35 | * This is kind of a dumb test. 36 | * Basically it loops for a long time, letting the AI player fight itself. 37 | * However, if there are any critical bugs, then the crash can be seen. 38 | */ 39 | @Test 40 | public void test() 41 | { 42 | SWOperationBean op = getOperation(SWOperationBean.TEST); 43 | op.setInt1(SWOperationBean.TEST_RESET_SEED); 44 | op.setInt2(1); 45 | SWContextBean context = SubWarGameAPI.invoke(op); 46 | assertNull(context.getLastOperationError()); 47 | 48 | op = getOperation(SWOperationBean.ENTER_GAME); 49 | context = SubWarGameAPI.invoke(op); 50 | assertNull(context.getLastOperationError()); 51 | assertNotNull(context.getUser()); 52 | 53 | for (int i = 0; i < 120; i++) 54 | { 55 | op = getOperation(SWOperationBean.TEST); 56 | op.setInt1(SWOperationBean.TEST_AI_MOVE); 57 | context = SubWarGameAPI.invoke(op); 58 | assertNull(context.getLastOperationError()); 59 | } 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/doc/overview-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Overview List 7 | 8 | 9 | 10 | 11 | 12 |
All Classes
13 |
14 |

Packages

15 | 29 |
30 |

 

31 | 32 | 33 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/src/com/tsatsatzu/subwar/game/logic/SWGameException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Jo Jaquinta, TsaTsaTzu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.tsatsatzu.subwar.game.logic; 17 | 18 | /** 19 | * The Class SWGameException. 20 | * Used for game logic throws 21 | */ 22 | public class SWGameException extends Exception 23 | { 24 | /** The Constant serialVersionUID. */ 25 | private static final long serialVersionUID = 8269692846238071844L; 26 | 27 | /** 28 | * Instantiates a new game exception. 29 | */ 30 | public SWGameException() 31 | { 32 | super(); 33 | } 34 | 35 | /** 36 | * Instantiates a new game exception. 37 | * 38 | * @param message the message 39 | * @param cause the cause 40 | * @param enableSuppression enables suppression 41 | * @param writableStackTrace the writable stack trace 42 | */ 43 | public SWGameException(String message, Throwable cause, 44 | boolean enableSuppression, boolean writableStackTrace) 45 | { 46 | super(message, cause, enableSuppression, writableStackTrace); 47 | } 48 | 49 | /** 50 | * Instantiates a new game exception. 51 | * 52 | * @param message the message 53 | * @param cause the cause 54 | */ 55 | public SWGameException(String message, Throwable cause) 56 | { 57 | super(message, cause); 58 | } 59 | 60 | /** 61 | * Instantiates a new game exception. 62 | * 63 | * @param message the message 64 | */ 65 | public SWGameException(String message) 66 | { 67 | super(message); 68 | } 69 | 70 | /** 71 | * Instantiates a new game exception. 72 | * 73 | * @param cause the cause 74 | */ 75 | public SWGameException(Throwable cause) 76 | { 77 | super(cause); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/src/com/tsatsatzu/subwar/audio/logic/SWAudioException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Jo Jaquinta, TsaTsaTzu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.tsatsatzu.subwar.audio.logic; 17 | 18 | /** 19 | * The Class SWAudioException. 20 | * For thowing exceptions from the audio layer 21 | */ 22 | public class SWAudioException extends Exception 23 | { 24 | /** The Constant serialVersionUID. */ 25 | private static final long serialVersionUID = 8269692846238071844L; 26 | 27 | /** 28 | * Instantiates a new audio exception. 29 | */ 30 | public SWAudioException() 31 | { 32 | super(); 33 | } 34 | 35 | /** 36 | * Instantiates a new audio exception. 37 | * 38 | * @param message the message 39 | * @param cause the cause 40 | * @param enableSuppression enables suppression 41 | * @param writableStackTrace the writable stack trace 42 | */ 43 | public SWAudioException(String message, Throwable cause, 44 | boolean enableSuppression, boolean writableStackTrace) 45 | { 46 | super(message, cause, enableSuppression, writableStackTrace); 47 | } 48 | 49 | /** 50 | * Instantiates a new audio exception. 51 | * 52 | * @param message the message 53 | * @param cause the cause 54 | */ 55 | public SWAudioException(String message, Throwable cause) 56 | { 57 | super(message, cause); 58 | } 59 | 60 | /** 61 | * Instantiates a new audio exception. 62 | * 63 | * @param message the message 64 | */ 65 | public SWAudioException(String message) 66 | { 67 | super(message); 68 | } 69 | 70 | /** 71 | * Instantiates a new audio exception. 72 | * 73 | * @param cause the cause 74 | */ 75 | public SWAudioException(Throwable cause) 76 | { 77 | super(cause); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar.test/src/com/tsatsatzu/subwar/test/audio/PreGameTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Jo Jaquinta, TsaTsaTzu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.tsatsatzu.subwar.test.audio; 17 | 18 | import static org.junit.Assert.assertFalse; 19 | import static org.junit.Assert.assertNull; 20 | import static org.junit.Assert.assertTrue; 21 | 22 | import org.junit.Test; 23 | 24 | import com.tsatsatzu.subwar.audio.api.SubWarAudioAPI; 25 | import com.tsatsatzu.subwar.audio.data.SWInvocationBean; 26 | 27 | /** 28 | * This test walks through the pre-game design dialog. 29 | */ 30 | public class PreGameTest extends BaseTest 31 | { 32 | 33 | /** 34 | * Pre-game dialog. 35 | */ 36 | @Test 37 | public void play() 38 | { 39 | SWInvocationBean resp; 40 | resp = dialog(SubWarAudioAPI.CMD_LAUNCH_APP); 41 | assertNull(resp.getGame()); 42 | assertFalse(resp.isEndSession()); 43 | resp = dialog(SubWarAudioAPI.CMD_NO); 44 | assertNull(resp.getGame()); 45 | assertFalse(resp.isEndSession()); 46 | resp = dialog(SubWarAudioAPI.CMD_YES); 47 | assertNull(resp.getGame()); 48 | assertFalse(resp.isEndSession()); 49 | resp = dialog(SubWarAudioAPI.CMD_NO); 50 | assertNull(resp.getGame()); 51 | assertFalse(resp.isEndSession()); 52 | resp = dialog(SubWarAudioAPI.CMD_SHIP); 53 | assertNull(resp.getGame()); 54 | assertFalse(resp.isEndSession()); 55 | resp = dialog(SubWarAudioAPI.CMD_COMBAT); 56 | assertNull(resp.getGame()); 57 | assertFalse(resp.isEndSession()); 58 | resp = dialog(SubWarAudioAPI.CMD_LEADERS); 59 | assertNull(resp.getGame()); 60 | assertFalse(resp.isEndSession()); 61 | resp = dialog(SubWarAudioAPI.CMD_STOP); 62 | assertNull(resp.getGame()); 63 | assertTrue(resp.isEndSession()); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/styles/styles.css: -------------------------------------------------------------------------------- 1 | /************************************* 2 | GENERAL 3 | *************************************/ 4 | body { 5 | margin: 0; 6 | padding: 0; 7 | font: 12px/1.4em "Lucida Grande", Verdana, sans-serif; 8 | color: #333; 9 | overflow-y: scroll; 10 | text-rendering: optimizeLegibility; 11 | background-color: #d5e9ed; 12 | } 13 | 14 | h2 { 15 | font-size: 1.3em; 16 | line-height: 1.5em; 17 | font-weight: bold; 18 | margin: 20px 0 0 0; 19 | padding: 0; 20 | border-bottom: 3px solid #eee; 21 | 22 | /* icon setup */ 23 | padding: 0.2em 1em 0.2em 30px; 24 | background-position: 0 50%; 25 | background-repeat: no-repeat; 26 | } 27 | 28 | 29 | /************************************* 30 | SECTIONS 31 | *************************************/ 32 | div#content { 33 | margin: 30px auto; 34 | padding: 0 30px 15px 30px; 35 | background-color: #fff; 36 | width: 940px; 37 | 38 | /* box-shadow */ 39 | -moz-box-shadow: 0 5px 10px #aaa; 40 | -webkit-box-shadow: 0 5px 10px #aaa; 41 | box-shadow: 0 5px 10px #aaa; 42 | 43 | /* bottom corners */ 44 | -webkit-border-bottom-right-radius: 7px; 45 | -webkit-border-bottom-left-radius: 7px; 46 | -moz-border-radius-bottomright: 7px; 47 | -moz-border-radius-bottomleft: 7px; 48 | border-bottom-right-radius: 7px; 49 | border-bottom-left-radius: 7px; 50 | } 51 | 52 | /*div#content div.section {}*/ 53 | 54 | div#content div.section ul { 55 | margin: 0; 56 | padding: 1em 0 0 2em; 57 | overflow: hidden; 58 | } 59 | 60 | div#content div.section ul li { 61 | list-style-type: square; 62 | white-space: nowrap; 63 | line-height: 1.5em; 64 | } 65 | 66 | /* Section titles */ 67 | div#content div.section.s3 h2 { 68 | background-image: url(../images/drive.png); 69 | } 70 | 71 | div#content div.section.ec2 h2 { 72 | background-image: url(../images/server.png); 73 | } 74 | 75 | div#content div.section.sdb h2 { 76 | background-image: url(../images/database.png); 77 | } 78 | 79 | 80 | /************************************* 81 | CONTAINERS 82 | *************************************/ 83 | .container { 84 | zoom: 1; 85 | } 86 | 87 | .container:after { 88 | content: "."; 89 | display: block; 90 | height: 0; 91 | clear: both; 92 | visibility: hidden; 93 | } 94 | 95 | 96 | /************************************* 97 | GRIDS 98 | *************************************/ 99 | .grid { float: left; margin-right: 20px; } 100 | .gridlast { margin-right: 0; } 101 | .grid5 { width: 300px; } 102 | .grid15 { width: 940px; } 103 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/src/com/tsatsatzu/subwar/game/logic/GameConstLogic.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Jo Jaquinta, TsaTsaTzu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.tsatsatzu.subwar.game.logic; 17 | 18 | /** 19 | * The Class GameConstLogic. 20 | * Constants that govenr game play 21 | */ 22 | public class GameConstLogic 23 | { 24 | 25 | /** The Constant MAX_SHIPS_PER_GAME. */ 26 | public static final int MAX_SHIPS_PER_GAME = 20; 27 | 28 | /** The Constant GAME_HEIGHT. 29 | * lattitude/N-S */ 30 | public static final int GAME_HEIGHT = 20; 31 | 32 | /** The Constant GAME_WIDTH. 33 | * longitude/E-W */ 34 | public static final int GAME_WIDTH = 10; 35 | 36 | /** The Constant GAME_DEPTH. */ 37 | public static final int GAME_DEPTH = 3; 38 | 39 | /** The Constant MAX_TORPEDOES. */ 40 | public static final int MAX_TORPEDOES = 6; 41 | 42 | /** The Constant LISTEN_RANGE. */ 43 | public static final double LISTEN_RANGE = Math.sqrt(2); 44 | 45 | /** The Constant PING_RANGE. */ 46 | public static final double PING_RANGE = 6; 47 | 48 | /** The Constant TORPEDO_RANGE. */ 49 | public static final double TORPEDO_RANGE = 6; 50 | 51 | /** The Constant MAX_AIS_PER_GAME. */ 52 | public static final int MAX_AIS_PER_GAME = MAX_SHIPS_PER_GAME/6; 53 | 54 | /** The Constant AI_MOVE_TICK. 55 | * how often the computer moves */ 56 | public static final long AI_MOVE_TICK = 12*1000L; 57 | 58 | /** The Constant ERR_YOU_ARE_OUT_OF_TORPEDOS. */ 59 | public static final String ERR_YOU_ARE_OUT_OF_TORPEDOS = "you are out of torpedos"; 60 | 61 | /** The Constant ERR_YOU_HAVE_BEEN_DESTROYED. */ 62 | public static final String ERR_YOU_HAVE_BEEN_DESTROYED = "you have been destroyed"; 63 | 64 | /** The Constant ERR_NOT_IN_GAME. */ 65 | public static final String ERR_NOT_IN_GAME = "not in game"; 66 | 67 | /** The Constant ERR_ALREADY_IN_GAME. */ 68 | public static final String ERR_ALREADY_IN_GAME = "already in game"; 69 | } -------------------------------------------------------------------------------- /com.tsatsatzu.subwar.test/src/com/tsatsatzu/subwar/test/game/BaseTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Jo Jaquinta, TsaTsaTzu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.tsatsatzu.subwar.test.game; 17 | 18 | import org.junit.Before; 19 | 20 | import com.tsatsatzu.subwar.game.data.SWOperationBean; 21 | 22 | /** 23 | * The Class BaseTest. 24 | * The is the parent class of all Game tests. It contains common set up logic that 25 | * each test has to perform, and a utility function to get a pre-configuration operation 26 | * to use. 27 | */ 28 | public class BaseTest 29 | { 30 | 31 | /** The Constant TEST_USER. 32 | * Used as the user-id for doing the tests. */ 33 | protected static final String TEST_USER = "amadan"; 34 | 35 | /** The Constant TEST_CREDENTIALS. 36 | * Have have to authenticate to use the game layer. 37 | * We define the credentials to do so here. */ 38 | protected static final String TEST_CREDENTIALS = "xyzzy"; 39 | 40 | /** 41 | Common set up code. Run before each test case. 42 | */ 43 | @Before 44 | public void setUp() 45 | { 46 | // Set I/O driver to the memory model. 47 | // Testing is going to screw with data. 48 | // We don't want to save that to Dynamo. 49 | System.setProperty("ioDriver", "com.tsatsatzu.subwar.game.logic.mem.MemIODriver"); 50 | // Override built in apiKeys with our test API key. 51 | // That way we don't have to use a real key for testing, 52 | // and the key is safe to check in while clear text. 53 | System.setProperty("apiKeys", TEST_CREDENTIALS); 54 | } 55 | 56 | /** 57 | * Gets an operation object. Fill in baisc parameters. 58 | * 59 | * @param opType the type of operation used 60 | * @return the populated operation 61 | */ 62 | protected SWOperationBean getOperation(String opType) 63 | { 64 | SWOperationBean op = new SWOperationBean(); 65 | op.setOperation(opType); 66 | op.setUserID(TEST_USER); 67 | op.setCredentials(TEST_CREDENTIALS); 68 | return op; 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/src/com/tsatsatzu/subwar/audio/logic/ResponseLogic.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Jo Jaquinta, TsaTsaTzu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.tsatsatzu.subwar.audio.logic; 17 | 18 | import java.util.List; 19 | 20 | /** 21 | * The Class ResponseLogic. 22 | * General utilities convienent for composing responses. 23 | */ 24 | public class ResponseLogic 25 | { 26 | /** The Constant ORDINAL. */ 27 | public static final String[] ORDINAL = 28 | { 29 | "first", 30 | "second", 31 | "third", 32 | "fourth", 33 | "fifth", 34 | "sixth", 35 | "seventh", 36 | "eighth", 37 | "ninth", 38 | "tenth", 39 | "eleventh", 40 | "twelfth", 41 | "thirteenth", 42 | "fourteenth", 43 | "fifteenth", 44 | "sixteenth", 45 | "seventeenth", 46 | "eighteenth", 47 | "nineteenth", 48 | "twentieth", 49 | "twenty first", 50 | "twenty second", 51 | "twenty third", 52 | "twenty fourth", 53 | "twenty fifth", 54 | "twenty sixth", 55 | "twenty seventh", 56 | "twenty eighth", 57 | "twenty ninth", 58 | "thirtieth", 59 | "thirty first", 60 | "thirty second", 61 | "thirty third", 62 | "thirty fourth", 63 | "thirty fifth", 64 | "thirty sixth", 65 | "thirty seventh", 66 | "thirty eighth", 67 | "thirty ninth", 68 | }; 69 | 70 | /** 71 | * This, that, and the other. 72 | * Linquistically combine a list of elements. 73 | * 74 | * @param listens the items 75 | * @return the string 76 | */ 77 | public static String andList(List listens) 78 | { 79 | StringBuffer txt = new StringBuffer(); 80 | for (int i = 0; i < listens.size(); i++) 81 | { 82 | if (i > 0) 83 | { 84 | txt.append(", "); 85 | if (i == listens.size() - 1) 86 | txt.append("and "); 87 | } 88 | txt.append(listens.get(i)); 89 | } 90 | return txt.toString(); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/src/com/tsatsatzu/subwar/game/logic/UserLogic.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Jo Jaquinta, TsaTsaTzu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.tsatsatzu.subwar.game.logic; 17 | 18 | import com.tsatsatzu.subwar.game.data.SWUserBean; 19 | 20 | /** 21 | * Business Logic for operating on a user. 22 | */ 23 | public class UserLogic 24 | { 25 | 26 | /** 27 | * Validate. 28 | * Fetch user from data store. If not there, create a new entry. 29 | * 30 | * @param userID the user id 31 | * @return the user data object 32 | */ 33 | public static SWUserBean validate(String userID) 34 | { 35 | SWUserBean user = IOLogic.getUser(userID); 36 | if (user == null) 37 | user = newInstance(userID); 38 | return user; 39 | } 40 | 41 | /** 42 | * New instance. 43 | * Create a new user. Initialize it with basic values. 44 | * 45 | * @param userID the user id 46 | * @return the user data object 47 | */ 48 | public static SWUserBean newInstance(String userID) 49 | { 50 | SWUserBean user = new SWUserBean(); 51 | user.setUserID(userID); 52 | user.setUserName(null); 53 | user.setTitle("Captain"); 54 | user.setSubName(null); 55 | user.setMaxTorpedoes(6); 56 | user.setInGame(-1); 57 | return user; 58 | } 59 | 60 | /** 61 | * Sets the user name. 62 | * Indicates the user's preference for how to be addressed. 63 | * 64 | * @param user the user 65 | * @param name the name 66 | */ 67 | public static void setUserName(SWUserBean user, String name) 68 | { 69 | if (name != null) 70 | if (name.length() == 0) 71 | user.setUserName(null); 72 | else 73 | user.setUserName(name); 74 | } 75 | 76 | /** 77 | * Sets the ship name. 78 | * Indicates the user's preference for how the ship is to be named. 79 | * 80 | * @param user the user 81 | * @param name the name 82 | */ 83 | public static void setShipName(SWUserBean user, String name) 84 | { 85 | if (name != null) 86 | if (name.length() == 0) 87 | user.setSubName(null); 88 | else 89 | user.setSubName(name); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/src/com/tsatsatzu/subwar/alexa/service/SubWarSpeechlet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Jo Jaquinta, TsaTsaTzu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.tsatsatzu.subwar.alexa.service; 17 | 18 | import com.amazon.speech.speechlet.IntentRequest; 19 | import com.amazon.speech.speechlet.LaunchRequest; 20 | import com.amazon.speech.speechlet.Session; 21 | import com.amazon.speech.speechlet.SessionEndedRequest; 22 | import com.amazon.speech.speechlet.SessionStartedRequest; 23 | import com.amazon.speech.speechlet.Speechlet; 24 | import com.amazon.speech.speechlet.SpeechletException; 25 | import com.amazon.speech.speechlet.SpeechletResponse; 26 | import com.tsatsatzu.subwar.alexa.api.SubWarAlexaAPI; 27 | 28 | /** 29 | * This directs Alexa calls into our API handlers. 30 | */ 31 | public class SubWarSpeechlet implements Speechlet 32 | { 33 | 34 | /* (non-Javadoc) 35 | * @see com.amazon.speech.speechlet.Speechlet#onSessionStarted(com.amazon.speech.speechlet.SessionStartedRequest, com.amazon.speech.speechlet.Session) 36 | */ 37 | @Override 38 | public void onSessionStarted(SessionStartedRequest request, Session session) 39 | throws SpeechletException 40 | { 41 | SubWarAlexaAPI.doSessionStarted(request, session); 42 | } 43 | 44 | /* (non-Javadoc) 45 | * @see com.amazon.speech.speechlet.Speechlet#onLaunch(com.amazon.speech.speechlet.LaunchRequest, com.amazon.speech.speechlet.Session) 46 | */ 47 | @Override 48 | public SpeechletResponse onLaunch(LaunchRequest request, Session session) 49 | throws SpeechletException 50 | { 51 | SpeechletResponse ret = SubWarAlexaAPI.doLaunch(request, session); 52 | return ret; 53 | } 54 | 55 | /* (non-Javadoc) 56 | * @see com.amazon.speech.speechlet.Speechlet#onIntent(com.amazon.speech.speechlet.IntentRequest, com.amazon.speech.speechlet.Session) 57 | */ 58 | @Override 59 | public SpeechletResponse onIntent(IntentRequest request, Session session) 60 | throws SpeechletException 61 | { 62 | SpeechletResponse ret = SubWarAlexaAPI.doIntent(request, session); 63 | return ret; 64 | } 65 | 66 | /* (non-Javadoc) 67 | * @see com.amazon.speech.speechlet.Speechlet#onSessionEnded(com.amazon.speech.speechlet.SessionEndedRequest, com.amazon.speech.speechlet.Session) 68 | */ 69 | @Override 70 | public void onSessionEnded(SessionEndedRequest request, Session session) 71 | throws SpeechletException 72 | { 73 | SubWarAlexaAPI.doSessionEnded(request, session); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/index.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> 2 | <%@ page import="com.amazonaws.*" %> 3 | <%@ page import="com.amazonaws.auth.*" %> 4 | <%@ page import="com.amazonaws.services.ec2.*" %> 5 | <%@ page import="com.amazonaws.services.ec2.model.*" %> 6 | <%@ page import="com.amazonaws.services.s3.*" %> 7 | <%@ page import="com.amazonaws.services.s3.model.*" %> 8 | <%@ page import="com.amazonaws.services.dynamodbv2.*" %> 9 | <%@ page import="com.amazonaws.services.dynamodbv2.model.*" %> 10 | 11 | <%! // Share the client objects across threads to 12 | // avoid creating new clients for each web request 13 | private AmazonEC2 ec2; 14 | private AmazonS3 s3; 15 | private AmazonDynamoDB dynamo; 16 | %> 17 | 18 | <% 19 | /* 20 | * AWS Elastic Beanstalk checks your application's health by periodically 21 | * sending an HTTP HEAD request to a resource in your application. By 22 | * default, this is the root or default resource in your application, 23 | * but can be configured for each environment. 24 | * 25 | * Here, we report success as long as the app server is up, but skip 26 | * generating the whole page since this is a HEAD request only. You 27 | * can employ more sophisticated health checks in your application. 28 | */ 29 | if (request.getMethod().equals("HEAD")) return; 30 | %> 31 | 32 | <% 33 | if (ec2 == null) { 34 | AWSCredentialsProvider credentialsProvider = new ClasspathPropertiesFileCredentialsProvider(); 35 | ec2 = new AmazonEC2Client(credentialsProvider); 36 | s3 = new AmazonS3Client(credentialsProvider); 37 | dynamo = new AmazonDynamoDBClient(credentialsProvider); 38 | } 39 | %> 40 | 41 | 42 | 43 | 44 | 45 | Hello AWS Web World! 46 | 47 | 48 | 49 |
50 |
51 |

Amazon S3 Buckets:

52 |
    53 | <% for (Bucket bucket : s3.listBuckets()) { %> 54 |
  • <%= bucket.getName() %>
  • 55 | <% } %> 56 |
57 |
58 | 59 |
60 |

Amazon DynamoDB Tables:

61 |
    62 | <% for (String tableName : dynamo.listTables().getTableNames()) { %> 63 |
  • <%= tableName %>
  • 64 | <% } %> 65 |
66 |
67 | 68 |
69 |

Amazon EC2 Instances:

70 |
    71 | <% for (Reservation reservation : ec2.describeInstances().getReservations()) { %> 72 | <% for (Instance instance : reservation.getInstances()) { %> 73 |
  • <%= instance.getInstanceId() %>
  • 74 | <% } %> 75 | <% } %> 76 |
77 |
78 |
79 | 80 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/doc/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Generated Documentation (Untitled) 7 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | <noscript> 68 | <div>JavaScript is disabled on your browser.</div> 69 | </noscript> 70 | <h2>Frame Alert</h2> 71 | <p>This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to <a href="overview-summary.html">Non-frame version</a>.</p> 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar.test/src/com/tsatsatzu/subwar/test/game/ObserveTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Jo Jaquinta, TsaTsaTzu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.tsatsatzu.subwar.test.game; 17 | 18 | import static org.junit.Assert.*; 19 | 20 | import org.junit.Test; 21 | 22 | import com.tsatsatzu.subwar.game.api.SubWarGameAPI; 23 | import com.tsatsatzu.subwar.game.data.SWContextBean; 24 | import com.tsatsatzu.subwar.game.data.SWOperationBean; 25 | 26 | /** 27 | * The Class ObserveTest. 28 | * Testing the different ways of detecting other ships. 29 | */ 30 | public class ObserveTest extends BaseTest 31 | { 32 | 33 | /** 34 | * Test sonar and underwater microphone. 35 | */ 36 | @Test 37 | public void test() 38 | { 39 | SWOperationBean op = getOperation(SWOperationBean.TEST); 40 | op.setInt1(SWOperationBean.TEST_CLEAR_USER); 41 | SWContextBean context = SubWarGameAPI.invoke(op); 42 | assertNull(context.getLastOperationError()); 43 | 44 | op = getOperation(SWOperationBean.TEST); 45 | op.setInt1(SWOperationBean.TEST_RESET_SEED); 46 | context = SubWarGameAPI.invoke(op); 47 | assertNull(context.getLastOperationError()); 48 | 49 | op = getOperation(SWOperationBean.QUERY_USER); 50 | context = SubWarGameAPI.invoke(op); 51 | assertNull(context.getLastOperationError()); 52 | assertNotNull(context.getUser()); 53 | assertNull(context.getUser().getUserName()); 54 | assertNull(context.getUser().getSubName()); 55 | 56 | op = getOperation(SWOperationBean.ENTER_GAME); 57 | context = SubWarGameAPI.invoke(op); 58 | assertNull(context.getLastOperationError()); 59 | assertNotNull(context.getGame()); 60 | assertNotNull(context.getGame().getUserPosition()); 61 | 62 | // test listen 63 | op = getOperation(SWOperationBean.MICROPHONE); 64 | context = SubWarGameAPI.invoke(op); 65 | assertNull(context.getLastOperationError()); 66 | assertNotNull(context.getGame()); 67 | assertNotNull(context.getGame().getUserPosition()); 68 | assertNotNull(context.getGame().getUserPosition().getSoundings()); 69 | 70 | // test ping 71 | op = getOperation(SWOperationBean.SONAR); 72 | context = SubWarGameAPI.invoke(op); 73 | assertNull(context.getLastOperationError()); 74 | assertNotNull(context.getGame()); 75 | assertNotNull(context.getGame().getUserPosition()); 76 | assertNotNull(context.getGame().getUserPosition().getSoundings()); 77 | 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/src/com/tsatsatzu/subwar/game/logic/IOLogic.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Jo Jaquinta, TsaTsaTzu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.tsatsatzu.subwar.game.logic; 17 | 18 | import java.util.List; 19 | 20 | import com.tsatsatzu.subwar.game.data.SWUserBean; 21 | 22 | /** 23 | * The Class IOLogic. 24 | * All I/O traffic comes through this class. In most cases it is 25 | * handed off to the driver class. This indirection is there so 26 | * that you can choose, later, to use a different storage mechanism. 27 | */ 28 | public class IOLogic 29 | { 30 | /** The Driver. */ 31 | private static IIODriver mDriver = null; 32 | 33 | /** 34 | * Gets the driver. 35 | * By default, this uses the dynamo driver. But this can be overridden by setting a value in the credentials. 36 | * 37 | * @return the driver 38 | */ 39 | public static IIODriver getDriver() 40 | { 41 | if (mDriver == null) 42 | { 43 | String driverClassName = CredentialsLogic.getProperty("ioDriver", "com.tsatsatzu.subwar.game.logic.dynamo.DynamoIODriver"); 44 | try 45 | { 46 | Class driverClass = Class.forName(driverClassName); 47 | mDriver = (IIODriver)driverClass.newInstance(); 48 | } 49 | catch (ClassNotFoundException | InstantiationException | IllegalAccessException | ClassCastException e) 50 | { 51 | throw new IllegalStateException("ioDriver set to '"+driverClassName+"', could not resolve", e); 52 | } 53 | } 54 | return mDriver; 55 | } 56 | 57 | /** 58 | * Save user. 59 | * Saves the user to the backing store 60 | * 61 | * @param user the user 62 | */ 63 | public static void saveUser(SWUserBean user) 64 | { 65 | getDriver().saveUser(user); 66 | } 67 | 68 | /** 69 | * Gets the user. 70 | * Gets the user from the backing store. 71 | * 72 | * @param userID the user id 73 | * @return the user 74 | */ 75 | public static SWUserBean getUser(String userID) 76 | { 77 | SWUserBean user = getDriver().getUser(userID); 78 | return user; 79 | } 80 | 81 | /** 82 | * Gets the top users. 83 | * Gets the top #total users from the backing store. 84 | * 85 | * @param total the total 86 | * @return the top users 87 | */ 88 | public static List getTopUsers(int total) 89 | { 90 | List users = getDriver().getTopUsers(total); 91 | return users; 92 | } 93 | } -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/src/com/tsatsatzu/subwar/game/data/SWContextBean.java: -------------------------------------------------------------------------------- 1 | /* * Copyright 2016 Jo Jaquinta, TsaTsaTzu * * 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. */ package com.tsatsatzu.subwar.game.data; import java.util.List; /** * The Class SWContextBean. * Return values from a game layer call. */ public class SWContextBean { /** The Operation performed. */ private SWOperationBean mOperation; /** The Last operation message. */ private String mLastOperationMessage; /** The Last operation error. */ private String mLastOperationError; /** The User. */ private SWUserBean mUser; /** The Game. */ private SWGameDetailsBean mGame; /** The Leaders. */ private List mLeaders; /** * Gets the last operation message. * * @return the last operation message */ public String getLastOperationMessage() { return mLastOperationMessage; } /** * Sets the last operation message. * * @param lastOperationMessage the new last operation message */ public void setLastOperationMessage(String lastOperationMessage) { mLastOperationMessage = lastOperationMessage; } /** * Gets the last operation error. * * @return the last operation error */ public String getLastOperationError() { return mLastOperationError; } /** * Sets the last operation error. * * @param lastOperationError the new last operation error */ public void setLastOperationError(String lastOperationError) { mLastOperationError = lastOperationError; } /** * Gets the user. * * @return the user */ public SWUserBean getUser() { return mUser; } /** * Sets the user. * * @param user the new user */ public void setUser(SWUserBean user) { mUser = user; } /** * Gets the game. * * @return the game */ public SWGameDetailsBean getGame() { return mGame; } /** * Sets the game. * * @param game the new game */ public void setGame(SWGameDetailsBean game) { mGame = game; } /** * Gets the operation. * * @return the operation */ public SWOperationBean getOperation() { return mOperation; } /** * Sets the operation. * * @param operation the new operation */ public void setOperation(SWOperationBean operation) { mOperation = operation; } /** * Gets the leaders. * * @return the leaders */ public List getLeaders() { return mLeaders; } /** * Sets the leaders. * * @param leaders the new leaders */ public void setLeaders(List leaders) { mLeaders = leaders; } } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # EchoSubWar 2 | 3 | This is [TsaTsaTzu's](https://www.tsatsatzu.com) entry for 4 | the [Hackster.io Alexa skills contest](https://www.hackster.io/challenges/amazon-alexa-skill-contest-one). 5 | Since all entrants are required to be published, we will not be pursuing this commercially after the contest is over, 6 | and will be donating it to the community. 7 | We would like to see more high quality skills available that make the most of the Alexa platform. 8 | It is hoped that by providing this, users will be able to take the techniques shown here and use them to better 9 | their own skills. Or that people will contribute to make this skill even better than it is. 10 | 11 | ## Gameplay 12 | 13 | You are the captain of a Colella Class Hunter/Killer submarine. 14 | You patrol the Acton straits, seeking to torpedo any other submarine you come across. 15 | You can issue commands to your 2nd in command, Lieuenant Alexa, to move, listen, do a sonar ping 16 | or fire one of your torpedoes. 17 | 18 | Other players may be playing the game at the same time as you. 19 | There are also several computer players. 20 | You all play in the same space, and can target, and be targeted by, each other. 21 | 22 | Your best score, and cumulative kills are logged and maintained on a leaderboard. 23 | Depending on how well you do, you can rise through the ranks of captains. 24 | 25 | You can choose to pick a first name to identify yourself with, and the name of a large (American) city, 26 | or President, to name your ship with. 27 | 28 | ## Code Structure 29 | 30 | The code has a three tier structure: game layer, audio layer, alexa interface. 31 | 32 | ### Game Layer 33 | This layer of code, contained in the com.tsatsatzu.subwar.game packages, comprises the core 34 | game mechanics. It is accessed, exclusively, through the single entry point in SubWarGameAPI. 35 | This layer is self-contained and persists its own data. 36 | 37 | The layer exists so that if another interface is desired, e.g. a web or mobile interface, it can be written on top of 38 | this layer. Those other interfaces would co-exist with this one and the gameplay would be interactive betwen the two. 39 | 40 | ### Audio Layer 41 | This layer of code, contained in the com.tsatsatzu.subwar.audio packages, comprises the audio interface 42 | to the game. It is accessed, exclusively, through the single entry point in SubWarAudioAPI. 43 | This layer uses the game layer to conduct the game, and its primary responsibility is to convert audio based 44 | commands into game actions, and the results of game actions back into audio messages. 45 | 46 | The layer exists so that if another audio interface is desired, e.g. if Google ever do a decent interface to OK Google, 47 | it can be written on top of this layer. 48 | 49 | ### Alexa Layer 50 | This layer interfaces to the Alexa specific requirements. It translates Alexa intents into calls to the audio API, 51 | and translates reponses from the audio API back to an Alexa response. 52 | 53 | ## Development Environment 54 | 55 | This code was developed with Eclipse Mars and Java 1.8. The AWS plugin was used for Eclipse. 56 | The code project is to be built into a war file and deployed to a web server. 57 | In production this will be a Tomcat 8 server running on an Elastic Beanstalk instance. 58 | 59 | ## Resources 60 | 61 | A quick Intro can be found [here](https://www.youtube.com/watch?v=LHFcFzVez2Q). 62 | 63 | A demo can be found [here](https://www.youtube.com/watch?v=0WkVEX1UC_g). 64 | 65 | A 45 minute deep dive into the design and architecture can be found [here](https://www.youtube.com/watch?v=lboatie5brk). 66 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/src/com/tsatsatzu/subwar/alexa/api/subwar.json: -------------------------------------------------------------------------------- 1 | { 2 | "intents":[ 3 | { 4 | "slots":[ 5 | 6 | ], 7 | "intent":"NORTH" 8 | }, 9 | { 10 | "slots":[ 11 | 12 | ], 13 | "intent":"SOUTH" 14 | }, 15 | { 16 | "slots":[ 17 | 18 | ], 19 | "intent":"EAST" 20 | }, 21 | { 22 | "slots":[ 23 | 24 | ], 25 | "intent":"WEST" 26 | }, 27 | { 28 | "slots":[ 29 | 30 | ], 31 | "intent":"NORTHWEST" 32 | }, 33 | { 34 | "slots":[ 35 | 36 | ], 37 | "intent":"NORTHEAST" 38 | }, 39 | { 40 | "slots":[ 41 | 42 | ], 43 | "intent":"SOUTHWEST" 44 | }, 45 | { 46 | "slots":[ 47 | 48 | ], 49 | "intent":"SOUTHEAST" 50 | }, 51 | { 52 | "slots":[ 53 | 54 | ], 55 | "intent":"DIVE" 56 | }, 57 | { 58 | "slots":[ 59 | 60 | ], 61 | "intent":"RISE" 62 | }, 63 | { 64 | "slots":[ 65 | 66 | ], 67 | "intent":"LISTEN" 68 | }, 69 | { 70 | "slots":[ 71 | 72 | ], 73 | "intent":"SONAR" 74 | }, 75 | { 76 | "slots":[ 77 | { 78 | "name":"dir", 79 | "type":"DIRECTION" 80 | } 81 | ], 82 | "intent":"FIRE" 83 | }, 84 | { 85 | "slots":[ 86 | { 87 | "name":"name", 88 | "type":"AMAZON.US_FIRST_NAME" 89 | } 90 | ], 91 | "intent":"CALLME" 92 | }, 93 | { 94 | "slots":[ 95 | { 96 | "name":"shipname", 97 | "type":"AMAZON.US_CITY" 98 | } 99 | ], 100 | "intent":"CALLSHIP" 101 | }, 102 | { 103 | "slots":[ 104 | 105 | ], 106 | "intent":"LAUNCH" 107 | }, 108 | { 109 | "slots":[ 110 | 111 | ], 112 | "intent":"DOCK" 113 | }, 114 | { 115 | "slots":[ 116 | 117 | ], 118 | "intent":"LEADERS" 119 | }, 120 | { 121 | "slots":[ 122 | 123 | ], 124 | "intent":"SHIP" 125 | }, 126 | { 127 | "slots":[ 128 | 129 | ], 130 | "intent":"COMBAT" 131 | }, 132 | { 133 | "slots":[ 134 | 135 | ], 136 | "intent":"AMAZON.NoIntent" 137 | }, 138 | { 139 | "slots":[ 140 | 141 | ], 142 | "intent":"AMAZON.YesIntent" 143 | }, 144 | { 145 | "slots":[ 146 | 147 | ], 148 | "intent":"AMAZON.RepeatIntent" 149 | }, 150 | { 151 | "slots":[ 152 | 153 | ], 154 | "intent":"AMAZON.StartOverIntent" 155 | }, 156 | { 157 | "slots":[ 158 | 159 | ], 160 | "intent":"AMAZON.HelpIntent" 161 | }, 162 | { 163 | "slots":[ 164 | 165 | ], 166 | "intent":"AMAZON.StopIntent" 167 | }, 168 | { 169 | "slots":[ 170 | 171 | ], 172 | "intent":"AMAZON.CancelIntent" 173 | } 174 | ] 175 | } -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/src/com/tsatsatzu/subwar/audio/logic/AudioConstLogic.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Jo Jaquinta, TsaTsaTzu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.tsatsatzu.subwar.audio.logic; 17 | 18 | import com.tsatsatzu.subwar.game.logic.CredentialsLogic; 19 | 20 | /** 21 | * The Class AudioConstLogic. 22 | * Constants controlling how the logic of the audio layer works. 23 | */ 24 | public class AudioConstLogic 25 | { 26 | 27 | /** The Constant API_KEY. */ 28 | static final String API_KEY = CredentialsLogic.getProperty("audio.api.key"); 29 | 30 | /** The Constant SOUND_ROOT. */ 31 | private static final String SOUND_ROOT = "https://s3.amazonaws.com/tsatsatzu-alexa/sound/subwar/"; 32 | 33 | /** The Constant SOUND_BOSUN_WHISTLE. */ 34 | public static final String SOUND_BOSUN_WHISTLE = SOUND_ROOT+"BOSUN_WHISTLE.mp3"; 35 | 36 | /** The Constant SOUND_SHIP_LAUNCH. */ 37 | public static final String SOUND_SHIP_LAUNCH = SOUND_ROOT+"SHIP_LAUNCH.mp3"; 38 | 39 | /** The Constant SOUND_MOTOR_RUNNING. */ 40 | public static final String SOUND_MOTOR_RUNNING = SOUND_ROOT+"MOTOR_RUNNING.mp3"; 41 | 42 | /** The Constant SOUND_EXPLOSION. */ 43 | public static final String SOUND_EXPLOSION = SOUND_ROOT+"EXPLOSION.mp3"; 44 | 45 | /** The Constant SOUND_TORPEDO. */ 46 | public static final String SOUND_TORPEDO = SOUND_ROOT+"TORPEDO.mp3"; 47 | 48 | /** The Constant SOUND_SONAR. */ 49 | public static final String SOUND_SONAR = SOUND_ROOT+"SONAR.mp3"; 50 | 51 | /** The Constant SOUND_LISTEN_SHIP. */ 52 | public static final String SOUND_LISTEN_SHIP = SOUND_ROOT+"LISTEN_SHIP.mp3"; 53 | 54 | /** The Constant SOUND_PAUSE. */ 55 | public static final String SOUND_PAUSE = ""; 56 | 57 | /** The Constant MAX_LEADERS. */ 58 | public static final int MAX_LEADERS = 3; 59 | 60 | /** The Constant STATE_INITIAL. */ 61 | public static final String STATE_INITIAL = "init"; 62 | 63 | /** The Constant STATE_INTRO1_1. */ 64 | public static final String STATE_INTRO1_1 = "intro.1.1"; 65 | 66 | /** The Constant STATE_INTRO1_2. */ 67 | public static final String STATE_INTRO1_2 = "intro.1.2"; 68 | 69 | /** The Constant STATE_INTRO1_3. */ 70 | public static final String STATE_INTRO1_3 = "intro.1.3"; 71 | 72 | /** The Constant STATE_PRE_GAME. */ 73 | public static final String STATE_PRE_GAME = "pregame.base"; 74 | 75 | /** The Constant STATE_INTRO2_1. */ 76 | public static final String STATE_INTRO2_1 = "intro.2.1"; 77 | 78 | /** The Constant STATE_INTRO3_1. */ 79 | public static final String STATE_INTRO3_1 = "intro.3.1"; 80 | 81 | /** The Constant STATE_GAME_BASE. */ 82 | public static final String STATE_GAME_BASE = "game.base"; 83 | 84 | /** The Constant STATE_GAME_ABORT. */ 85 | public static final String STATE_GAME_ABORT = "game.abort.query"; 86 | 87 | /** The Constant TIMEOUT_IDLE. */ 88 | public static final long TIMEOUT_IDLE = 5*60*1000L; 89 | } 90 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar.test/src/com/tsatsatzu/subwar/test/game/UserTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Jo Jaquinta, TsaTsaTzu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.tsatsatzu.subwar.test.game; 17 | 18 | import static org.junit.Assert.*; 19 | 20 | import org.junit.Test; 21 | 22 | import com.tsatsatzu.subwar.game.api.SubWarGameAPI; 23 | import com.tsatsatzu.subwar.game.data.SWContextBean; 24 | import com.tsatsatzu.subwar.game.data.SWOperationBean; 25 | 26 | // TODO: Auto-generated Javadoc 27 | /** 28 | * The Class UserTest. 29 | * Test the customization aspects for a user. 30 | */ 31 | public class UserTest extends BaseTest 32 | { 33 | 34 | /** 35 | * Test that we can name a user and their ship. 36 | */ 37 | @Test 38 | public void test() 39 | { 40 | SWOperationBean op = getOperation(SWOperationBean.QUERY_USER); 41 | SWContextBean context = SubWarGameAPI.invoke(op); 42 | assertNull(context.getLastOperationError()); 43 | assertNotNull(context.getUser()); 44 | assertNull(context.getUser().getUserName()); 45 | assertNull(context.getUser().getSubName()); 46 | 47 | op = getOperation(SWOperationBean.SET_USER_DETAILS); 48 | op.setString1("Dick"); 49 | context = SubWarGameAPI.invoke(op); 50 | assertNull(context.getLastOperationError()); 51 | assertNotNull(context.getUser()); 52 | assertEquals("Dick", context.getUser().getUserName()); 53 | assertNull(context.getUser().getSubName()); 54 | 55 | op = getOperation(SWOperationBean.SET_USER_DETAILS); 56 | op.setString2("Ticonderoga"); 57 | context = SubWarGameAPI.invoke(op); 58 | assertNull(context.getLastOperationError()); 59 | assertNotNull(context.getUser()); 60 | assertEquals("Dick", context.getUser().getUserName()); 61 | assertEquals("Ticonderoga", context.getUser().getSubName()); 62 | 63 | op = getOperation(SWOperationBean.SET_USER_DETAILS); 64 | op.setString1("Jane"); 65 | op.setString2("Lollipop"); 66 | context = SubWarGameAPI.invoke(op); 67 | assertNull(context.getLastOperationError()); 68 | assertNotNull(context.getUser()); 69 | assertEquals("Jane", context.getUser().getUserName()); 70 | assertEquals("Lollipop", context.getUser().getSubName()); 71 | 72 | op = getOperation(SWOperationBean.SET_USER_DETAILS); 73 | op.setString1(""); 74 | op.setString2(""); 75 | context = SubWarGameAPI.invoke(op); 76 | assertNull(context.getLastOperationError()); 77 | assertNotNull(context.getUser()); 78 | assertNull(context.getUser().getUserName()); 79 | assertNull(context.getUser().getSubName()); 80 | 81 | op = getOperation(SWOperationBean.QUERY_USER); 82 | context = SubWarGameAPI.invoke(op); 83 | assertNull(context.getLastOperationError()); 84 | assertNotNull(context.getUser()); 85 | assertNull(context.getUser().getUserName()); 86 | assertNull(context.getUser().getSubName()); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar.test/src/com/tsatsatzu/subwar/test/audio/Launch4Test.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Jo Jaquinta, TsaTsaTzu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.tsatsatzu.subwar.test.audio; 17 | 18 | import static org.junit.Assert.*; 19 | 20 | import org.junit.Test; 21 | 22 | import com.tsatsatzu.subwar.audio.api.SubWarAudioAPI; 23 | import com.tsatsatzu.subwar.audio.data.SWInvocationBean; 24 | 25 | /** 26 | * The Class tests launching for the Fourth time. 27 | */ 28 | public class Launch4Test extends BaseTest 29 | { 30 | 31 | /** 32 | * Launch and reply Yes. 33 | */ 34 | @Test 35 | public void launchY() 36 | { 37 | SWInvocationBean resp; 38 | // first launch 39 | resp = dialog(SubWarAudioAPI.CMD_LAUNCH_APP); 40 | assertNull(resp.getGame()); 41 | assertFalse(resp.isEndSession()); 42 | resp = dialog(SubWarAudioAPI.CMD_LAUNCH); 43 | assertNotNull(resp.getGame()); 44 | assertFalse(resp.isEndSession()); 45 | resp = dialog(SubWarAudioAPI.CMD_STOP); 46 | assertNull(resp.getGame()); 47 | assertTrue(resp.isEndSession()); 48 | 49 | // second launch 50 | resp = dialog(SubWarAudioAPI.CMD_LAUNCH_APP); 51 | assertNull(resp.getGame()); 52 | assertFalse(resp.isEndSession()); 53 | resp = dialog(SubWarAudioAPI.CMD_YES); 54 | assertNull(resp.getGame()); 55 | assertFalse(resp.isEndSession()); 56 | resp = dialog(SubWarAudioAPI.CMD_CALL_ME, "Diana"); 57 | assertNull(resp.getGame()); 58 | assertFalse(resp.isEndSession()); 59 | resp = dialog(SubWarAudioAPI.CMD_LAUNCH); 60 | assertNotNull(resp.getGame()); 61 | assertFalse(resp.isEndSession()); 62 | resp = dialog(SubWarAudioAPI.CMD_STOP); 63 | assertNull(resp.getGame()); 64 | assertTrue(resp.isEndSession()); 65 | 66 | // third launch 67 | resp = dialog(SubWarAudioAPI.CMD_LAUNCH_APP); 68 | assertNull(resp.getGame()); 69 | assertFalse(resp.isEndSession()); 70 | resp = dialog(SubWarAudioAPI.CMD_YES); 71 | assertNull(resp.getGame()); 72 | assertFalse(resp.isEndSession()); 73 | resp = dialog(SubWarAudioAPI.CMD_CALL_SHIP, "Cincinnati"); 74 | assertNull(resp.getGame()); 75 | assertFalse(resp.isEndSession()); 76 | resp = dialog(SubWarAudioAPI.CMD_LAUNCH); 77 | assertNotNull(resp.getGame()); 78 | assertFalse(resp.isEndSession()); 79 | resp = dialog(SubWarAudioAPI.CMD_STOP); 80 | assertNull(resp.getGame()); 81 | assertTrue(resp.isEndSession()); 82 | 83 | // fourth launch 84 | resp = dialog(SubWarAudioAPI.CMD_LAUNCH_APP); 85 | assertNull(resp.getGame()); 86 | assertFalse(resp.isEndSession()); 87 | resp = dialog(SubWarAudioAPI.CMD_LAUNCH); 88 | assertNotNull(resp.getGame()); 89 | assertFalse(resp.isEndSession()); 90 | resp = dialog(SubWarAudioAPI.CMD_STOP); 91 | assertNull(resp.getGame()); 92 | assertTrue(resp.isEndSession()); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello AWS Web World! 6 | 7 | 8 | 9 |
10 | 11 |
12 | 13 |

AWS Java Web Project

14 |

15 | Welcome to your new AWS Java Web Project! This project template gives you 16 | basic a starting point for creating a web application on AWS. 17 |

18 | 19 |

Contents of this Project

20 | 21 |

22 | This page is rendered from WebContent/index.html - a simple static 23 | HTML page. Any static content in the WebContent folder will be accessible 24 | from the equivalent path in your web application (for example, 25 | https://your-app-93s2kypa5y.elasticbeanstalk.com/index.html). 26 |

27 | 28 |

29 | Any JSP files in the WebContent folder 30 | will be processed dynamically to generate HTML pages. For example, the 31 | index.jsp file renders a simple page that displays 32 | a list of any Amazon S3 Buckets, 33 | Amazon DynamoDB Tables, 34 | and Amazon EC2 Instances currently 35 | associated with your AWS account. 36 |

37 | 38 |

Deploying this Project Locally

39 | 40 |

41 | If you have a local installation of 42 | Apache Tomcat, you can deploy this project to it for local testing 43 | using the standard Eclipse Web Tools Platform integration with Tomcat. 44 |

45 | 46 |
    47 |
  • Right/control click on this project in the Project Explorer
  • 48 |
  • Choose Run As, then Run on Server
  • 49 |
  • Select the option to manually define a new server
  • 50 |
  • Expand the Apache folder, then select an appropriate version of Tomcat
  • 51 |
  • Point Eclipse at your local Tomcat installation and click Finish
  • 52 |
53 | 54 |

55 | This page will open up, now served by your local Tomcat installation. 56 |

57 | 58 |

Deploying the Project to AWS Elastic Beanstalk

59 | 60 |

61 | AWS Elastic Beanstalk 62 | is the quickest and easiest way to deploy an AWS Java Web Project to the 63 | cloud. To deploy this project to AWS Elastic Beanstalk: 64 |

65 | 66 |
    67 |
  • Right/control click on this project in the Project Explorer
  • 68 |
  • Choose run As, then Run on Server
  • 69 |
  • Select the option to manually define a new server
  • 70 |
  • Expand the Amazon Web Services folder, then select an appropriate version of Tomcat
  • 71 |
  • Select the AWS region where your application will be hosted
  • 72 |
  • Provide a name for your application and environment and click Finish
  • 73 |
74 | 75 |

76 | Your project will be uploaded to AWS Elastic Beanstalk, which will 77 | provision infrastructure to host your application and deploy your code 78 | to it. When it's finished, you will again see this page open up, now hosted 79 | in the cloud! 80 |

81 | 82 |

83 | For more information about working with AWS Elastic Beanstalk, refer to the 84 | 85 | AWS Elastic Beanstalk Developer Guide. 86 |

87 | 88 |
89 | 90 | 91 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar.test/src/com/tsatsatzu/subwar/test/audio/GameTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Jo Jaquinta, TsaTsaTzu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.tsatsatzu.subwar.test.audio; 17 | 18 | import static org.junit.Assert.*; 19 | 20 | import org.junit.Test; 21 | 22 | import com.tsatsatzu.subwar.audio.api.SubWarAudioAPI; 23 | import com.tsatsatzu.subwar.audio.data.SWInvocationBean; 24 | import com.tsatsatzu.subwar.game.api.SubWarGameAPI; 25 | import com.tsatsatzu.subwar.game.data.SWContextBean; 26 | import com.tsatsatzu.subwar.game.data.SWOperationBean; 27 | 28 | /** 29 | * This test walks through the game play design dialog. 30 | */ 31 | public class GameTest extends BaseTest 32 | { 33 | 34 | /** 35 | * Play a basic round of the game. 36 | */ 37 | @Test 38 | public void play() 39 | { 40 | SWOperationBean op = getOperation(SWOperationBean.TEST); 41 | op.setInt1(SWOperationBean.TEST_RESET_SEED); 42 | op.setInt2(1); 43 | SWContextBean context = SubWarGameAPI.invoke(op); 44 | assertNull(context.getLastOperationError()); 45 | 46 | SWInvocationBean resp; 47 | resp = dialog(SubWarAudioAPI.CMD_LAUNCH_APP); 48 | assertNull(resp.getGame()); 49 | assertFalse(resp.isEndSession()); 50 | resp = dialog(SubWarAudioAPI.CMD_LAUNCH); 51 | assertNotNull(resp.getGame()); 52 | assertFalse(resp.isEndSession()); 53 | aiMove(); 54 | resp = dialog(SubWarAudioAPI.CMD_HELP); 55 | assertNotNull(resp.getGame()); 56 | assertFalse(resp.isEndSession()); 57 | aiMove(); 58 | resp = dialog(SubWarAudioAPI.CMD_NORTH); 59 | assertNotNull(resp.getGame()); 60 | assertFalse(resp.isEndSession()); 61 | aiMove(); 62 | resp = dialog(SubWarAudioAPI.CMD_LISTEN); 63 | assertNotNull(resp.getGame()); 64 | assertFalse(resp.isEndSession()); 65 | aiMove(); 66 | resp = dialog(SubWarAudioAPI.CMD_SONAR); 67 | assertNotNull(resp.getGame()); 68 | assertFalse(resp.isEndSession()); 69 | aiMove(); 70 | resp = dialog(SubWarAudioAPI.CMD_DIVE); 71 | assertNotNull(resp.getGame()); 72 | assertFalse(resp.isEndSession()); 73 | aiMove(); 74 | resp = dialog(SubWarAudioAPI.CMD_WEST); 75 | assertNotNull(resp.getGame()); 76 | assertFalse(resp.isEndSession()); 77 | aiMove(); 78 | resp = dialog(SubWarAudioAPI.CMD_LISTEN); 79 | assertNotNull(resp.getGame()); 80 | assertFalse(resp.isEndSession()); 81 | aiMove(); 82 | resp = dialog(SubWarAudioAPI.CMD_FIRE, "east"); 83 | assertNotNull(resp.getGame()); 84 | assertFalse(resp.isEndSession()); 85 | aiMove(); 86 | resp = dialog(SubWarAudioAPI.CMD_EAST); 87 | assertNotNull(resp.getGame()); 88 | assertFalse(resp.isEndSession()); 89 | aiMove(); 90 | resp = dialog(SubWarAudioAPI.CMD_DIVE); 91 | assertNotNull(resp.getGame()); 92 | assertFalse(resp.isEndSession()); 93 | resp = dialog(SubWarAudioAPI.CMD_DOCK); 94 | assertNull(resp.getGame()); 95 | assertFalse(resp.isEndSession()); 96 | resp = dialog(SubWarAudioAPI.CMD_STOP); 97 | assertNull(resp.getGame()); 98 | assertTrue(resp.isEndSession()); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/src/com/tsatsatzu/subwar/game/data/SWGameDetailsBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Jo Jaquinta, TsaTsaTzu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.tsatsatzu.subwar.game.data; 17 | 18 | /** 19 | * The Class SWGameDetailsBean. 20 | * These are the details the user knows about a running game. 21 | */ 22 | public class SWGameDetailsBean 23 | { 24 | 25 | /** The Eastern boundary. */ 26 | private int mEast; 27 | 28 | /** The Western boundary. */ 29 | private int mWest; 30 | 31 | /** The Northern boundary. */ 32 | private int mNorth; 33 | 34 | /** The Southern boundary. */ 35 | private int mSouth; 36 | 37 | /** The Max depth. */ 38 | private int mMaxDepth; 39 | 40 | /** The User position. */ 41 | private SWPositionBean mUserPosition; 42 | 43 | /** 44 | * Gets the eastern boundary. 45 | * 46 | * @return the eastern boundary 47 | */ 48 | public int getEast() 49 | { 50 | return mEast; 51 | } 52 | 53 | /** 54 | * Sets the eastern boundary. 55 | * 56 | * @param east the new eastern boundary 57 | */ 58 | public void setEast(int east) 59 | { 60 | mEast = east; 61 | } 62 | 63 | /** 64 | * Gets the western boundary. 65 | * 66 | * @return the western boundary 67 | */ 68 | public int getWest() 69 | { 70 | return mWest; 71 | } 72 | 73 | /** 74 | * Sets the western boundary. 75 | * 76 | * @param west the new western boundary 77 | */ 78 | public void setWest(int west) 79 | { 80 | mWest = west; 81 | } 82 | 83 | /** 84 | * Gets the northern boundary. 85 | * 86 | * @return the northern boundary 87 | */ 88 | public int getNorth() 89 | { 90 | return mNorth; 91 | } 92 | 93 | /** 94 | * Sets the northern boundary. 95 | * 96 | * @param north the new northern boundary 97 | */ 98 | public void setNorth(int north) 99 | { 100 | mNorth = north; 101 | } 102 | 103 | /** 104 | * Gets the southern boundary. 105 | * 106 | * @return the southern boundary 107 | */ 108 | public int getSouth() 109 | { 110 | return mSouth; 111 | } 112 | 113 | /** 114 | * Sets the southern boundary. 115 | * 116 | * @param south the new southern boundary 117 | */ 118 | public void setSouth(int south) 119 | { 120 | mSouth = south; 121 | } 122 | 123 | /** 124 | * Gets the max depth. 125 | * 126 | * @return the max depth 127 | */ 128 | public int getMaxDepth() 129 | { 130 | return mMaxDepth; 131 | } 132 | 133 | /** 134 | * Sets the max depth. 135 | * 136 | * @param maxDepth the new max depth 137 | */ 138 | public void setMaxDepth(int maxDepth) 139 | { 140 | mMaxDepth = maxDepth; 141 | } 142 | 143 | /** 144 | * Gets the user position. 145 | * 146 | * @return the user position 147 | */ 148 | public SWPositionBean getUserPosition() 149 | { 150 | return mUserPosition; 151 | } 152 | 153 | /** 154 | * Sets the user position. 155 | * 156 | * @param userPosition the new user position 157 | */ 158 | public void setUserPosition(SWPositionBean userPosition) 159 | { 160 | mUserPosition = userPosition; 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/src/com/tsatsatzu/subwar/game/logic/mem/MemIODriver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Jo Jaquinta, TsaTsaTzu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.tsatsatzu.subwar.game.logic.mem; 17 | 18 | import java.util.ArrayList; 19 | import java.util.Collections; 20 | import java.util.Comparator; 21 | import java.util.HashMap; 22 | import java.util.List; 23 | import java.util.Map; 24 | 25 | import com.tsatsatzu.subwar.game.data.SWUserBean; 26 | import com.tsatsatzu.subwar.game.logic.IIODriver; 27 | 28 | /* 29 | * This I/O driver is used for unit testing purposes. It stores the User base only 30 | * in memory. 31 | */ 32 | 33 | /** 34 | * The Class MemIODriver. 35 | */ 36 | public class MemIODriver implements IIODriver 37 | { 38 | 39 | /** The User store. */ 40 | private Map mUserStore = new HashMap(); 41 | 42 | /* (non-Javadoc) 43 | * @see com.tsatsatzu.subwar.game.logic.IIODriver#clearCaches() 44 | */ 45 | @Override 46 | public void clearCaches() 47 | { 48 | // NOOP: everything is in memory. Nothing to clear. 49 | } 50 | 51 | /* (non-Javadoc) 52 | * @see com.tsatsatzu.subwar.game.logic.IIODriver#getUser(java.lang.String) 53 | */ 54 | @Override 55 | public SWUserBean getUser(String id) 56 | { 57 | return mUserStore.get(id); 58 | } 59 | 60 | /* (non-Javadoc) 61 | * @see com.tsatsatzu.subwar.game.logic.IIODriver#saveUser(com.tsatsatzu.subwar.game.data.SWUserBean) 62 | */ 63 | @Override 64 | public void saveUser(SWUserBean user) 65 | { 66 | mUserStore.put(user.getUserID(), user); 67 | } 68 | 69 | /* (non-Javadoc) 70 | * @see com.tsatsatzu.subwar.game.logic.IIODriver#deleteUser(java.lang.String) 71 | */ 72 | @Override 73 | public void deleteUser(String id) 74 | { 75 | mUserStore.remove(id); 76 | } 77 | 78 | /* (non-Javadoc) 79 | * @see com.tsatsatzu.subwar.game.logic.IIODriver#getTopUsers(int) 80 | */ 81 | @Override 82 | public List getTopUsers(int total) 83 | { 84 | List users = new ArrayList<>(); 85 | // get all the users 86 | users.addAll(mUserStore.values()); 87 | // sort them 88 | // (Since we ony want the top #total, there are more efficient sorts that could 89 | // be used. But this is in-memory, and for testing purposes. Simplicity of code 90 | // was the better choice. So built in sort used. 91 | Collections.sort(users, new Comparator() { 92 | @Override 93 | public int compare(SWUserBean o1, SWUserBean o2) 94 | { 95 | int k1 = o1.getNumberOfKills(); 96 | int k2 = o2.getNumberOfKills(); 97 | if (k1 != k2) 98 | return k1 - k2; 99 | if (k1 == 0) 100 | return 0; // avoid divide by zero 101 | double s1 = (double)o1.getNumberOfKills()/(double)o1.getNumberOfShots(); 102 | double s2 = (double)o2.getNumberOfKills()/(double)o2.getNumberOfShots(); 103 | return (int)Math.signum(s1 - s2); 104 | } 105 | }); 106 | // trim to just the top ten 107 | while (users.size() > total) 108 | users.remove(total); 109 | return users; 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/src/com/tsatsatzu/subwar/game/logic/dynamo/DynamoUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Jo Jaquinta, TsaTsaTzu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.tsatsatzu.subwar.game.logic.dynamo; 17 | 18 | import java.util.Map; 19 | 20 | import com.amazonaws.services.dynamodbv2.model.AttributeValue; 21 | 22 | // TODO: Auto-generated Javadoc 23 | /** 24 | * The Class DynamoUtils. 25 | */ 26 | public class DynamoUtils 27 | { 28 | 29 | /** 30 | * Gets the string. 31 | * 32 | * @param data the data 33 | * @param name the name 34 | * @return the string 35 | */ 36 | public static String getString(Map data, String name) 37 | { 38 | return getString(data, name, ""); 39 | } 40 | 41 | /** 42 | * Gets the string. 43 | * 44 | * @param data the data 45 | * @param name the name 46 | * @param def the def 47 | * @return the string 48 | */ 49 | public static String getString(Map data, String name, String def) 50 | { 51 | AttributeValue val = data.get(name); 52 | if (val == null) 53 | return def; 54 | String snum = val.getS(); 55 | if (snum == null) 56 | return def; 57 | return snum; 58 | } 59 | 60 | /** 61 | * Gets the int. 62 | * 63 | * @param data the data 64 | * @param name the name 65 | * @return the int 66 | */ 67 | public static int getInt(Map data, String name) 68 | { 69 | return getInt(data, name, 0); 70 | } 71 | 72 | /** 73 | * Gets the int. 74 | * 75 | * @param data the data 76 | * @param name the name 77 | * @param def the def 78 | * @return the int 79 | */ 80 | public static int getInt(Map data, String name, int def) 81 | { 82 | AttributeValue val = data.get(name); 83 | if (val == null) 84 | return def; 85 | String snum = val.getN(); 86 | if (snum == null) 87 | return def; 88 | try 89 | { 90 | int inum = Integer.parseInt(snum); 91 | return inum; 92 | } 93 | catch (NumberFormatException e) 94 | { 95 | return def; 96 | } 97 | } 98 | 99 | /** 100 | * Gets the long. 101 | * 102 | * @param data the data 103 | * @param name the name 104 | * @return the long 105 | */ 106 | public static long getLong(Map data, String name) 107 | { 108 | return getLong(data, name, 0); 109 | } 110 | 111 | /** 112 | * Gets the long. 113 | * 114 | * @param data the data 115 | * @param name the name 116 | * @param def the def 117 | * @return the long 118 | */ 119 | public static long getLong(Map data, String name, long def) 120 | { 121 | AttributeValue val = data.get(name); 122 | if (val == null) 123 | return def; 124 | String snum = val.getN(); 125 | if (snum == null) 126 | return def; 127 | try 128 | { 129 | long inum = Long.parseLong(snum); 130 | return inum; 131 | } 132 | catch (NumberFormatException e) 133 | { 134 | return def; 135 | } 136 | } 137 | 138 | } 139 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/doc/deprecated-list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Deprecated List 7 | 8 | 9 | 10 | 11 | 12 | 22 | 25 | 26 |
27 | 28 | 29 | 30 | 31 | 32 | 33 | 43 |
44 | 71 | 72 |
73 |

Deprecated API

74 |

Contents

75 |
76 | 77 |
78 | 79 | 80 | 81 | 82 | 83 | 84 | 94 |
95 | 122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/src/com/tsatsatzu/subwar/game/logic/CredentialsLogic.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Jo Jaquinta, TsaTsaTzu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.tsatsatzu.subwar.game.logic; 17 | 18 | import java.io.IOException; 19 | import java.io.InputStream; 20 | import java.util.Properties; 21 | 22 | /** 23 | * The Class CredentialsLogic. 24 | * Application secrets are kept in a AwsCredentials.properties file in the root of the source 25 | * tree. This is not checked into source control. Several values are contained there. 26 | * Your AWS Credentials from http://aws.amazon.com/security-credentials: 27 | * secretKey= 28 | * accessKey= 29 | * One or more API keys may be specified here in a comma deliminated list 30 | * apiKeys= 31 | */ 32 | public class CredentialsLogic 33 | { 34 | 35 | /** The Constant SYSTEM_SECRETS. */ 36 | private static final String SYSTEM_SECRETS = "AwsCredentials.properties"; 37 | 38 | /** The Credentials. */ 39 | private static Properties mCredentials = null; 40 | 41 | /** 42 | * Gets a property from the credentials file. 43 | * 44 | * @param key the key 45 | * @return the property 46 | */ 47 | public static String getProperty(String key) 48 | { 49 | return getProperty(key, null); 50 | } 51 | 52 | /** 53 | * Gets a property from the credentials file. 54 | * 55 | * @param key the key 56 | * @param defaultValue the default value 57 | * @return the property 58 | */ 59 | public static String getProperty(String key, String defaultValue) 60 | { 61 | // System properties are bound later than compiled in settings. 62 | // Therefore they can be used to override the compiled settings. 63 | // So we check them first. 64 | if (System.getProperties().containsKey(key)) 65 | return System.getProperties().getProperty(key); 66 | // This section is synchronized to ensure that we don't double-load the values 67 | // in case they are called from multiple threads. 68 | synchronized (CredentialsLogic.class) 69 | { 70 | if (mCredentials == null) 71 | { 72 | try 73 | { 74 | mCredentials = new Properties(); 75 | ClassLoader loader = CredentialsLogic.class.getClassLoader(); 76 | InputStream is = loader.getResourceAsStream(SYSTEM_SECRETS); 77 | mCredentials.load(is); 78 | is.close(); 79 | } 80 | catch (IOException e) 81 | { 82 | // This should never happen. If it does, there is a deployment error. 83 | // The system secret file is not checked in. If you have cloned this project, you 84 | // need to set up your own one. 85 | throw new IllegalStateException("Failure to load system secrets from "+SYSTEM_SECRETS, e); 86 | } 87 | } 88 | } 89 | if (mCredentials.containsKey(key)) 90 | return mCredentials.getProperty(key); 91 | return defaultValue; 92 | } 93 | 94 | /** 95 | * Validate an api key. 96 | * 97 | * @param credentials the credentials 98 | * @return true, if successful 99 | */ 100 | public static boolean validateAPIKey(String credentials) 101 | { 102 | if (credentials == null) 103 | return false; 104 | String apiKeys = getProperty("apiKeys"); 105 | if (apiKeys == null) 106 | { 107 | // This should never happen. If it does, there is a deployment error, API keys has not been set. 108 | throw new IllegalStateException("No API keys set in system secrets"); 109 | } 110 | return apiKeys.indexOf(credentials) >= 0; 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/doc/com/tsatsatzu/utils/obj/package-use.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Package com.tsatsatzu.utils.obj 7 | 8 | 9 | 10 | 11 | 12 | 22 | 25 | 26 |
27 | 28 | 29 | 30 | 31 | 32 | 33 | 43 |
44 | 71 | 72 |
73 |

Uses of Package
com.tsatsatzu.utils.obj

74 |
75 |
No usage of com.tsatsatzu.utils.obj
76 | 77 |
78 | 79 | 80 | 81 | 82 | 83 | 84 | 94 |
95 | 122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/doc/com/tsatsatzu/subwar/alexa/api/package-use.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Package com.tsatsatzu.subwar.alexa.api 7 | 8 | 9 | 10 | 11 | 12 | 22 | 25 | 26 |
27 | 28 | 29 | 30 | 31 | 32 | 33 | 43 |
44 | 71 | 72 |
73 |

Uses of Package
com.tsatsatzu.subwar.alexa.api

74 |
75 |
No usage of com.tsatsatzu.subwar.alexa.api
76 | 77 |
78 | 79 | 80 | 81 | 82 | 83 | 84 | 94 |
95 | 122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/src/com/tsatsatzu/subwar/game/data/SWGameBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Jo Jaquinta, TsaTsaTzu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.tsatsatzu.subwar.game.data; 17 | 18 | import java.util.HashMap; 19 | import java.util.Map; 20 | 21 | import com.tsatsatzu.subwar.game.logic.ai.IComputerPlayer; 22 | 23 | /** 24 | * The Class SWGameBean. 25 | * Details of a running shard. 26 | */ 27 | public class SWGameBean 28 | { 29 | 30 | /** The Eastern boundary. */ 31 | private int mEast; 32 | 33 | /** The Western boundary. */ 34 | private int mWest; 35 | 36 | /** The Northern boundary. */ 37 | private int mNorth; 38 | 39 | /** The Southern boundary. */ 40 | private int mSouth; 41 | 42 | /** The Max depth. */ 43 | private int mMaxDepth; 44 | 45 | /** The Ships. */ 46 | private Map mShips = new HashMap<>(); 47 | 48 | /** The AIs. */ 49 | private Map mAI = new HashMap<>(); 50 | 51 | /** 52 | * Gets the eastern boundary. 53 | * 54 | * @return the eastern boundary 55 | */ 56 | public int getEast() 57 | { 58 | return mEast; 59 | } 60 | 61 | /** 62 | * Sets the eastern boundary. 63 | * 64 | * @param east the new eastern boundary 65 | */ 66 | public void setEast(int east) 67 | { 68 | mEast = east; 69 | } 70 | 71 | /** 72 | * Gets the western boundary. 73 | * 74 | * @return the western boundary 75 | */ 76 | public int getWest() 77 | { 78 | return mWest; 79 | } 80 | 81 | /** 82 | * Sets the western boundary. 83 | * 84 | * @param west the new western boundary 85 | */ 86 | public void setWest(int west) 87 | { 88 | mWest = west; 89 | } 90 | 91 | /** 92 | * Gets the northern boundary. 93 | * 94 | * @return the northern boundary 95 | */ 96 | public int getNorth() 97 | { 98 | return mNorth; 99 | } 100 | 101 | /** 102 | * Sets the northern boundary. 103 | * 104 | * @param north the new northern boundary 105 | */ 106 | public void setNorth(int north) 107 | { 108 | mNorth = north; 109 | } 110 | 111 | /** 112 | * Gets the southern boundary. 113 | * 114 | * @return the southern boundary 115 | */ 116 | public int getSouth() 117 | { 118 | return mSouth; 119 | } 120 | 121 | /** 122 | * Sets the southern boundary. 123 | * 124 | * @param south the new southern boundary 125 | */ 126 | public void setSouth(int south) 127 | { 128 | mSouth = south; 129 | } 130 | 131 | /** 132 | * Gets the max depth. 133 | * 134 | * @return the max depth 135 | */ 136 | public int getMaxDepth() 137 | { 138 | return mMaxDepth; 139 | } 140 | 141 | /** 142 | * Sets the max depth. 143 | * 144 | * @param maxDepth the new max depth 145 | */ 146 | public void setMaxDepth(int maxDepth) 147 | { 148 | mMaxDepth = maxDepth; 149 | } 150 | 151 | /** 152 | * Gets the ships. 153 | * 154 | * @return the ships 155 | */ 156 | public Map getShips() 157 | { 158 | return mShips; 159 | } 160 | 161 | /** 162 | * Sets the ships. 163 | * 164 | * @param ships the ships 165 | */ 166 | public void setShips(Map ships) 167 | { 168 | mShips = ships; 169 | } 170 | 171 | /** 172 | * Gets the ais. 173 | * 174 | * @return the ais 175 | */ 176 | public Map getAI() 177 | { 178 | return mAI; 179 | } 180 | 181 | /** 182 | * Sets the ais. 183 | * 184 | * @param aI the ais 185 | */ 186 | public void setAI(Map aI) 187 | { 188 | mAI = aI; 189 | } 190 | } 191 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/doc/com/tsatsatzu/subwar/alexa/service/package-use.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Package com.tsatsatzu.subwar.alexa.service 7 | 8 | 9 | 10 | 11 | 12 | 22 | 25 | 26 |
27 | 28 | 29 | 30 | 31 | 32 | 33 | 43 |
44 | 71 | 72 |
73 |

Uses of Package
com.tsatsatzu.subwar.alexa.service

74 |
75 |
No usage of com.tsatsatzu.subwar.alexa.service
76 | 77 |
78 | 79 | 80 | 81 | 82 | 83 | 84 | 94 |
95 | 122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/src/com/tsatsatzu/subwar/audio/logic/InvocationLogic.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Jo Jaquinta, TsaTsaTzu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.tsatsatzu.subwar.audio.logic; 17 | 18 | import com.tsatsatzu.subwar.audio.data.SWInvocationBean; 19 | import com.tsatsatzu.subwar.game.api.SubWarGameAPI; 20 | import com.tsatsatzu.subwar.game.data.SWContextBean; 21 | import com.tsatsatzu.subwar.game.data.SWOperationBean; 22 | 23 | /** 24 | * The Class InvocationLogic. 25 | * Logic for invoking the game layer from the audio layer 26 | */ 27 | public class InvocationLogic 28 | { 29 | 30 | /** 31 | * Game. 32 | * Call the game layer. 33 | * 34 | * @param ssn the session 35 | * @param opType the type of operation 36 | * @return the context 37 | * @throws SWAudioException the audio exception 38 | */ 39 | public static SWContextBean game(SWInvocationBean ssn, String opType) throws SWAudioException 40 | { 41 | return game(ssn, opType, (String)null, (String)null, (Integer)null, (Integer)null); 42 | } 43 | 44 | /** 45 | * Game. 46 | * Call the game layer. 47 | * 48 | * @param ssn the session 49 | * @param opType the type of operation 50 | * @param string1 the string1 51 | * @param string2 the string2 52 | * @return the context 53 | * @throws SWAudioException the audio exception 54 | */ 55 | public static SWContextBean game(SWInvocationBean ssn, String opType, String string1, String string2) throws SWAudioException 56 | { 57 | return game(ssn, opType, string1, string2, null, null); 58 | } 59 | 60 | /** 61 | * Game. 62 | * Call the game layer. 63 | * 64 | * @param ssn the session 65 | * @param opType the type of operation 66 | * @param int1 the int1 67 | * @param int2 the int2 68 | * @return the context 69 | * @throws SWAudioException the audio exception 70 | */ 71 | public static SWContextBean game(SWInvocationBean ssn, String opType, Integer int1, Integer int2) throws SWAudioException 72 | { 73 | return game(ssn, opType, null, null, int1, int2); 74 | } 75 | 76 | /** 77 | * Game. 78 | * Call the game layer. 79 | * 80 | * @param ssn the session 81 | * @param opType the type of operation 82 | * @param string1 the string1 83 | * @param string2 the string2 84 | * @param int1 the int1 85 | * @param int2 the int2 86 | * @return the context 87 | * @throws SWAudioException the audio exception 88 | */ 89 | public static SWContextBean game(SWInvocationBean ssn, String opType, 90 | String string1, String string2, 91 | Integer int1, Integer int2) throws SWAudioException 92 | { 93 | SWOperationBean op = new SWOperationBean(); 94 | op.setUserID(ssn.getSession().getUserID()); 95 | op.setCredentials(AudioConstLogic.API_KEY); 96 | op.setOperation(opType); 97 | op.setString1(string1); 98 | op.setString2(string2); 99 | if (int1 != null) 100 | op.setInt1(int1); 101 | if (int2 != null) 102 | op.setInt1(int2); 103 | SWContextBean context = SubWarGameAPI.invoke(op); 104 | if (context.getLastOperationError() != null) 105 | throw new SWAudioException(context.getLastOperationError()); 106 | ssn.setUser(context.getUser()); 107 | ssn.setGame(context.getGame()); 108 | return context; 109 | } 110 | 111 | /** 112 | * Record exception. 113 | * Write to the response a description of an exception 114 | * 115 | * @param context the context 116 | * @param e the exception 117 | */ 118 | public static void recordException(SWInvocationBean context, 119 | SWAudioException e) 120 | { 121 | context.addText("An unexpected situation happened: "+e.getMessage()); 122 | context.addWrittenLine(""); 123 | for (StackTraceElement ele : e.getStackTrace()) 124 | { 125 | context.addWrittenLine(ele.toString()); 126 | } 127 | context.setEndSession(true); 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/doc/com/tsatsatzu/subwar/game/logic/mem/package-use.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Package com.tsatsatzu.subwar.game.logic.mem 7 | 8 | 9 | 10 | 11 | 12 | 22 | 25 | 26 |
27 | 28 | 29 | 30 | 31 | 32 | 33 | 43 |
44 | 71 | 72 |
73 |

Uses of Package
com.tsatsatzu.subwar.game.logic.mem

74 |
75 |
No usage of com.tsatsatzu.subwar.game.logic.mem
76 | 77 |
78 | 79 | 80 | 81 | 82 | 83 | 84 | 94 |
95 | 122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar.test/src/com/tsatsatzu/subwar/test/audio/Launch2Test.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Jo Jaquinta, TsaTsaTzu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.tsatsatzu.subwar.test.audio; 17 | 18 | import static org.junit.Assert.*; 19 | 20 | import org.junit.Test; 21 | 22 | import com.tsatsatzu.subwar.audio.api.SubWarAudioAPI; 23 | import com.tsatsatzu.subwar.audio.data.SWInvocationBean; 24 | 25 | /** 26 | * The Class tests launching for the Second time. 27 | */ 28 | public class Launch2Test extends BaseTest 29 | { 30 | 31 | /** 32 | * Launch and reply Yes. 33 | */ 34 | @Test 35 | public void launchY() 36 | { 37 | SWInvocationBean resp; 38 | // first launch 39 | resp = dialog(SubWarAudioAPI.CMD_LAUNCH_APP); 40 | assertNull(resp.getGame()); 41 | assertFalse(resp.isEndSession()); 42 | resp = dialog(SubWarAudioAPI.CMD_LAUNCH); 43 | assertNotNull(resp.getGame()); 44 | assertFalse(resp.isEndSession()); 45 | resp = dialog(SubWarAudioAPI.CMD_STOP); 46 | assertNull(resp.getGame()); 47 | assertTrue(resp.isEndSession()); 48 | 49 | // second launch 50 | resp = dialog(SubWarAudioAPI.CMD_LAUNCH_APP); 51 | assertNull(resp.getGame()); 52 | assertFalse(resp.isEndSession()); 53 | resp = dialog(SubWarAudioAPI.CMD_YES); 54 | assertNull(resp.getGame()); 55 | assertFalse(resp.isEndSession()); 56 | resp = dialog(SubWarAudioAPI.CMD_CALL_ME, "Diana"); 57 | assertNull(resp.getGame()); 58 | assertFalse(resp.isEndSession()); 59 | resp = dialog(SubWarAudioAPI.CMD_LAUNCH); 60 | assertNotNull(resp.getGame()); 61 | assertFalse(resp.isEndSession()); 62 | resp = dialog(SubWarAudioAPI.CMD_STOP); 63 | assertNull(resp.getGame()); 64 | assertTrue(resp.isEndSession()); 65 | } 66 | 67 | /** 68 | * Launch and reply No. 69 | */ 70 | @Test 71 | public void launchN() 72 | { 73 | SWInvocationBean resp; 74 | // first launch 75 | resp = dialog(SubWarAudioAPI.CMD_LAUNCH_APP); 76 | assertNull(resp.getGame()); 77 | assertFalse(resp.isEndSession()); 78 | resp = dialog(SubWarAudioAPI.CMD_LAUNCH); 79 | assertNotNull(resp.getGame()); 80 | assertFalse(resp.isEndSession()); 81 | resp = dialog(SubWarAudioAPI.CMD_STOP); 82 | assertNull(resp.getGame()); 83 | assertTrue(resp.isEndSession()); 84 | 85 | // second launch 86 | resp = dialog(SubWarAudioAPI.CMD_LAUNCH_APP); 87 | assertNull(resp.getGame()); 88 | assertFalse(resp.isEndSession()); 89 | resp = dialog(SubWarAudioAPI.CMD_NO); 90 | assertNull(resp.getGame()); 91 | assertFalse(resp.isEndSession()); 92 | resp = dialog(SubWarAudioAPI.CMD_LAUNCH); 93 | assertNotNull(resp.getGame()); 94 | assertFalse(resp.isEndSession()); 95 | resp = dialog(SubWarAudioAPI.CMD_STOP); 96 | assertNull(resp.getGame()); 97 | assertTrue(resp.isEndSession()); 98 | } 99 | 100 | /** 101 | * Launch with no reply. 102 | */ 103 | @Test 104 | public void launch() 105 | { 106 | SWInvocationBean resp; 107 | // first launch 108 | resp = dialog(SubWarAudioAPI.CMD_LAUNCH_APP); 109 | assertNull(resp.getGame()); 110 | assertFalse(resp.isEndSession()); 111 | resp = dialog(SubWarAudioAPI.CMD_LAUNCH); 112 | assertNotNull(resp.getGame()); 113 | assertFalse(resp.isEndSession()); 114 | resp = dialog(SubWarAudioAPI.CMD_STOP); 115 | assertNull(resp.getGame()); 116 | assertTrue(resp.isEndSession()); 117 | 118 | // second launch 119 | resp = dialog(SubWarAudioAPI.CMD_LAUNCH_APP); 120 | assertNull(resp.getGame()); 121 | assertFalse(resp.isEndSession()); 122 | resp = dialog(SubWarAudioAPI.CMD_LAUNCH); 123 | assertNotNull(resp.getGame()); 124 | assertFalse(resp.isEndSession()); 125 | resp = dialog(SubWarAudioAPI.CMD_STOP); 126 | assertNull(resp.getGame()); 127 | assertTrue(resp.isEndSession()); 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar.test/src/com/tsatsatzu/subwar/test/audio/Launch1Test.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Jo Jaquinta, TsaTsaTzu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.tsatsatzu.subwar.test.audio; 17 | 18 | import static org.junit.Assert.*; 19 | 20 | import org.junit.Test; 21 | 22 | import com.tsatsatzu.subwar.audio.api.SubWarAudioAPI; 23 | import com.tsatsatzu.subwar.audio.data.SWInvocationBean; 24 | 25 | /** 26 | * The Class tests launching for the first time. 27 | */ 28 | public class Launch1Test extends BaseTest 29 | { 30 | 31 | /** 32 | * Launch and reply No-Yes-No. 33 | */ 34 | @Test 35 | public void launchNYN() 36 | { 37 | SWInvocationBean resp; 38 | resp = dialog(SubWarAudioAPI.CMD_LAUNCH_APP); 39 | assertNull(resp.getGame()); 40 | assertFalse(resp.isEndSession()); 41 | resp = dialog(SubWarAudioAPI.CMD_NO); 42 | assertNull(resp.getGame()); 43 | assertFalse(resp.isEndSession()); 44 | resp = dialog(SubWarAudioAPI.CMD_YES); 45 | assertNull(resp.getGame()); 46 | assertFalse(resp.isEndSession()); 47 | resp = dialog(SubWarAudioAPI.CMD_NO); 48 | assertNull(resp.getGame()); 49 | assertFalse(resp.isEndSession()); 50 | resp = dialog(SubWarAudioAPI.CMD_STOP); 51 | assertNull(resp.getGame()); 52 | assertTrue(resp.isEndSession()); 53 | } 54 | 55 | /** 56 | * Launch and reply No-Yes-yes. 57 | */ 58 | @Test 59 | public void launchNYY() 60 | { 61 | SWInvocationBean resp; 62 | resp = dialog(SubWarAudioAPI.CMD_LAUNCH_APP); 63 | assertNull(resp.getGame()); 64 | assertFalse(resp.isEndSession()); 65 | resp = dialog(SubWarAudioAPI.CMD_NO); 66 | assertNull(resp.getGame()); 67 | assertFalse(resp.isEndSession()); 68 | resp = dialog(SubWarAudioAPI.CMD_YES); 69 | assertNull(resp.getGame()); 70 | assertFalse(resp.isEndSession()); 71 | resp = dialog(SubWarAudioAPI.CMD_YES); 72 | assertNotNull(resp.getGame()); 73 | assertFalse(resp.isEndSession()); 74 | resp = dialog(SubWarAudioAPI.CMD_STOP); 75 | assertNull(resp.getGame()); 76 | assertTrue(resp.isEndSession()); 77 | } 78 | 79 | /** 80 | * Launch and reply No-No. 81 | */ 82 | @Test 83 | public void launchNN() 84 | { 85 | SWInvocationBean resp; 86 | resp = dialog(SubWarAudioAPI.CMD_LAUNCH_APP); 87 | assertNull(resp.getGame()); 88 | assertFalse(resp.isEndSession()); 89 | resp = dialog(SubWarAudioAPI.CMD_NO); 90 | assertNull(resp.getGame()); 91 | assertFalse(resp.isEndSession()); 92 | resp = dialog(SubWarAudioAPI.CMD_NO); 93 | assertNull(resp.getGame()); 94 | assertFalse(resp.isEndSession()); 95 | resp = dialog(SubWarAudioAPI.CMD_LAUNCH); 96 | assertNotNull(resp.getGame()); 97 | assertFalse(resp.isEndSession()); 98 | resp = dialog(SubWarAudioAPI.CMD_STOP); 99 | assertNull(resp.getGame()); 100 | assertTrue(resp.isEndSession()); 101 | } 102 | 103 | /** 104 | * Launch and reply Yes. 105 | */ 106 | @Test 107 | public void launchY() 108 | { 109 | SWInvocationBean resp; 110 | resp = dialog(SubWarAudioAPI.CMD_LAUNCH_APP); 111 | assertNull(resp.getGame()); 112 | assertFalse(resp.isEndSession()); 113 | resp = dialog(SubWarAudioAPI.CMD_YES); 114 | assertNotNull(resp.getGame()); 115 | assertFalse(resp.isEndSession()); 116 | resp = dialog(SubWarAudioAPI.CMD_STOP); 117 | assertNull(resp.getGame()); 118 | assertTrue(resp.isEndSession()); 119 | } 120 | 121 | /** 122 | * Launch with no further dialog. 123 | */ 124 | @Test 125 | public void launch() 126 | { 127 | SWInvocationBean resp; 128 | resp = dialog(SubWarAudioAPI.CMD_LAUNCH_APP); 129 | assertNull(resp.getGame()); 130 | assertFalse(resp.isEndSession()); 131 | resp = dialog(SubWarAudioAPI.CMD_STOP); 132 | assertNull(resp.getGame()); 133 | assertTrue(resp.isEndSession()); 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/doc/com/tsatsatzu/subwar/game/logic/dynamo/package-use.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Package com.tsatsatzu.subwar.game.logic.dynamo 7 | 8 | 9 | 10 | 11 | 12 | 22 | 25 | 26 |
27 | 28 | 29 | 30 | 31 | 32 | 33 | 43 |
44 | 71 | 72 |
73 |

Uses of Package
com.tsatsatzu.subwar.game.logic.dynamo

74 |
75 |
No usage of com.tsatsatzu.subwar.game.logic.dynamo
76 | 77 |
78 | 79 | 80 | 81 | 82 | 83 | 84 | 94 |
95 | 122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/src/com/tsatsatzu/subwar/game/data/SWPositionBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Jo Jaquinta, TsaTsaTzu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.tsatsatzu.subwar.game.data; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | /** 22 | * The Class SWPositionBean. 23 | * Notes the use's position and the tracked game details. 24 | */ 25 | public class SWPositionBean 26 | { 27 | 28 | /** The Longitude. */ 29 | private int mLongitude; 30 | 31 | /** The Lattitude. */ 32 | private int mLattitude; 33 | 34 | /** The Depth. */ 35 | private int mDepth; 36 | 37 | /** The Soundings. */ 38 | private List mSoundings = new ArrayList<>(); 39 | 40 | /** The Last move. */ 41 | private long mLastMove; 42 | 43 | /** The Torpedoes. */ 44 | private int mTorpedoes; 45 | 46 | /** The Hits. */ 47 | private int mHits; 48 | 49 | /* (non-Javadoc) 50 | * @see java.lang.Object#toString() 51 | */ 52 | // utils 53 | @Override 54 | public String toString() 55 | { 56 | return mLongitude+","+mLattitude+","+mDepth; 57 | } 58 | 59 | // getters and setters 60 | 61 | /** 62 | * Gets the soundings. 63 | * 64 | * @return the soundings 65 | */ 66 | public List getSoundings() 67 | { 68 | return mSoundings; 69 | } 70 | 71 | /** 72 | * Sets the soundings. 73 | * 74 | * @param soundings the new soundings 75 | */ 76 | public void setSoundings(List soundings) 77 | { 78 | mSoundings = soundings; 79 | } 80 | 81 | /** 82 | * Gets the longitude. 83 | * 84 | * @return the longitude 85 | */ 86 | public int getLongitude() 87 | { 88 | return mLongitude; 89 | } 90 | 91 | /** 92 | * Sets the longitude. 93 | * 94 | * @param longitude the new longitude 95 | */ 96 | public void setLongitude(int longitude) 97 | { 98 | mLongitude = longitude; 99 | } 100 | 101 | /** 102 | * Gets the lattitude. 103 | * 104 | * @return the lattitude 105 | */ 106 | public int getLattitude() 107 | { 108 | return mLattitude; 109 | } 110 | 111 | /** 112 | * Sets the lattitude. 113 | * 114 | * @param lattitude the new lattitude 115 | */ 116 | public void setLattitude(int lattitude) 117 | { 118 | mLattitude = lattitude; 119 | } 120 | 121 | /** 122 | * Gets the depth. 123 | * 124 | * @return the depth 125 | */ 126 | public int getDepth() 127 | { 128 | return mDepth; 129 | } 130 | 131 | /** 132 | * Sets the depth. 133 | * 134 | * @param depth the new depth 135 | */ 136 | public void setDepth(int depth) 137 | { 138 | mDepth = depth; 139 | } 140 | 141 | /** 142 | * Gets the last move. 143 | * 144 | * @return the last move 145 | */ 146 | public long getLastMove() 147 | { 148 | return mLastMove; 149 | } 150 | 151 | /** 152 | * Sets the last move. 153 | * 154 | * @param lastMove the new last move 155 | */ 156 | public void setLastMove(long lastMove) 157 | { 158 | mLastMove = lastMove; 159 | } 160 | 161 | /** 162 | * Gets the torpedoes. 163 | * 164 | * @return the torpedoes 165 | */ 166 | public int getTorpedoes() 167 | { 168 | return mTorpedoes; 169 | } 170 | 171 | /** 172 | * Sets the torpedoes. 173 | * 174 | * @param torpedoes the new torpedoes 175 | */ 176 | public void setTorpedoes(int torpedoes) 177 | { 178 | mTorpedoes = torpedoes; 179 | } 180 | 181 | /** 182 | * Gets the hits. 183 | * 184 | * @return the hits 185 | */ 186 | public int getHits() 187 | { 188 | return mHits; 189 | } 190 | 191 | /** 192 | * Sets the hits. 193 | * 194 | * @param hits the new hits 195 | */ 196 | public void setHits(int hits) 197 | { 198 | mHits = hits; 199 | } 200 | } 201 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/doc/com/tsatsatzu/utils/obj/class-use/StringUtils.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class com.tsatsatzu.utils.obj.StringUtils 7 | 8 | 9 | 10 | 11 | 12 | 22 | 25 | 26 |
27 | 28 | 29 | 30 | 31 | 32 | 33 | 43 |
44 | 71 | 72 |
73 |

Uses of Class
com.tsatsatzu.utils.obj.StringUtils

74 |
75 |
No usage of com.tsatsatzu.utils.obj.StringUtils
76 | 77 |
78 | 79 | 80 | 81 | 82 | 83 | 84 | 94 |
95 | 122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/src/com/tsatsatzu/subwar/audio/logic/ScanLogic.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Jo Jaquinta, TsaTsaTzu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.tsatsatzu.subwar.audio.logic; 17 | 18 | import com.tsatsatzu.subwar.audio.data.SWInvocationBean; 19 | import com.tsatsatzu.subwar.game.data.SWOperationBean; 20 | 21 | /** 22 | * The Class ScanLogic. 23 | * Audio logic around basic scanning verbs 24 | */ 25 | public class ScanLogic 26 | { 27 | 28 | /** 29 | * Listen. 30 | * Handle the listen verb. 31 | * 32 | * @param ssn the session 33 | * @throws SWAudioException the audio exception 34 | */ 35 | public static void listen(SWInvocationBean ssn) throws SWAudioException 36 | { 37 | switch (ssn.getState().getState()) 38 | { 39 | case AudioConstLogic.STATE_INITIAL: 40 | case AudioConstLogic.STATE_INTRO1_1: 41 | case AudioConstLogic.STATE_INTRO1_2: 42 | case AudioConstLogic.STATE_INTRO1_3: 43 | case AudioConstLogic.STATE_INTRO2_1: 44 | case AudioConstLogic.STATE_INTRO3_1: 45 | case AudioConstLogic.STATE_PRE_GAME: 46 | ssn.addText("I'm sorry sir."); 47 | ssn.addText("We can't use the underwater microphones until we launch."); 48 | FrameworkLogic.addPregamePrompt(ssn); 49 | ssn.getState().setState(AudioConstLogic.STATE_PRE_GAME); 50 | break; 51 | case AudioConstLogic.STATE_GAME_ABORT: 52 | ssn.getState().setState(AudioConstLogic.STATE_GAME_BASE); 53 | // fall through into normal command 54 | case AudioConstLogic.STATE_GAME_BASE: 55 | InvocationLogic.game(ssn, SWOperationBean.MICROPHONE); 56 | ssn.addText("Silent running sir."); 57 | ssn.addPause(); 58 | if (ssn.getGame().getUserPosition().getSoundings().size() > 0) 59 | PlayLogic.describeSoundings(ssn); 60 | else 61 | ssn.addText("Nothing heard, {captain}."); 62 | ssn.addPause(); 63 | ssn.addText("What next?"); 64 | break; 65 | default: 66 | throw new SWAudioException("LISTEN:"+ssn.getState().getState()+" not implemented"); 67 | } 68 | } 69 | 70 | /** 71 | * Sonar. 72 | * Handle the ping verb. 73 | * 74 | * @param ssn the session 75 | * @throws SWAudioException the audio exception 76 | */ 77 | public static void sonar(SWInvocationBean ssn) throws SWAudioException 78 | { 79 | switch (ssn.getState().getState()) 80 | { 81 | case AudioConstLogic.STATE_INITIAL: 82 | case AudioConstLogic.STATE_INTRO1_1: 83 | case AudioConstLogic.STATE_INTRO1_2: 84 | case AudioConstLogic.STATE_INTRO1_3: 85 | case AudioConstLogic.STATE_INTRO2_1: 86 | case AudioConstLogic.STATE_INTRO3_1: 87 | case AudioConstLogic.STATE_PRE_GAME: 88 | ssn.addText("I'm sorry sir."); 89 | ssn.addText("We can't use the sonar until we launch."); 90 | FrameworkLogic.addPregamePrompt(ssn); 91 | ssn.getState().setState(AudioConstLogic.STATE_PRE_GAME); 92 | break; 93 | case AudioConstLogic.STATE_GAME_ABORT: 94 | ssn.getState().setState(AudioConstLogic.STATE_GAME_BASE); 95 | // fall through into normal command 96 | case AudioConstLogic.STATE_GAME_BASE: 97 | InvocationLogic.game(ssn, SWOperationBean.SONAR); 98 | ssn.addSound(AudioConstLogic.SOUND_SONAR); 99 | ssn.addText("Pinging sonar sir."); 100 | ssn.addSound(AudioConstLogic.SOUND_SONAR); 101 | ssn.addPause(); 102 | ssn.addSound(AudioConstLogic.SOUND_SONAR); 103 | if (ssn.getGame().getUserPosition().getSoundings().size() > 0) 104 | PlayLogic.describeSoundings(ssn); 105 | else 106 | ssn.addText("Nothing heard, {captain}."); 107 | ssn.addPause(); 108 | ssn.addText("What next?"); 109 | break; 110 | default: 111 | throw new SWAudioException("SONAR:"+ssn.getState().getState()+" not implemented"); 112 | } 113 | } 114 | 115 | } 116 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/doc/com/tsatsatzu/subwar/game/logic/class-use/IOLogic.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class com.tsatsatzu.subwar.game.logic.IOLogic 7 | 8 | 9 | 10 | 11 | 12 | 22 | 25 | 26 |
27 | 28 | 29 | 30 | 31 | 32 | 33 | 43 |
44 | 71 | 72 |
73 |

Uses of Class
com.tsatsatzu.subwar.game.logic.IOLogic

74 |
75 |
No usage of com.tsatsatzu.subwar.game.logic.IOLogic
76 | 77 |
78 | 79 | 80 | 81 | 82 | 83 | 84 | 94 |
95 | 122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/doc/com/tsatsatzu/subwar/game/logic/class-use/GameLogic.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class com.tsatsatzu.subwar.game.logic.GameLogic 7 | 8 | 9 | 10 | 11 | 12 | 22 | 25 | 26 |
27 | 28 | 29 | 30 | 31 | 32 | 33 | 43 |
44 | 71 | 72 |
73 |

Uses of Class
com.tsatsatzu.subwar.game.logic.GameLogic

74 |
75 |
No usage of com.tsatsatzu.subwar.game.logic.GameLogic
76 | 77 |
78 | 79 | 80 | 81 | 82 | 83 | 84 | 94 |
95 | 122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/doc/com/tsatsatzu/subwar/game/logic/class-use/UserLogic.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class com.tsatsatzu.subwar.game.logic.UserLogic 7 | 8 | 9 | 10 | 11 | 12 | 22 | 25 | 26 |
27 | 28 | 29 | 30 | 31 | 32 | 33 | 43 |
44 | 71 | 72 |
73 |

Uses of Class
com.tsatsatzu.subwar.game.logic.UserLogic

74 |
75 |
No usage of com.tsatsatzu.subwar.game.logic.UserLogic
76 | 77 |
78 | 79 | 80 | 81 | 82 | 83 | 84 | 94 |
95 | 122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /com.tsatsatzu.subwar/WebContent/doc/com/tsatsatzu/subwar/audio/logic/class-use/MoveLogic.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class com.tsatsatzu.subwar.audio.logic.MoveLogic 7 | 8 | 9 | 10 | 11 | 12 | 22 | 25 | 26 |
27 | 28 | 29 | 30 | 31 | 32 | 33 | 43 |
44 | 71 | 72 |
73 |

Uses of Class
com.tsatsatzu.subwar.audio.logic.MoveLogic

74 |
75 |
No usage of com.tsatsatzu.subwar.audio.logic.MoveLogic
76 | 77 |
78 | 79 | 80 | 81 | 82 | 83 | 84 | 94 |
95 | 122 | 123 | 124 | 125 | --------------------------------------------------------------------------------