diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a9e41a4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,118 @@ +# Created by .ignore support plugin (hsz.mobi) +### JetBrains template +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +.idea/artifacts +.idea/compiler.xml +.idea/jarRepositories.xml +.idea/modules.xml +.idea/*.iml +.idea/modules +*.iml +*.ipr + +# Sonarlint +.idea/sonarlint + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### Java template +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +### Gradle template +.gradle +**/build/ +!src/**/build/ + +# Ignore Gradle GUI config +gradle-app.setting + +# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) +!gradle-wrapper.jar + +# Cache of project +.gradletasknamecache + +# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 +# gradle/wrapper/gradle-wrapper.properties diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..87c0a80 --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..6df95bc --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..ac21435 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..56e9b54 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ChangeLog.md b/ChangeLog.md new file mode 100644 index 0000000..9dd3704 --- /dev/null +++ b/ChangeLog.md @@ -0,0 +1,22 @@ +ChangeLog +========= + +Version 2.0 +----------- +Write your changes in here + +Version 1.0 +----------- +- (RC.1) Implemented missing tests +- (B.5) Updated License +- (B.4) Implementation and testing of Enemy class (ensured 100% branch coverage) +- (B.3) Created .gitignore +- (B.2) Implementation of most base elements of the model +- (B.1) Created project + +A note on the version naming +---------------------------- +- B.n: Version ``x.y`` _beta x_, alternative to ``x.y-b.n``. + For example: ``v1.0-b.3``. +- RC.n: Release candidate x, alternative to ``x.y-rc.n``. + For example: ``v1.0-rc.2``. \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..4ea99c2 --- /dev/null +++ b/LICENSE @@ -0,0 +1,395 @@ +Attribution 4.0 International + +======================================================================= + +Creative Commons Corporation ("Creative Commons") is not a law firm and +does not provide legal services or legal advice. Distribution of +Creative Commons public licenses does not create a lawyer-client or +other relationship. Creative Commons makes its licenses and related +information available on an "as-is" basis. Creative Commons gives no +warranties regarding its licenses, any material licensed under their +terms and conditions, or any related information. Creative Commons +disclaims all liability for damages resulting from their use to the +fullest extent possible. + +Using Creative Commons Public Licenses + +Creative Commons public licenses provide a standard set of terms and +conditions that creators and other rights holders may use to share +original works of authorship and other material subject to copyright +and certain other rights specified in the public license below. The +following considerations are for informational purposes only, are not +exhaustive, and do not form part of our licenses. + + Considerations for licensors: Our public licenses are + intended for use by those authorized to give the public + permission to use material in ways otherwise restricted by + copyright and certain other rights. Our licenses are + irrevocable. Licensors should read and understand the terms + and conditions of the license they choose before applying it. + Licensors should also secure all rights necessary before + applying our licenses so that the public can reuse the + material as expected. Licensors should clearly mark any + material not subject to the license. This includes other CC- + licensed material, or material used under an exception or + limitation to copyright. More considerations for licensors: + wiki.creativecommons.org/Considerations_for_licensors + + Considerations for the public: By using one of our public + licenses, a licensor grants the public permission to use the + licensed material under specified terms and conditions. If + the licensor's permission is not necessary for any reason--for + example, because of any applicable exception or limitation to + copyright--then that use is not regulated by the license. Our + licenses grant only permissions under copyright and certain + other rights that a licensor has authority to grant. Use of + the licensed material may still be restricted for other + reasons, including because others have copyright or other + rights in the material. A licensor may make special requests, + such as asking that all changes be marked or described. + Although not required by our licenses, you are encouraged to + respect those requests where reasonable. More considerations + for the public: + wiki.creativecommons.org/Considerations_for_licensees + +======================================================================= + +Creative Commons Attribution 4.0 International Public License + +By exercising the Licensed Rights (defined below), You accept and agree +to be bound by the terms and conditions of this Creative Commons +Attribution 4.0 International Public License ("Public License"). To the +extent this Public License may be interpreted as a contract, You are +granted the Licensed Rights in consideration of Your acceptance of +these terms and conditions, and the Licensor grants You such rights in +consideration of benefits the Licensor receives from making the +Licensed Material available under these terms and conditions. + + +Section 1 -- Definitions. + + a. Adapted Material means material subject to Copyright and Similar + Rights that is derived from or based upon the Licensed Material + and in which the Licensed Material is translated, altered, + arranged, transformed, or otherwise modified in a manner requiring + permission under the Copyright and Similar Rights held by the + Licensor. For purposes of this Public License, where the Licensed + Material is a musical work, performance, or sound recording, + Adapted Material is always produced where the Licensed Material is + synched in timed relation with a moving image. + + b. Adapter's License means the license You apply to Your Copyright + and Similar Rights in Your contributions to Adapted Material in + accordance with the terms and conditions of this Public License. + + c. Copyright and Similar Rights means copyright and/or similar rights + closely related to copyright including, without limitation, + performance, broadcast, sound recording, and Sui Generis Database + Rights, without regard to how the rights are labeled or + categorized. For purposes of this Public License, the rights + specified in Section 2(b)(1)-(2) are not Copyright and Similar + Rights. + + d. Effective Technological Measures means those measures that, in the + absence of proper authority, may not be circumvented under laws + fulfilling obligations under Article 11 of the WIPO Copyright + Treaty adopted on December 20, 1996, and/or similar international + agreements. + + e. Exceptions and Limitations means fair use, fair dealing, and/or + any other exception or limitation to Copyright and Similar Rights + that applies to Your use of the Licensed Material. + + f. Licensed Material means the artistic or literary work, database, + or other material to which the Licensor applied this Public + License. + + g. Licensed Rights means the rights granted to You subject to the + terms and conditions of this Public License, which are limited to + all Copyright and Similar Rights that apply to Your use of the + Licensed Material and that the Licensor has authority to license. + + h. Licensor means the individual(s) or entity(ies) granting rights + under this Public License. + + i. Share means to provide material to the public by any means or + process that requires permission under the Licensed Rights, such + as reproduction, public display, public performance, distribution, + dissemination, communication, or importation, and to make material + available to the public including in ways that members of the + public may access the material from a place and at a time + individually chosen by them. + + j. Sui Generis Database Rights means rights other than copyright + resulting from Directive 96/9/EC of the European Parliament and of + the Council of 11 March 1996 on the legal protection of databases, + as amended and/or succeeded, as well as other essentially + equivalent rights anywhere in the world. + + k. You means the individual or entity exercising the Licensed Rights + under this Public License. Your has a corresponding meaning. + + +Section 2 -- Scope. + + a. License grant. + + 1. Subject to the terms and conditions of this Public License, + the Licensor hereby grants You a worldwide, royalty-free, + non-sublicensable, non-exclusive, irrevocable license to + exercise the Licensed Rights in the Licensed Material to: + + a. reproduce and Share the Licensed Material, in whole or + in part; and + + b. produce, reproduce, and Share Adapted Material. + + 2. Exceptions and Limitations. For the avoidance of doubt, where + Exceptions and Limitations apply to Your use, this Public + License does not apply, and You do not need to comply with + its terms and conditions. + + 3. Term. The term of this Public License is specified in Section + 6(a). + + 4. Media and formats; technical modifications allowed. The + Licensor authorizes You to exercise the Licensed Rights in + all media and formats whether now known or hereafter created, + and to make technical modifications necessary to do so. The + Licensor waives and/or agrees not to assert any right or + authority to forbid You from making technical modifications + necessary to exercise the Licensed Rights, including + technical modifications necessary to circumvent Effective + Technological Measures. For purposes of this Public License, + simply making modifications authorized by this Section 2(a) + (4) never produces Adapted Material. + + 5. Downstream recipients. + + a. Offer from the Licensor -- Licensed Material. Every + recipient of the Licensed Material automatically + receives an offer from the Licensor to exercise the + Licensed Rights under the terms and conditions of this + Public License. + + b. No downstream restrictions. You may not offer or impose + any additional or different terms or conditions on, or + apply any Effective Technological Measures to, the + Licensed Material if doing so restricts exercise of the + Licensed Rights by any recipient of the Licensed + Material. + + 6. No endorsement. Nothing in this Public License constitutes or + may be construed as permission to assert or imply that You + are, or that Your use of the Licensed Material is, connected + with, or sponsored, endorsed, or granted official status by, + the Licensor or others designated to receive attribution as + provided in Section 3(a)(1)(A)(i). + + b. Other rights. + + 1. Moral rights, such as the right of integrity, are not + licensed under this Public License, nor are publicity, + privacy, and/or other similar personality rights; however, to + the extent possible, the Licensor waives and/or agrees not to + assert any such rights held by the Licensor to the limited + extent necessary to allow You to exercise the Licensed + Rights, but not otherwise. + + 2. Patent and trademark rights are not licensed under this + Public License. + + 3. To the extent possible, the Licensor waives any right to + collect royalties from You for the exercise of the Licensed + Rights, whether directly or through a collecting society + under any voluntary or waivable statutory or compulsory + licensing scheme. In all other cases the Licensor expressly + reserves any right to collect such royalties. + + +Section 3 -- License Conditions. + +Your exercise of the Licensed Rights is expressly made subject to the +following conditions. + + a. Attribution. + + 1. If You Share the Licensed Material (including in modified + form), You must: + + a. retain the following if it is supplied by the Licensor + with the Licensed Material: + + i. identification of the creator(s) of the Licensed + Material and any others designated to receive + attribution, in any reasonable manner requested by + the Licensor (including by pseudonym if + designated); + + ii. a copyright notice; + + iii. a notice that refers to this Public License; + + iv. a notice that refers to the disclaimer of + warranties; + + v. a URI or hyperlink to the Licensed Material to the + extent reasonably practicable; + + b. indicate if You modified the Licensed Material and + retain an indication of any previous modifications; and + + c. indicate the Licensed Material is licensed under this + Public License, and include the text of, or the URI or + hyperlink to, this Public License. + + 2. You may satisfy the conditions in Section 3(a)(1) in any + reasonable manner based on the medium, means, and context in + which You Share the Licensed Material. For example, it may be + reasonable to satisfy the conditions by providing a URI or + hyperlink to a resource that includes the required + information. + + 3. If requested by the Licensor, You must remove any of the + information required by Section 3(a)(1)(A) to the extent + reasonably practicable. + + 4. If You Share Adapted Material You produce, the Adapter's + License You apply must not prevent recipients of the Adapted + Material from complying with this Public License. + + +Section 4 -- Sui Generis Database Rights. + +Where the Licensed Rights include Sui Generis Database Rights that +apply to Your use of the Licensed Material: + + a. for the avoidance of doubt, Section 2(a)(1) grants You the right + to extract, reuse, reproduce, and Share all or a substantial + portion of the contents of the database; + + b. if You include all or a substantial portion of the database + contents in a database in which You have Sui Generis Database + Rights, then the database in which You have Sui Generis Database + Rights (but not its individual contents) is Adapted Material; and + + c. You must comply with the conditions in Section 3(a) if You Share + all or a substantial portion of the contents of the database. + +For the avoidance of doubt, this Section 4 supplements and does not +replace Your obligations under this Public License where the Licensed +Rights include other Copyright and Similar Rights. + + +Section 5 -- Disclaimer of Warranties and Limitation of Liability. + + a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE + EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS + AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF + ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, + IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, + WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR + PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, + ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT + KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT + ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. + + b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE + TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, + NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, + INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, + COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR + USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN + ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR + DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR + IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. + + c. The disclaimer of warranties and limitation of liability provided + above shall be interpreted in a manner that, to the extent + possible, most closely approximates an absolute disclaimer and + waiver of all liability. + + +Section 6 -- Term and Termination. + + a. This Public License applies for the term of the Copyright and + Similar Rights licensed here. However, if You fail to comply with + this Public License, then Your rights under this Public License + terminate automatically. + + b. Where Your right to use the Licensed Material has terminated under + Section 6(a), it reinstates: + + 1. automatically as of the date the violation is cured, provided + it is cured within 30 days of Your discovery of the + violation; or + + 2. upon express reinstatement by the Licensor. + + For the avoidance of doubt, this Section 6(b) does not affect any + right the Licensor may have to seek remedies for Your violations + of this Public License. + + c. For the avoidance of doubt, the Licensor may also offer the + Licensed Material under separate terms or conditions or stop + distributing the Licensed Material at any time; however, doing so + will not terminate this Public License. + + d. Sections 1, 5, 6, 7, and 8 survive termination of this Public + License. + + +Section 7 -- Other Terms and Conditions. + + a. The Licensor shall not be bound by any additional or different + terms or conditions communicated by You unless expressly agreed. + + b. Any arrangements, understandings, or agreements regarding the + Licensed Material not stated herein are separate from and + independent of the terms and conditions of this Public License. + + +Section 8 -- Interpretation. + + a. For the avoidance of doubt, this Public License does not, and + shall not be interpreted to, reduce, limit, restrict, or impose + conditions on any use of the Licensed Material that could lawfully + be made without permission under this Public License. + + b. To the extent possible, if any provision of this Public License is + deemed unenforceable, it shall be automatically reformed to the + minimum extent necessary to make it enforceable. If the provision + cannot be reformed, it shall be severed from this Public License + without affecting the enforceability of the remaining terms and + conditions. + + c. No term or condition of this Public License will be waived and no + failure to comply consented to unless expressly agreed to by the + Licensor. + + d. Nothing in this Public License constitutes or may be interpreted + as a limitation upon, or waiver of, any privileges and immunities + that apply to the Licensor or You, including from the legal + processes of any jurisdiction or authority. + + +======================================================================= + +Creative Commons is not a party to its public +licenses. Notwithstanding, Creative Commons may elect to apply one of +its public licenses to material it publishes and in those instances +will be considered the “Licensor.” The text of the Creative Commons +public licenses is dedicated to the public domain under the CC0 Public +Domain Dedication. Except for the limited purpose of indicating that +material is shared under a Creative Commons public license or as +otherwise permitted by the Creative Commons policies published at +creativecommons.org/policies, Creative Commons does not authorize the +use of the trademark "Creative Commons" or any other trademark or logo +of Creative Commons without its prior written consent including, +without limitation, in connection with any unauthorized modifications +to any of its public licenses or any other arrangements, +understandings, or agreements concerning use of licensed material. For +the avoidance of doubt, this paragraph does not form part of the +public licenses. + +Creative Commons may be contacted at creativecommons.org. diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..b22d835 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,391 @@ +Attribution 4.0 International +======================================================================= + +Creative Commons Corporation ("Creative Commons") is not a law firm and +does not provide legal services or legal advice. Distribution of +Creative Commons public licenses does not create a lawyer-client or +other relationship. Creative Commons makes its licenses and related +information available on an "as-is" basis. Creative Commons gives no +warranties regarding its licenses, any material licensed under their +terms and conditions, or any related information. Creative Commons +disclaims all liability for damages resulting from their use to the +fullest extent possible. + +Using Creative Commons Public Licenses + +Creative Commons public licenses provide a standard set of terms and +conditions that creators and other rights holders may use to share +original works of authorship and other material subject to copyright +and certain other rights specified in the public license below. The +following considerations are for informational purposes only, are not +exhaustive, and do not form part of our licenses. + +> Considerations for licensors: Our public licenses are +> intended for use by those authorized to give the public +> permission to use material in ways otherwise restricted by +> copyright and certain other rights. Our licenses are +> irrevocable. Licensors should read and understand the terms +> and conditions of the license they choose before applying it. +> Licensors should also secure all rights necessary before +> applying our licenses so that the public can reuse the +> material as expected. Licensors should clearly mark any +> material not subject to the license. This includes other CC- +> licensed material, or material used under an exception or +> limitation to copyright. More considerations for licensors: +> wiki.creativecommons.org/Considerations_for_licensors + +> Considerations for the public: By using one of our public +> licenses, a licensor grants the public permission to use the +> licensed material under specified terms and conditions. If +> the licensor's permission is not necessary for any reason--for +> example, because of any applicable exception or limitation to +> copyright--then that use is not regulated by the license. Our +> licenses grant only permissions under copyright and certain +> other rights that a licensor has authority to grant. Use of +> the licensed material may still be restricted for other +> reasons, including because others have copyright or other +> rights in the material. A licensor may make special requests, +> such as asking that all changes be marked or described. +> Although not required by our licenses, you are encouraged to +> respect those requests where reasonable. More considerations +> for the public: +> wiki.creativecommons.org/Considerations_for_licensees + +Creative Commons Attribution 4.0 International Public License +------------------------------------------------------------- +By exercising the Licensed Rights (defined below), You accept and agree +to be bound by the terms and conditions of this Creative Commons +Attribution 4.0 International Public License ("Public License"). To the +extent this Public License may be interpreted as a contract, You are +granted the Licensed Rights in consideration of Your acceptance of +these terms and conditions, and the Licensor grants You such rights in +consideration of benefits the Licensor receives from making the +Licensed Material available under these terms and conditions. + + +### Section 1 -- Definitions. + +1. Adapted Material means material subject to Copyright and Similar + Rights that is derived from or based upon the Licensed Material + and in which the Licensed Material is translated, altered, + arranged, transformed, or otherwise modified in a manner requiring + permission under the Copyright and Similar Rights held by the + Licensor. For purposes of this Public License, where the Licensed + Material is a musical work, performance, or sound recording, + Adapted Material is always produced where the Licensed Material is + synched in timed relation with a moving image. + +2. Adapter's License means the license You apply to Your Copyright + and Similar Rights in Your contributions to Adapted Material in + accordance with the terms and conditions of this Public License. + +3. Copyright and Similar Rights means copyright and/or similar rights + closely related to copyright including, without limitation, + performance, broadcast, sound recording, and Sui Generis Database + Rights, without regard to how the rights are labeled or + categorized. For purposes of this Public License, the rights + specified in Section 2(b)(1)-(2) are not Copyright and Similar + Rights. + +4. Effective Technological Measures means those measures that, in the + absence of proper authority, may not be circumvented under laws + fulfilling obligations under Article 11 of the WIPO Copyright + Treaty adopted on December 20, 1996, and/or similar international + agreements. + +5. Exceptions and Limitations means fair use, fair dealing, and/or + any other exception or limitation to Copyright and Similar Rights + that applies to Your use of the Licensed Material. + +6. Licensed Material means the artistic or literary work, database, + or other material to which the Licensor applied this Public + License. + +7. Licensed Rights means the rights granted to You subject to the + terms and conditions of this Public License, which are limited to + all Copyright and Similar Rights that apply to Your use of the + Licensed Material and that the Licensor has authority to license. + +8. Licensor means the individual(s) or entity(ies) granting rights + under this Public License. + + 1. Share means to provide material to the public by any means or + process that requires permission under the Licensed Rights, such + as reproduction, public display, public performance, distribution, + dissemination, communication, or importation, and to make material + available to the public including in ways that members of the + public may access the material from a place and at a time + individually chosen by them. + + 2. Sui Generis Database Rights means rights other than copyright + resulting from Directive 96/9/EC of the European Parliament and of + the Council of 11 March 1996 on the legal protection of databases, + as amended and/or succeeded, as well as other essentially + equivalent rights anywhere in the world. + +9. You means the individual or entity exercising the Licensed Rights + under this Public License. Your has a corresponding meaning. + + +### Section 2 -- Scope. + +1. License grant. + + 1. Subject to the terms and conditions of this Public License, + the Licensor hereby grants You a worldwide, royalty-free, + non-sublicensable, non-exclusive, irrevocable license to + exercise the Licensed Rights in the Licensed Material to: + + 1. reproduce and Share the Licensed Material, in whole or + in part; and + + 2. produce, reproduce, and Share Adapted Material. + + 2. Exceptions and Limitations. For the avoidance of doubt, where + Exceptions and Limitations apply to Your use, this Public + License does not apply, and You do not need to comply with + its terms and conditions. + + 3. Term. The term of this Public License is specified in Section + 6(1). + + 4. Media and formats; technical modifications allowed. The + Licensor authorizes You to exercise the Licensed Rights in + all media and formats whether now known or hereafter created, + and to make technical modifications necessary to do so. The + Licensor waives and/or agrees not to assert any right or + authority to forbid You from making technical modifications + necessary to exercise the Licensed Rights, including + technical modifications necessary to circumvent Effective + Technological Measures. For purposes of this Public License, + simply making modifications authorized by this Section 2(6) + (iv) never produces Adapted Material. + + 5. Downstream recipients. + + 1. Offer from the Licensor -- Licensed Material. Every + recipient of the Licensed Material automatically + receives an offer from the Licensor to exercise the + Licensed Rights under the terms and conditions of this + Public License. + + 2. No downstream restrictions. You may not offer or impose + any additional or different terms or conditions on, or + apply any Effective Technological Measures to, the + Licensed Material if doing so restricts exercise of the + Licensed Rights by any recipient of the Licensed + Material. + + 6. No endorsement. Nothing in this Public License constitutes or + may be construed as permission to assert or imply that You + are, or that Your use of the Licensed Material is, connected + with, or sponsored, endorsed, or granted official status by, + the Licensor or others designated to receive attribution as + provided in Section 3(1)(i)(a)(a). + +2. Other rights. + + 1. Moral rights, such as the right of integrity, are not + licensed under this Public License, nor are publicity, + privacy, and/or other similar personality rights; however, to + the extent possible, the Licensor waives and/or agrees not to + assert any such rights held by the Licensor to the limited + extent necessary to allow You to exercise the Licensed + Rights, but not otherwise. + + 2. Patent and trademark rights are not licensed under this + Public License. + + 3. To the extent possible, the Licensor waives any right to + collect royalties from You for the exercise of the Licensed + Rights, whether directly or through a collecting society + under any voluntary or waivable statutory or compulsory + licensing scheme. In all other cases the Licensor expressly + reserves any right to collect such royalties. + + +### Section 3 -- License Conditions. + +Your exercise of the Licensed Rights is expressly made subject to the +following conditions. + +1. Attribution. + + 1. If You Share the Licensed Material (including in modified + form), You must: + + 1. retain the following if it is supplied by the Licensor + with the Licensed Material: + + 1. identification of the creator(s) of the Licensed + Material and any others designated to receive + attribution, in any reasonable manner requested by + the Licensor (including by pseudonym if + designated); + + 2. a copyright notice; + + 3. a notice that refers to this Public License; + + 4. a notice that refers to the disclaimer of + warranties; + + 5. a URI or hyperlink to the Licensed Material to the + extent reasonably practicable; + + b. indicate if You modified the Licensed Material and + retain an indication of any previous modifications; and + + c. indicate the Licensed Material is licensed under this + Public License, and include the text of, or the URI or + hyperlink to, this Public License. + +2. You may satisfy the conditions in Section 3(1)(i) in any + reasonable manner based on the medium, means, and context in + which You Share the Licensed Material. For example, it may be + reasonable to satisfy the conditions by providing a URI or + hyperlink to a resource that includes the required + information. + +3. If requested by the Licensor, You must remove any of the + information required by Section 3(1)(i)(a) to the extent + reasonably practicable. + +4. If You Share Adapted Material You produce, the Adapter's + License You apply must not prevent recipients of the Adapted + Material from complying with this Public License. + + +### Section 4 -- Sui Generis Database Rights. + +Where the Licensed Rights include Sui Generis Database Rights that +apply to Your use of the Licensed Material: + +1. for the avoidance of doubt, Section 2(a)(1) grants You the right + to extract, reuse, reproduce, and Share all or a substantial + portion of the contents of the database; + +2. if You include all or a substantial portion of the database + contents in a database in which You have Sui Generis Database + Rights, then the database in which You have Sui Generis Database + Rights (but not its individual contents) is Adapted Material; and + +3. You must comply with the conditions in Section 3(a) if You Share + all or a substantial portion of the contents of the database. + +For the avoidance of doubt, this Section 4 supplements and does not +replace Your obligations under this Public License where the Licensed +Rights include other Copyright and Similar Rights. + + +### Section 5 -- Disclaimer of Warranties and Limitation of Liability. + +1. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE + EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS + AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF + ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, + IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, + WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR + PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, + ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT + KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT + ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. + +2. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE + TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, + NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, + INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, + COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR + USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN + ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR + DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR + IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. + +3. The disclaimer of warranties and limitation of liability provided + above shall be interpreted in a manner that, to the extent + possible, most closely approximates an absolute disclaimer and + waiver of all liability. + + +### Section 6 -- Term and Termination. + +1. This Public License applies for the term of the Copyright and + Similar Rights licensed here. However, if You fail to comply with + this Public License, then Your rights under this Public License + terminate automatically. + +2. Where Your right to use the Licensed Material has terminated under + Section 6(1), it reinstates: + + 1. automatically as of the date the violation is cured, provided + it is cured within 30 days of Your discovery of the + violation; or + + 2. upon express reinstatement by the Licensor. + + For the avoidance of doubt, this Section 6(b) does not affect any + right the Licensor may have to seek remedies for Your violations + of this Public License. + +3. For the avoidance of doubt, the Licensor may also offer the + Licensed Material under separate terms or conditions or stop + distributing the Licensed Material at any time; however, doing so + will not terminate this Public License. + +d. Sections 1, 5, 6, 7, and 8 survive termination of this Public + License. + + +### Section 7 -- Other Terms and Conditions. + +1. The Licensor shall not be bound by any additional or different + terms or conditions communicated by You unless expressly agreed. + +2. Any arrangements, understandings, or agreements regarding the + Licensed Material not stated herein are separate from and + independent of the terms and conditions of this Public License. + + +### Section 8 -- Interpretation. + +1. For the avoidance of doubt, this Public License does not, and + shall not be interpreted to, reduce, limit, restrict, or impose + conditions on any use of the Licensed Material that could lawfully + be made without permission under this Public License. + +2. To the extent possible, if any provision of this Public License is + deemed unenforceable, it shall be automatically reformed to the + minimum extent necessary to make it enforceable. If the provision + cannot be reformed, it shall be severed from this Public License + without affecting the enforceability of the remaining terms and + conditions. + +3. No term or condition of this Public License will be waived and no + failure to comply consented to unless expressly agreed to by the + Licensor. + +4. Nothing in this Public License constitutes or may be interpreted + as a limitation upon, or waiver of, any privileges and immunities + that apply to the Licensor or You, including from the legal + processes of any jurisdiction or authority. + +----------------------------------------------------------------------- + +Creative Commons is not a party to its public +licenses. Notwithstanding, Creative Commons may elect to apply one of +its public licenses to material it publishes and in those instances +will be considered the “Licensor.” The text of the Creative Commons +public licenses is dedicated to the public domain under the CC0 Public +Domain Dedication. Except for the limited purpose of indicating that +material is shared under a Creative Commons public license or as +otherwise permitted by the Creative Commons policies published at +creativecommons.org/policies, Creative Commons does not authorize the +use of the trademark "Creative Commons" or any other trademark or logo +of Creative Commons without its prior written consent including, +without limitation, in connection with any unauthorized modifications +to any of its public licenses or any other arrangements, +understandings, or agreements concerning use of licensed material. For +the avoidance of doubt, this paragraph does not form part of the +public licenses. + +Creative Commons may be contacted at creativecommons.org. diff --git a/README.md b/README.md new file mode 100644 index 0000000..8d98131 --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +Final Reality +============= + +![http://creativecommons.org/licenses/by/4.0/](https://i.creativecommons.org/l/by/4.0/88x31.png) + +This work is licensed under a +[Creative Commons Attribution 4.0 International License](http://creativecommons.org/licenses/by/4.0/) + +Context +------- + +This project's goal is to create a (simplified) clone of _Final Fantasy_'s combat, a game developed +by [_Square Enix_](https://www.square-enix.com) +Broadly speaking for the combat the player has a group of characters to control and a group of +enemies controlled by the computer. + +--- + +**The rest of the documentation is left for the users of this template to complete** diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..40b80e6 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,41 @@ +@file:Suppress("SpellCheckingInspection") + +plugins { + java + id("application") + id("org.openjfx.javafxplugin") version "0.0.8" + id("jacoco") +} + +application { + mainClassName = "$moduleName/com.github.cc3002.finalreality.gui.FinalReality" +} + +group = "com.github.cc3002" +version = "1.0-RELEASE" + +repositories { + mavenCentral() +} + +dependencies { + implementation(group = "org.openjfx", name = "javafx", version = "14-ea+6", ext = "pom") + implementation("org.jetbrains:annotations:19.0.0") + testImplementation(group = "org.junit.jupiter", name = "junit-jupiter-api", + version = "5.1.0") + testRuntimeOnly(group = "org.junit.jupiter", name = "junit-jupiter-engine", + version = "5.1.0") +} + +javafx { + version = "14-ea+6" + modules = mutableListOf("javafx.controls") +} + +configure { + sourceCompatibility = JavaVersion.VERSION_11 +} + +tasks.named("test") { + useJUnitPlatform() +} \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..62d4c05 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..a4b4429 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..fbd7c51 --- /dev/null +++ b/gradlew @@ -0,0 +1,185 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# 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 +# +# https://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. +# + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=`expr $i + 1` + done + case $i in + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=`save "$@"` + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..5093609 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,104 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..e7ceff2 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,2 @@ +rootProject.name = "final-reality" + diff --git a/src/main/java/com/github/cc3002/TimerExample.java b/src/main/java/com/github/cc3002/TimerExample.java new file mode 100644 index 0000000..d534814 --- /dev/null +++ b/src/main/java/com/github/cc3002/TimerExample.java @@ -0,0 +1,36 @@ +package com.github.cc3002; + +import com.github.cc3002.finalreality.model.character.ICharacter; +import com.github.cc3002.finalreality.model.character.player.CharacterClass; +import com.github.cc3002.finalreality.model.character.player.PlayerCharacter; +import com.github.cc3002.finalreality.model.weapon.Weapon; +import com.github.cc3002.finalreality.model.weapon.WeaponType; +import java.util.Random; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; + +/** + * @author Ignacio Slater Muñoz. + */ +public class TimerExample { + + public static void main(String[] args) throws InterruptedException { + BlockingQueue queue = new LinkedBlockingQueue<>(); + Random rng = new Random(); + for (int i = 0; i < 10; i++) { + // Gives a random speed to each character to generate different waiting times + var weapon = new Weapon("", 0, rng.nextInt(50), WeaponType.KNIFE); + var character = new PlayerCharacter(Integer.toString(i), queue, + CharacterClass.THIEF); + character.equip(weapon); + character.waitTurn(); + } + // Waits for 6 seconds to ensure that all characters have finished waiting + Thread.sleep(6000); + while (!queue.isEmpty()) { + // Pops and prints the names of the characters of the queue to illustrate the turns + // order + System.out.println(queue.poll().getName()); + } + } +} diff --git a/src/main/java/com/github/cc3002/finalreality/gui/FinalReality.java b/src/main/java/com/github/cc3002/finalreality/gui/FinalReality.java new file mode 100644 index 0000000..91de482 --- /dev/null +++ b/src/main/java/com/github/cc3002/finalreality/gui/FinalReality.java @@ -0,0 +1,36 @@ +package com.github.cc3002.finalreality.gui; + +import javafx.application.Application; +import javafx.geometry.Pos; +import javafx.scene.Scene; +import javafx.scene.control.Label; +import javafx.stage.Stage; + +/** + * Main entry point for the application. + *

+ * + * + * @author Ignacio Slater Muñoz. + * @author + */ +public class FinalReality extends Application { + + public static void main(String[] args) { + launch(args); + } + + @Override + public void start(Stage primaryStage) { + primaryStage.setTitle("Final reality"); + + Label label = new Label("This will be a game sometime"); + label.setAlignment(Pos.CENTER); + + // This sets the size of the Scene to be 400px wide, 200px high + Scene scene = new Scene(label, 400, 200); + primaryStage.setScene(scene); + + primaryStage.show(); + } +} \ No newline at end of file diff --git a/src/main/java/com/github/cc3002/finalreality/model/character/AbstractCharacter.java b/src/main/java/com/github/cc3002/finalreality/model/character/AbstractCharacter.java new file mode 100644 index 0000000..671da1e --- /dev/null +++ b/src/main/java/com/github/cc3002/finalreality/model/character/AbstractCharacter.java @@ -0,0 +1,75 @@ +package com.github.cc3002.finalreality.model.character; + +import com.github.cc3002.finalreality.model.character.player.CharacterClass; +import com.github.cc3002.finalreality.model.character.player.PlayerCharacter; +import com.github.cc3002.finalreality.model.weapon.Weapon; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import org.jetbrains.annotations.NotNull; + +/** + * An abstract class that holds the common behaviour of all the characters in the game. + * + * @author Ignacio Slater Muñoz. + * @author + */ +public abstract class AbstractCharacter implements ICharacter { + + protected final BlockingQueue turnsQueue; + protected final String name; + private final CharacterClass characterClass; + private Weapon equippedWeapon = null; + private ScheduledExecutorService scheduledExecutor; + + protected AbstractCharacter(@NotNull BlockingQueue turnsQueue, + @NotNull String name, CharacterClass characterClass) { + this.turnsQueue = turnsQueue; + this.name = name; + this.characterClass = characterClass; + } + + @Override + public void waitTurn() { + scheduledExecutor = Executors.newSingleThreadScheduledExecutor(); + if (this instanceof PlayerCharacter) { + scheduledExecutor + .schedule(this::addToQueue, equippedWeapon.getWeight() / 10, TimeUnit.SECONDS); + } else { + var enemy = (Enemy) this; + scheduledExecutor + .schedule(this::addToQueue, enemy.getWeight() / 10, TimeUnit.SECONDS); + } + } + + /** + * Adds this character to the turns queue. + */ + private void addToQueue() { + turnsQueue.add(this); + scheduledExecutor.shutdown(); + } + + @Override + public String getName() { + return name; + } + + @Override + public void equip(Weapon weapon) { + if (this instanceof PlayerCharacter) { + this.equippedWeapon = weapon; + } + } + + @Override + public Weapon getEquippedWeapon() { + return equippedWeapon; + } + + @Override + public CharacterClass getCharacterClass() { + return characterClass; + } +} diff --git a/src/main/java/com/github/cc3002/finalreality/model/character/Enemy.java b/src/main/java/com/github/cc3002/finalreality/model/character/Enemy.java new file mode 100644 index 0000000..e32598c --- /dev/null +++ b/src/main/java/com/github/cc3002/finalreality/model/character/Enemy.java @@ -0,0 +1,51 @@ +package com.github.cc3002.finalreality.model.character; + +import com.github.cc3002.finalreality.model.character.player.CharacterClass; +import java.util.Objects; +import java.util.concurrent.BlockingQueue; +import org.jetbrains.annotations.NotNull; + +/** + * A class that holds all the information of a single enemy of the game. + * + * @author Ignacio Slater Muñoz + * @author + */ +public class Enemy extends AbstractCharacter { + + private final int weight; + + /** + * Creates a new enemy with a name, a weight and the queue with the characters ready to + * play. + */ + public Enemy(@NotNull final String name, final int weight, + @NotNull final BlockingQueue turnsQueue) { + super(turnsQueue, name, CharacterClass.ENEMY); + this.weight = weight; + } + + /** + * Returns the weight of this enemy. + */ + public int getWeight() { + return weight; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if (!(o instanceof Enemy)) { + return false; + } + final Enemy enemy = (Enemy) o; + return getWeight() == enemy.getWeight(); + } + + @Override + public int hashCode() { + return Objects.hash(getWeight()); + } +} diff --git a/src/main/java/com/github/cc3002/finalreality/model/character/ICharacter.java b/src/main/java/com/github/cc3002/finalreality/model/character/ICharacter.java new file mode 100644 index 0000000..f76b08f --- /dev/null +++ b/src/main/java/com/github/cc3002/finalreality/model/character/ICharacter.java @@ -0,0 +1,40 @@ +package com.github.cc3002.finalreality.model.character; + +import com.github.cc3002.finalreality.model.character.player.CharacterClass; +import com.github.cc3002.finalreality.model.weapon.Weapon; + +/** + * This represents a character from the game. + * A character can be controlled by the player or by the CPU (an enemy). + * + * @author Ignacio Slater Muñoz. + * @author + */ +public interface ICharacter { + + /** + * Sets a scheduled executor to make this character (thread) wait for {@code speed / 10} + * seconds before adding the character to the queue. + */ + void waitTurn(); + + /** + * Returns this character's name. + */ + String getName(); + + /** + * Equips a weapon to the character. + */ + void equip(Weapon weapon); + + /** + * Return this character's equipped weapon. + */ + Weapon getEquippedWeapon(); + + /** + * Returns this character's class. + */ + CharacterClass getCharacterClass(); +} diff --git a/src/main/java/com/github/cc3002/finalreality/model/character/player/CharacterClass.java b/src/main/java/com/github/cc3002/finalreality/model/character/player/CharacterClass.java new file mode 100644 index 0000000..8f28f26 --- /dev/null +++ b/src/main/java/com/github/cc3002/finalreality/model/character/player/CharacterClass.java @@ -0,0 +1,11 @@ +package com.github.cc3002.finalreality.model.character.player; + +/** + * Enumeration of the classes a player character may have. + * + * @author Ignacio Slater Muñoz. + * @author + */ +public enum CharacterClass { + KNIGHT, ENGINEER, THIEF, BLACK_MAGE, WHITE_MAGE, ENEMY +} diff --git a/src/main/java/com/github/cc3002/finalreality/model/character/player/PlayerCharacter.java b/src/main/java/com/github/cc3002/finalreality/model/character/player/PlayerCharacter.java new file mode 100644 index 0000000..3985abe --- /dev/null +++ b/src/main/java/com/github/cc3002/finalreality/model/character/player/PlayerCharacter.java @@ -0,0 +1,50 @@ +package com.github.cc3002.finalreality.model.character.player; + +import com.github.cc3002.finalreality.model.character.AbstractCharacter; +import com.github.cc3002.finalreality.model.character.ICharacter; +import java.util.Objects; +import java.util.concurrent.BlockingQueue; +import org.jetbrains.annotations.NotNull; + +/** + * A class that holds all the information of a single character of the game. + * + * @author Ignacio Slater Muñoz. + * @author + */ +public class PlayerCharacter extends AbstractCharacter { + + /** + * Creates a new character. + * + * @param name + * the character's name + * @param turnsQueue + * the queue with the characters waiting for their turn + * @param characterClass + * the class of this character + */ + public PlayerCharacter(@NotNull String name, + @NotNull BlockingQueue turnsQueue, + final CharacterClass characterClass) { + super(turnsQueue, name, characterClass); + } + + @Override + public int hashCode() { + return Objects.hash(getCharacterClass()); + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if (!(o instanceof PlayerCharacter)) { + return false; + } + final PlayerCharacter that = (PlayerCharacter) o; + return getCharacterClass() == that.getCharacterClass() + && getName().equals(that.getName()); + } +} diff --git a/src/main/java/com/github/cc3002/finalreality/model/weapon/Weapon.java b/src/main/java/com/github/cc3002/finalreality/model/weapon/Weapon.java new file mode 100644 index 0000000..dd2c93f --- /dev/null +++ b/src/main/java/com/github/cc3002/finalreality/model/weapon/Weapon.java @@ -0,0 +1,66 @@ +package com.github.cc3002.finalreality.model.weapon; + +import java.util.Objects; + +/** + * A class that holds all the information of a weapon. + * + * @author Ignacio Slater Muñoz. + * @author + */ +public class Weapon { + + private final String name; + private final int damage; + private final int weight; + private final WeaponType type; + + /** + * Creates a weapon with a name, a base damage, speed and it's type. + * + * @see WeaponType + */ + public Weapon(final String name, final int damage, final int weight, + final WeaponType type) { + this.name = name; + this.damage = damage; + this.weight = weight; + this.type = type; + } + + private String getName() { + return name; + } + + private int getDamage() { + return damage; + } + + public int getWeight() { + return weight; + } + + private WeaponType getType() { + return type; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if (!(o instanceof Weapon)) { + return false; + } + final Weapon weapon = (Weapon) o; + return getDamage() == weapon.getDamage() && + getWeight() == weapon.getWeight() && + getName().equals(weapon.getName()) && + getType() == weapon.getType(); + } + + @Override + public int hashCode() { + return Objects.hash(getName(), getDamage(), getWeight(), getType()); + } +} diff --git a/src/main/java/com/github/cc3002/finalreality/model/weapon/WeaponType.java b/src/main/java/com/github/cc3002/finalreality/model/weapon/WeaponType.java new file mode 100644 index 0000000..1785d95 --- /dev/null +++ b/src/main/java/com/github/cc3002/finalreality/model/weapon/WeaponType.java @@ -0,0 +1,11 @@ +package com.github.cc3002.finalreality.model.weapon; + +/** + * Enumeration of all the weapon types. + * + * @author Ignacio Slater Muñoz. + * @author + */ +public enum WeaponType { + SWORD, AXE, KNIFE, STAFF, BOW +} diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java new file mode 100644 index 0000000..edd4fbb --- /dev/null +++ b/src/main/java/module-info.java @@ -0,0 +1,5 @@ +module finalreality.main { + exports com.github.cc3002.finalreality.gui; + requires javafx.controls; + requires org.jetbrains.annotations; +} \ No newline at end of file diff --git a/src/test/java/com/github/cc3002/finalreality/model/character/AbstractCharacterTest.java b/src/test/java/com/github/cc3002/finalreality/model/character/AbstractCharacterTest.java new file mode 100644 index 0000000..5ecd285 --- /dev/null +++ b/src/test/java/com/github/cc3002/finalreality/model/character/AbstractCharacterTest.java @@ -0,0 +1,69 @@ +package com.github.cc3002.finalreality.model.character; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; + +import com.github.cc3002.finalreality.model.weapon.Weapon; +import com.github.cc3002.finalreality.model.weapon.WeaponType; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +/** + * Abstract class containing the common tests for all the types of characters. + * + * @author Ignacio Slater Muñoz. + * @author + * @see ICharacter + */ +public abstract class AbstractCharacterTest { + + protected BlockingQueue turns; + protected List testCharacters; + protected Weapon testWeapon; + + /** + * Checks that the character waits the appropriate amount of time for it's turn. + */ + @Test + void waitTurnTest() { + Assertions.assertTrue(turns.isEmpty()); + tryToEquip(testCharacters.get(0)); + testCharacters.get(0).waitTurn(); + try { + // Thread.sleep is not accurate so this values may be changed to adjust the + // acceptable error margin. + // We're testing that the character waits approximately 1 second. + Thread.sleep(900); + Assertions.assertEquals(0, turns.size()); + Thread.sleep(200); + Assertions.assertEquals(1, turns.size()); + Assertions.assertEquals(testCharacters.get(0), turns.peek()); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + private void tryToEquip(ICharacter character) { + character.equip(testWeapon); + } + + protected void checkConstruction(final ICharacter expectedCharacter, + final ICharacter testEqualCharacter, + final ICharacter sameClassDifferentCharacter, + final ICharacter differentClassCharacter) { + assertEquals(expectedCharacter, testEqualCharacter); + assertNotEquals(sameClassDifferentCharacter, testEqualCharacter); + assertNotEquals(testEqualCharacter, differentClassCharacter); + assertEquals(expectedCharacter.hashCode(), testEqualCharacter.hashCode()); + } + + protected void basicSetUp() { + turns = new LinkedBlockingQueue<>(); + testWeapon = new Weapon("Test", 15, 10, WeaponType.AXE); + testCharacters = new ArrayList<>(); + } +} diff --git a/src/test/java/com/github/cc3002/finalreality/model/character/EnemyTest.java b/src/test/java/com/github/cc3002/finalreality/model/character/EnemyTest.java new file mode 100644 index 0000000..f39345f --- /dev/null +++ b/src/test/java/com/github/cc3002/finalreality/model/character/EnemyTest.java @@ -0,0 +1,25 @@ +package com.github.cc3002.finalreality.model.character; + +import com.github.cc3002.finalreality.model.character.player.CharacterClass; +import com.github.cc3002.finalreality.model.character.player.PlayerCharacter; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +class EnemyTest extends AbstractCharacterTest { + + private static final String ENEMY_NAME = "Goblin"; + + @BeforeEach + void setUp() { + basicSetUp(); + testCharacters.add(new Enemy(ENEMY_NAME, 10, turns)); + } + + @Test + void constructorTest() { + checkConstruction(new Enemy(ENEMY_NAME, 10, turns), + testCharacters.get(0), + new Enemy(ENEMY_NAME, 11, turns), + new PlayerCharacter(ENEMY_NAME, turns, CharacterClass.THIEF)); + } +} \ No newline at end of file diff --git a/src/test/java/com/github/cc3002/finalreality/model/character/PlayerCharacterTest.java b/src/test/java/com/github/cc3002/finalreality/model/character/PlayerCharacterTest.java new file mode 100644 index 0000000..31f7e2b --- /dev/null +++ b/src/test/java/com/github/cc3002/finalreality/model/character/PlayerCharacterTest.java @@ -0,0 +1,82 @@ +package com.github.cc3002.finalreality.model.character; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + +import com.github.cc3002.finalreality.model.character.player.CharacterClass; +import com.github.cc3002.finalreality.model.character.player.PlayerCharacter; +import java.util.EnumMap; +import java.util.Map; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +/** + * Set of tests for the {@code GameCharacter} class. + * + * @author Ignacio Slater Muñoz. + * @author + * @see PlayerCharacter + */ +class PlayerCharacterTest extends AbstractCharacterTest { + + private static final String BLACK_MAGE_NAME = "Vivi"; + private static final String KNIGHT_NAME = "Adelbert"; + private static final String WHITE_MAGE_NAME = "Eiko"; + private static final String ENGINEER_NAME = "Cid"; + private static final String THIEF_NAME = "Zidane"; + private Map characterNames; + + /** + * Setup method. + * Creates a new character named Vivi with 10 speed and links it to a turn queue. + */ + @BeforeEach + void setUp() { + super.basicSetUp(); + + characterNames = new EnumMap<>(CharacterClass.class); + characterNames.put(CharacterClass.BLACK_MAGE, BLACK_MAGE_NAME); + characterNames.put(CharacterClass.KNIGHT, KNIGHT_NAME); + characterNames.put(CharacterClass.WHITE_MAGE, WHITE_MAGE_NAME); + characterNames.put(CharacterClass.ENGINEER, ENGINEER_NAME); + characterNames.put(CharacterClass.THIEF, THIEF_NAME); + + for (var characterClass : + characterNames.keySet()) { + testCharacters.add( + new PlayerCharacter(characterNames.get(characterClass), turns, characterClass)); + } + } + + /** + * Checks that the class' constructor and equals method works properly. + */ + @Test + void constructorTest() { + var enemy = new Enemy("Enemy", 10, turns); + for (var character : + testCharacters) { + var characterClass = character.getCharacterClass(); + var characterName = characterNames.get(characterClass); + checkConstruction(new PlayerCharacter(characterName, turns, characterClass), + character, + new PlayerCharacter("Test", turns, characterClass), + new PlayerCharacter(characterName, turns, + characterClass == CharacterClass.THIEF ? CharacterClass.BLACK_MAGE + : CharacterClass.THIEF)); + assertNotEquals(character, enemy); + } + + } + + @Test + void equipWeaponTest() { + for (var character : + testCharacters) { + assertNull(character.getEquippedWeapon()); + character.equip(testWeapon); + assertEquals(testWeapon, character.getEquippedWeapon()); + } + } +} diff --git a/src/test/java/com/github/cc3002/finalreality/model/weapon/WeaponTest.java b/src/test/java/com/github/cc3002/finalreality/model/weapon/WeaponTest.java new file mode 100644 index 0000000..f33301b --- /dev/null +++ b/src/test/java/com/github/cc3002/finalreality/model/weapon/WeaponTest.java @@ -0,0 +1,52 @@ +package com.github.cc3002.finalreality.model.weapon; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +class WeaponTest { + + private static final String AXE_NAME = "Test Axe"; + private static final String STAFF_NAME = "Test Staff"; + private static final String SWORD_NAME = "Test Sword"; + private static final String BOW_NAME = "Test Bow"; + private static final String KNIFE_NAME = "Test Knife"; + private static final int DAMAGE = 15; + private static final int SPEED = 10; + + private Weapon testAxe; + private Weapon testStaff; + private Weapon testSword; + private Weapon testBow; + private Weapon testKnife; + + @BeforeEach + void setUp() { + testAxe = new Weapon(AXE_NAME, DAMAGE, SPEED, WeaponType.AXE); + testStaff = new Weapon(STAFF_NAME, DAMAGE, SPEED, WeaponType.STAFF); + testSword = new Weapon(SWORD_NAME, DAMAGE, SPEED, WeaponType.SWORD); + testBow = new Weapon(BOW_NAME, DAMAGE, SPEED, WeaponType.BOW); + testKnife = new Weapon(KNIFE_NAME, DAMAGE, SPEED, WeaponType.KNIFE); + } + + @Test + void constructorTest() { + var expectedAxe = new Weapon(AXE_NAME, DAMAGE, SPEED, WeaponType.AXE); + var expectedStaff = new Weapon(STAFF_NAME, DAMAGE, SPEED, WeaponType.STAFF); + var expectedSword = new Weapon(SWORD_NAME, DAMAGE, SPEED, WeaponType.SWORD); + var expectedBow = new Weapon(BOW_NAME, DAMAGE, SPEED, WeaponType.BOW); + var expectedKnife = new Weapon(KNIFE_NAME, DAMAGE, SPEED, WeaponType.KNIFE); + + assertEquals(expectedAxe, testAxe); + assertEquals(expectedAxe.hashCode(), testAxe.hashCode()); + assertEquals(expectedStaff, testStaff); + assertEquals(expectedStaff.hashCode(), testStaff.hashCode()); + assertEquals(expectedSword, testSword); + assertEquals(expectedSword.hashCode(), testSword.hashCode()); + assertEquals(expectedBow, testBow); + assertEquals(expectedBow.hashCode(), testBow.hashCode()); + assertEquals(expectedKnife, testKnife); + assertEquals(expectedKnife.hashCode(), testKnife.hashCode()); + } +} \ No newline at end of file