Initial setup of project.
|
@ -0,0 +1 @@
|
|||
bin
|
|
@ -0,0 +1,29 @@
|
|||
== Current Developers ==
|
||||
* Dorian Pula
|
||||
** Founder, lead developer, project management, documentation & core programming.
|
||||
|
||||
== Past Developers ==
|
||||
* Chris Bellini
|
||||
** Game engine data objects, XML settings & project management.
|
||||
** Versions 0.0-0.1
|
||||
|
||||
* Daniel D'Alimonte (skwirl)
|
||||
** Code clean-up, refactoring, documentation & file releases.
|
||||
** Versions 0.0-0.1
|
||||
|
||||
* Ross Etchells
|
||||
** Game engine logic and progressing.
|
||||
** Versions 0.0-0.1
|
||||
|
||||
* Rras Lekone
|
||||
** Console UI (jCurses)
|
||||
** Versions 0.0
|
||||
|
||||
* Brinick Simmons
|
||||
** Core programming, XML settings and processing.
|
||||
** Versions 0.0-0.1
|
||||
|
||||
== Inspiration ==
|
||||
* Nick Nolfi
|
||||
** Creator of the Chubby Checkers project and assignment.
|
||||
** Inspiration for Civilization Checkers and justCheckers.
|
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.justcheckers.android"
|
||||
android:versionCode="1"
|
||||
android:versionName="0.2">
|
||||
<application android:icon="@drawable/icon" android:label="@string/app_name">
|
||||
<activity android:name=".MenuActivity"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name=".GameActivity"
|
||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" />
|
||||
<activity android:name=".InfoActivity"
|
||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" />
|
||||
<activity android:name=".SettingsActivity"
|
||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" />
|
||||
</application>
|
||||
<uses-sdk android:minSdkVersion="7" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
</manifest>
|
|
@ -0,0 +1,5 @@
|
|||
== Bugs in JustCheckers 0.1 ==
|
||||
* Artifacts of black left behind if the user tries to drag a piece of the right
|
||||
or bottom side of the board and then brings the dragged piece back on the board.
|
||||
|
||||
* Spits out tons of background data that ought to be visible in debug mode.
|
|
@ -0,0 +1,674 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
|
@ -0,0 +1,13 @@
|
|||
== Version 0.1.1 (upcoming release) ==
|
||||
* Cleaning up code for license reasons.
|
||||
* Improved Ant build automation.
|
||||
* Relicensed on software to use the GPL 3.0 license instead of the GPL 2.0.
|
||||
|
||||
== Version 0.1.0 (2005-01-07) ==
|
||||
* Fixed up build file.
|
||||
* Working single player game.
|
||||
|
||||
== Pre-Version 0.0.7-20040402 ==
|
||||
* Changed the directory and build structure.
|
||||
* Updated the Documentation.
|
||||
* Added GNU standard docs in the root directory.
|
|
@ -0,0 +1,14 @@
|
|||
== What is justCheckers? ==
|
||||
justCheckers is an open source advanced checkers game built using Java. The aim
|
||||
of the project is to create a checkers game that:
|
||||
|
||||
* handles skins and themes
|
||||
* handles multimedia
|
||||
* allows for network games
|
||||
* contains a powerful yet fun computer opponent
|
||||
* handles different checker rules
|
||||
|
||||
Version 0.1 lets you play a game of checkers (standard American rules) against
|
||||
another player on the same computer.
|
||||
|
||||
Project homepage: http://justcheckers.sourceforge.net/
|
|
@ -0,0 +1,79 @@
|
|||
/* AUTO-GENERATED FILE. DO NOT MODIFY.
|
||||
*
|
||||
* This class was automatically generated by the
|
||||
* aapt tool from the resource data it found. It
|
||||
* should not be modified by hand.
|
||||
*/
|
||||
|
||||
package org.justcheckers.android;
|
||||
|
||||
public final class R {
|
||||
public static final class array {
|
||||
public static final int checkers_variants=0x7f060000;
|
||||
}
|
||||
public static final class attr {
|
||||
}
|
||||
public static final class drawable {
|
||||
public static final int attack_king=0x7f020000;
|
||||
public static final int attack_pawn=0x7f020001;
|
||||
public static final int backdrop=0x7f020002;
|
||||
public static final int defend_king=0x7f020003;
|
||||
public static final int defend_pawn=0x7f020004;
|
||||
public static final int icon=0x7f020005;
|
||||
public static final int idea=0x7f020006;
|
||||
public static final int logo=0x7f020007;
|
||||
public static final int non_play=0x7f020008;
|
||||
public static final int play=0x7f020009;
|
||||
public static final int splash=0x7f02000a;
|
||||
}
|
||||
public static final class id {
|
||||
public static final int about_us_button=0x7f070013;
|
||||
public static final int app_logo=0x7f070001;
|
||||
public static final int current_player_king=0x7f07000b;
|
||||
public static final int current_player_king_captured=0x7f07000c;
|
||||
public static final int current_player_label=0x7f07000a;
|
||||
public static final int current_player_pawn=0x7f07000d;
|
||||
public static final int current_player_pawn_captured=0x7f07000e;
|
||||
public static final int game_board=0x7f070002;
|
||||
public static final int game_button=0x7f070011;
|
||||
public static final int info_text=0x7f07000f;
|
||||
public static final int license_button=0x7f070014;
|
||||
public static final int menu_table=0x7f070010;
|
||||
public static final int opponent_captured_pieces=0x7f070009;
|
||||
public static final int opposing_player_king=0x7f070005;
|
||||
public static final int opposing_player_king_captured=0x7f070006;
|
||||
public static final int opposing_player_label=0x7f070004;
|
||||
public static final int opposing_player_pawn=0x7f070007;
|
||||
public static final int opposing_player_pawn_captured=0x7f070008;
|
||||
public static final int player_captured_pieces=0x7f070003;
|
||||
public static final int quit_button=0x7f070016;
|
||||
public static final int screen_root=0x7f070000;
|
||||
public static final int settings_button=0x7f070015;
|
||||
public static final int website_button=0x7f070012;
|
||||
}
|
||||
public static final class layout {
|
||||
public static final int game_screen_landscape=0x7f030000;
|
||||
public static final int game_screen_portrait=0x7f030001;
|
||||
public static final int info_screen=0x7f030002;
|
||||
public static final int main_menu=0x7f030003;
|
||||
public static final int settings_screen=0x7f030004;
|
||||
}
|
||||
public static final class raw {
|
||||
public static final int gpl_3_license=0x7f040000;
|
||||
public static final int readme=0x7f040001;
|
||||
}
|
||||
public static final class string {
|
||||
public static final int app_name=0x7f050000;
|
||||
public static final int app_version=0x7f050001;
|
||||
public static final int caption_about_us=0x7f050003;
|
||||
public static final int caption_license=0x7f050004;
|
||||
public static final int caption_play_checkers=0x7f050005;
|
||||
public static final int caption_quit=0x7f050008;
|
||||
public static final int caption_settings=0x7f050006;
|
||||
public static final int caption_visit_us=0x7f050007;
|
||||
public static final int project_website=0x7f050002;
|
||||
public static final int template_capture_amounts=0x7f050009;
|
||||
public static final int template_current_player=0x7f05000a;
|
||||
public static final int template_opposing_player=0x7f05000b;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
-optimizationpasses 5
|
||||
-dontusemixedcaseclassnames
|
||||
-dontskipnonpubliclibraryclasses
|
||||
-dontpreverify
|
||||
-verbose
|
||||
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
|
||||
|
||||
-keep public class * extends android.app.Activity
|
||||
-keep public class * extends android.app.Application
|
||||
-keep public class * extends android.app.Service
|
||||
-keep public class * extends android.content.BroadcastReceiver
|
||||
-keep public class * extends android.content.ContentProvider
|
||||
-keep public class com.android.vending.licensing.ILicensingService
|
||||
|
||||
-keepclasseswithmembernames class * {
|
||||
native <methods>;
|
||||
}
|
||||
|
||||
-keepclasseswithmembernames class * {
|
||||
public <init>(android.content.Context, android.util.AttributeSet);
|
||||
}
|
||||
|
||||
-keepclasseswithmembernames class * {
|
||||
public <init>(android.content.Context, android.util.AttributeSet, int);
|
||||
}
|
||||
|
||||
-keepclassmembers enum * {
|
||||
public static **[] values();
|
||||
public static ** valueOf(java.lang.String);
|
||||
}
|
||||
|
||||
-keep class * implements android.os.Parcelable {
|
||||
public static final android.os.Parcelable$Creator *;
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
# This file is automatically generated by Android Tools.
|
||||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||
#
|
||||
# This file must be checked in Version Control Systems.
|
||||
#
|
||||
# To customize properties used by the Ant build system use,
|
||||
# "ant.properties", and override values to adapt the script to your
|
||||
# project structure.
|
||||
|
||||
# Project target.
|
||||
target=android-7
|
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 66 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 9.8 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 2.5 KiB |
|
@ -0,0 +1,405 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/screen_root"
|
||||
android:background="@drawable/backdrop"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
|
||||
<ImageView android:id="@+id/app_logo"
|
||||
android:background="#DDFFFFFF"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="5dip"
|
||||
android:src="@drawable/logo" />
|
||||
|
||||
|
||||
<TableLayout android:id="@+id/game_board"
|
||||
android:layout_below="@id/app_logo"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dip">
|
||||
|
||||
<TableRow android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
|
||||
</TableRow>
|
||||
<TableRow android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
|
||||
</TableRow>
|
||||
<TableRow android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
|
||||
</TableRow>
|
||||
<TableRow android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
|
||||
</TableRow>
|
||||
<TableRow android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
|
||||
</TableRow>
|
||||
<TableRow android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
|
||||
</TableRow>
|
||||
<TableRow android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
|
||||
</TableRow>
|
||||
<TableRow android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
</TableRow>
|
||||
</TableLayout>
|
||||
|
||||
<TableLayout android:id="@+id/player_captured_pieces"
|
||||
android:background="#DDFFFFFF"
|
||||
android:layout_below="@+id/app_logo"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dip"
|
||||
android:layout_toRightOf="@+id/game_board"
|
||||
android:layout_width="wrap_content">
|
||||
|
||||
<TableRow android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView android:id="@+id/opposing_player_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="5dip"
|
||||
android:text="@string/template_opposing_player"
|
||||
android:textColor="#FF000000"/>
|
||||
|
||||
<ImageView android:id="@+id/opposing_player_king"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/defend_king" />
|
||||
|
||||
<TextView android:id="@+id/opposing_player_king_captured"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#FF000000"
|
||||
android:text="@string/template_capture_amounts" />
|
||||
|
||||
<ImageView android:id="@+id/opposing_player_pawn"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/defend_pawn" />
|
||||
|
||||
<TextView android:id="@+id/opposing_player_pawn_captured"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#FF000000"
|
||||
android:text="@string/template_capture_amounts" />
|
||||
|
||||
|
||||
</TableRow>
|
||||
</TableLayout>
|
||||
<TableLayout android:id="@+id/opponent_captured_pieces"
|
||||
android:background="#DDFFFFFF"
|
||||
android:layout_below="@id/player_captured_pieces"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dip"
|
||||
android:layout_toRightOf="@+id/game_board"
|
||||
android:layout_width="wrap_content">
|
||||
<TableRow
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView android:id="@+id/current_player_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/template_current_player"
|
||||
android:textColor="#FF000000" android:padding="5dip"/>
|
||||
|
||||
<ImageView android:id="@+id/current_player_king"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/attack_king" />
|
||||
|
||||
<TextView android:id="@+id/current_player_king_captured"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#FF000000"
|
||||
android:text="@string/template_capture_amounts" />
|
||||
|
||||
<ImageView android:id="@+id/current_player_pawn"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/attack_pawn" />
|
||||
|
||||
<TextView android:id="@+id/current_player_pawn_captured"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#FF000000"
|
||||
android:text="@string/template_capture_amounts" />
|
||||
|
||||
</TableRow>
|
||||
</TableLayout>
|
||||
|
||||
</RelativeLayout>
|
|
@ -0,0 +1,407 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/screen_root"
|
||||
android:background="@drawable/backdrop"
|
||||
android:gravity="center_horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
|
||||
<ImageView android:id="@+id/app_logo"
|
||||
android:background="#DDFFFFFF"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="5dip"
|
||||
android:src="@drawable/logo" />
|
||||
|
||||
<TableLayout android:id="@+id/game_board"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dip">
|
||||
|
||||
<TableRow android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
|
||||
</TableRow>
|
||||
<TableRow android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
|
||||
</TableRow>
|
||||
<TableRow android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
|
||||
</TableRow>
|
||||
<TableRow android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
|
||||
</TableRow>
|
||||
<TableRow android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
|
||||
</TableRow>
|
||||
<TableRow android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
|
||||
</TableRow>
|
||||
<TableRow android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
|
||||
</TableRow>
|
||||
<TableRow android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/play" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/non_play" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
</TableLayout>
|
||||
|
||||
<TableLayout android:id="@+id/player_captured_pieces"
|
||||
android:background="#DDFFFFFF"
|
||||
android:layout_below="@+id/game_board"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dip"
|
||||
android:layout_width="wrap_content">
|
||||
|
||||
<TableRow android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView android:id="@+id/opposing_player_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="5dip"
|
||||
android:text="@string/template_opposing_player"
|
||||
android:textColor="#FF000000"/>
|
||||
|
||||
<ImageView android:id="@+id/opposing_player_king"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/defend_king" />
|
||||
|
||||
<TextView android:id="@+id/opposing_player_king_captured"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#FF000000"
|
||||
android:text="@string/template_capture_amounts" />
|
||||
|
||||
<ImageView android:id="@+id/opposing_player_pawn"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/defend_pawn" />
|
||||
|
||||
<TextView android:id="@+id/opposing_player_pawn_captured"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#FF000000"
|
||||
android:text="@string/template_capture_amounts" />
|
||||
|
||||
|
||||
</TableRow>
|
||||
</TableLayout>
|
||||
<TableLayout android:id="@+id/opponent_captured_pieces"
|
||||
android:background="#DDFFFFFF"
|
||||
android:layout_below="@id/player_captured_pieces"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dip"
|
||||
android:layout_width="wrap_content">
|
||||
|
||||
<TableRow
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView android:id="@+id/current_player_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/template_current_player"
|
||||
android:textColor="#FF000000" android:padding="5dip"/>
|
||||
|
||||
<ImageView android:id="@+id/current_player_king"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/attack_king" />
|
||||
|
||||
<TextView android:id="@+id/current_player_king_captured"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#FF000000"
|
||||
android:text="@string/template_capture_amounts" />
|
||||
|
||||
<ImageView android:id="@+id/current_player_pawn"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/attack_pawn" />
|
||||
|
||||
<TextView android:id="@+id/current_player_pawn_captured"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#FF000000"
|
||||
android:text="@string/template_capture_amounts" />
|
||||
|
||||
</TableRow>
|
||||
</TableLayout>
|
||||
|
||||
</RelativeLayout>
|
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/screen_root"
|
||||
android:background="@drawable/backdrop"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView android:id="@+id/app_logo"
|
||||
android:background="#DDFFFFFF"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="5dip"
|
||||
android:src="@drawable/logo" />
|
||||
|
||||
<ScrollView
|
||||
android:layout_below="@+id/app_logo"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dip"
|
||||
android:layout_width="fill_parent">
|
||||
<LinearLayout
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="fill_parent">
|
||||
|
||||
<TextView android:id="@+id/info_text"
|
||||
android:background="#BBFFFFFF"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:padding="5dip"
|
||||
android:textColor="#FF000000" />
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
||||
</RelativeLayout>
|
|
@ -0,0 +1,70 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/screen_root"
|
||||
android:background="@drawable/backdrop"
|
||||
android:gravity="center_horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView android:id="@+id/app_logo"
|
||||
android:background="#DDFFFFFF"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="5dp"
|
||||
android:src="@drawable/logo"/>
|
||||
|
||||
<TableLayout android:id="@+id/menu_table"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="5dp">
|
||||
|
||||
<TableRow
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<Button android:id="@+id/game_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/caption_play_checkers" />
|
||||
<Button android:id="@+id/website_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/caption_visit_us" />
|
||||
|
||||
</TableRow>
|
||||
<TableRow
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
|
||||
<Button android:id="@+id/about_us_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/caption_about_us" />
|
||||
<Button android:id="@+id/license_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/caption_license" />
|
||||
|
||||
</TableRow>
|
||||
<TableRow
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<Button android:id="@+id/settings_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/caption_settings" />
|
||||
<Button android:id="@+id/quit_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/caption_quit" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
</TableLayout>
|
||||
|
||||
|
||||
</RelativeLayout>
|
|
@ -0,0 +1,38 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<PreferenceCategory
|
||||
android:title="Application Settings">
|
||||
|
||||
<CheckBoxPreference
|
||||
android:title="Start New Game on Startup"
|
||||
android:defaultValue="false"
|
||||
android:summary="Should the app automatically start a new game."
|
||||
android:key="startGameAtStartup" />
|
||||
|
||||
<!-- CheckBoxPreference
|
||||
android:title="Save Game on Exit"
|
||||
android:defaultValue="true"
|
||||
android:summary="Saves the game automatically when exiting the app."
|
||||
android:key="saveGameAtExit" /-->
|
||||
|
||||
</PreferenceCategory>
|
||||
<!-- PreferenceCategory
|
||||
android:title="Game Settings">
|
||||
|
||||
<CheckBoxPreference
|
||||
android:title="Ask What Variant to Play"
|
||||
android:defaultValue="true"
|
||||
android:summary="Asks what variant of checkers you want to play, for each new game."
|
||||
android:key="askVariantToPlay" />
|
||||
|
||||
<ListPreference
|
||||
android:title="Type of Checkers Game"
|
||||
android:summary="Should the app automatically start a new game."
|
||||
android:defaultValue="American/Standard"
|
||||
android:entries="@array/checkers_variants"
|
||||
android:entryValues="@array/checkers_variants"
|
||||
android:key="checkersVariant" />
|
||||
|
||||
</PreferenceCategory -->
|
||||
|
||||
</PreferenceScreen>
|
|
@ -0,0 +1,674 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
|
@ -0,0 +1,42 @@
|
|||
== What is justCheckers? ==
|
||||
justCheckers is an open source advanced checkers game built using Java. The aim
|
||||
of the project is to create a checkers game that:
|
||||
|
||||
* handles skins and themes
|
||||
* handles multimedia
|
||||
* allows for network games
|
||||
* contains a powerful yet fun computer opponent
|
||||
* simplifies managing on-line checkers tournaments
|
||||
* handles different checker rules
|
||||
|
||||
Project homepage: http://justcheckers.sourceforge.net/
|
||||
|
||||
== Current Developers ==
|
||||
* Dorian Pula
|
||||
** Founder, lead developer, project management, documentation & core programming.
|
||||
|
||||
== Past Developers ==
|
||||
* Chris Bellini
|
||||
** Game engine data objects, XML settings & project management.
|
||||
** Versions 0.0-0.1
|
||||
|
||||
* Daniel D'Alimonte (skwirl)
|
||||
** Code clean-up, refactoring, documentation & file releases.
|
||||
** Versions 0.0-0.1
|
||||
|
||||
* Ross Etchells
|
||||
** Game engine logic and progressing.
|
||||
** Versions 0.0-0.1
|
||||
|
||||
* Rras Lekone
|
||||
** Console UI (jCurses)
|
||||
** Versions 0.0
|
||||
|
||||
* Brinick Simmons
|
||||
** Core programming, XML settings and processing.
|
||||
** Versions 0.0-0.1
|
||||
|
||||
== Inspiration ==
|
||||
* Nick Nolfi
|
||||
** Creator of the Chubby Checkers project and assignment.
|
||||
** Inspiration for Civilization Checkers and justCheckers.
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">justCheckers</string>
|
||||
<string name="app_version">0.2-alpha</string>
|
||||
<string name="project_website">http://justcheckers.org/</string>
|
||||
<string-array name="checkers_variants">
|
||||
<item>American/Standard</item>
|
||||
<item>European</item>
|
||||
<item>Canadian</item>
|
||||
</string-array>
|
||||
</resources>
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="caption_about_us">About Us</string>
|
||||
<string name="caption_license">License</string>
|
||||
<string name="caption_play_checkers">Play Checkers</string>
|
||||
<string name="caption_settings">Settings</string>
|
||||
<string name="caption_visit_us">Visit Our Website</string>
|
||||
<string name="caption_quit">Quit</string>
|
||||
</resources>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="template_capture_amounts">x0</string>
|
||||
<string name="template_current_player">Current Player</string>
|
||||
<string name="template_opposing_player">Opposing Player</string>
|
||||
</resources>
|
|
@ -0,0 +1,82 @@
|
|||
/*****************************************************************************
|
||||
GameActivity.java - The activity that handles the actual checkers games.
|
||||
*****************************************************************************
|
||||
|
||||
*****************************************************************************
|
||||
This file is part of justCheckers.
|
||||
|
||||
justCheckers is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
justCheckers is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with justCheckers. If not, see <http://www.gnu.org/licenses/>.
|
||||
*****************************************************************************/
|
||||
|
||||
package org.justcheckers.android;
|
||||
|
||||
import org.justcheckers.game.Game;
|
||||
import org.justcheckers.game.Rulebook;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
|
||||
public class GameActivity extends Activity implements OnClickListener {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// Setup the user interface for the main menu.
|
||||
|
||||
// Weirdness in orientation values in Galaxy Tab.
|
||||
// http://www.ceveni.com/2009/08/how-to-get-screen-orientation-in.html
|
||||
int screenOrientation =
|
||||
this.getWindowManager().getDefaultDisplay().getOrientation();
|
||||
|
||||
//TODO: Cleaner per device implementation. Developed on Samsung Galaxy S Vibrant.
|
||||
if (screenOrientation == 1) {
|
||||
// Counter-clockwise landscape
|
||||
this.setContentView(R.layout.game_screen_landscape);
|
||||
} else if (screenOrientation == 3) {
|
||||
// Clockwise landscape
|
||||
this.setContentView(R.layout.game_screen_landscape);
|
||||
} else if (screenOrientation == 0) {
|
||||
// Portrait for Samsung Galaxy devices.
|
||||
this.setContentView(R.layout.game_screen_portrait);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
//TODO: Stub
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a new game with the specified rulebook.
|
||||
*
|
||||
* @param rules
|
||||
* The rules for the new game.
|
||||
*/
|
||||
public static void startGame(Rulebook rules) {
|
||||
Game currentGame = new Game(rules.getCheckersVariant());
|
||||
/* Instead of specialized UI commands, just a single method
|
||||
that updates the UI with the current state of the game. */
|
||||
// ui.setCurrentGame(currentGame);
|
||||
//
|
||||
// // Current until different game types are added.
|
||||
// ui.clearBoard();
|
||||
// ui.placePieces();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
/*****************************************************************************
|
||||
InfoActivity.java - The activity that provides built-in information.
|
||||
*****************************************************************************
|
||||
|
||||
*****************************************************************************
|
||||
This file is part of justCheckers.
|
||||
|
||||
justCheckers is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
justCheckers is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with justCheckers. If not, see <http://www.gnu.org/licenses/>.
|
||||
*****************************************************************************/
|
||||
|
||||
package org.justcheckers.android;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
import org.justcheckers.common.GlobalConstants;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class InfoActivity extends Activity {
|
||||
|
||||
private int flagInformationToDisplay;
|
||||
|
||||
//TODO: Clean this up into something more modularized.
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// Setup the user interface for the main menu.
|
||||
this.setContentView(R.layout.info_screen);
|
||||
|
||||
// Figure out which text to load. The default
|
||||
if (savedInstanceState != null) {
|
||||
this.flagInformationToDisplay =
|
||||
savedInstanceState.getInt(GlobalConstants.EXTRA_INFORMATION_DISPLAY_FLAG);
|
||||
|
||||
} else {
|
||||
Bundle extras = this.getIntent().getExtras();
|
||||
if (extras != null) {
|
||||
this.flagInformationToDisplay =
|
||||
extras.getInt(GlobalConstants.EXTRA_INFORMATION_DISPLAY_FLAG);
|
||||
}
|
||||
}
|
||||
|
||||
// Load the right text.
|
||||
int rawInfoRes = 0;
|
||||
if (this.flagInformationToDisplay == GlobalConstants.FLAG_INFORMATION_DISPLAY_ABOUT_US) {
|
||||
rawInfoRes = R.raw.readme;
|
||||
} else if (this.flagInformationToDisplay == GlobalConstants.FLAG_INFORMATION_DISPLAY_LICENSE) {
|
||||
rawInfoRes = R.raw.gpl_3_license;
|
||||
} else {
|
||||
rawInfoRes = R.raw.readme;
|
||||
}
|
||||
|
||||
// Read the raw document into a string.
|
||||
InputStream docInfoStream = this.getResources().openRawResource(rawInfoRes);
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(docInfoStream));
|
||||
String result = "Text here";
|
||||
|
||||
try {
|
||||
// Gather all the data.
|
||||
StringBuilder buildDoc = new StringBuilder();
|
||||
String docLine = reader.readLine();
|
||||
|
||||
while (docLine != null) {
|
||||
buildDoc.append(docLine + "\n");
|
||||
docLine = reader.readLine();
|
||||
}
|
||||
|
||||
result = buildDoc.toString();
|
||||
|
||||
} catch (IOException e) {
|
||||
Log.e("InfoActivity", "Input error: " + e.getMessage());
|
||||
}
|
||||
|
||||
TextView infoText = (TextView) this.findViewById(R.id.info_text);
|
||||
infoText.setText(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putInt(GlobalConstants.EXTRA_INFORMATION_DISPLAY_FLAG,
|
||||
this.flagInformationToDisplay);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,141 @@
|
|||
/*****************************************************************************
|
||||
MenuActivity.java - The activity that provides the main menu for the app.
|
||||
*****************************************************************************
|
||||
|
||||
*****************************************************************************
|
||||
This file is part of justCheckers.
|
||||
|
||||
justCheckers is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
justCheckers is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with justCheckers. If not, see <http://www.gnu.org/licenses/>.
|
||||
*****************************************************************************/
|
||||
|
||||
package org.justcheckers.android;
|
||||
|
||||
import org.justcheckers.common.GlobalConstants;
|
||||
import org.justcheckers.common.LoggingAndStatistics;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
|
||||
public class MenuActivity extends Activity implements OnClickListener {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// Setup the user interface for the main menu.
|
||||
this.setContentView(R.layout.main_menu);
|
||||
|
||||
// Link up all the UI elements with their listeners.
|
||||
Button menuButton = (Button) this.findViewById(R.id.game_button);
|
||||
menuButton.setOnClickListener(this);
|
||||
menuButton = (Button) this.findViewById(R.id.game_button);
|
||||
menuButton.setOnClickListener(this);
|
||||
menuButton = (Button) this.findViewById(R.id.website_button);
|
||||
menuButton.setOnClickListener(this);
|
||||
menuButton = (Button) this.findViewById(R.id.settings_button);
|
||||
menuButton.setOnClickListener(this);
|
||||
menuButton = (Button) this.findViewById(R.id.about_us_button);
|
||||
menuButton.setOnClickListener(this);
|
||||
menuButton = (Button) this.findViewById(R.id.license_button);
|
||||
menuButton.setOnClickListener(this);
|
||||
menuButton = (Button) this.findViewById(R.id.quit_button);
|
||||
menuButton.setOnClickListener(this);
|
||||
|
||||
// TODO: Move logging info in a better place.
|
||||
LoggingAndStatistics.logApplicationInfo(this);
|
||||
LoggingAndStatistics.logDeviceAndSystemInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
// Determine which view fired off this event.
|
||||
switch (view.getId()) {
|
||||
case R.id.game_button:
|
||||
this.startGame();
|
||||
break;
|
||||
case R.id.website_button:
|
||||
this.launchWebsite();
|
||||
break;
|
||||
case R.id.settings_button:
|
||||
this.displaySettings();
|
||||
break;
|
||||
case R.id.about_us_button:
|
||||
this.displayInfo(GlobalConstants.FLAG_INFORMATION_DISPLAY_ABOUT_US);
|
||||
break;
|
||||
case R.id.license_button:
|
||||
this.displayInfo(GlobalConstants.FLAG_INFORMATION_DISPLAY_LICENSE);
|
||||
break;
|
||||
case R.id.quit_button:
|
||||
this.quitApp();
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Quits the application.
|
||||
*/
|
||||
private void quitApp() {
|
||||
this.finish();
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays an information screen.
|
||||
*/
|
||||
private void displayInfo(int infoToDisplay) {
|
||||
|
||||
// Validate info.
|
||||
if ((infoToDisplay != GlobalConstants.FLAG_INFORMATION_DISPLAY_ABOUT_US) &&
|
||||
(infoToDisplay != GlobalConstants.FLAG_INFORMATION_DISPLAY_LICENSE)) {
|
||||
infoToDisplay = GlobalConstants.FLAG_INFORMATION_DISPLAY_ABOUT_US;
|
||||
}
|
||||
|
||||
|
||||
Intent launchDisplay = new Intent(this, InfoActivity.class);
|
||||
launchDisplay.putExtra(GlobalConstants.EXTRA_INFORMATION_DISPLAY_FLAG,
|
||||
infoToDisplay);
|
||||
startActivity(launchDisplay);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the settings for the application.
|
||||
*/
|
||||
private void displaySettings() {
|
||||
Intent launchDisplay = new Intent(this, SettingsActivity.class);
|
||||
startActivity(launchDisplay);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts an external browser to visit the project's website.
|
||||
*/
|
||||
private void launchWebsite() {
|
||||
String url = this.getString(R.string.project_website);
|
||||
Intent launcher = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
||||
startActivity(launcher);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a new game or continues an existing one.
|
||||
*/
|
||||
private void startGame() {
|
||||
Intent launchDisplay = new Intent(this, GameActivity.class);
|
||||
startActivity(launchDisplay);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
/*****************************************************************************
|
||||
SettingsActivity.java - The activity for adjustings settings in the app.
|
||||
*****************************************************************************
|
||||
|
||||
*****************************************************************************
|
||||
This file is part of justCheckers.
|
||||
|
||||
justCheckers is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
justCheckers is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with justCheckers. If not, see <http://www.gnu.org/licenses/>.
|
||||
*****************************************************************************/
|
||||
|
||||
package org.justcheckers.android;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceActivity;
|
||||
|
||||
public class SettingsActivity extends PreferenceActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
this.addPreferencesFromResource(R.layout.settings_screen);
|
||||
this.getListView().setBackgroundResource(R.drawable.backdrop);
|
||||
this.getListView().setCacheColorHint(Color.TRANSPARENT);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
/*****************************************************************************
|
||||
GlobalConstants.java - Constants for the entire application.
|
||||
*****************************************************************************
|
||||
|
||||
*****************************************************************************
|
||||
This file is part of justCheckers.
|
||||
|
||||
justCheckers is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
justCheckers is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with justCheckers. If not, see <http://www.gnu.org/licenses/>.
|
||||
*****************************************************************************/
|
||||
|
||||
package org.justcheckers.common;
|
||||
|
||||
/**
|
||||
* Organizational class to keep all the constants in.
|
||||
* @author Dorian Pula
|
||||
*
|
||||
*/
|
||||
public class GlobalConstants {
|
||||
|
||||
/** Flag for the information screen to display a "About Us". */
|
||||
public final static int FLAG_INFORMATION_DISPLAY_ABOUT_US = 0;
|
||||
/** Flag for the information screen to display the license of the app. */
|
||||
public final static int FLAG_INFORMATION_DISPLAY_LICENSE = 1;
|
||||
|
||||
/**
|
||||
* The extras key that contains the information screens needs to display
|
||||
* the right information.
|
||||
*/
|
||||
public final static String EXTRA_INFORMATION_DISPLAY_FLAG = "info-display";
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
/*****************************************************************************
|
||||
GameLoop.java - Main controlling class for the justCheckers game.
|
||||
*****************************************************************************
|
||||
|
||||
*****************************************************************************
|
||||
This file is part of justCheckers.
|
||||
|
||||
justCheckers is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
justCheckers is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with justCheckers. If not, see <http://www.gnu.org/licenses/>.
|
||||
*****************************************************************************/
|
||||
|
||||
package org.justcheckers.common;import org.justcheckers.android.R;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* Functions for logging errors and gathering statistics.
|
||||
*
|
||||
* @author Dorian Pula
|
||||
*/
|
||||
public class LoggingAndStatistics {
|
||||
|
||||
/**
|
||||
* Logs information about the program. Displays the game's header and
|
||||
* relevant system properties at runtime.
|
||||
*/
|
||||
public static void logApplicationInfo(Activity caller) {
|
||||
|
||||
String gameVersion = caller.getString(R.string.app_version);
|
||||
String gameWebsite = caller.getString(R.string.project_website);
|
||||
String appInfo = "justCheckers -- Version:" + gameVersion
|
||||
+ " - Website: " + gameWebsite;
|
||||
|
||||
Log.i("ApplInfo", appInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs information about the device and system, the app is
|
||||
* running on.
|
||||
*/
|
||||
public static void logDeviceAndSystemInfo() {
|
||||
|
||||
// System properties.
|
||||
String sysList = "SDK version: " + Build.VERSION.RELEASE
|
||||
+ " - API: " + Build.VERSION.SDK_INT
|
||||
+ " - Device: " + Build.MANUFACTURER + " " + Build.MODEL;
|
||||
|
||||
Log.i("DevSysInfo", sysList);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,497 @@
|
|||
/*****************************************************************************
|
||||
Board.java -- Container for the state of the board of a game.
|
||||
*****************************************************************************
|
||||
|
||||
*****************************************************************************
|
||||
This file is part of justCheckers.
|
||||
|
||||
justCheckers is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
justCheckers is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with justCheckers. If not, see <http://www.gnu.org/licenses/>.
|
||||
*****************************************************************************/
|
||||
|
||||
package org.justcheckers.game;
|
||||
|
||||
/**
|
||||
* Container for the state of the checker board during a game.
|
||||
*
|
||||
* The size of the board is defined by the number of squares along one side,
|
||||
* since all checker boards are square. The board coordinate system has both
|
||||
* horizontal and vertical numeric components ranging from 0 to boardSize-1.
|
||||
* Depicted on-screen, the horizontal component extends to the right and the
|
||||
* vertical component extends downwards, making the upper left square (0, 0) and
|
||||
* the lower right square (boardSize-1, boardSize-1).
|
||||
*
|
||||
* <b>Navigating through the Board</b> Internally, the checker board is
|
||||
* organized as a two-dimensional array. So when iterating through the board,
|
||||
* you first specify the vertical component and then the horizontal component.
|
||||
* Another way of thinking about is first specifying which row you want to look
|
||||
* at from top to bottom. Then you specify how across the row you are looking at
|
||||
* from left to right.
|
||||
*
|
||||
* <b>Players Places</b> The light player (the starting player) starts at the
|
||||
* top of the board. The dark player starts at the bottom of the board.
|
||||
*
|
||||
* @author Dorian Pula
|
||||
* @author Ross Etchells
|
||||
*/
|
||||
public class Board {
|
||||
|
||||
/** Constant representing a dark king. */
|
||||
public static final int DARK_KING = 4;
|
||||
/** Constant representing a dark single man. */
|
||||
public static final int DARK_PAWN = 3;
|
||||
/** Constant representing an empty space. */
|
||||
public static final int EMPTY_SPACE = 0;
|
||||
// -- Constants ------------------------------------------------------------
|
||||
/**
|
||||
* Constant representing an illegal square. That is a white square in
|
||||
* checkers.
|
||||
*/
|
||||
public static final int ILLEGAL_SPACE = -1;
|
||||
/** Constant representing a light king. */
|
||||
public static final int LIGHT_KING = 2;
|
||||
/** Constant representing a light single man. */
|
||||
public static final int LIGHT_PAWN = 1;
|
||||
|
||||
// -- Object Fields --------------------------------------------------------
|
||||
|
||||
/** Is the board mirrored or a regular checker board. */
|
||||
private final boolean amIMirrored;
|
||||
/**
|
||||
* Holds the positions of the pieces on the board.
|
||||
*/
|
||||
private final int[][] board;
|
||||
/** The size of the board. */
|
||||
private final int boardSize;
|
||||
/** A reference to the rules being used. */
|
||||
private final Rulebook myRules;
|
||||
|
||||
// -- Constructors ---------------------------------------------------------
|
||||
/**
|
||||
* Creates a new board for checkers.
|
||||
*
|
||||
* @param rules
|
||||
* The rules for this board.
|
||||
*/
|
||||
public Board(Rulebook rules) {
|
||||
this.myRules = rules;
|
||||
final int size = this.myRules.getBoardSize();
|
||||
this.board = new int[size][size];
|
||||
this.boardSize = size;
|
||||
this.amIMirrored = this.myRules.isBoardMirrored();
|
||||
}
|
||||
|
||||
// -- Public Methods (Setting Up the Board) --------------------------------
|
||||
/**
|
||||
* Clears the board of pieces. Creates a brand new empty board already laid
|
||||
* out by the rules (regular or mirrored).
|
||||
*/
|
||||
public void clearBoard() {
|
||||
for (int row = 0; this.boardSize > row; row++) {
|
||||
for (int col = 0; this.boardSize > col; col++) {
|
||||
|
||||
// Mirrored has opposite setup to a regular board.
|
||||
if (row % 2 == 0 && col % 2 == 0) {
|
||||
if (this.amIMirrored) {
|
||||
this.board[row][col] = Board.ILLEGAL_SPACE;
|
||||
} else {
|
||||
this.board[row][col] = Board.EMPTY_SPACE;
|
||||
}
|
||||
} else if (row % 2 == 0 && col % 2 == 1) {
|
||||
if (this.amIMirrored) {
|
||||
this.board[row][col] = Board.EMPTY_SPACE;
|
||||
} else {
|
||||
this.board[row][col] = Board.ILLEGAL_SPACE;
|
||||
}
|
||||
} else if (row % 2 == 1 && col % 2 == 0) {
|
||||
if (this.amIMirrored) {
|
||||
this.board[row][col] = Board.EMPTY_SPACE;
|
||||
} else {
|
||||
this.board[row][col] = Board.ILLEGAL_SPACE;
|
||||
}
|
||||
} else {
|
||||
if (this.amIMirrored) {
|
||||
this.board[row][col] = Board.ILLEGAL_SPACE;
|
||||
} else {
|
||||
this.board[row][col] = Board.EMPTY_SPACE;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// -- Get/Set Methods ------------------------------------------------------
|
||||
/**
|
||||
* Gets the size of the board. The board size is measured as the number of
|
||||
* squares down one side of the board.
|
||||
*
|
||||
* @return The size of the board.
|
||||
*/
|
||||
public int getBoardSize() {
|
||||
return this.boardSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a reference to a 2 dimensional array representation of the
|
||||
* current board state. This is for use by the user interface. Each
|
||||
* dimension of the array extends from 0 to boardSize - 1. Note that the
|
||||
* referenced array is a clone of the internal board representation. Changes
|
||||
* made to the array will not affect the board state.
|
||||
*
|
||||
* @return A 2 dimensional array representing the current state of the
|
||||
* board.
|
||||
*/
|
||||
public int[][] getBoardState() {
|
||||
final int[][] repBoard = new int[this.boardSize][this.boardSize];
|
||||
System.arraycopy(this.board, 0, repBoard, 0, this.boardSize);
|
||||
return repBoard;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the piece at board coordinate (row, col) is dark. If
|
||||
* the coordinates do not exist on the board or are empty, this method will
|
||||
* return false.
|
||||
*
|
||||
* @param row
|
||||
* The row of the square.
|
||||
* @param col
|
||||
* The column of the square.
|
||||
* @return True if the piece at the specified coordinate is dark. False if
|
||||
* otherwise.
|
||||
*/
|
||||
public boolean isDark(int row, int col) {
|
||||
if (row >= 0 && row < this.boardSize && col >= 0
|
||||
&& col < this.boardSize) {
|
||||
return this.board[row][col] == Board.DARK_KING
|
||||
|| this.board[row][col] == Board.DARK_PAWN;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the piece at board coordinate (row, col) is empty. If
|
||||
* the coordinates do not exist on the board or is illegal, this method will
|
||||
* return false.
|
||||
*
|
||||
* @param row
|
||||
* The row of the square.
|
||||
* @param col
|
||||
* The column of the square.
|
||||
* @return True if the piece at the specified coordinate is empty. False if
|
||||
* otherwise.
|
||||
*/
|
||||
public boolean isEmpty(int row, int col) {
|
||||
if (row >= 0 && row < this.boardSize && col >= 0
|
||||
&& col < this.boardSize) {
|
||||
return this.board[row][col] == Board.EMPTY_SPACE;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the board coordinate (x, y) is used in the game. In
|
||||
* most cases, all light spaces on the board will be considered illegal.
|
||||
* Also, any coordinate which does not exist is also considered illegal.
|
||||
*
|
||||
* @param row
|
||||
* The row of the square.
|
||||
* @param col
|
||||
* The column of the square.
|
||||
* @return True if the specified coordinate is nonexistent or unused in the
|
||||
* current rules. False if otherwise.
|
||||
*/
|
||||
public boolean isIllegalSpace(int row, int col) {
|
||||
if (row >= 0 && row < this.boardSize && col >= 0
|
||||
&& col < this.boardSize) {
|
||||
return this.board[row][col] == Board.ILLEGAL_SPACE;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the piece at board coordinate (row, col) is a king. If
|
||||
* the coordinates do not exist on the board or are empty, this method will
|
||||
* return false.
|
||||
*
|
||||
* @param row
|
||||
* The row of the square.
|
||||
* @param col
|
||||
* The column of the square.
|
||||
* @return True if the piece at the specified coordinate is a king. False if
|
||||
* otherwise.
|
||||
*/
|
||||
public boolean isKing(int row, int col) {
|
||||
if (row >= 0 && row < this.boardSize && col >= 0
|
||||
&& col < this.boardSize) {
|
||||
return this.board[row][col] == Board.LIGHT_KING
|
||||
|| this.board[row][col] == Board.DARK_KING;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if a position specified is legal. Returns true if the position is
|
||||
* on the board, and if the space is not an illegal white space. Returns
|
||||
* false otherwise.
|
||||
*
|
||||
* @param row
|
||||
* The row coordinate of the position.
|
||||
* @param col
|
||||
* The column coordinate of the position.
|
||||
* @return Returns true if the position is a legal playing position.
|
||||
*/
|
||||
public boolean isLegalPosition(int row, int col) {
|
||||
return row >= 0 && row < this.boardSize && col >= 0
|
||||
&& col < this.boardSize && !this.isIllegalSpace(row, col);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the piece at board coordinate (row, col) is light. If
|
||||
* the coordinates do not exist on the board or are empty, this method will
|
||||
* return false.
|
||||
*
|
||||
* @param row
|
||||
* The row of the square.
|
||||
* @param col
|
||||
* The column of the square.
|
||||
* @return True if the piece at the specified coordinate is light. False if
|
||||
* otherwise.
|
||||
*/
|
||||
public boolean isLight(int row, int col) {
|
||||
if (row >= 0 && row < this.boardSize && col >= 0
|
||||
&& col < this.boardSize) {
|
||||
return this.board[row][col] == Board.LIGHT_KING
|
||||
|| this.board[row][col] == Board.LIGHT_PAWN;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the piece at board coordinate (row, col) is a pawn. If
|
||||
* the coordinates do not exist on the board or are empty, this method will
|
||||
* return false.
|
||||
*
|
||||
* @param row
|
||||
* The row of the square.
|
||||
* @param col
|
||||
* The column of the square.
|
||||
* @return True if the piece at the specified coordinate is a pawn. False if
|
||||
* otherwise.
|
||||
*/
|
||||
public boolean isPawn(int row, int col) {
|
||||
if (row >= 0 && row < this.boardSize && col >= 0
|
||||
&& col < this.boardSize) {
|
||||
return this.board[row][col] == Board.LIGHT_PAWN
|
||||
|| this.board[row][col] == Board.DARK_PAWN;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// -- Board Updating Methods -----------------------------------------------
|
||||
/**
|
||||
* Moves a pieces from one location to another. This method should be called
|
||||
* from the Game using this Board. This method does not check for rule
|
||||
* validity but does check for illegal white spaces. Also checks that the
|
||||
* destination position is empty.
|
||||
*
|
||||
* @param sourceRow
|
||||
* The row from where the piece is moving from.
|
||||
* @param sourceCol
|
||||
* The column from where the piece is moving from.
|
||||
* @param targetRow
|
||||
* The row to where the piece is moving to.
|
||||
* @param targetCol
|
||||
* The column to where the piece is moving to.
|
||||
*/
|
||||
protected void movePiece(int sourceRow, int sourceCol, int targetRow,
|
||||
int targetCol) {
|
||||
|
||||
if (this.isLegalPosition(sourceRow, sourceCol)
|
||||
&& this.isLegalPosition(targetRow, targetCol)
|
||||
&& this.board[targetRow][targetCol] == Board.EMPTY_SPACE) {
|
||||
|
||||
final int piece = this.board[sourceRow][sourceCol];
|
||||
this.board[targetRow][targetCol] = piece;
|
||||
this.board[sourceRow][sourceCol] = Board.EMPTY_SPACE;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a pieces from the specified location. This method should be
|
||||
* called from the Game using this Board. This method does not check for
|
||||
* rule validity but does check for illegal white spaces.
|
||||
*
|
||||
* @param row
|
||||
* The row where the piece is to be removed from.
|
||||
* @param col
|
||||
* The column where the piece is to be removed from.
|
||||
*/
|
||||
protected void removePiece(int row, int col) {
|
||||
|
||||
if (this.isLegalPosition(row, col)) {
|
||||
this.board[row][col] = Board.EMPTY_SPACE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Setups the board for a new game. There are three different setups for the
|
||||
* three different types of boards:
|
||||
*
|
||||
* <table>
|
||||
* <tr>
|
||||
* <b>
|
||||
* <td>Name</td>
|
||||
* <td>Size</td>
|
||||
* <td>Number of Pieces Per Player</td>
|
||||
* <td>Number of Rows Per Player</td>
|
||||
* </b>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Standard</td>
|
||||
* <td>8 x 8</td>
|
||||
* <td>12</td>
|
||||
* <td>3</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>International</td>
|
||||
* <td>10 x 10</td>
|
||||
* <td>20</td>
|
||||
* <td>4</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Canadian</td>
|
||||
* <td>12 x 12</td>
|
||||
* <td>30</td>
|
||||
* <td>5</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* The columns containing the players' tokens alternate between columns. The
|
||||
* dark player traditionally takes the first few upper rows (0-3). The light
|
||||
* player takes the last of the lower rows (5-7, 6-9 or 7-11).
|
||||
*
|
||||
* Note that the suicide checkers variant has a completely different setup,
|
||||
* and has a setup function of its own: setupNewSuicideGame().
|
||||
*/
|
||||
public void setupNewGame() {
|
||||
this.clearBoard();
|
||||
|
||||
if (this.myRules.getCheckersVariant() == Rulebook.SUICIDE_CHECKERS) {
|
||||
this.setupNewSuicideGame();
|
||||
} else {
|
||||
|
||||
// Used to decide which rows to fill up.
|
||||
int darkPlayerBottomRow;
|
||||
int lightPlayerTopRow;
|
||||
|
||||
// Figure out the size of the board.
|
||||
if (this.boardSize == Rulebook.INTERNATIONAL_BOARD_SIZE) {
|
||||
darkPlayerBottomRow = 3;
|
||||
lightPlayerTopRow = 6;
|
||||
} else if (this.boardSize == Rulebook.CANADIAN_BOARD_SIZE) {
|
||||
darkPlayerBottomRow = 3;
|
||||
lightPlayerTopRow = 7;
|
||||
} else { // Default board is 8x8 Standard size.
|
||||
darkPlayerBottomRow = 2;
|
||||
lightPlayerTopRow = 5;
|
||||
}
|
||||
|
||||
// Go through the board and set it up.
|
||||
for (int row = 0; row < this.boardSize; row++) {
|
||||
for (int col = 0; col < this.boardSize; col++) {
|
||||
if (row <= darkPlayerBottomRow
|
||||
&& this.board[row][col] == Board.EMPTY_SPACE) {
|
||||
this.board[row][col] = Board.DARK_PAWN;
|
||||
} else if (row >= lightPlayerTopRow
|
||||
&& this.board[row][col] == Board.EMPTY_SPACE) {
|
||||
this.board[row][col] = Board.LIGHT_PAWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Setups a checker board according to the suicide "French" rules.
|
||||
*/
|
||||
private void setupNewSuicideGame() {
|
||||
// TODO: Implement the suicide game setup.
|
||||
}
|
||||
|
||||
// -- Private (Implementation) Methods -------------------------------------
|
||||
|
||||
/**
|
||||
* Returns a string to represent the board state. This string is formatted
|
||||
* for use as a simple board display in the command window.
|
||||
*
|
||||
* <b>Legend</b> ## - White space which the piece can not move on to. __ -
|
||||
* An empty space. LP - A light pawn. LK - A light king. DP - A dark pawn.
|
||||
* DK - A dark king.
|
||||
*
|
||||
* @return A string representing the current board state.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
// Prepare for output with a nice looking to banner.
|
||||
String output = " ";
|
||||
for (int i = 0; i < this.boardSize; i++) {
|
||||
if (i < 9) {
|
||||
output = output + " " + (i + 1);
|
||||
} else {
|
||||
output = output + " " + (i + 1);
|
||||
}
|
||||
}
|
||||
output = output + "\n\n";
|
||||
|
||||
// Go row by row, printing out the row number and the board's state.
|
||||
for (int row = 0; row < this.boardSize; row++) {
|
||||
if (row < 9) {
|
||||
output = output + " " + (row + 1);
|
||||
} else {
|
||||
output = output + " " + (row + 1);
|
||||
}
|
||||
|
||||
// Get current row's state.
|
||||
for (int col = 0; col < this.boardSize; col++) {
|
||||
switch (this.board[row][col]) {
|
||||
case Board.ILLEGAL_SPACE:
|
||||
output = output + "## ";
|
||||
break;
|
||||
case Board.EMPTY_SPACE:
|
||||
output = output + "__ ";
|
||||
break;
|
||||
case Board.LIGHT_PAWN:
|
||||
output = output + "LP ";
|
||||
break;
|
||||
case Board.LIGHT_KING:
|
||||
output = output + "LK ";
|
||||
break;
|
||||
case Board.DARK_PAWN:
|
||||
output = output + "DP ";
|
||||
break;
|
||||
case Board.DARK_KING:
|
||||
output = output + "DK ";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
output = output + "\n";
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,251 @@
|
|||
/*****************************************************************************
|
||||
Board.java -- Container for the state of a game in progress.
|
||||
*****************************************************************************
|
||||
|
||||
*****************************************************************************
|
||||
This file is part of justCheckers.
|
||||
|
||||
justCheckers is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
justCheckers is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with justCheckers. If not, see <http://www.gnu.org/licenses/>.
|
||||
*****************************************************************************/
|
||||
|
||||
package org.justcheckers.game;
|
||||
|
||||
import android.graphics.Point;
|
||||
|
||||
/**
|
||||
* The main game handling object of GameLoop.
|
||||
*
|
||||
* Objects registering as observers on an instance of GameEngine will be
|
||||
* notified of a change in either the board state or the turn state. The turn
|
||||
* will change automatically when a complete move is made. Multiple jumps are
|
||||
* managed by a call to the makeMove method for each jump segment, and the turn
|
||||
* will not pass to the other player until the jump sequence is complete.
|
||||
*
|
||||
* @author Ross Etchells
|
||||
* @author Dorian Pula
|
||||
*/
|
||||
public class Game {
|
||||
|
||||
// -- Constants -----------------------------------------------------------
|
||||
/** State of the game when the dark player wins. */
|
||||
public static final int STATE_DARK_VICTORY = 2;
|
||||
/** State of the game when both players draw. */
|
||||
public static final int STATE_GAME_DRAWN = 3;
|
||||
/** State of the game when game is in progress. */
|
||||
public static final int STATE_GAME_IN_PROGRESS = 0;
|
||||
/** State of the game when the light player wins. */
|
||||
public static final int STATE_LIGHT_VICTORY = 1;
|
||||
|
||||
// -- Object Fields -------------------------------------------------------
|
||||
/** Represents the dark (usually defending) player. */
|
||||
private Player darkPlayer;
|
||||
/** Contains the current checker board used for the game. */
|
||||
private Board gameBoard;
|
||||
/** Contains the current rules used for playing the game. */
|
||||
private Rulebook gameRules;
|
||||
/** The state of the game. */
|
||||
private int gameState;
|
||||
/**
|
||||
* This point holds the coordinates of a piece making a jump. Mostly used
|
||||
* for a piece whose move has not finished after 1 jump. This point is set
|
||||
* to null if not in use.
|
||||
*/
|
||||
private final Point jumpInProgress;
|
||||
/** Represents the light (usually attacking) player. */
|
||||
private Player lightPlayer;
|
||||
/** Represents whose turn it is. */
|
||||
private boolean lightPlayerTurn;
|
||||
|
||||
/*
|
||||
* TODO: Game needs to declare who won or better yet, the state of the game
|
||||
* to be: in progress, light win, dark win or draw.
|
||||
*/
|
||||
|
||||
// -- Constructors --------------------------------------------------------
|
||||
/**
|
||||
* Create a new game. Uses the defaults of two unnamed players and the
|
||||
* American rules.
|
||||
*/
|
||||
public Game() {
|
||||
this(Rulebook.AMERICAN_CHECKERS, new Player(), new Player());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new game. Uses the default of two unnamed players. The variant
|
||||
* (which rules) can be set here.
|
||||
*
|
||||
* @param variant
|
||||
* Which variant of checkers will this game be.
|
||||
*/
|
||||
public Game(int variant) {
|
||||
this(variant, new Player(), new Player());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new game.
|
||||
*
|
||||
* @param variant
|
||||
* The variant of checkers to be played.
|
||||
* @param light
|
||||
* The player playing the light side.
|
||||
* @param dark
|
||||
* The player playing the dark side.
|
||||
*/
|
||||
public Game(int variant, Player light, Player dark) {
|
||||
// Setup all the components of the game.
|
||||
this.gameRules = new Rulebook(variant);
|
||||
this.gameBoard = new Board(this.gameRules);
|
||||
this.darkPlayer = dark;
|
||||
this.lightPlayer = light;
|
||||
|
||||
// Setup the board and start the game.
|
||||
this.lightPlayerTurn = this.gameRules.isLightPlayerFirst();
|
||||
this.gameBoard.setupNewGame();
|
||||
this.jumpInProgress = null; // No moves in progress yet.
|
||||
this.gameState = Game.STATE_GAME_IN_PROGRESS;
|
||||
}
|
||||
|
||||
// TODO: Add a constructor for games already in progress.
|
||||
|
||||
// -- Game methods --------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Gets the player playing the dark side.
|
||||
*
|
||||
* @return The player playing the dark side.
|
||||
*/
|
||||
public Player getDarkPlayer() {
|
||||
return this.darkPlayer;
|
||||
}
|
||||
|
||||
// -- Get/Set Methods ------------------------------------------------------
|
||||
/**
|
||||
* Gets the board used for this game.
|
||||
*
|
||||
* @return The board used for this game.
|
||||
*/
|
||||
public Board getGameBoard() {
|
||||
return this.gameBoard;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the rules used for this game.
|
||||
*
|
||||
* @return The rules used for this game.
|
||||
*/
|
||||
public Rulebook getGameRules() {
|
||||
return this.gameRules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the state of the game. The state is defined by the STATE_*
|
||||
* constants.
|
||||
*
|
||||
* @return The state of the game.
|
||||
*/
|
||||
public int getGameState() {
|
||||
return this.gameState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the player playing the light side.
|
||||
*
|
||||
* @return The player playing the light side.
|
||||
*/
|
||||
public Player getLightPlayer() {
|
||||
return this.lightPlayer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets if it is the light player's turn. Returns false if it is the dark
|
||||
* player's turn.
|
||||
*
|
||||
* @return If it is the light player's turn. Returns false if it is the dark
|
||||
* player's turn.
|
||||
*/
|
||||
public boolean isLightPlayerTurn() {
|
||||
return this.lightPlayerTurn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the player playing the dark side.
|
||||
*
|
||||
* @param player
|
||||
* The player playing the dark side.
|
||||
*/
|
||||
public void setDarkPlayer(Player player) {
|
||||
this.darkPlayer = player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the board used for this game.
|
||||
*
|
||||
* @param board
|
||||
* The board for this game.
|
||||
*/
|
||||
public void setGameBoard(Board board) {
|
||||
this.gameBoard = board;
|
||||
}
|
||||
|
||||
// -- Private Methods ------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Sets the rules used for this game.
|
||||
*
|
||||
* @param rules
|
||||
* The rules used for this game.
|
||||
*/
|
||||
public void setGameRules(Rulebook rules) {
|
||||
this.gameRules = rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the state of the game. The state is defined by the STATE_*
|
||||
* constants.
|
||||
*
|
||||
* @param state
|
||||
* The state of the game.
|
||||
*/
|
||||
public void setGameState(int state) {
|
||||
this.gameState = state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the player playing the light side.
|
||||
*
|
||||
* @param player
|
||||
* The player playing the light side.
|
||||
*/
|
||||
public void setLightPlayer(Player player) {
|
||||
this.lightPlayer = player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets if it is the light player's turn. Set it to false if its the dark
|
||||
* player's turn.
|
||||
*
|
||||
* @param playerTurn
|
||||
* If it is the light player's turn.
|
||||
*/
|
||||
public void setLightPlayerTurn(boolean playerTurn) {
|
||||
this.lightPlayerTurn = playerTurn;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the jumpInProgress
|
||||
*/
|
||||
public Point getJumpInProgress() {
|
||||
return jumpInProgress;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,295 @@
|
|||
/*****************************************************************************
|
||||
GameEngine.java -- Logic engine for manipulating the state of a game.
|
||||
*****************************************************************************
|
||||
|
||||
*****************************************************************************
|
||||
This file is part of justCheckers.
|
||||
|
||||
justCheckers is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
justCheckers is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with justCheckers. If not, see <http://www.gnu.org/licenses/>.
|
||||
*****************************************************************************/
|
||||
|
||||
package org.justcheckers.game;
|
||||
|
||||
/**
|
||||
* @author dpula
|
||||
*
|
||||
*/
|
||||
public class GameEngine {
|
||||
|
||||
// TODO: Add a constructor for games already in progress.
|
||||
|
||||
// -- Game methods --------------------------------------------------------
|
||||
|
||||
private static boolean canJump(Game game, int sourceRow, int sourceCol, int targetRow,
|
||||
int targetCol) {
|
||||
|
||||
// TODO: Implement me.
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if a piece can or cannot move. This move maybe either be a move
|
||||
* or a jump. This method is called by a user interface when a user wants to
|
||||
* moves a piece on screen or over the network. The piece can moved if the
|
||||
* current state of the game allows for it to do so.
|
||||
*
|
||||
* TODO: Add priority for king jumps over pawn jumps for any variants that
|
||||
* do so.
|
||||
*
|
||||
* @param sourceRow
|
||||
* The row from where the piece is moving from.
|
||||
* @param sourceCol
|
||||
* The column from where the piece is moving from.
|
||||
* @param targetRow
|
||||
* The row to where the piece is moving to.
|
||||
* @param targetCol
|
||||
* The column to where the piece is moving to.
|
||||
* @return True if the piece can move. False if the piece can not move.
|
||||
*/
|
||||
public static boolean canMove(Game game, int sourceRow, int sourceCol, int targetRow,
|
||||
int targetCol) {
|
||||
|
||||
// A few things to figure out priorities in moving a piece.
|
||||
boolean legalMove = false; // Is the proposed move/jump legal?
|
||||
boolean realPositions = false; // Are the positions really on the board?
|
||||
boolean isJump = false; // Is this a jump?
|
||||
|
||||
// Sanity check.
|
||||
if (game.getGameBoard().isLegalPosition(sourceRow, sourceCol)
|
||||
&& game.getGameBoard().isLegalPosition(targetRow, targetCol)) {
|
||||
realPositions = true;
|
||||
|
||||
}
|
||||
|
||||
// Is there a jump in progress?
|
||||
if (realPositions && game.getJumpInProgress() != null) {
|
||||
|
||||
// Only allow the piece in movement to be moved.
|
||||
if (sourceRow == game.getJumpInProgress().y
|
||||
&& sourceCol == game.getJumpInProgress().x) {
|
||||
legalMove = canJump(game, sourceRow, sourceCol, targetRow,
|
||||
targetCol);
|
||||
isJump = true;
|
||||
}
|
||||
|
||||
} else if (realPositions) {
|
||||
|
||||
// Go with the regular flow, jumps first then "slides".
|
||||
isJump = canPlayerJump(game);
|
||||
if (isJump) {
|
||||
legalMove = canJump(game, sourceRow, sourceCol, targetRow,
|
||||
targetCol);
|
||||
} else {
|
||||
legalMove = canSlide(game, sourceRow, sourceCol, targetRow,
|
||||
targetCol);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return legalMove;
|
||||
}
|
||||
|
||||
private static boolean canPlayerJump(Game game) {
|
||||
// TODO: Implement me.
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean canSlide(Game game, int sourceRow, int sourceCol, int targetRow,
|
||||
int targetCol) {
|
||||
|
||||
boolean legalMove = true;
|
||||
boolean mustJump = canPlayerJump(game);
|
||||
|
||||
// Is the move even on the board?
|
||||
legalMove = game.getGameBoard().isLegalPosition(sourceRow, sourceCol)
|
||||
&& game.getGameBoard().isLegalPosition(targetRow, targetCol);
|
||||
|
||||
// See if the destination is even empty.
|
||||
if (legalMove) {
|
||||
legalMove = game.getGameBoard().isEmpty(targetRow, targetCol);
|
||||
}
|
||||
|
||||
// If yes, then look if right pieces were chosen.
|
||||
if (legalMove && !mustJump) {
|
||||
if (game.isLightPlayerTurn()
|
||||
&& game.getGameBoard().isLight(sourceRow, sourceCol)) {
|
||||
|
||||
// To deal with flying kings.
|
||||
if (game.getGameBoard().isKing(sourceRow, sourceCol)
|
||||
&& game.getGameRules().canKingsFly()) {
|
||||
|
||||
// FIXME: Fix this!
|
||||
} else {
|
||||
// if ((Math.abs(targetRow - sourceRow) == 1) && (Math.abs(targetRow - sourceRow) == 1)) {
|
||||
// legalMove = false;
|
||||
// }
|
||||
}
|
||||
|
||||
// Is the path clear for that move?
|
||||
|
||||
} else if (!game.isLightPlayerTurn()
|
||||
&& game.getGameBoard().isDark(sourceRow, sourceCol)) {
|
||||
|
||||
//TODO: Implement me, sometime.
|
||||
} else {
|
||||
legalMove = false;
|
||||
}
|
||||
}
|
||||
|
||||
return legalMove;
|
||||
}
|
||||
|
||||
private static void checkForVictory(Game game) {
|
||||
// TODO: Implement me.
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets if a piece is movable. Returns true if the piece can slide or jump.
|
||||
* This method only calculates slides to the adjacent positions. Similarly,
|
||||
* the method only looks at jumping an adjacent enemy piece. This check is
|
||||
* used by the graphical user interface to determine if a piece can be moved
|
||||
* either for sliding or jumping. The method is aware of whose turn is it to
|
||||
* move.
|
||||
*
|
||||
* @param row
|
||||
* The row coordinate of the piece to check.
|
||||
* @param col
|
||||
* The column coordinate of the piece to check.
|
||||
* @return Returns true if the piece can slide or jump in this turn.
|
||||
*/
|
||||
public static boolean isMovablePiece(Game game, int row, int col) {
|
||||
|
||||
// Fields for determining of a piece is movable.
|
||||
boolean moveUpLeft = true;
|
||||
boolean moveUpRight = true;
|
||||
boolean moveDownLeft = true;
|
||||
boolean moveDownRight = true;
|
||||
|
||||
/*
|
||||
* Checks first if the first colour of piece is being grabbed. Next if
|
||||
* the piece is blocked by its own pieces. Next if the opponent has
|
||||
* double blocked off the pieces. Also sanity checks if looking past the
|
||||
* size of the board.
|
||||
*/
|
||||
if (game.isLightPlayerTurn() && game.getGameBoard().isLight(row, col)) { // Light
|
||||
// player.
|
||||
|
||||
// Can piece move normally?
|
||||
moveDownLeft = canSlide(game, row, col, row + 1, col - 1);
|
||||
moveDownRight = canSlide(game, row, col, row + 1, col + 1);
|
||||
|
||||
if (game.getGameBoard().isKing(row, col)) {
|
||||
moveUpLeft = canSlide(game, row, col, row - 1, col - 1);
|
||||
moveUpRight = canSlide(game, row, col, row - 1, col + 1);
|
||||
} else {
|
||||
moveUpLeft = false;
|
||||
moveUpRight = false;
|
||||
}
|
||||
|
||||
// If no slides available try doing the same except for jumps.
|
||||
if (!moveDownLeft) {
|
||||
moveDownLeft = canJump(game, row, col, row + 2, col - 2);
|
||||
} else if (!moveDownRight) {
|
||||
moveDownRight = canJump(game, row, col, row + 2, col + 2);
|
||||
} else if (game.getGameBoard().isKing(row, col)
|
||||
|| game.getGameRules().canPawnsJumpBackwards()) {
|
||||
|
||||
if (!moveUpLeft) {
|
||||
moveUpLeft = canJump(game, row, col, row - 2, col + 2);
|
||||
} else if (!moveUpRight) {
|
||||
moveUpRight = canJump(game, row, col, row - 2, col - 2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return moveUpLeft || moveUpRight || moveDownLeft || moveDownRight;
|
||||
|
||||
} else if (game.isLightPlayerTurn() && game.getGameBoard().isDark(row, col)) { // Dark
|
||||
// player
|
||||
|
||||
// Can piece move normally?
|
||||
moveUpLeft = canSlide(game, row, col, row - 1, col - 1);
|
||||
moveUpRight = canSlide(game, row, col, row - 1, col + 1);
|
||||
|
||||
if (game.getGameBoard().isKing(row, col)) {
|
||||
moveDownLeft = canSlide(game, row, col, row + 1, col - 1);
|
||||
moveDownRight = canSlide(game, row, col, row + 1, col + 1);
|
||||
} else {
|
||||
moveDownLeft = false;
|
||||
moveDownRight = false;
|
||||
}
|
||||
|
||||
// If no slides available try doing the same except for jumps.
|
||||
if (!moveUpLeft) {
|
||||
moveUpLeft = canJump(game, row, col, row - 2, col - 2);
|
||||
} else if (!moveUpRight) {
|
||||
moveUpRight = canJump(game, row, col, row - 2, col + 2);
|
||||
} else if (game.getGameBoard().isKing(row, col)
|
||||
|| game.getGameRules().canPawnsJumpBackwards()) {
|
||||
|
||||
if (!moveDownLeft) {
|
||||
moveDownLeft = canJump(game, row, col, row + 2, col + 2);
|
||||
} else if (!moveDownRight) {
|
||||
moveDownRight = canJump(game, row, col, row + 2, col - 2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return moveUpLeft || moveUpRight || moveDownLeft || moveDownRight;
|
||||
|
||||
} else {
|
||||
return false; // A wrong coloured piece.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves a pieces from one location to another. This move maybe either be a
|
||||
* move or a jump. This method is called by a user interface when a user
|
||||
* moves a piece on screen or over the network. The piece is moved if the
|
||||
* current state of the game allows for it to do so.
|
||||
*
|
||||
* TODO: Add priority for king jumps over pawn jumps for any variants that
|
||||
* do so. TODO: Implement jumping by piece removal.
|
||||
*
|
||||
* @param sourceRow
|
||||
* The row from where the piece is moving from.
|
||||
* @param sourceCol
|
||||
* The column from where the piece is moving from.
|
||||
* @param targetRow
|
||||
* The row to where the piece is moving to.
|
||||
* @param targetCol
|
||||
* The column to where the piece is moving to.
|
||||
*/
|
||||
public static void movePiece(Game game, int sourceRow, int sourceCol, int targetRow,
|
||||
int targetCol) {
|
||||
|
||||
// If everything checks out... move the piece!
|
||||
if (canMove(game, sourceRow, sourceCol, targetRow, targetCol)) {
|
||||
if (game.getJumpInProgress() != null) {
|
||||
|
||||
// TODO: Implement jumping via removing of piece.
|
||||
game.getGameBoard().movePiece(sourceRow, sourceCol, targetRow,
|
||||
targetCol);
|
||||
} else {
|
||||
game.getGameBoard().movePiece(sourceRow, sourceCol, targetRow,
|
||||
targetCol);
|
||||
}
|
||||
|
||||
checkForVictory(game);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,145 @@
|
|||
/*****************************************************************************
|
||||
Player.java -- Data objects for maintaining player information.
|
||||
*****************************************************************************
|
||||
|
||||
*****************************************************************************
|
||||
This file is part of justCheckers.
|
||||
|
||||
justCheckers is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
justCheckers is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with justCheckers. If not, see <http://www.gnu.org/licenses/>.
|
||||
*****************************************************************************/
|
||||
|
||||
package org.justcheckers.game;
|
||||
|
||||
/**
|
||||
* Manages the information of a single player.
|
||||
*
|
||||
* @author Chris Bellini
|
||||
* @author Dorian Pula
|
||||
*/
|
||||
public class Player {
|
||||
|
||||
/** The player's total number of losses. */
|
||||
private int gamesLost;
|
||||
/** The total number of games played by the player. */
|
||||
private int gamesPlayed;
|
||||
/** The player's total number of ties. */
|
||||
private int gamesTied;
|
||||
/** The player's total number of wins. */
|
||||
private int gamesWon;
|
||||
/** The player's name. */
|
||||
private final String playerName;
|
||||
|
||||
/** Creates an unnamed player with a blank record. */
|
||||
public Player() {
|
||||
this("Unnamed Player", 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a player with a given name and a blank record.
|
||||
*
|
||||
* @param name
|
||||
* The name of the player.
|
||||
*/
|
||||
public Player(String name) {
|
||||
this(name, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a player with a given name and record.
|
||||
*
|
||||
* @param name
|
||||
* The name of the player to be created.
|
||||
* @param wins
|
||||
* Player's total wins.
|
||||
* @param losses
|
||||
* Player's total losses.
|
||||
* @param ties
|
||||
* Player's total ties.
|
||||
* @param played
|
||||
* Total games played by the player.
|
||||
*/
|
||||
public Player(String name, int wins, int losses, int ties, int played) {
|
||||
this.playerName = name;
|
||||
this.gamesWon = wins;
|
||||
this.gamesLost = losses;
|
||||
this.gamesTied = ties;
|
||||
this.gamesPlayed = played;
|
||||
}
|
||||
|
||||
/** Adds a new loss for the player's total losses. */
|
||||
public void addLoss() {
|
||||
this.gamesLost++;
|
||||
this.gamesPlayed++;
|
||||
}
|
||||
|
||||
/** Adds a new tie for the player's total ties. */
|
||||
public void addTie() {
|
||||
this.gamesTied++;
|
||||
this.gamesPlayed++;
|
||||
}
|
||||
|
||||
/** Adds a new win for the player's total wins. */
|
||||
public void addWin() {
|
||||
this.gamesWon++;
|
||||
this.gamesPlayed++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the player's total losses.
|
||||
*
|
||||
* @return The player's total losses.
|
||||
*/
|
||||
public int getLosses() {
|
||||
return this.gamesLost;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the total number of games played by the player.
|
||||
*
|
||||
* @return The total number of games played by the player.
|
||||
*/
|
||||
public int getPlayedGames() {
|
||||
return this.gamesPlayed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the player's total score.
|
||||
*
|
||||
* @return The player's total score.
|
||||
*/
|
||||
public int getTies() {
|
||||
return this.gamesTied;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the player's total wins.
|
||||
*
|
||||
* @return The player's total wins.
|
||||
*/
|
||||
public int getWins() {
|
||||
return this.gamesWon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints all the data about the player.
|
||||
*
|
||||
* @return A string representing the player's data.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Name: " + this.playerName + "\n" + "Games: Won "
|
||||
+ this.gamesWon + " Lost " + this.gamesLost + " Tied "
|
||||
+ this.gamesTied;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,352 @@
|
|||
/*****************************************************************************
|
||||
Rulebook.java -- A generic 'rulebook' for a checkers game.
|
||||
*****************************************************************************
|
||||
|
||||
*****************************************************************************
|
||||
This file is part of justCheckers.
|
||||
|
||||
justCheckers is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
justCheckers is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with justCheckers. If not, see <http://www.gnu.org/licenses/>.
|
||||
*****************************************************************************/
|
||||
|
||||
package org.justcheckers.game;
|
||||
|
||||
/**
|
||||
* The rules for a game of checkers. This class provides a reference object for
|
||||
* a game of checkers. This helps deal with the number of variants of checkers.
|
||||
* One of the goals of justCheckers is to provide the flexibility of choose
|
||||
* between different kinds of checker variants. This class builds a skeleton of
|
||||
* the rules by defining what setup, moves, jumps, victory conditions and
|
||||
* special moves make up a particular variant of checkers.
|
||||
*
|
||||
* @author Dorian Pula
|
||||
* @author Chris Bellini
|
||||
*/
|
||||
public class Rulebook {
|
||||
|
||||
// -- Constants -----------------------------------------------------------
|
||||
|
||||
// Checkers variants.
|
||||
/** Playing by the American rules. */
|
||||
public static final int AMERICAN_CHECKERS = 0;
|
||||
/** Playing by International (Polish) rules. */
|
||||
public static final int INTERNATIONAL_CHECKERS = 1;
|
||||
/** Playing by the Brazilian rules. */
|
||||
public static final int BRAZILIAN_CHECKERS = 2;
|
||||
/** Playing by the Canadian rules. */
|
||||
public static final int CANADIAN_CHECKERS = 3;
|
||||
/** Playing by Pool (Southern USA) rules. */
|
||||
public static final int POOL_CHECKERS = 4;
|
||||
/** Playing by the Spanish rules. */
|
||||
public static final int SPANISH_CHECKERS = 5;
|
||||
/** Playing by the Russian rules. */
|
||||
public static final int RUSSIAN_CHECKERS = 6;
|
||||
/** Playing by the Italian rules. */
|
||||
public static final int ITALIAN_CHECKERS = 7;
|
||||
/** Playing by Suicide rules. */
|
||||
public static final int SUICIDE_CHECKERS = 8;
|
||||
/** Playing by the Ghanaian rules. */
|
||||
public static final int GHANAIAN_CHECKERS = 9;
|
||||
|
||||
// TODO: Implement special rules for these checkers. Version >0.1.1?
|
||||
// Victory conditions.
|
||||
/** Victory achieved by capturing all enemy pieces. */
|
||||
public static final int CAPTURE_ALL_ENEMIES_VICTORY = 0;
|
||||
/**
|
||||
* Victory achieved by capturing all pieces. Only caveat is the three king
|
||||
* versus one king draw rule:
|
||||
*
|
||||
* In many games at the end one adversary has three kings while the other
|
||||
* one has just one king. In such a case the first adversary must win in
|
||||
* thirteen moves or the game is declared a draw. (Shamelessly stolen from
|
||||
* http://en.wikipedia.org/wiki/Draughts).
|
||||
*/
|
||||
public static final int SPECIAL_POOL_VICTORY = 1;
|
||||
/** Victory achieved some bizarre manner. TODO: Figure out Russian checkers. */
|
||||
public static final int SPECIAL_RUSSIAN_VICTORY = 2;
|
||||
/** Victory achieved by losing all your pieces. */
|
||||
public static final int SPECIAL_SUICIDE_VICTORY = 3;
|
||||
/** Victory achieved by not being the first with one piece left. */
|
||||
public static final int SPECIAL_GHANAIAN_VICTORY = 4;
|
||||
|
||||
// Checker board sizes.
|
||||
/** Using a "standard" American checkers board. */
|
||||
public static final int STANDARD_BOARD_SIZE = 8;
|
||||
/** Using an international sized checkers board. */
|
||||
public static final int INTERNATIONAL_BOARD_SIZE = 10;
|
||||
/** Using a Canadian sized checkers board. */
|
||||
public static final int CANADIAN_BOARD_SIZE = 12;
|
||||
|
||||
/** The number of variants currently supported. */
|
||||
private static final int NUMBER_OF_VARIANTS_SUPPORTED = 2;
|
||||
|
||||
/** The size of the board. */
|
||||
private int boardSize;
|
||||
/** Can kings fly across the board? */
|
||||
private boolean canKingsFly;
|
||||
/** Can pawns capture backwards? */
|
||||
private boolean canPawnsJumpBackwards;
|
||||
|
||||
// -- Object Fields --------------------------------------------------------
|
||||
/** Stores what kind of checkers variant of rule are we playing? */
|
||||
private int checkersVariant;
|
||||
/** Does the light player start first? */
|
||||
private boolean lightPlayerFirst;
|
||||
/** Is the board mirrored? As in white square lower right corner. */
|
||||
private boolean mirroredBoard;
|
||||
/** Must capture if have opportunity. */
|
||||
private boolean mustCapture;
|
||||
/** Must player capture the highest number of pieces. */
|
||||
private boolean mustCaptureMaxium;
|
||||
/** The type of victory conditions. */
|
||||
private int victoryConditions;
|
||||
|
||||
// -- Constructors ---------------------------------------------------------
|
||||
/**
|
||||
* Creates a rulebook for a checkers game. We use the American variant rules
|
||||
* by default.
|
||||
*/
|
||||
public Rulebook() {
|
||||
this(Rulebook.AMERICAN_CHECKERS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a rulebook for a checkers game. If a bad/unsupported variant is
|
||||
* created, the default of American checkers is chosen.
|
||||
*
|
||||
* @param variant
|
||||
* The variant of checkers we will play.
|
||||
*/
|
||||
public Rulebook(int variant) {
|
||||
if (variant >= 0 && variant < Rulebook.NUMBER_OF_VARIANTS_SUPPORTED) {
|
||||
this.checkersVariant = variant;
|
||||
} else {
|
||||
this.checkersVariant = Rulebook.AMERICAN_CHECKERS;
|
||||
}
|
||||
this.setUpRules();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if kings can fly. That is can kings move as far they wish.
|
||||
*
|
||||
* @return If kings can fly.
|
||||
*/
|
||||
public boolean canKingsFly() {
|
||||
return this.canKingsFly;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if pawns can capture backwards.
|
||||
*
|
||||
* @return If pawns can capture backwards.
|
||||
*/
|
||||
public boolean canPawnsJumpBackwards() {
|
||||
return this.canPawnsJumpBackwards;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the size of the board.
|
||||
*
|
||||
* @return The size of the board.
|
||||
*/
|
||||
public int getBoardSize() {
|
||||
return this.boardSize;
|
||||
}
|
||||
|
||||
// -- Get/set methods ------------------------------------------------------
|
||||
/**
|
||||
* Returns the checkers variant being played.
|
||||
*
|
||||
* @return The checkers variant being played.
|
||||
*/
|
||||
public int getCheckersVariant() {
|
||||
return this.checkersVariant;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the victory conditions of this game.
|
||||
*
|
||||
* @return The victory conditions of this game.
|
||||
*/
|
||||
public int getVictoryConditions() {
|
||||
return this.victoryConditions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns is the board mirrored in this game.
|
||||
*
|
||||
* @return Is the board mirrored in this game.
|
||||
*/
|
||||
public boolean isBoardMirrored() {
|
||||
return this.mirroredBoard;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the light player starts the game.
|
||||
*
|
||||
* @return If the light player starts the game.
|
||||
*/
|
||||
public boolean isLightPlayerFirst() {
|
||||
return this.lightPlayerFirst;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if you must capture a piece if you can.
|
||||
*
|
||||
* @return If you must capture a piece if you can.
|
||||
*/
|
||||
public boolean mustCapture() {
|
||||
return this.mustCapture;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if you must capture the maximum number of pieces possible.
|
||||
*
|
||||
* @return If you must capture the maximum number of pieces possible.
|
||||
*/
|
||||
public boolean mustCaptureMaxium() {
|
||||
return this.mustCaptureMaxium;
|
||||
}
|
||||
|
||||
// -- Private implementation methods.
|
||||
/**
|
||||
* Setups the rules according to what variant of checkers was chosen.
|
||||
*/
|
||||
private void setUpRules() {
|
||||
// Save my sanity.
|
||||
assert this.checkersVariant >= 0;
|
||||
assert this.checkersVariant < Rulebook.NUMBER_OF_VARIANTS_SUPPORTED;
|
||||
|
||||
// Set up the rules by the type of variant.
|
||||
switch (this.checkersVariant) {
|
||||
case Rulebook.AMERICAN_CHECKERS:
|
||||
this.boardSize = Rulebook.STANDARD_BOARD_SIZE;
|
||||
this.canKingsFly = false;
|
||||
this.canPawnsJumpBackwards = false;
|
||||
this.lightPlayerFirst = false;
|
||||
this.mirroredBoard = false;
|
||||
this.mustCapture = true;
|
||||
this.mustCaptureMaxium = false;
|
||||
this.victoryConditions = Rulebook.CAPTURE_ALL_ENEMIES_VICTORY;
|
||||
break;
|
||||
|
||||
case Rulebook.INTERNATIONAL_CHECKERS:
|
||||
this.boardSize = Rulebook.INTERNATIONAL_BOARD_SIZE;
|
||||
this.canKingsFly = true;
|
||||
this.canPawnsJumpBackwards = true;
|
||||
this.lightPlayerFirst = true;
|
||||
this.mirroredBoard = false;
|
||||
this.mustCapture = true;
|
||||
this.mustCaptureMaxium = true;
|
||||
this.victoryConditions = Rulebook.CAPTURE_ALL_ENEMIES_VICTORY;
|
||||
break;
|
||||
|
||||
case Rulebook.BRAZILIAN_CHECKERS:
|
||||
this.boardSize = Rulebook.STANDARD_BOARD_SIZE;
|
||||
this.canKingsFly = true;
|
||||
this.canPawnsJumpBackwards = true;
|
||||
this.lightPlayerFirst = true;
|
||||
this.mirroredBoard = false;
|
||||
this.mustCapture = true;
|
||||
this.mustCaptureMaxium = true;
|
||||
this.victoryConditions = Rulebook.CAPTURE_ALL_ENEMIES_VICTORY;
|
||||
break;
|
||||
|
||||
case Rulebook.CANADIAN_CHECKERS:
|
||||
this.boardSize = Rulebook.CANADIAN_BOARD_SIZE;
|
||||
this.canKingsFly = true;
|
||||
this.canPawnsJumpBackwards = true;
|
||||
this.lightPlayerFirst = true;
|
||||
this.mirroredBoard = false;
|
||||
this.mustCapture = true;
|
||||
this.mustCaptureMaxium = false;
|
||||
this.victoryConditions = Rulebook.CAPTURE_ALL_ENEMIES_VICTORY;
|
||||
break;
|
||||
|
||||
case Rulebook.POOL_CHECKERS:
|
||||
this.boardSize = Rulebook.STANDARD_BOARD_SIZE;
|
||||
this.canKingsFly = true;
|
||||
this.canPawnsJumpBackwards = true;
|
||||
this.lightPlayerFirst = false;
|
||||
this.mirroredBoard = false;
|
||||
this.mustCapture = true;
|
||||
this.mustCaptureMaxium = false;
|
||||
this.victoryConditions = Rulebook.SPECIAL_POOL_VICTORY;
|
||||
break;
|
||||
|
||||
case Rulebook.SPANISH_CHECKERS:
|
||||
this.boardSize = Rulebook.STANDARD_BOARD_SIZE;
|
||||
this.canKingsFly = true;
|
||||
this.canPawnsJumpBackwards = false;
|
||||
this.lightPlayerFirst = true;
|
||||
this.mirroredBoard = true;
|
||||
this.mustCapture = true;
|
||||
this.mustCaptureMaxium = true;
|
||||
this.victoryConditions = Rulebook.CAPTURE_ALL_ENEMIES_VICTORY;
|
||||
break;
|
||||
|
||||
case Rulebook.RUSSIAN_CHECKERS:
|
||||
// TODO: Needs special freshly-kinged-but-still-can-jump special
|
||||
// rule.
|
||||
this.boardSize = Rulebook.STANDARD_BOARD_SIZE;
|
||||
this.canKingsFly = true;
|
||||
this.canPawnsJumpBackwards = true;
|
||||
this.lightPlayerFirst = true;
|
||||
this.mirroredBoard = false;
|
||||
this.mustCapture = true;
|
||||
this.mustCaptureMaxium = false;
|
||||
this.victoryConditions = Rulebook.SPECIAL_RUSSIAN_VICTORY;
|
||||
break;
|
||||
|
||||
case Rulebook.ITALIAN_CHECKERS:
|
||||
// TODO: Special rule on must jump most number of kings per capture.
|
||||
this.boardSize = Rulebook.STANDARD_BOARD_SIZE;
|
||||
this.canKingsFly = true;
|
||||
// TODO: Special rule that pawns can't capture kings.
|
||||
this.canPawnsJumpBackwards = false;
|
||||
this.lightPlayerFirst = true;
|
||||
this.mirroredBoard = true;
|
||||
this.mustCapture = true;
|
||||
this.mustCaptureMaxium = true;
|
||||
this.victoryConditions = Rulebook.CAPTURE_ALL_ENEMIES_VICTORY;
|
||||
break;
|
||||
|
||||
case Rulebook.SUICIDE_CHECKERS:
|
||||
// TODO: Needs unconventional setup.
|
||||
this.boardSize = Rulebook.STANDARD_BOARD_SIZE;
|
||||
this.canKingsFly = true;
|
||||
this.canPawnsJumpBackwards = true;
|
||||
this.lightPlayerFirst = true;
|
||||
this.mirroredBoard = false;
|
||||
this.mustCapture = true;
|
||||
this.mustCaptureMaxium = true;
|
||||
this.victoryConditions = Rulebook.SPECIAL_SUICIDE_VICTORY;
|
||||
break;
|
||||
|
||||
case Rulebook.GHANAIAN_CHECKERS:
|
||||
// TODO: Special forfeit king if passing up a king's capture
|
||||
// opportunity.
|
||||
this.boardSize = Rulebook.INTERNATIONAL_BOARD_SIZE;
|
||||
this.canKingsFly = true;
|
||||
this.canPawnsJumpBackwards = true;
|
||||
this.lightPlayerFirst = true;
|
||||
this.mirroredBoard = true;
|
||||
this.mustCapture = true;
|
||||
this.mustCaptureMaxium = false;
|
||||
this.victoryConditions = Rulebook.SPECIAL_GHANAIAN_VICTORY;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
/*****************************************************************************
|
||||
AmericanGameTest.java -- Regression test of a game played according to
|
||||
American rules.
|
||||
*****************************************************************************
|
||||
|
||||
*****************************************************************************
|
||||
This file is part of justCheckers.
|
||||
|
||||
justCheckers is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
justCheckers is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with justCheckers. If not, see <http://www.gnu.org/licenses/>.
|
||||
*****************************************************************************/
|
||||
|
||||
package org.justcheckers.test.game;
|
||||
|
||||
/**
|
||||
* Regression test for a game of checkers played according to American rules.
|
||||
* American rules are:
|
||||
* - 8x8 board.
|
||||
* - Pawns can only move 1 space forward.
|
||||
* - Kings can move 1 space forward or backwards.
|
||||
* - The game ends when one player is eliminated or completely blocked.
|
||||
*
|
||||
* TestNG version: 5.10
|
||||
*
|
||||
* @author Dorian Pula
|
||||
*
|
||||
*/
|
||||
public class AmericanGameTest {
|
||||
//TODO: Populate with test cases.
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
/*****************************************************************************
|
||||
GameLogicTest.java -- Unit tests related to the game engine.
|
||||
*****************************************************************************
|
||||
|
||||
*****************************************************************************
|
||||
This file is part of justCheckers.
|
||||
|
||||
justCheckers is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
justCheckers is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with justCheckers. If not, see <http://www.gnu.org/licenses/>.
|
||||
*****************************************************************************/
|
||||
|
||||
package org.justcheckers.test.game;
|
||||
|
||||
/**
|
||||
* Test the game engine logic. Tests if the game engine can manipulate the
|
||||
* state of a game and its board, in accordance to the rules of the game. The
|
||||
* set of rule change from variant to variant. These tests should check basic
|
||||
* correctness of the game engine.
|
||||
*
|
||||
* TestNG version: 5.10
|
||||
*
|
||||
* @author Dorian Pula
|
||||
*
|
||||
*/
|
||||
public class GameLogicTest {
|
||||
//TODO: Populate with test cases.
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
/*****************************************************************************
|
||||
GameStateTest.java -- Unit tests related to managing a game's state.
|
||||
*****************************************************************************
|
||||
|
||||
*****************************************************************************
|
||||
This file is part of justCheckers.
|
||||
|
||||
justCheckers is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
justCheckers is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with justCheckers. If not, see <http://www.gnu.org/licenses/>.
|
||||
*****************************************************************************/
|
||||
|
||||
package org.justcheckers.test.game;
|
||||
|
||||
import org.justcheckers.game.Game;
|
||||
import org.justcheckers.game.Rulebook;
|
||||
|
||||
/**
|
||||
* Test the game state logic. Tests the NQPOJO (not quite plain old Java
|
||||
* objects) that handle the state of a game. This includes the Rulebook
|
||||
* (that dictate what rules will be used for a game), the Board (that represents
|
||||
* the state of the board, pieces, etc.) and the Game itself.
|
||||
*
|
||||
* TestNG version: 5.10
|
||||
*
|
||||
* @author dorianpula
|
||||
*/
|
||||
public class GameStateTest {
|
||||
|
||||
/** A test game of checkers. */
|
||||
private Game testGame;
|
||||
|
||||
/**
|
||||
* Sets up a rather plain game of checkers. Game is based on the American
|
||||
* rules, to make life easier.
|
||||
*/
|
||||
//@BeforeClass
|
||||
public void setUp() {
|
||||
this.testGame = new Game();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the rulebook of a default initialized game.
|
||||
*/
|
||||
//@Test
|
||||
public void testDefaultRulebookSetup() {
|
||||
Rulebook testRules = this.testGame.getGameRules();
|
||||
|
||||
junit.framework.Assert.assertNull(testRules);
|
||||
|
||||
//TODO: Test the ruleset that is gets initialized properly.
|
||||
}
|
||||
|
||||
//TODO: Populate with test cases.
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
/*****************************************************************************
|
||||
InternationalGameTest.java -- Regression test of a game played according to
|
||||
International rules.
|
||||
*****************************************************************************
|
||||
|
||||
*****************************************************************************
|
||||
This file is part of justCheckers.
|
||||
|
||||
justCheckers is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
justCheckers is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with justCheckers. If not, see <http://www.gnu.org/licenses/>.
|
||||
*****************************************************************************/
|
||||
|
||||
package org.justcheckers.test.game;
|
||||
|
||||
/**
|
||||
* Regression test for a game of checkers played according to International
|
||||
* rules.
|
||||
* International rules are:
|
||||
* - 10x10 board.
|
||||
* - Pawns can move 1 space forward.
|
||||
* - Kings can move 1 space forward. But can capture backwards.
|
||||
* - The game ends when one player is eliminated or completely blocked.
|
||||
*
|
||||
* TestNG version: 5.10
|
||||
*
|
||||
* @author Dorian Pula
|
||||
*
|
||||
*/
|
||||
public class InternationalGameTest {
|
||||
//TODO: Populate with test cases.
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
package org.justcheckers.xml;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
/**
|
||||
* Holds the justCheckers configuration settings.
|
||||
* @author Brinick Simmons (brinick@users.sourceforge.net)
|
||||
*/
|
||||
|
||||
final public class ConfigSettings extends Settings{
|
||||
|
||||
//---------------------------//
|
||||
// Class Fields //
|
||||
//---------------------------//
|
||||
|
||||
private static ConfigSettings cs = null;
|
||||
|
||||
//---------------------------//
|
||||
// Class Methods //
|
||||
//---------------------------//
|
||||
|
||||
//======= PUBLIC ============//
|
||||
|
||||
/**
|
||||
* Accessor method for obtaining the one
|
||||
* and only instance of this class
|
||||
*/
|
||||
public static ConfigSettings getInstance(){
|
||||
if(cs==null) cs = new ConfigSettings(new DefaultConfigSettings());
|
||||
return cs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the default config settings.
|
||||
*/
|
||||
public static void loadDefault(){
|
||||
cs = new ConfigSettings(new DefaultConfigSettings());
|
||||
}
|
||||
|
||||
//======= PRIVATE CONSTRUCTORS ========//
|
||||
private ConfigSettings(){
|
||||
super();
|
||||
}
|
||||
|
||||
private ConfigSettings(DefaultConfigSettings cus){
|
||||
super(cus.getTextMap(),cus.getAttributeMap());
|
||||
}
|
||||
|
||||
//======= PRIVATE INNER CLASS ============//
|
||||
|
||||
/* The default class from which to get settings */
|
||||
private static class DefaultConfigSettings extends Settings.DefaultSettings{
|
||||
private String userHome = System.getProperty("user.home");
|
||||
private String userDir = System.getProperty("user.dir");
|
||||
private String [][] text =
|
||||
{
|
||||
{"configsettings.directory.configFile",userDir+"/config.xml"},
|
||||
{"configsettings.directory.settings",userHome+"/settings/"},
|
||||
{"configsettings.directory.skins",userDir+"/skins/"},
|
||||
{"configsettings.directory.sounds",userDir+"/sounds/"},
|
||||
{"configsettings.directory.language",userDir+"/language/"},
|
||||
};
|
||||
|
||||
private String [][] attribute =
|
||||
{
|
||||
{"configsettings.general.id","3"},
|
||||
{"configsettings.general.id2","5"},
|
||||
{"configsettings.language.default","english"},
|
||||
{"configsettings.appearance.pretty","true"},
|
||||
};
|
||||
|
||||
DefaultConfigSettings(){
|
||||
super();
|
||||
super.setFields(text,attribute);
|
||||
}
|
||||
}//end of default class
|
||||
}
|
|
@ -0,0 +1,289 @@
|
|||
package org.justcheckers.xml;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.jdom.Attribute;
|
||||
import org.jdom.Comment;
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.JDOMException;
|
||||
import org.jdom.input.SAXBuilder;
|
||||
import org.jdom.output.XMLOutputter;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
/**
|
||||
* Concrete child class of the XML_IO class. Use its load() and save() methods
|
||||
* to write XML into/write out XML from, the associated ConfigSettings object.
|
||||
* @author Brinick Simmons (brinick@users.sourceforge.net)
|
||||
*/
|
||||
public class ConfigSettingsIO extends XML_IO{
|
||||
|
||||
//---------------------------//
|
||||
// Class Methods //
|
||||
//---------------------------//
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// -- Interface -------------------------------------------------------
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Causes the XML data held within the File object referenced by the member
|
||||
* variable "file" (inherited from XML_IO) to be loaded into the ConfigSettings
|
||||
* object associated with this class. The reading in of XML data and subsequent
|
||||
* transformation is dealt with by the inner reader class of this class.
|
||||
*/
|
||||
public void load(){
|
||||
try{
|
||||
SAXBuilder builder = new SAXBuilder();
|
||||
Document doc = builder.build(getFile());
|
||||
Element rootElement = doc.getRootElement();
|
||||
ConfigSettingsIOReader csior = new ConfigSettingsIOReader();
|
||||
csior.visit(rootElement);
|
||||
}
|
||||
catch(IOException e){
|
||||
String msg = "Problem : " + e.getMessage();
|
||||
Log.e("ConfigSettingsIO", msg);
|
||||
}
|
||||
catch(JDOMException e){
|
||||
String msg = "Problem : " + getFile().toString()
|
||||
+ " is not a well formed XML document";
|
||||
Log.e("ConfigSettingsIO", msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Causes the data held within the ConfigSettings object associated with
|
||||
* this class to be saved as XML format into the File object referenced by
|
||||
* the member variable "file". Transformation of ConfigSettings data into XML
|
||||
* format and subsequent writing to file is handled by the inner writer
|
||||
* class of this class.
|
||||
*/
|
||||
public void save(){
|
||||
try{
|
||||
ConfigSettingsIOWriter csiow = new ConfigSettingsIOWriter();
|
||||
Document doc = csiow.createXMLDocument();
|
||||
XMLOutputter outputter = new XMLOutputter("",true);
|
||||
PrintWriter pw = new PrintWriter(
|
||||
new BufferedWriter(
|
||||
new FileWriter(getFile())));
|
||||
outputter.output(doc,pw);
|
||||
}
|
||||
catch(IOException e){
|
||||
String msg = "Problem : couldn't output to the given file : "
|
||||
+ getFile().toString();
|
||||
Log.e("ConfigSettingsIO", msg);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// -- Contructors -----------------------------------------------------
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The constructor used to initiate the ConfigSettingsIO
|
||||
* object with a given file object
|
||||
* @param fileObject The file object with which
|
||||
* to initiate this ConfigSettingsIO.
|
||||
*/
|
||||
public ConfigSettingsIO(File fileObject){
|
||||
super(fileObject,ConfigSettings.getInstance());
|
||||
}
|
||||
|
||||
public ConfigSettingsIO(File fileObject, ConfigSettings cs){
|
||||
super(fileObject,cs);
|
||||
}
|
||||
|
||||
public ConfigSettingsIO(URL urlObject){
|
||||
super(urlObject, ConfigSettings.getInstance());
|
||||
}
|
||||
|
||||
public ConfigSettingsIO(URL urlObject, ConfigSettings cs){
|
||||
super(urlObject,cs);
|
||||
}
|
||||
|
||||
///////////////////////////////////
|
||||
// INNER CLASS : READER //
|
||||
///////////////////////////////////
|
||||
|
||||
private class ConfigSettingsIOReader extends XML_IO.XMLFileReader{
|
||||
|
||||
/*
|
||||
* Loads text information held in an Element object
|
||||
* into the ConfigSettings object
|
||||
*/
|
||||
protected void loadElementIntoSettings(Element e){
|
||||
String text = e.getTextTrim();
|
||||
if(text!=null && text.length()!=0){
|
||||
ConfigSettings.getInstance().setElementText(toFullSettingName(e),text);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Loads Attribute information held in an Element object
|
||||
* into the ConfigSettings object
|
||||
*/
|
||||
protected void loadAttributesIntoSettings(Element e){
|
||||
List attributes = e.getAttributes();
|
||||
ConfigSettings cs = ConfigSettings.getInstance();
|
||||
for(int k=0;k<attributes.size();k++){
|
||||
Attribute current = (Attribute)attributes.get(k);
|
||||
|
||||
String total = toFullSettingName(e) + "." + current.getName();
|
||||
cs.setElementAttribute(total,current.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
/** Adds the correct number on the end of the settings key.
|
||||
Thus a.b.c.d becomes a.b.c.d.x where x=1,2,3...Checks if the key
|
||||
a.b.c.d.1 exists. If so, looks for a.b.c.d.2, etc. in the settings class,
|
||||
and so on, until it has a new key. This method thus allows multi Elements
|
||||
with the same name to be stored uniquely. Without this, for example,
|
||||
game moves would all have the same key e.g. gamesettings.game.move
|
||||
*/
|
||||
protected String correctKeyForNumber(String uncorrectedKey){
|
||||
int i = 1;
|
||||
String correctedKey = uncorrectedKey + "." + i;
|
||||
//is there a key with this name?
|
||||
boolean reachedEnd = (ConfigSettings.getInstance().getElementText(correctedKey) == null);
|
||||
while(!reachedEnd){
|
||||
i++;
|
||||
int lastDotIndex = correctedKey.lastIndexOf('.');
|
||||
correctedKey = correctedKey.substring(0,lastDotIndex+1) + i;
|
||||
reachedEnd = (ConfigSettings.getInstance().getElementText(correctedKey) == null);
|
||||
}
|
||||
|
||||
return correctedKey;
|
||||
}
|
||||
|
||||
} //end of inner class ConfigSettingsIOReader
|
||||
|
||||
|
||||
///////////////////////////////////
|
||||
// INNER CLASS : WRITER //
|
||||
///////////////////////////////////
|
||||
private class ConfigSettingsIOWriter extends XML_IO.XMLFileWriter{
|
||||
/* Creates and returns the Document root Element */
|
||||
public Element createRootElement(){
|
||||
ConfigSettings cs = ConfigSettings.getInstance();
|
||||
Iterator textEntries = cs.getTextEntries().iterator();
|
||||
Map.Entry me = (Map.Entry)textEntries.next();
|
||||
String settingKey = (String)me.getKey();
|
||||
String settingValue = (String)me.getValue();
|
||||
ArrayList settingKeyTokens = splitSettingKey(settingKey);
|
||||
|
||||
return new Element((String)settingKeyTokens.get(0));
|
||||
}
|
||||
|
||||
/* Adds org.jdom.Comment objects to the current Document */
|
||||
public void addComments(Document doc){
|
||||
String text = "This file is important. Do not delete it,"
|
||||
+ " do not displace it, do not rename it. Do any of these things"
|
||||
+ " and as the universe is our witness we'll fry your ass, your"
|
||||
+ " hard drive, sleep with your girlfriend (and she'll enjoy it,"
|
||||
+ " believe us!), have you fired from your job, and transfer your"
|
||||
+ " bank accounts to our names. Yes; this program is that good.";
|
||||
doc.addContent(new Comment(text));
|
||||
}
|
||||
|
||||
/* Create the JDOM tree from the ConfigSettings class */
|
||||
public void addElements(Element rootElement){
|
||||
ConfigSettings cs = ConfigSettings.getInstance();
|
||||
Iterator textEntries = cs.getTextEntries().iterator();
|
||||
//iterator returns Map.Entry objects
|
||||
while(textEntries.hasNext()){
|
||||
Map.Entry me = (Map.Entry)textEntries.next();
|
||||
String settingKey = (String)me.getKey();
|
||||
String settingValue = (String)me.getValue();
|
||||
ArrayList settingKeyTokens = splitSettingKey(settingKey);
|
||||
|
||||
Element parent = rootElement;
|
||||
Element child = null;
|
||||
for(int k=1;k<settingKeyTokens.size();k++){
|
||||
String childName = (String)settingKeyTokens.get(k);
|
||||
child = getChildElement(parent,childName);
|
||||
if(child==null){
|
||||
child = new Element(childName);
|
||||
parent.addContent(child);
|
||||
if(isLastToken(k,settingKeyTokens.size())){
|
||||
child.addContent(settingValue);
|
||||
}
|
||||
}
|
||||
parent = child;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Adds org.jdom.Attribute objects to the DOM tree Elements */
|
||||
public void addAttributes(Element root){
|
||||
Iterator attributeEntries =
|
||||
ConfigSettings.getInstance().getAttributeEntries().iterator();
|
||||
|
||||
while(attributeEntries.hasNext()){
|
||||
Map.Entry me = (Map.Entry)attributeEntries.next();
|
||||
String settingKey = (String)me.getKey();
|
||||
String settingValue = (String)me.getValue();
|
||||
ArrayList settingKeyTokens = splitSettingKey(settingKey);
|
||||
Element e = getElement(settingKeyTokens,root);
|
||||
e.setAttribute((String)settingKeyTokens.get(
|
||||
settingKeyTokens.size()-1),settingValue);
|
||||
}
|
||||
}
|
||||
|
||||
//Checks whether the token from the StringTokenizer operation
|
||||
private boolean isLastToken(int k, int listSize){
|
||||
return (k==listSize-1);
|
||||
}
|
||||
|
||||
//Navigates down the jdom tree until it reaches the element
|
||||
//to which we wish to attach an attribute. Returns that element.
|
||||
private Element getElement(ArrayList tokens, Element root){
|
||||
Element e = root;
|
||||
for(int k=1;k<tokens.size()-1;k++){
|
||||
e = e.getChild((String)tokens.get(k));
|
||||
}
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
/*
|
||||
* Does this parent Element already have a child with this name attached?
|
||||
* If so, return it, else return null
|
||||
*/
|
||||
private Element getChildElement(Element parent, String childName){
|
||||
return parent.getChild(childName);
|
||||
}
|
||||
|
||||
/* Splits a Setting key of the form a.b.c.d into it's
|
||||
respective parts, delimited by the "." */
|
||||
private ArrayList splitSettingKey(String key){
|
||||
ArrayList l = new ArrayList();
|
||||
StringTokenizer st = new StringTokenizer(key,".",false);
|
||||
while(st.hasMoreTokens()){
|
||||
l.add(st.nextToken());
|
||||
}
|
||||
|
||||
return l;
|
||||
}
|
||||
}//end of inner class ConfigSettingsIOWriter
|
||||
|
||||
}//end of class ConfigSettingsIO
|
|
@ -0,0 +1,68 @@
|
|||
package org.justcheckers.xml;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
/**
|
||||
* Holds the current game settings (Players, moves, etc).
|
||||
* Currently, only one game may be open at a time.
|
||||
* Future versions may allow more than one game to be open at
|
||||
* a given moment.
|
||||
*
|
||||
* @author Brinick Simmons (brinick@users.sourceforge.net)
|
||||
*/
|
||||
final public class GameSettings extends Settings{
|
||||
|
||||
//---------------------------//
|
||||
// Class Fields //
|
||||
//---------------------------//
|
||||
|
||||
private HashMap text = new HashMap(), attribute = new HashMap();
|
||||
private static GameSettings gs = null;
|
||||
|
||||
//---------------------------//
|
||||
// Class Methods //
|
||||
//---------------------------//
|
||||
|
||||
//======= PUBLIC ============//
|
||||
|
||||
/**
|
||||
* Accessor method for reaching the one and only instance of this class.
|
||||
* @return Reference to the GameSettings object
|
||||
*/
|
||||
public static GameSettings getInstance(){
|
||||
if(gs==null) gs = new GameSettings();
|
||||
return gs;
|
||||
}
|
||||
|
||||
/*
|
||||
================ NOTE : ===============================================
|
||||
=======================================================================
|
||||
For GameSettings, we need in addition to the inherited Settings methods
|
||||
methods that will be used to fill this object when a new game is started.
|
||||
To be able to code these required methods (there will be more than the two
|
||||
I give as example below) we need to agree on a format for games XML files.
|
||||
|
||||
public void addMove(CheckersMove cm){...}
|
||||
public void addPlayer(Player p){...}
|
||||
...
|
||||
...
|
||||
...
|
||||
=========================================================================
|
||||
|
||||
*/
|
||||
|
||||
// -- Private Constructors -----------------------------------------------
|
||||
|
||||
private GameSettings(){
|
||||
super();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,292 @@
|
|||
package org.justcheckers.xml;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.jdom.Attribute;
|
||||
import org.jdom.Comment;
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.JDOMException;
|
||||
import org.jdom.input.SAXBuilder;
|
||||
import org.jdom.output.XMLOutputter;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
/* **************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
/**
|
||||
* Concrete child class of the @link(XML_IO) class. Represents an
|
||||
* "intelligent" XML file that can read XML data into/write data from
|
||||
* the @link(GameSettings) information associated with this class.
|
||||
*
|
||||
* @author Brinick Simmons (brinick@users.sourceforge.net)
|
||||
*/
|
||||
public class GameSettingsIO extends XML_IO{
|
||||
|
||||
//---------------------------//
|
||||
// Class Methods //
|
||||
//---------------------------//
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// -- Interface -------------------------------------------------------
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Causes the XML data held within the File object referenced by the member
|
||||
* variable "file" (inherited from XML_IO) to be loaded into the GameSettings
|
||||
* object associated with this class. The reading in of XML data and subsequent
|
||||
* transformation is dealt with by the inner reader class of this class.
|
||||
*/
|
||||
public void load(){
|
||||
try{
|
||||
SAXBuilder builder = new SAXBuilder();
|
||||
Document doc = builder.build(getFile());
|
||||
Element rootElement = doc.getRootElement();
|
||||
GameSettingsIOReader gsior = new GameSettingsIOReader();
|
||||
gsior.visit(rootElement);
|
||||
}
|
||||
catch(IOException e){
|
||||
String msg = "Problem : " + e.getMessage();
|
||||
Log.e("GameSettingsIO", msg);
|
||||
}
|
||||
catch(JDOMException e){
|
||||
String msg = "Problem : " + getFile().toString()
|
||||
+ " is not a well formed XML document";
|
||||
Log.e("GameSettingsIO", msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Causes the data held within the GameSettings object associated with
|
||||
* this class to be saved as XML format into the File object referenced by
|
||||
* the member variable "file". Transformation of GameSettings data into XML
|
||||
* format and subsequent writing to file is handled by the inner writer
|
||||
* class of this class.
|
||||
*/
|
||||
public void save(){
|
||||
try{
|
||||
GameSettingsIOWriter gsiow = new GameSettingsIOWriter();
|
||||
Document doc = gsiow.createXMLDocument();
|
||||
XMLOutputter outputter = new XMLOutputter("",true);
|
||||
PrintWriter pw = new PrintWriter(
|
||||
new BufferedWriter(
|
||||
new FileWriter(getFile())));
|
||||
outputter.output(doc,pw);
|
||||
}
|
||||
catch(IOException e){
|
||||
String msg = "Problem : couldn't output to the given file : "
|
||||
+ getFile().toString();
|
||||
Log.e("GameSettingsIO", msg);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// -- Contructors -----------------------------------------------------
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The constructor used to initiate the GameSettingsIO
|
||||
* object with a given file object
|
||||
* @param fileObject The file object with which
|
||||
* to initiate this GameSettingsIO.
|
||||
*/
|
||||
public GameSettingsIO(File fileObject){
|
||||
super(fileObject,GameSettings.getInstance());
|
||||
}
|
||||
|
||||
public GameSettingsIO(File fileObject, GameSettings cs){
|
||||
super(fileObject,cs);
|
||||
}
|
||||
|
||||
public GameSettingsIO(URL urlObject){
|
||||
super(urlObject, GameSettings.getInstance());
|
||||
}
|
||||
|
||||
public GameSettingsIO(URL urlObject, GameSettings cs){
|
||||
super(urlObject,cs);
|
||||
}
|
||||
|
||||
///////////////////////////////////
|
||||
// INNER CLASS : READER //
|
||||
///////////////////////////////////
|
||||
|
||||
private class GameSettingsIOReader extends XML_IO.XMLFileReader{
|
||||
|
||||
/*
|
||||
* Loads text information held in an Element object
|
||||
* into the GameSettings object
|
||||
*/
|
||||
protected void loadElementIntoSettings(Element e){
|
||||
String text = e.getTextTrim();
|
||||
if(text!=null && text.length()!=0){
|
||||
GameSettings.getInstance().setElementText(toFullSettingName(e),text);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Loads Attribute information held in an Element object
|
||||
* into the GameSettings object
|
||||
*/
|
||||
protected void loadAttributesIntoSettings(Element e){
|
||||
List attributes = e.getAttributes();
|
||||
GameSettings gs = GameSettings.getInstance();
|
||||
for(int k=0;k<attributes.size();k++){
|
||||
Attribute current = (Attribute)attributes.get(k);
|
||||
|
||||
String total = toFullSettingName(e) + "." + current.getName();
|
||||
gs.setElementAttribute(total,current.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
/** Adds the correct number on the end of the settings key.
|
||||
Thus a.b.c.d becomes a.b.c.d.x where x=1,2,3...Checks if the key
|
||||
a.b.c.d.1 exists. If so, looks for a.b.c.d.2, etc. in the settings class,
|
||||
and so on, until it has a new key. This method thus allows multi Elements
|
||||
with the same name to be stored uniquely. Without this, for example,
|
||||
game moves would all have the same key e.g. gamesettings.game.move
|
||||
*/
|
||||
protected String correctKeyForNumber(String uncorrectedKey){
|
||||
int i = 1;
|
||||
String correctedKey = uncorrectedKey + "." + i;
|
||||
//is there a key with this name?
|
||||
boolean reachedEnd = (GameSettings.getInstance().getElementText(correctedKey) == null);
|
||||
while(!reachedEnd){
|
||||
i++;
|
||||
int lastDotIndex = correctedKey.lastIndexOf('.');
|
||||
correctedKey = correctedKey.substring(0,lastDotIndex+1) + i;
|
||||
reachedEnd = (GameSettings.getInstance().getElementText(correctedKey) == null);
|
||||
}
|
||||
|
||||
return correctedKey;
|
||||
}
|
||||
|
||||
} //end of inner class GameSettingsIOReader
|
||||
|
||||
|
||||
///////////////////////////////////
|
||||
// INNER CLASS : WRITER //
|
||||
///////////////////////////////////
|
||||
private class GameSettingsIOWriter extends XML_IO.XMLFileWriter{
|
||||
/* Creates and returns the Document root Element */
|
||||
public Element createRootElement(){
|
||||
GameSettings gs = GameSettings.getInstance();
|
||||
Iterator textEntries = gs.getTextEntries().iterator();
|
||||
Map.Entry me = (Map.Entry)textEntries.next();
|
||||
String settingKey = (String)me.getKey();
|
||||
String settingValue = (String)me.getValue();
|
||||
ArrayList settingKeyTokens = splitSettingKey(settingKey);
|
||||
|
||||
return new Element((String)settingKeyTokens.get(0));
|
||||
}
|
||||
|
||||
/* Adds org.jdom.Comment objects to the current Document */
|
||||
public void addComments(Document doc){
|
||||
String text = "This file is important. Do not delete it,"
|
||||
+ " do not displace it, do not rename it. Do any of these things"
|
||||
+ " and as the universe is our witness we'll fry your ass, your"
|
||||
+ " hard drive, sleep with your girlfriend (and she'll enjoy it,"
|
||||
+ " believe us!), have you fired from your job, and transfer your"
|
||||
+ " bank accounts to our names. Yes; this program is that good.";
|
||||
doc.addContent(new Comment(text));
|
||||
}
|
||||
|
||||
/* Create the JDOM tree from the GameSettings class */
|
||||
public void addElements(Element rootElement){
|
||||
GameSettings gs = GameSettings.getInstance();
|
||||
Iterator textEntries = gs.getTextEntries().iterator();
|
||||
//iterator returns Map.Entry objects
|
||||
while(textEntries.hasNext()){
|
||||
Map.Entry me = (Map.Entry)textEntries.next();
|
||||
String settingKey = (String)me.getKey();
|
||||
String settingValue = (String)me.getValue();
|
||||
ArrayList settingKeyTokens = splitSettingKey(settingKey);
|
||||
|
||||
Element parent = rootElement;
|
||||
Element child = null;
|
||||
for(int k=1;k<settingKeyTokens.size();k++){
|
||||
String childName = (String)settingKeyTokens.get(k);
|
||||
child = getChildElement(parent,childName);
|
||||
if(child==null){
|
||||
child = new Element(childName);
|
||||
parent.addContent(child);
|
||||
if(isLastToken(k,settingKeyTokens.size())){
|
||||
child.addContent(settingValue);
|
||||
}
|
||||
}
|
||||
parent = child;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Adds org.jdom.Attribute objects to the DOM tree Elements */
|
||||
public void addAttributes(Element root){
|
||||
Iterator attributeEntries =
|
||||
GameSettings.getInstance().getAttributeEntries().iterator();
|
||||
|
||||
while(attributeEntries.hasNext()){
|
||||
Map.Entry me = (Map.Entry)attributeEntries.next();
|
||||
String settingKey = (String)me.getKey();
|
||||
String settingValue = (String)me.getValue();
|
||||
ArrayList settingKeyTokens = splitSettingKey(settingKey);
|
||||
Element e = getElement(settingKeyTokens,root);
|
||||
e.setAttribute((String)settingKeyTokens.get(
|
||||
settingKeyTokens.size()-1),settingValue);
|
||||
}
|
||||
}
|
||||
|
||||
//Checks whether the token from the StringTokenizer operation
|
||||
private boolean isLastToken(int k, int listSize){
|
||||
return (k==listSize-1);
|
||||
}
|
||||
|
||||
//Navigates down the jdom tree until it reaches the element
|
||||
//to which we wish to attach an attribute. Returns that element.
|
||||
private Element getElement(ArrayList tokens, Element root){
|
||||
Element e = root;
|
||||
for(int k=1;k<tokens.size()-1;k++){
|
||||
e = e.getChild((String)tokens.get(k));
|
||||
}
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
/*
|
||||
* Does this parent Element already have a child with this name attached?
|
||||
* If so, return it, else return null
|
||||
*/
|
||||
private Element getChildElement(Element parent, String childName){
|
||||
return parent.getChild(childName);
|
||||
}
|
||||
|
||||
/* Splits a Setting key of the form a.b.c.d into it's
|
||||
respective parts, delimited by the "." */
|
||||
private ArrayList splitSettingKey(String key){
|
||||
ArrayList l = new ArrayList();
|
||||
StringTokenizer st = new StringTokenizer(key,".",false);
|
||||
while(st.hasMoreTokens()){
|
||||
l.add(st.nextToken());
|
||||
}
|
||||
|
||||
return l;
|
||||
}
|
||||
}//end of inner class GameSettingsIOWriter
|
||||
|
||||
}//end of class GameSettingsIO
|
||||
|
|
@ -0,0 +1,124 @@
|
|||
package org.justcheckers.xml;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
/**
|
||||
* Defines a common template for all classes that
|
||||
* store some sort of Settings. Text, Attribute and Element
|
||||
* are references to the XML objects as implemented
|
||||
* by the JDOM API (http://www.jdom.org).
|
||||
*
|
||||
* @author Brinick Simmons (brinick@users.sourceforge.net)
|
||||
*/
|
||||
public abstract class Settings{
|
||||
//---------------------------//
|
||||
// Class Fields //
|
||||
//---------------------------//
|
||||
|
||||
protected HashMap text = null, attribute = null;
|
||||
|
||||
//---------------------------//
|
||||
// Class Methods //
|
||||
//---------------------------//
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// -- Interface -------------------------------------------------------
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
public static void loadDefault(){}
|
||||
|
||||
//get/set methods on the HashMaps
|
||||
public String getElementText(String key){
|
||||
if(!text.containsKey(key)) return null;
|
||||
return (String)text.get(key);
|
||||
}
|
||||
|
||||
public void setElementText(String key, String value){
|
||||
text.put(key,value);
|
||||
}
|
||||
|
||||
public String getElementAttribute(String key){
|
||||
if(!attribute.containsKey(key)) return null;
|
||||
return (String)attribute.get(key);
|
||||
}
|
||||
|
||||
public void setElementAttribute(String key, String value){
|
||||
attribute.put(key,value);
|
||||
}
|
||||
|
||||
public String getSetting(String key){
|
||||
if(text.containsKey(key)) return getElementText(key);
|
||||
else if(attribute.containsKey(key)) return getElementAttribute(key);
|
||||
return null;
|
||||
}
|
||||
|
||||
public Set getTextEntries(){return text.entrySet();}
|
||||
public Set getAttributeEntries(){return attribute.entrySet();}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// -- Constructors ----------------------------------------------------
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
protected Settings(){
|
||||
text = new HashMap();
|
||||
attribute = new HashMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initiate the two class HashMap member objects with the parameters
|
||||
* @param t The HashMap with which to initiate the "text" member
|
||||
* @param a The HashMap with which to initiate the "attribute" member
|
||||
*/
|
||||
protected Settings(HashMap t, HashMap a){
|
||||
text = t;
|
||||
attribute = a;
|
||||
}
|
||||
|
||||
////////////////////////////////////
|
||||
// INNER CLASS : Default Settings //
|
||||
////////////////////////////////////
|
||||
/**
|
||||
* The outer Settings object employs this nested one to obtain default values
|
||||
* for its member HashMap objects "text" and "attribute".
|
||||
*/
|
||||
protected abstract static class DefaultSettings{
|
||||
//------ Class Fields -----------
|
||||
protected String [][] text = {};
|
||||
protected String [][] attribute = {};
|
||||
|
||||
//------ Class Methods ----------
|
||||
protected void setFields(String [][] text, String [][] attribute){
|
||||
this.text = text;
|
||||
this.attribute = attribute;
|
||||
}
|
||||
|
||||
public HashMap getTextMap(){
|
||||
HashMap hm = new HashMap(text.length);
|
||||
for(int k=0;k<text.length;k++){
|
||||
hm.put(text[k][0],text[k][1]);
|
||||
}
|
||||
|
||||
return hm;
|
||||
}
|
||||
|
||||
public HashMap getAttributeMap(){
|
||||
HashMap hm = new HashMap(attribute.length);
|
||||
for(int k=0;k<attribute.length;k++){
|
||||
hm.put(attribute[k][0],attribute[k][1]);
|
||||
}
|
||||
|
||||
return hm;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
package org.justcheckers.xml;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
/**
|
||||
* Stores the user preferences in the application memory.
|
||||
* Implements the singleton pattern.
|
||||
*
|
||||
* @author Brinick Simmons (brinick@users.sourceforge.net)
|
||||
*/
|
||||
final public class UserSettings extends Settings{
|
||||
|
||||
//---------------------------//
|
||||
// Class Fields //
|
||||
//---------------------------//
|
||||
|
||||
private static UserSettings us = null;
|
||||
private HashMap text = null, attribute = null;
|
||||
|
||||
//---------------------------//
|
||||
// Class Methods //
|
||||
//---------------------------//
|
||||
|
||||
// -- Interface ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Accessor method for obtaining the one and only instance of this class
|
||||
*/
|
||||
public static UserSettings getInstance(){
|
||||
if(us==null) loadDefault();
|
||||
return us;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the default user settings.
|
||||
*/
|
||||
public static void loadDefault(){
|
||||
us = new UserSettings(new DefaultUserSettings());
|
||||
//somehow would have to log that properties have changed
|
||||
//so that things can be updated e.g. the UI, or whatever
|
||||
}
|
||||
|
||||
// -- Private Constructors -----------------------------------------------
|
||||
|
||||
private UserSettings(){
|
||||
super();
|
||||
}
|
||||
|
||||
private UserSettings(DefaultUserSettings dus){
|
||||
super(dus.getTextMap(), dus.getAttributeMap());
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
// INNER CLASS : DefaultSettings //
|
||||
//////////////////////////////////////
|
||||
|
||||
private static class DefaultUserSettings extends Settings.DefaultSettings{
|
||||
private String [][] text =
|
||||
{
|
||||
{"usersettings.general.splashOnLaunch","true"},
|
||||
{"usersettings.general.maxActiveGames","3"},
|
||||
{"usersettings.audio.activateBkgdOnLaunch","false"},
|
||||
{"usersettings.audio.defaultBkgdSong","song1.wav"},
|
||||
{"usersettings.audio.appSoundsActive","true"},
|
||||
{"usersettings.language.current","english"},
|
||||
{"usersettings.appearance.fullScreenOnLaunch","true"},
|
||||
{"usersettings.appearance.activePieceSet","pieceset1"},
|
||||
};
|
||||
|
||||
private String [][] attribute =
|
||||
{
|
||||
{"usersettings.general.id","3"},
|
||||
{"usersettings.general.id2","5"},
|
||||
{"usersettings.language.default","english"},
|
||||
{"usersettings.appearance.pretty","true"},
|
||||
};
|
||||
|
||||
DefaultUserSettings(){
|
||||
super();
|
||||
super.setFields(text,attribute);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,295 @@
|
|||
package org.justcheckers.xml;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.jdom.Attribute;
|
||||
import org.jdom.Comment;
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.JDOMException;
|
||||
import org.jdom.input.SAXBuilder;
|
||||
import org.jdom.output.XMLOutputter;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
/* **************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
/**
|
||||
* Concrete child class of the @link(XML_IO) class. Represents an
|
||||
* "intelligent" XML file that can read XML data into/write data from
|
||||
* the @link(UserSettings) information associated with this class.
|
||||
*
|
||||
* @author Brinick Simmons (brinick@users.sourceforge.net)
|
||||
*/
|
||||
public class UserSettingsIO extends XML_IO{
|
||||
|
||||
//---------------------------//
|
||||
// Class Methods //
|
||||
//---------------------------//
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// -- Interface -------------------------------------------------------
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Causes the XML data held within the File object referenced by the member
|
||||
* variable "file" (inherited from XML_IO) to be loaded into the UserSettings
|
||||
* object associated with this class. The reading in of XML data and subsequent
|
||||
* transformation is dealt with by the inner reader class of this class.
|
||||
*/
|
||||
public void load(){
|
||||
try{
|
||||
SAXBuilder builder = new SAXBuilder();
|
||||
Document doc = builder.build(getFile());
|
||||
Element rootElement = doc.getRootElement();
|
||||
UserSettingsIOReader usior = new UserSettingsIOReader();
|
||||
usior.visit(rootElement);
|
||||
}
|
||||
catch(IOException e){
|
||||
String msg = "Problem : " + e.getMessage();
|
||||
Log.e("UserSettingsIO", msg);
|
||||
}
|
||||
catch(JDOMException e){
|
||||
String msg = "Problem : " + getFile().toString()
|
||||
+ " is not a well formed XML document";
|
||||
Log.e("UserSettingsIO", msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Causes the data held within the UserSettings object associated with
|
||||
* this class to be saved as XML format into the File object referenced by
|
||||
* the member variable "file". Transformation of UserSettings data into XML
|
||||
* format and subsequent writing to file is handled by the inner writer
|
||||
* class of this class.
|
||||
*/
|
||||
public void save(){
|
||||
try{
|
||||
UserSettingsIOWriter usiow = new UserSettingsIOWriter();
|
||||
Document doc = usiow.createXMLDocument();
|
||||
XMLOutputter outputter = new XMLOutputter("",true);
|
||||
PrintWriter pw = new PrintWriter(
|
||||
new BufferedWriter(
|
||||
new FileWriter(getFile())));
|
||||
outputter.output(doc,pw);
|
||||
}
|
||||
catch(IOException e){
|
||||
String msg = "Problem : couldn't output to the given file : "
|
||||
+ getFile().toString();
|
||||
Log.e("UserSettingsIO", msg);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// -- Contructors -----------------------------------------------------
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The constructor used to initiate the UserSettingsIO
|
||||
* object with a given file object
|
||||
* @param fileObject The file object with which
|
||||
* to initiate this UserSettingsIO.
|
||||
*/
|
||||
public UserSettingsIO(File fileObject){
|
||||
super(fileObject,UserSettings.getInstance());
|
||||
}
|
||||
|
||||
public UserSettingsIO(File fileObject, UserSettings us){
|
||||
super(fileObject,us);
|
||||
}
|
||||
|
||||
public UserSettingsIO(URL urlObject){
|
||||
super(urlObject,UserSettings.getInstance());
|
||||
}
|
||||
|
||||
public UserSettingsIO(URL urlObject, UserSettings us){
|
||||
super(urlObject,us);
|
||||
}
|
||||
|
||||
///////////////////////////////////
|
||||
// INNER CLASS : READER //
|
||||
///////////////////////////////////
|
||||
|
||||
private class UserSettingsIOReader extends XML_IO.XMLFileReader{
|
||||
|
||||
/*
|
||||
* Loads text information held in an Element object
|
||||
* into the UserSettings object
|
||||
*/
|
||||
protected void loadElementIntoSettings(Element e){
|
||||
String text = e.getTextTrim();
|
||||
if(text!=null && text.length()!=0){
|
||||
String fullName = toFullSettingName(e);
|
||||
UserSettings.getInstance().setElementText(fullName,text);
|
||||
System.out.println("element: " + fullName + " = " + text);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Loads Attribute information held in an Element object
|
||||
* into the UserSettings object
|
||||
*/
|
||||
protected void loadAttributesIntoSettings(Element e){
|
||||
List attributes = e.getAttributes();
|
||||
UserSettings us = UserSettings.getInstance();
|
||||
for(int k=0;k<attributes.size();k++){
|
||||
Attribute current = (Attribute)attributes.get(k);
|
||||
|
||||
String total = toFullSettingName(e) + "." + current.getName();
|
||||
us.setElementAttribute(total,current.getValue());
|
||||
System.out.println("attribute: " + total + " = " + current.getValue());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/** Adds the correct number on the end of the settings key.
|
||||
Thus a.b.c.d becomes a.b.c.d.x where x=1,2,3...Checks if the key
|
||||
a.b.c.d.1 exists. If so, looks for a.b.c.d.2, etc. in the settings class,
|
||||
and so on, until it has a new key. This method thus allows multi Elements
|
||||
with the same name to be stored uniquely. Without this, for example,
|
||||
game moves would all have the same key e.g. gamesettings.game.move
|
||||
*/
|
||||
protected String correctKeyForNumber(String uncorrectedKey){
|
||||
int i = 1;
|
||||
String correctedKey = uncorrectedKey + "." + i;
|
||||
//is there a key with this name?
|
||||
boolean reachedEnd = (UserSettings.getInstance().getElementText(correctedKey) == null);
|
||||
while(!reachedEnd){
|
||||
i++;
|
||||
int lastDotIndex = correctedKey.lastIndexOf('.');
|
||||
correctedKey = correctedKey.substring(0,lastDotIndex+1) + i;
|
||||
reachedEnd = (UserSettings.getInstance().getElementText(correctedKey) == null);
|
||||
}
|
||||
|
||||
return correctedKey;
|
||||
}
|
||||
|
||||
} //end of inner class UserSettingsIOReader
|
||||
|
||||
|
||||
///////////////////////////////////
|
||||
// INNER CLASS : WRITER //
|
||||
///////////////////////////////////
|
||||
private class UserSettingsIOWriter extends XML_IO.XMLFileWriter{
|
||||
/* Creates and returns the Document root Element */
|
||||
public Element createRootElement(){
|
||||
UserSettings us = UserSettings.getInstance();
|
||||
Iterator textEntries = us.getTextEntries().iterator();
|
||||
Map.Entry me = (Map.Entry)textEntries.next();
|
||||
String settingKey = (String)me.getKey();
|
||||
String settingValue = (String)me.getValue();
|
||||
ArrayList settingKeyTokens = splitSettingKey(settingKey);
|
||||
|
||||
return new Element((String)settingKeyTokens.get(0));
|
||||
}
|
||||
|
||||
/* Adds org.jdom.Comment objects to the current Document */
|
||||
public void addComments(Document doc){
|
||||
String text = "This file is important. Do not delete it,"
|
||||
+ " do not displace it, do not rename it. Do any of these things"
|
||||
+ " and as the universe is our witness we'll fry your ass, your"
|
||||
+ " hard drive, sleep with your girlfriend (and she'll enjoy it,"
|
||||
+ " believe us!), have you fired from your job, and transfer your"
|
||||
+ " bank accounts to our names. Yes; this program is that good.";
|
||||
doc.addContent(new Comment(text));
|
||||
}
|
||||
|
||||
/* Create the JDOM tree from the UserSettings class */
|
||||
public void addElements(Element rootElement){
|
||||
UserSettings us = UserSettings.getInstance();
|
||||
Iterator textEntries = us.getTextEntries().iterator();
|
||||
//iterator returns Map.Entry objects
|
||||
while(textEntries.hasNext()){
|
||||
Map.Entry me = (Map.Entry)textEntries.next();
|
||||
String settingKey = (String)me.getKey();
|
||||
String settingValue = (String)me.getValue();
|
||||
ArrayList settingKeyTokens = splitSettingKey(settingKey);
|
||||
|
||||
Element parent = rootElement;
|
||||
Element child = null;
|
||||
for(int k=1;k<settingKeyTokens.size();k++){
|
||||
String childName = (String)settingKeyTokens.get(k);
|
||||
child = getChildElement(parent,childName);
|
||||
if(child==null){
|
||||
child = new Element(childName);
|
||||
parent.addContent(child);
|
||||
if(isLastToken(k,settingKeyTokens.size())){
|
||||
child.addContent(settingValue);
|
||||
}
|
||||
}
|
||||
parent = child;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Adds org.jdom.Attribute objects to the DOM tree Elements */
|
||||
public void addAttributes(Element root){
|
||||
Iterator attributeEntries =
|
||||
UserSettings.getInstance().getAttributeEntries().iterator();
|
||||
|
||||
while(attributeEntries.hasNext()){
|
||||
Map.Entry me = (Map.Entry)attributeEntries.next();
|
||||
String settingKey = (String)me.getKey();
|
||||
String settingValue = (String)me.getValue();
|
||||
ArrayList settingKeyTokens = splitSettingKey(settingKey);
|
||||
Element e = getElement(settingKeyTokens,root);
|
||||
e.setAttribute((String)settingKeyTokens.get(
|
||||
settingKeyTokens.size()-1),settingValue);
|
||||
}
|
||||
}
|
||||
|
||||
//Checks whether the token from the StringTokenizer operation
|
||||
private boolean isLastToken(int k, int listSize){
|
||||
return (k==listSize-1);
|
||||
}
|
||||
|
||||
//Navigates down the jdom tree until it reaches the element
|
||||
//to which we wish to attach an attribute. Returns that element.
|
||||
private Element getElement(ArrayList tokens, Element root){
|
||||
Element e = root;
|
||||
for(int k=1;k<tokens.size()-1;k++){
|
||||
e = e.getChild((String)tokens.get(k));
|
||||
}
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
/*
|
||||
* Does this parent Element already have a child with this name attached?
|
||||
* If so, return it, else return null
|
||||
*/
|
||||
private Element getChildElement(Element parent, String childName){
|
||||
return parent.getChild(childName);
|
||||
}
|
||||
|
||||
/* Splits a Setting key of the form a.b.c.d into it's
|
||||
respective parts, delimited by the "." */
|
||||
private ArrayList splitSettingKey(String key){
|
||||
ArrayList l = new ArrayList();
|
||||
StringTokenizer st = new StringTokenizer(key,".",false);
|
||||
while(st.hasMoreTokens()){
|
||||
l.add(st.nextToken());
|
||||
}
|
||||
|
||||
return l;
|
||||
}
|
||||
}//end of inner class UserSettingsIOWriter
|
||||
|
||||
}//end of class UserSettingsIO
|
|
@ -0,0 +1,102 @@
|
|||
//********************************************************************
|
||||
// VisitDOM.java -- Abstract class for traversing XML documents.
|
||||
// ********************************************************************
|
||||
|
||||
// ********************************************************************
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
// ********************************************************************
|
||||
|
||||
package org.justcheckers.xml;
|
||||
import java.util.Iterator;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.Text;
|
||||
|
||||
/**
|
||||
* An abstract class that provides a framework to do any processing of a
|
||||
* DOM tree created with the JDOM package ( http://www.jdom.org ). It
|
||||
* provides a recursive traverse with data processing methods that run
|
||||
* before traversal, after traversal and at each Element object and Text
|
||||
* object encountered. The default methods are do-nothing place-holders.
|
||||
* These methods can be over-ridden in a child class that extends this one,
|
||||
* doing what ever data processing needs to be done. Other methods and
|
||||
* fields can also be added to child classes as needed.
|
||||
*
|
||||
* @author Dan D'Alimonte
|
||||
*/
|
||||
public abstract class VisitDOM {
|
||||
|
||||
// -- Interface ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Actions to preform before the traversal of the DOM tree begins.
|
||||
* @param e The root Element of the tree.
|
||||
*/
|
||||
protected void preRoot(Element e) {}
|
||||
|
||||
/**
|
||||
* Actions to preform after the traversal has been completed.
|
||||
* @param e The root Element of the tree.
|
||||
*/
|
||||
protected void postRoot(Element e) {}
|
||||
|
||||
/**
|
||||
* Actions to preform when an Element object is encountered in the DOM tree.
|
||||
* @param e The Element object to process.
|
||||
*/
|
||||
protected void elementHandler(Element e) {}
|
||||
|
||||
/**
|
||||
* Actions to preform when a Text object is encountered in the DOM tree.
|
||||
* @param t The Text object to process.
|
||||
*/
|
||||
protected void textHandler(Text t) {}
|
||||
|
||||
|
||||
// -- Contructors -------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Construct a new VisitDOM instance.
|
||||
*/
|
||||
public VisitDOM() {}
|
||||
|
||||
|
||||
// -- Public methods ----------------------------------------------------
|
||||
|
||||
/**
|
||||
* Preform the taversal on the DOM tree, visiting each node and
|
||||
* processing them in turn.
|
||||
* @param root The root Element of the tree to preform the traversal on.
|
||||
*/
|
||||
public void visit(Element root) {
|
||||
preRoot(root);
|
||||
elementHandler(root);
|
||||
recurse(root);
|
||||
postRoot(root);
|
||||
}
|
||||
|
||||
|
||||
// -- Protected Methods -------------------------------------------------
|
||||
|
||||
/**
|
||||
* Traverses to children of Elements, calling appropriate data processing
|
||||
* methods on the child objects, recursing deeper if needed.
|
||||
* @param e The element whose children are to be processed.
|
||||
*/
|
||||
protected void recurse(Element e) {
|
||||
Iterator iElement = e.getChildren().iterator();
|
||||
while (iElement.hasNext()) {
|
||||
Object next = iElement.next();
|
||||
if (next instanceof Element) {
|
||||
elementHandler((Element)next);
|
||||
recurse((Element)next);
|
||||
}
|
||||
else if ( next instanceof Text ) {
|
||||
textHandler((Text)next);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package org.justcheckers.xml;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
/**
|
||||
* XMLFileFilter returns only File objects that represent XML files.
|
||||
*
|
||||
* @author Brinick Simmons (brinick@users.sourceforge.net)
|
||||
*
|
||||
*/
|
||||
public class XMLFileFilter implements FileFilter{
|
||||
public boolean accept(File f){
|
||||
return f.toString().endsWith(".xml");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,267 @@
|
|||
package org.justcheckers.xml;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.Text;
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
/**
|
||||
* Abstract version of an "intelligent" XML file. Objects of this class know
|
||||
* how to read/write the @see(Settings) information they are associated with,
|
||||
* into justCheckers memory/out to disk. The user creates a child object of
|
||||
* this class giving the name and location of the File object to be represented
|
||||
* by this class.
|
||||
*
|
||||
* NOTE :
|
||||
* For the time being, data may only be outputted to XML files stored locally.
|
||||
*
|
||||
* @author Brinick Simmons (brinick@users.sourceforge.net)
|
||||
*/
|
||||
public abstract class XML_IO{
|
||||
|
||||
//---------------------------//
|
||||
// Class Fields //
|
||||
//---------------------------//
|
||||
//protected URL url;
|
||||
protected File file;
|
||||
protected Settings settings;
|
||||
|
||||
//---------------------------//
|
||||
// Class Methods //
|
||||
//---------------------------//
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// -- Interface -------------------------------------------------------
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Causes the XML data held within the File object referenced by the class
|
||||
* member variable "file" to be loaded into the Settings object associated
|
||||
* with this class. The reading in of XML data and subsequent transformation
|
||||
* is dealt with by the inner reader class of this class.
|
||||
*/
|
||||
public abstract void load();
|
||||
|
||||
/**
|
||||
* Causes the data held within the Settings object associated with this class
|
||||
* to be saved as XML format into the File object referenced by the class
|
||||
* member variable "file". Transformation of Settings data to XML format and
|
||||
* subsequent writing to File is handled by the inner writer class of this
|
||||
* class.
|
||||
*/
|
||||
public abstract void save();
|
||||
|
||||
/** Sets the member variable File object to the parameter object passed in.
|
||||
* @param f The File object with which to set the class member variable "file"
|
||||
*/
|
||||
protected void setFile(File f){file = f;}
|
||||
|
||||
/** Gets the member variable File object.
|
||||
* @return The File object held in the class member variable "file".
|
||||
*/
|
||||
protected File getFile(){return file;}
|
||||
|
||||
/* Place holder for a later version */
|
||||
// protected void setFile(URL u){}
|
||||
// protected URL getFile(){}
|
||||
|
||||
/** Sets the member variable Settings object to the parameter object passed in.
|
||||
* @param s The Settings object with which to set the class member variable "settings"
|
||||
*/
|
||||
protected void setSettings(Settings s){settings = s;}
|
||||
|
||||
/** Gets the member variable Settings object.
|
||||
* @return The Settings object held in the class member variable "settings".
|
||||
*/
|
||||
protected Settings getSettings(){return settings;}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// -- Constructors ----------------------------------------------------
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
protected XML_IO(){}
|
||||
protected XML_IO(File f, Settings s){file = f; settings=s;}
|
||||
protected XML_IO(URL u, Settings s){}
|
||||
|
||||
|
||||
///////////////////////////////////
|
||||
// INNER CLASS : READER //
|
||||
///////////////////////////////////
|
||||
|
||||
/**
|
||||
* An abstract class that provides a framework to do any processing of a
|
||||
* DOM tree created with the JDOM package ( http://www.jdom.org ). It
|
||||
* provides a recursive traverse with data processing methods that run
|
||||
* before traversal, after traversal and at each Element object and Text
|
||||
* object encountered. The default methods are do-nothing place-holders.
|
||||
* These methods can be over-ridden in a child class that extends this one,
|
||||
* doing what ever data processing needs to be done. Other methods and
|
||||
* fields can also be added to child classes as needed.
|
||||
*
|
||||
* @author Dan D'Alimonte (skwirl@users.sourceforge.net)
|
||||
*/
|
||||
protected abstract class XMLFileReader{
|
||||
|
||||
// -- Interface ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Actions to preform before the traversal of the DOM tree begins.
|
||||
* @param e The root Element of the tree.
|
||||
*/
|
||||
protected void preRoot( Element e ) {}
|
||||
|
||||
/**
|
||||
* Actions to preform after the traversal has been completed.
|
||||
* @param e The root Element of the tree.
|
||||
*/
|
||||
protected void postRoot( Element e ) {}
|
||||
|
||||
/**
|
||||
* Actions to preform when an Element object is encountered in the DOM tree.
|
||||
* @param e The Element object to process.
|
||||
*/
|
||||
protected void elementHandler( Element e ) {
|
||||
loadElementIntoSettings(e);
|
||||
loadAttributesIntoSettings(e);
|
||||
}
|
||||
|
||||
protected abstract void loadElementIntoSettings(Element e);
|
||||
protected abstract void loadAttributesIntoSettings(Element e);
|
||||
|
||||
/**
|
||||
* Actions to preform when a Text object is encountered in the DOM tree.
|
||||
* @param t The Text object to process.
|
||||
*/
|
||||
protected void textHandler( Text t ) {}
|
||||
|
||||
|
||||
// -- Constructors -------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Construct a new VisitDOM instance.
|
||||
*/
|
||||
public XMLFileReader() {}
|
||||
|
||||
|
||||
// -- Public methods ----------------------------------------------------
|
||||
|
||||
/**
|
||||
* Preform the traversal on the DOM tree, visiting each node and
|
||||
* processing them in turn.
|
||||
* @param root The root Element of the tree to preform the traversal on.
|
||||
*/
|
||||
public void visit( Element root ) {
|
||||
preRoot( root );
|
||||
elementHandler( root );
|
||||
recurse( root );
|
||||
postRoot( root );
|
||||
}
|
||||
|
||||
// -- Protected Methods -------------------------------------------------
|
||||
|
||||
/**
|
||||
* Traverses to children of Elements, calling appropriate data processing
|
||||
* methods on the child objects, recursing deeper if needed.
|
||||
* @param e The element whose children are to be processed.
|
||||
*/
|
||||
protected void recurse( Element e ) {
|
||||
Iterator iElement = e.getChildren().iterator();
|
||||
while ( iElement.hasNext() ) {
|
||||
Object next = iElement.next();
|
||||
if ( next instanceof Element ) {
|
||||
elementHandler( (Element)next );
|
||||
recurse( (Element)next );
|
||||
}
|
||||
else if ( next instanceof Text ) {
|
||||
textHandler( (Text)next );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the full path name in the form a.b.c.d
|
||||
* of an Element object d
|
||||
*/
|
||||
protected String toFullSettingName(Element e){
|
||||
String path = e.getName();
|
||||
Element currentElement = e;
|
||||
while(!currentElement.isRootElement()){
|
||||
currentElement = currentElement.getParent();
|
||||
path = currentElement.getName() + "." + path;
|
||||
}
|
||||
|
||||
return correctKeyForNumber(path);
|
||||
}
|
||||
|
||||
protected abstract String correctKeyForNumber(String path);
|
||||
|
||||
}
|
||||
|
||||
///////////////////////////////////
|
||||
// INNER CLASS : WRITER //
|
||||
///////////////////////////////////
|
||||
|
||||
/**
|
||||
* Abstract framework for creating a DOM tree
|
||||
* (using the JDOM API http://www.jdom.org) from an
|
||||
* in-application memory "Settings" class.
|
||||
* The default methods are do-nothing place-holders
|
||||
* that should be over-ridden by a child class.
|
||||
* @author Brinick Simmons
|
||||
* @see UserSettings
|
||||
* @see GameSettings
|
||||
*/
|
||||
protected abstract class XMLFileWriter{
|
||||
|
||||
/**
|
||||
* Creates and returns a JDOM Document object
|
||||
* @return org.jdom.Document object storing Settings information
|
||||
*/
|
||||
protected Document createXMLDocument(){
|
||||
Element root = createRootElement();
|
||||
Document doc = new Document(root);
|
||||
addComments(doc);
|
||||
addElements(root);
|
||||
addAttributes(root);
|
||||
return doc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the root org.jdom.Element for the Document in memory
|
||||
* @return The newly created root Element
|
||||
*/
|
||||
abstract protected Element createRootElement();
|
||||
|
||||
/**
|
||||
* Adds org.jdom.Comment objects to the Document
|
||||
* @param d The Document to which Comments will be added
|
||||
*/
|
||||
protected void addComments(Document d){}
|
||||
|
||||
/**
|
||||
* Builds the tree structure of org.jdom.Element objects in the Document.
|
||||
* @param root The tree root Element to which all other
|
||||
* Elements are (in)directly attached.
|
||||
*/
|
||||
protected void addElements(Element root){}
|
||||
|
||||
/**
|
||||
* Adds any org.jdom.Attribute objects to the appropriate Element objects.
|
||||
* @param root The tree root Element.
|
||||
*/
|
||||
protected void addAttributes(Element root){}
|
||||
}
|
||||
}
|
||||
|