mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
Merge branch 'master' of https://git.cardforge.org/core-developers/forge into mobile-translations02
This commit is contained in:
674
LICENSE
Normal file
674
LICENSE
Normal file
@@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://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 <https://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
|
||||
<https://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
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<artifactId>forge</artifactId>
|
||||
<groupId>forge</groupId>
|
||||
<version>1.6.28-SNAPSHOT</version>
|
||||
<version>1.6.29-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>forge-ai</artifactId>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
package forge.ai;
|
||||
|
||||
public enum AIOption {
|
||||
USE_SIMULATION;
|
||||
USE_SIMULATION
|
||||
}
|
||||
|
||||
@@ -1021,7 +1021,7 @@ public class AiAttackController {
|
||||
} // stay at home to block
|
||||
|
||||
if ( LOG_AI_ATTACKS )
|
||||
System.out.println(String.valueOf(this.aiAggression) + " = ai aggression");
|
||||
System.out.println(this.aiAggression + " = ai aggression");
|
||||
|
||||
// ****************
|
||||
// Evaluation the end
|
||||
@@ -1457,7 +1457,7 @@ public class AiAttackController {
|
||||
if (artifact != null) {
|
||||
return artifact;
|
||||
}
|
||||
return null; //should never get here
|
||||
return null;//should never get here
|
||||
}
|
||||
|
||||
private void doLightmineFieldAttackLogic(List<Card> attackersLeft, int numForcedAttackers, boolean playAggro) {
|
||||
|
||||
@@ -859,7 +859,7 @@ public class AiBlockController {
|
||||
damageToPW += ComputerUtilCombat.predictDamageTo((Card) def, pwatkr.getNetCombatDamage(), pwatkr, true);
|
||||
}
|
||||
}
|
||||
if ((!onlyIfLethal && damageToPW > 0) || damageToPW >= ((Card) def).getCounters(CounterType.LOYALTY)) {
|
||||
if ((!onlyIfLethal && damageToPW > 0) || damageToPW >= def.getCounters(CounterType.LOYALTY)) {
|
||||
threatenedPWs.add((Card) def);
|
||||
}
|
||||
}
|
||||
@@ -879,7 +879,7 @@ public class AiBlockController {
|
||||
if (!chumpPWDefenders.isEmpty()) {
|
||||
for (final Card attacker : attackers) {
|
||||
GameEntity def = combat.getDefenderByAttacker(attacker);
|
||||
if (def instanceof Card && threatenedPWs.contains((Card) def)) {
|
||||
if (def instanceof Card && threatenedPWs.contains(def)) {
|
||||
if (attacker.hasKeyword(Keyword.TRAMPLE)) {
|
||||
// don't bother trying to chump a trampling creature
|
||||
continue;
|
||||
@@ -914,7 +914,7 @@ public class AiBlockController {
|
||||
pwDefenders.addAll(combat.getBlockers(pwAtk));
|
||||
} else {
|
||||
isFullyBlocked = false;
|
||||
damageToPW += ComputerUtilCombat.predictDamageTo((Card) pw, pwAtk.getNetCombatDamage(), pwAtk, true);
|
||||
damageToPW += ComputerUtilCombat.predictDamageTo(pw, pwAtk.getNetCombatDamage(), pwAtk, true);
|
||||
}
|
||||
}
|
||||
if (!isFullyBlocked && damageToPW >= pw.getCounters(CounterType.LOYALTY)) {
|
||||
@@ -1329,13 +1329,9 @@ public class AiBlockController {
|
||||
&& ((Card) combat.getDefenderByAttacker(attacker)).isPlaneswalker();
|
||||
boolean wantToTradeDownToSavePW = chanceToTradeDownToSaveWalker > 0;
|
||||
|
||||
if (((evalBlk <= evalAtk + 1) || (wantToSavePlaneswalker && wantToTradeDownToSavePW)) // "1" accounts for tapped.
|
||||
return ((evalBlk <= evalAtk + 1) || (wantToSavePlaneswalker && wantToTradeDownToSavePW)) // "1" accounts for tapped.
|
||||
&& powerParityOrHigher
|
||||
&& (creatureParityOrAllowedDiff || wantToTradeWithCreatInHand)
|
||||
&& (MyRandom.percentTrue(chance) || wantToSavePlaneswalker)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
&& (MyRandom.percentTrue(chance) || wantToSavePlaneswalker);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ public class AiCardMemory {
|
||||
|
||||
Set<Card> memorySet = getMemorySet(set);
|
||||
|
||||
return memorySet == null ? false : memorySet.contains(c);
|
||||
return memorySet != null && memorySet.contains(c);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -291,7 +291,7 @@ public class AiCardMemory {
|
||||
* @return true, if the given memory set contains no remembered cards.
|
||||
*/
|
||||
public boolean isMemorySetEmpty(MemorySet set) {
|
||||
return set == null ? true : getMemorySet(set).isEmpty();
|
||||
return set == null || getMemorySet(set).isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1645,7 +1645,6 @@ public class AiController {
|
||||
// For non-converted triggers (such as Cumulative Upkeep) that don't have costs or targets to worry about
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1690,16 +1689,11 @@ public class AiController {
|
||||
left = AbilityUtils.calculateAmount(hostCard, svarToCheck, sa);
|
||||
}
|
||||
System.out.println("aiShouldRun?" + left + comparator + compareTo);
|
||||
if (Expressions.compare(left, comparator, compareTo)) {
|
||||
return true;
|
||||
}
|
||||
return Expressions.compare(left, comparator, compareTo);
|
||||
} else if (effect.getMapParams().containsKey("AICheckDredge")) {
|
||||
return player.getCardsIn(ZoneType.Library).size() > 8 || player.isCardInPlay("Laboratory Maniac");
|
||||
} else if (sa != null && doTrigger(sa, false)) {
|
||||
return true;
|
||||
}
|
||||
} else return sa != null && doTrigger(sa, false);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<SpellAbility> chooseSaToActivateFromOpeningHand(List<SpellAbility> usableFromOpeningHand) {
|
||||
@@ -2078,9 +2072,7 @@ public class AiController {
|
||||
// AI-specific restrictions specified as activation parameters in spell abilities
|
||||
|
||||
if (sa.hasParam("AILifeThreshold")) {
|
||||
if (player.getLife() <= Integer.parseInt(sa.getParam("AILifeThreshold"))) {
|
||||
return false;
|
||||
}
|
||||
return player.getLife() > Integer.parseInt(sa.getParam("AILifeThreshold"));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -56,7 +56,7 @@ public class AiCostDecision extends CostDecisionMakerBase {
|
||||
@Override
|
||||
public PaymentDecision visit(CostChooseCreatureType cost) {
|
||||
String choice = player.getController().chooseSomeType("Creature", ability, CardType.getAllCreatureTypes(),
|
||||
Lists.<String>newArrayList());
|
||||
Lists.newArrayList());
|
||||
return PaymentDecision.type(choice);
|
||||
}
|
||||
|
||||
@@ -475,7 +475,7 @@ public class AiCostDecision extends CostDecisionMakerBase {
|
||||
if (ability.getPayCosts().hasTapCost() && typeList.contains(ability.getHostCard())) {
|
||||
c--;
|
||||
}
|
||||
source.setSVar("ChosenX", "Number$" + Integer.toString(c));
|
||||
source.setSVar("ChosenX", "Number$" + c);
|
||||
} else {
|
||||
if (!isVehicle) {
|
||||
c = AbilityUtils.calculateAmount(source, amount, ability);
|
||||
@@ -809,7 +809,7 @@ public class AiCostDecision extends CostDecisionMakerBase {
|
||||
final String sVar = ability.getSVar(amount);
|
||||
if (sVar.equals("XChoice")) {
|
||||
c = AbilityUtils.calculateAmount(source, "ChosenX", ability);
|
||||
source.setSVar("ChosenX", "Number$" + String.valueOf(c));
|
||||
source.setSVar("ChosenX", "Number$" + c);
|
||||
} else if (amount.equals("All")) {
|
||||
c = source.getCounters(cost.counter);
|
||||
} else if (sVar.equals("Targeted$CardManaCost")) {
|
||||
@@ -865,7 +865,7 @@ public class AiCostDecision extends CostDecisionMakerBase {
|
||||
}
|
||||
typeList = CardLists.filter(typeList, Presets.TAPPED);
|
||||
c = typeList.size();
|
||||
source.setSVar("ChosenX", "Number$" + Integer.toString(c));
|
||||
source.setSVar("ChosenX", "Number$" + c);
|
||||
} else {
|
||||
c = AbilityUtils.calculateAmount(source, amount, ability);
|
||||
}
|
||||
|
||||
@@ -17,5 +17,5 @@ public enum AiPlayDecision {
|
||||
WouldBecomeZeroToughnessCreature,
|
||||
WouldDestroyWorldEnchantment,
|
||||
BadEtbEffects,
|
||||
CurseEffects;
|
||||
CurseEffects
|
||||
}
|
||||
@@ -423,7 +423,7 @@ public class ComputerUtil {
|
||||
int mana = ComputerUtilMana.getAvailableManaEstimate(ai, false);
|
||||
|
||||
boolean cantAffordSoon = activate.getCMC() > mana + 1;
|
||||
boolean wrongColor = !activate.determineColor().hasNoColorsExcept(ColorSet.fromNames(ComputerUtilCost.getAvailableManaColors(ai, ImmutableList.<Card>of())).getColor());
|
||||
boolean wrongColor = !activate.determineColor().hasNoColorsExcept(ColorSet.fromNames(ComputerUtilCost.getAvailableManaColors(ai, ImmutableList.of())).getColor());
|
||||
|
||||
// Only do this for spells, not activated abilities
|
||||
// We can't pay for this spell even if we play another land, or have wrong colors
|
||||
@@ -524,7 +524,7 @@ public class ComputerUtil {
|
||||
|
||||
typeList = CardLists.filter(typeList, CardPredicates.canBeSacrificedBy(ability));
|
||||
|
||||
if ((target != null) && target.getController() == ai && typeList.contains(target)) {
|
||||
if ((target != null) && target.getController() == ai) {
|
||||
typeList.remove(target); // don't sacrifice the card we're pumping
|
||||
}
|
||||
|
||||
@@ -554,7 +554,7 @@ public class ComputerUtil {
|
||||
final Card target, final int amount) {
|
||||
CardCollection typeList = CardLists.getValidCards(ai.getCardsIn(zone), type.split(";"), activate.getController(), activate, null);
|
||||
|
||||
if ((target != null) && target.getController() == ai && typeList.contains(target)) {
|
||||
if ((target != null) && target.getController() == ai) {
|
||||
typeList.remove(target); // don't exile the card we're pumping
|
||||
}
|
||||
|
||||
@@ -575,7 +575,7 @@ public class ComputerUtil {
|
||||
final Card target, final int amount) {
|
||||
CardCollection typeList = CardLists.getValidCards(ai.getCardsIn(zone), type.split(";"), activate.getController(), activate, null);
|
||||
|
||||
if ((target != null) && target.getController() == ai && typeList.contains(target)) {
|
||||
if ((target != null) && target.getController() == ai) {
|
||||
typeList.remove(target); // don't move the card we're pumping
|
||||
}
|
||||
|
||||
@@ -704,7 +704,7 @@ public class ComputerUtil {
|
||||
public static CardCollection chooseReturnType(final Player ai, final String type, final Card activate, final Card target, final int amount) {
|
||||
final CardCollection typeList =
|
||||
CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), type.split(";"), activate.getController(), activate, null);
|
||||
if ((target != null) && target.getController() == ai && typeList.contains(target)) {
|
||||
if ((target != null) && target.getController() == ai) {
|
||||
// don't bounce the card we're pumping
|
||||
typeList.remove(target);
|
||||
}
|
||||
@@ -1926,8 +1926,8 @@ public class ComputerUtil {
|
||||
return true;
|
||||
}
|
||||
if (game.getPhaseHandler().inCombat() &&
|
||||
ComputerUtilCombat.combatantWouldBeDestroyed(ai, source, game.getCombat())) {
|
||||
return true;
|
||||
ComputerUtilCombat.combatantWouldBeDestroyed(ai, source, game.getCombat())) {
|
||||
return true;
|
||||
}
|
||||
} else if (zone.getZoneType() == ZoneType.Exile && sa.getMayPlay() != null) {
|
||||
// play cards in exile that can only be played that turn
|
||||
@@ -1967,11 +1967,8 @@ public class ComputerUtil {
|
||||
final CardCollectionView lands = CardLists.filter(handList, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
if (c.getManaCost().getCMC() > 0 || c.hasSVar("NeedsToPlay")
|
||||
|| (!c.getType().isLand() && !c.getType().isArtifact())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return c.getManaCost().getCMC() <= 0 && !c.hasSVar("NeedsToPlay")
|
||||
&& (c.getType().isLand() || c.getType().isArtifact());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1986,10 +1983,7 @@ public class ComputerUtil {
|
||||
final CardCollectionView castables = CardLists.filter(handList, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
if (c.getManaCost().getCMC() > 0 && c.getManaCost().getCMC() <= landSize) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return c.getManaCost().getCMC() <= 0 || c.getManaCost().getCMC() > landSize;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -2186,10 +2180,7 @@ public class ComputerUtil {
|
||||
CardCollection goodChoices = CardLists.filter(validCards, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
if (c.hasSVar("DiscardMeByOpp") || c.hasSVar("DiscardMe")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !c.hasSVar("DiscardMeByOpp") && !c.hasSVar("DiscardMe");
|
||||
}
|
||||
});
|
||||
if (goodChoices.isEmpty()) {
|
||||
@@ -2225,7 +2216,7 @@ public class ComputerUtil {
|
||||
|
||||
public static String chooseSomeType(Player ai, String kindOfType, String logic, List<String> invalidTypes) {
|
||||
if (invalidTypes == null) {
|
||||
invalidTypes = ImmutableList.<String>of();
|
||||
invalidTypes = ImmutableList.of();
|
||||
}
|
||||
|
||||
final Game game = ai.getGame();
|
||||
@@ -2546,8 +2537,7 @@ public class ComputerUtil {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
if (c.getController() == ai) {
|
||||
if (c.getSVar("Targeting").equals("Dies") || c.getSVar("Targeting").equals("Counter"))
|
||||
return false;
|
||||
return !c.getSVar("Targeting").equals("Dies") && !c.getSVar("Targeting").equals("Counter");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -2875,7 +2865,6 @@ public class ComputerUtil {
|
||||
} else if (Iterables.any(list, CardTraitPredicates.hasParam("AiLogic", "LichDraw"))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -368,7 +368,7 @@ public class ComputerUtilCard {
|
||||
}
|
||||
|
||||
if (hasEnchantmants || hasArtifacts) {
|
||||
final List<Card> ae = CardLists.filter(list, Predicates.and(Predicates.<Card>or(CardPredicates.Presets.ARTIFACTS, CardPredicates.Presets.ENCHANTMENTS), new Predicate<Card>() {
|
||||
final List<Card> ae = CardLists.filter(list, Predicates.and(Predicates.or(CardPredicates.Presets.ARTIFACTS, CardPredicates.Presets.ENCHANTMENTS), new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card card) {
|
||||
return !card.hasSVar("DoNotDiscardIfAble");
|
||||
@@ -1301,7 +1301,7 @@ public class ComputerUtilCard {
|
||||
combatTrick = true;
|
||||
|
||||
final List<String> kws = sa.hasParam("KW") ? Arrays.asList(sa.getParam("KW").split(" & "))
|
||||
: Lists.<String>newArrayList();
|
||||
: Lists.newArrayList();
|
||||
for (String kw : kws) {
|
||||
if (!kw.equals("Trample") && !kw.equals("First Strike") && !kw.equals("Double Strike")) {
|
||||
combatTrick = false;
|
||||
@@ -1601,8 +1601,8 @@ public class ComputerUtilCard {
|
||||
}
|
||||
|
||||
pumped.addNewPT(c.getCurrentPower(), c.getCurrentToughness(), timestamp);
|
||||
pumped.addTempPowerBoost(c.getTempPowerBoost() + power + berserkPower);
|
||||
pumped.addTempToughnessBoost(c.getTempToughnessBoost() + toughness);
|
||||
pumped.setPTBoost(c.getPTBoostMap());
|
||||
pumped.addPTBoost(power + berserkPower, toughness, timestamp);
|
||||
pumped.addChangedCardKeywords(kws, null, false, false, timestamp);
|
||||
Set<CounterType> types = c.getCounters().keySet();
|
||||
for(CounterType ct : types) {
|
||||
@@ -1648,6 +1648,8 @@ public class ComputerUtilCard {
|
||||
}
|
||||
list.add(vCard); // account for the static abilities that may be present on the card itself
|
||||
for (final Card c : list) {
|
||||
// remove old boost that might be copied
|
||||
vCard.removePTBoost(c.getTimestamp());
|
||||
for (final StaticAbility stAb : c.getStaticAbilities()) {
|
||||
final Map<String, String> params = stAb.getMapParams();
|
||||
if (!params.get("Mode").equals("Continuous")) {
|
||||
@@ -1663,26 +1665,25 @@ public class ComputerUtilCard {
|
||||
if (!vCard.isValid(valid, c.getController(), c, null)) {
|
||||
continue;
|
||||
}
|
||||
int att = 0;
|
||||
if (params.containsKey("AddPower")) {
|
||||
String addP = params.get("AddPower");
|
||||
int att = 0;
|
||||
if (addP.equals("AffectedX")) {
|
||||
att = CardFactoryUtil.xCount(vCard, AbilityUtils.getSVar(stAb, addP));
|
||||
} else {
|
||||
att = AbilityUtils.calculateAmount(c, addP, stAb);
|
||||
}
|
||||
vCard.addTempPowerBoost(att);
|
||||
}
|
||||
int def = 0;
|
||||
if (params.containsKey("AddToughness")) {
|
||||
String addT = params.get("AddToughness");
|
||||
int def = 0;
|
||||
if (addT.equals("AffectedY")) {
|
||||
def = CardFactoryUtil.xCount(vCard, AbilityUtils.getSVar(stAb, addT));
|
||||
} else {
|
||||
def = AbilityUtils.calculateAmount(c, addT, stAb);
|
||||
}
|
||||
vCard.addTempToughnessBoost(def);
|
||||
}
|
||||
vCard.addPTBoost(att, def, c.getTimestamp());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ public class ComputerUtilCombat {
|
||||
return Iterables.any(defenders, new Predicate<GameEntity>() {
|
||||
@Override public boolean apply(final GameEntity input) {
|
||||
return ComputerUtilCombat.canAttackNextTurn(attacker, input);
|
||||
};
|
||||
}
|
||||
});
|
||||
} // canAttackNextTurn(Card)
|
||||
|
||||
@@ -119,11 +119,7 @@ public class ComputerUtilCombat {
|
||||
}
|
||||
|
||||
// The creature won't untap next turn
|
||||
if (atacker.isTapped() && !Untap.canUntap(atacker)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return !atacker.isTapped() || Untap.canUntap(atacker);
|
||||
} // canAttackNextTurn(Card, GameEntity)
|
||||
|
||||
/**
|
||||
@@ -883,20 +879,19 @@ public class ComputerUtilCombat {
|
||||
} else if (mode == TriggerType.DamageDone) {
|
||||
willTrigger = true;
|
||||
if (trigParams.containsKey("ValidSource")) {
|
||||
if (CardTraitBase.matchesValid(defender, trigParams.get("ValidSource").split(","), source)
|
||||
if (!(CardTraitBase.matchesValid(defender, trigParams.get("ValidSource").split(","), source)
|
||||
&& defender.getNetCombatDamage() > 0
|
||||
&& (!trigParams.containsKey("ValidTarget")
|
||||
|| CardTraitBase.matchesValid(attacker, trigParams.get("ValidTarget").split(","), source))) {
|
||||
return true;
|
||||
|| CardTraitBase.matchesValid(attacker, trigParams.get("ValidTarget").split(","), source)))) {
|
||||
return false;
|
||||
}
|
||||
if (CardTraitBase.matchesValid(attacker, trigParams.get("ValidSource").split(","), source)
|
||||
if (!(CardTraitBase.matchesValid(attacker, trigParams.get("ValidSource").split(","), source)
|
||||
&& attacker.getNetCombatDamage() > 0
|
||||
&& (!trigParams.containsKey("ValidTarget")
|
||||
|| CardTraitBase.matchesValid(defender, trigParams.get("ValidTarget").split(","), source))) {
|
||||
return true;
|
||||
|| CardTraitBase.matchesValid(defender, trigParams.get("ValidTarget").split(","), source)))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return willTrigger;
|
||||
@@ -1414,7 +1409,7 @@ public class ComputerUtilCombat {
|
||||
if (att.matches("[0-9][0-9]?") || att.matches("-" + "[0-9][0-9]?")) {
|
||||
power += Integer.parseInt(att);
|
||||
} else {
|
||||
String bonus = new String(source.getSVar(att));
|
||||
String bonus = source.getSVar(att);
|
||||
if (bonus.contains("TriggerCount$NumBlockers")) {
|
||||
bonus = TextUtil.fastReplace(bonus, "TriggerCount$NumBlockers", "Number$1");
|
||||
} else if (bonus.contains("TriggeredPlayersDefenders$Amount")) { // for Melee
|
||||
@@ -1655,7 +1650,7 @@ public class ComputerUtilCombat {
|
||||
if (def.matches("[0-9][0-9]?") || def.matches("-" + "[0-9][0-9]?")) {
|
||||
toughness += Integer.parseInt(def);
|
||||
} else {
|
||||
String bonus = new String(source.getSVar(def));
|
||||
String bonus = source.getSVar(def);
|
||||
if (bonus.contains("TriggerCount$NumBlockers")) {
|
||||
bonus = TextUtil.fastReplace(bonus, "TriggerCount$NumBlockers", "Number$1");
|
||||
} else if (bonus.contains("TriggeredPlayersDefenders$Amount")) { // for Melee
|
||||
@@ -1948,7 +1943,7 @@ public class ComputerUtilCombat {
|
||||
return defenderDamage >= attackerLife;
|
||||
|
||||
} // defender no double strike
|
||||
return false; // should never arrive here
|
||||
return false;// should never arrive here
|
||||
} // canDestroyAttacker
|
||||
|
||||
// For AI safety measures like Regeneration
|
||||
@@ -2195,7 +2190,7 @@ public class ComputerUtilCombat {
|
||||
return attackerDamage >= defenderLife;
|
||||
|
||||
} // attacker no double strike
|
||||
return false; // should never arrive here
|
||||
return false;// should never arrive here
|
||||
} // canDestroyBlocker
|
||||
|
||||
|
||||
|
||||
@@ -424,7 +424,7 @@ public class ComputerUtilCost {
|
||||
continue;
|
||||
}
|
||||
final int remainingLife = ai.getLife();
|
||||
final int lifeCost = ((CostPayLife) part).convertAmount();
|
||||
final int lifeCost = part.convertAmount();
|
||||
if ((remainingLife - lifeCost) < 10) {
|
||||
return false; //Don't pay life if it would put AI under 10 life
|
||||
} else if ((remainingLife / lifeCost) < 4) {
|
||||
@@ -552,7 +552,7 @@ public class ComputerUtilCost {
|
||||
final Card source = sa.getHostCard();
|
||||
final String aiLogic = sa.getParam("UnlessAI");
|
||||
boolean payForOwnOnly = "OnlyOwn".equals(aiLogic);
|
||||
boolean payOwner = sa.hasParam("UnlessAI") ? aiLogic.startsWith("Defined") : false;
|
||||
boolean payOwner = sa.hasParam("UnlessAI") && aiLogic.startsWith("Defined");
|
||||
boolean payNever = "Never".equals(aiLogic);
|
||||
boolean shockland = "Shockland".equals(aiLogic);
|
||||
boolean isMine = sa.getActivatingPlayer().equals(payer);
|
||||
|
||||
@@ -880,10 +880,12 @@ public class ComputerUtilMana {
|
||||
|
||||
// For combat tricks, always obey mana reservation
|
||||
if (curPhase == PhaseType.COMBAT_DECLARE_BLOCKERS || curPhase == PhaseType.CLEANUP) {
|
||||
AiCardMemory.clearMemorySet(ai, AiCardMemory.MemorySet.HELD_MANA_SOURCES_FOR_DECLBLK);
|
||||
} else if (!(ai.getGame().getPhaseHandler().isPlayerTurn(ai)) && (curPhase == PhaseType.COMBAT_DECLARE_BLOCKERS || curPhase == PhaseType.CLEANUP)) {
|
||||
AiCardMemory.clearMemorySet(ai, AiCardMemory.MemorySet.HELD_MANA_SOURCES_FOR_ENEMY_DECLBLK);
|
||||
AiCardMemory.clearMemorySet(ai, AiCardMemory.MemorySet.CHOSEN_FOG_EFFECT);
|
||||
if (!(ai.getGame().getPhaseHandler().isPlayerTurn(ai))) {
|
||||
AiCardMemory.clearMemorySet(ai, AiCardMemory.MemorySet.HELD_MANA_SOURCES_FOR_ENEMY_DECLBLK);
|
||||
AiCardMemory.clearMemorySet(ai, AiCardMemory.MemorySet.CHOSEN_FOG_EFFECT);
|
||||
}
|
||||
else
|
||||
AiCardMemory.clearMemorySet(ai, AiCardMemory.MemorySet.HELD_MANA_SOURCES_FOR_DECLBLK);
|
||||
} else {
|
||||
if ((AiCardMemory.isRememberedCard(ai, sourceCard, AiCardMemory.MemorySet.HELD_MANA_SOURCES_FOR_DECLBLK)) ||
|
||||
(AiCardMemory.isRememberedCard(ai, sourceCard, AiCardMemory.MemorySet.HELD_MANA_SOURCES_FOR_ENEMY_DECLBLK))) {
|
||||
|
||||
@@ -1061,7 +1061,7 @@ public abstract class GameState {
|
||||
}
|
||||
|
||||
private void applyCountersToGameEntity(GameEntity entity, String counterString) {
|
||||
entity.setCounters(Maps.<CounterType, Integer>newEnumMap(CounterType.class));
|
||||
entity.setCounters(Maps.newEnumMap(CounterType.class));
|
||||
String[] allCounterStrings = counterString.split(",");
|
||||
for (final String counterPair : allCounterStrings) {
|
||||
String[] pair = counterPair.split("=", 2);
|
||||
@@ -1107,7 +1107,7 @@ public abstract class GameState {
|
||||
Map<CounterType, Integer> counters = c.getCounters();
|
||||
// Note: Not clearCounters() since we want to keep the counters
|
||||
// var as-is.
|
||||
c.setCounters(Maps.<CounterType, Integer>newEnumMap(CounterType.class));
|
||||
c.setCounters(Maps.newEnumMap(CounterType.class));
|
||||
if (c.isAura()) {
|
||||
// dummy "enchanting" to indicate that the card will be force-attached elsewhere
|
||||
// (will be overridden later, so the actual value shouldn't matter)
|
||||
|
||||
@@ -492,7 +492,7 @@ public class PlayerControllerAi extends PlayerController {
|
||||
Card toDiscard = Aggregates.itemWithMin(cardsOfType, CardPredicates.Accessors.fnGetCmc);
|
||||
return new CardCollection(toDiscard);
|
||||
}
|
||||
return getAi().getCardsToDiscard(num, (String[])null, sa);
|
||||
return getAi().getCardsToDiscard(num, null, sa);
|
||||
}
|
||||
|
||||
|
||||
@@ -612,7 +612,7 @@ public class PlayerControllerAi extends PlayerController {
|
||||
|
||||
@Override
|
||||
public CardCollection chooseCardsToDiscardToMaximumHandSize(int numDiscard) {
|
||||
return brains.getCardsToDiscard(numDiscard, (String[])null, null);
|
||||
return brains.getCardsToDiscard(numDiscard, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -669,7 +669,7 @@ public class PlayerControllerAi extends PlayerController {
|
||||
throw new InvalidParameterException("SA is not api-based, this is not supported yet");
|
||||
}
|
||||
return SpellApiToAi.Converter.get(api).chooseNumber(player, sa, min, max, params);
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public int chooseNumber(SpellAbility sa, String title, List<Integer> options, Player relatedPlayer) {
|
||||
|
||||
@@ -94,12 +94,8 @@ public class SpecialCardAi {
|
||||
int minCMC = isLowCMCDeck ? 3 : 4; // probably not worth wasting a lotus on a low-CMC spell (<4 CMC), except in low-CMC decks, where 3 CMC may be fine
|
||||
int paidCMC = cost.getConvertedManaCost();
|
||||
if (paidCMC < minCMC) {
|
||||
if (paidCMC == 3 && numManaSrcs < 3) {
|
||||
// if it's a CMC 3 spell and we're more than one mana source short for it, might be worth it anyway
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
// if it's a CMC 3 spell and we're more than one mana source short for it, might be worth it anyway
|
||||
return paidCMC == 3 && numManaSrcs < 3;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -218,11 +214,7 @@ public class SpecialCardAi {
|
||||
}
|
||||
}
|
||||
|
||||
if (ai.getLife() <= sa.getHostCard().getNetPower() && !hasUsefulBlocker) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return ai.getLife() <= sa.getHostCard().getNetPower() && !hasUsefulBlocker;
|
||||
}
|
||||
|
||||
public static int getSacThreshold() {
|
||||
@@ -335,7 +327,7 @@ public class SpecialCardAi {
|
||||
boolean canTrample = source.hasKeyword(Keyword.TRAMPLE);
|
||||
|
||||
if (!isBlocking && combat.getDefenderByAttacker(source) instanceof Card) {
|
||||
int loyalty = ((Card)combat.getDefenderByAttacker(source)).getCounters(CounterType.LOYALTY);
|
||||
int loyalty = combat.getDefenderByAttacker(source).getCounters(CounterType.LOYALTY);
|
||||
int totalDamageToPW = 0;
|
||||
for (Card atk : (combat.getAttackersOf(combat.getDefenderByAttacker(source)))) {
|
||||
if (combat.isUnblocked(atk)) {
|
||||
@@ -411,11 +403,7 @@ public class SpecialCardAi {
|
||||
Pair<Integer, Integer> predictedPT = getPumpedPT(ai, source.getNetCombatDamage(), source.getNetToughness());
|
||||
int oppT = Aggregates.sum(potentialBlockers, CardPredicates.Accessors.fnGetNetToughness);
|
||||
|
||||
if (potentialBlockers.isEmpty() || (source.hasKeyword(Keyword.TRAMPLE) && predictedPT.getLeft() - oppT >= oppLife)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return potentialBlockers.isEmpty() || (source.hasKeyword(Keyword.TRAMPLE) && predictedPT.getLeft() - oppT >= oppLife);
|
||||
}
|
||||
|
||||
public static Pair<Integer, Integer> getPumpedPT(Player ai, int power, int toughness) {
|
||||
@@ -522,7 +510,7 @@ public class SpecialCardAi {
|
||||
best.add(sp); // these SAs are prioritized since the AI sees a reason to play them now
|
||||
}
|
||||
final List<String> keywords = sp.hasParam("KW") ? Arrays.asList(sp.getParam("KW").split(" & "))
|
||||
: Lists.<String>newArrayList();
|
||||
: Lists.newArrayList();
|
||||
for (String kw : keywords) {
|
||||
if (!tgtCard.hasKeyword(kw)) {
|
||||
if ("Indestructible".equals(kw) && ai.getOpponents().getCreaturesInPlay().isEmpty()) {
|
||||
@@ -568,10 +556,7 @@ public class SpecialCardAi {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
// Don't enchant creatures that can survive
|
||||
if (!c.canBeDestroyed() || c.getNetCombatDamage() < c.getNetToughness() || c.isEnchantedBy("Guilty Conscience")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return c.canBeDestroyed() && c.getNetCombatDamage() >= c.getNetToughness() && !c.isEnchantedBy("Guilty Conscience");
|
||||
}
|
||||
});
|
||||
chosen = ComputerUtilCard.getBestCreatureAI(creatures);
|
||||
@@ -919,7 +904,6 @@ public class SpecialCardAi {
|
||||
// Only activate in AI's own turn (sans the exception above)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -941,11 +925,7 @@ public class SpecialCardAi {
|
||||
|
||||
}
|
||||
// Maybe use it for some important high-impact spells even if there are more cards in hand?
|
||||
if (ai.getCardsIn(ZoneType.Hand).size() > 1 && !hasEnsnaringBridgeEffect) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return ai.getCardsIn(ZoneType.Hand).size() <= 1 || hasEnsnaringBridgeEffect;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1310,12 +1290,8 @@ public class SpecialCardAi {
|
||||
}
|
||||
}
|
||||
|
||||
if (aiHandSize < HAND_SIZE_THRESHOLD || maxOppHandSize - aiHandSize > HAND_SIZE_THRESHOLD) {
|
||||
// use in case we're getting low on cards or if we're significantly behind our opponent in cards in hand
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
// use in case we're getting low on cards or if we're significantly behind our opponent in cards in hand
|
||||
return aiHandSize < HAND_SIZE_THRESHOLD || maxOppHandSize - aiHandSize > HAND_SIZE_THRESHOLD;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1342,9 +1318,7 @@ public class SpecialCardAi {
|
||||
if (topGY == null
|
||||
|| !topGY.isCreature()
|
||||
|| ComputerUtilCard.evaluateCreature(creatHand) > ComputerUtilCard.evaluateCreature(topGY) + 80) {
|
||||
if (numCreatsInHand > 1 || !ComputerUtilMana.canPayManaCost(creatHand.getSpellPermanent(), ai, 0)) {
|
||||
return true;
|
||||
}
|
||||
return numCreatsInHand > 1 || !ComputerUtilMana.canPayManaCost(creatHand.getSpellPermanent(), ai, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1466,7 +1440,6 @@ public class SpecialCardAi {
|
||||
// Only activate in AI's own turn (sans the exception above)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,12 +56,9 @@ public class ActivateAbilityAi extends SpellAbilityAi {
|
||||
} else {
|
||||
final List<Player> defined = AbilityUtils.getDefinedPlayers(source, sa.getParam("Defined"), sa);
|
||||
|
||||
if (!defined.contains(opp)) {
|
||||
return false;
|
||||
}
|
||||
return defined.contains(opp);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
sa.resetTargets();
|
||||
sa.getTargets().add(opp);
|
||||
|
||||
@@ -67,10 +67,8 @@ public class AddTurnAi extends SpellAbilityAi {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!StringUtils.isNumeric(sa.getParam("NumTurns"))) {
|
||||
// TODO: improve ai for Sage of Hours
|
||||
return false;
|
||||
}
|
||||
// TODO: improve ai for Sage of Hours
|
||||
return StringUtils.isNumeric(sa.getParam("NumTurns"));
|
||||
// not sure if the AI should be playing with cards that give the
|
||||
// Human more turns.
|
||||
}
|
||||
|
||||
@@ -23,9 +23,7 @@ public class AmassAi extends SpellAbilityAi {
|
||||
final Game game = ai.getGame();
|
||||
|
||||
if (!aiArmies.isEmpty()) {
|
||||
if (CardLists.count(aiArmies, CardPredicates.canReceiveCounters(CounterType.P1P1)) <= 0) {
|
||||
return false;
|
||||
}
|
||||
return CardLists.count(aiArmies, CardPredicates.canReceiveCounters(CounterType.P1P1)) > 0;
|
||||
} else {
|
||||
final String tokenScript = "b_0_0_zombie_army";
|
||||
final int amount = AbilityUtils.calculateAmount(host, sa.getParamOrDefault("Num", "1"), sa);
|
||||
@@ -57,12 +55,9 @@ public class AmassAi extends SpellAbilityAi {
|
||||
//reset static abilities
|
||||
game.getAction().checkStaticAbilities(false);
|
||||
|
||||
if (!result) {
|
||||
return false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -207,21 +207,16 @@ public class AnimateAi extends SpellAbilityAi {
|
||||
return bFlag; // All of the defined stuff is animated, not very useful
|
||||
} else {
|
||||
sa.resetTargets();
|
||||
if (!animateTgtAI(sa)) {
|
||||
return false;
|
||||
}
|
||||
return animateTgtAI(sa);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
if (sa.usesTargeting()) {
|
||||
sa.resetTargets();
|
||||
if (!animateTgtAI(sa)) {
|
||||
return false;
|
||||
}
|
||||
return animateTgtAI(sa);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -8,11 +8,7 @@ public class AnimateAllAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
if ("Always".equals(sa.getParam("AILogic"))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return "Always".equals(sa.getParam("AILogic"));
|
||||
} // end animateAllCanPlayAI()
|
||||
|
||||
@Override
|
||||
|
||||
@@ -123,9 +123,7 @@ public class AttachAi extends SpellAbilityAi {
|
||||
return !(c.hasProtectionFrom(source) || c.hasKeyword(Keyword.SHROUD) || c.hasKeyword(Keyword.HEXPROOF));
|
||||
}
|
||||
});
|
||||
if (targets.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return !targets.isEmpty();
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -239,9 +237,7 @@ public class AttachAi extends SpellAbilityAi {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(combat.isAttacking(attachTarget) || combat.isBlocking(attachTarget))) {
|
||||
return false;
|
||||
}
|
||||
return combat.isAttacking(attachTarget) || combat.isBlocking(attachTarget);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -987,9 +983,7 @@ public class AttachAi extends SpellAbilityAi {
|
||||
return false;
|
||||
}
|
||||
// don't equip creatures that don't gain anything
|
||||
if (card.hasSVar("NonStackingAttachEffect") && newTarget.isEquippedBy(card.getName())) {
|
||||
return false;
|
||||
}
|
||||
return !card.hasSVar("NonStackingAttachEffect") || !newTarget.isEquippedBy(card.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1218,10 +1212,10 @@ public class AttachAi extends SpellAbilityAi {
|
||||
if (isUsefulAttachKeyword(keyword, c, sa, pow)) {
|
||||
return true;
|
||||
}
|
||||
if (c.hasKeyword(Keyword.INFECT) && pow >= 2) {
|
||||
// consider +2 power a significant bonus on Infect creatures
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (c.hasKeyword(Keyword.INFECT) && pow >= 2) {
|
||||
// consider +2 power a significant bonus on Infect creatures
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -1353,7 +1347,7 @@ public class AttachAi extends SpellAbilityAi {
|
||||
CardCollection prefList = list;
|
||||
|
||||
// Filter AI-specific targets if provided
|
||||
prefList = ComputerUtil.filterAITgts(sa, aiPlayer, (CardCollection)list, true);
|
||||
prefList = ComputerUtil.filterAITgts(sa, aiPlayer, list, true);
|
||||
|
||||
Card c = attachGeneralAI(aiPlayer, sa, prefList, mandatory, attachSource, sa.getParam("AILogic"));
|
||||
|
||||
@@ -1557,86 +1551,55 @@ public class AttachAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
if (evasive) {
|
||||
if (card.getNetCombatDamage() + powerBonus <= 0
|
||||
|| !ComputerUtilCombat.canAttackNextTurn(card)
|
||||
|| !canBeBlocked) {
|
||||
return false;
|
||||
}
|
||||
return card.getNetCombatDamage() + powerBonus > 0
|
||||
&& ComputerUtilCombat.canAttackNextTurn(card)
|
||||
&& canBeBlocked;
|
||||
} else if (keyword.equals("Haste")) {
|
||||
if (!card.hasSickness() || !ph.isPlayerTurn(sa.getActivatingPlayer()) || card.isTapped()
|
||||
|| card.getNetCombatDamage() + powerBonus <= 0
|
||||
|| card.hasKeyword("CARDNAME can attack as though it had haste.")
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
|| !ComputerUtilCombat.canAttackNextTurn(card)) {
|
||||
return false;
|
||||
}
|
||||
return card.hasSickness() && ph.isPlayerTurn(sa.getActivatingPlayer()) && !card.isTapped()
|
||||
&& card.getNetCombatDamage() + powerBonus > 0
|
||||
&& !card.hasKeyword("CARDNAME can attack as though it had haste.")
|
||||
&& !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
&& ComputerUtilCombat.canAttackNextTurn(card);
|
||||
} else if (keyword.endsWith("Indestructible")) {
|
||||
return true;
|
||||
} else if (keyword.endsWith("Deathtouch") || keyword.endsWith("Wither")) {
|
||||
if (card.getNetCombatDamage() + powerBonus <= 0
|
||||
|| ((!canBeBlocked || !ComputerUtilCombat.canAttackNextTurn(card))
|
||||
&& !CombatUtil.canBlock(card, true))) {
|
||||
return false;
|
||||
}
|
||||
return card.getNetCombatDamage() + powerBonus > 0
|
||||
&& ((canBeBlocked && ComputerUtilCombat.canAttackNextTurn(card))
|
||||
|| CombatUtil.canBlock(card, true));
|
||||
} else if (keyword.equals("Double Strike") || keyword.equals("Lifelink")) {
|
||||
if (card.getNetCombatDamage() + powerBonus <= 0
|
||||
|| (!ComputerUtilCombat.canAttackNextTurn(card) && !CombatUtil.canBlock(card, true))) {
|
||||
return false;
|
||||
}
|
||||
return card.getNetCombatDamage() + powerBonus > 0
|
||||
&& (ComputerUtilCombat.canAttackNextTurn(card) || CombatUtil.canBlock(card, true));
|
||||
} else if (keyword.equals("First Strike")) {
|
||||
if (card.getNetCombatDamage() + powerBonus <= 0 || card.hasKeyword(Keyword.DOUBLE_STRIKE)
|
||||
|| (!ComputerUtilCombat.canAttackNextTurn(card) && !CombatUtil.canBlock(card, true))) {
|
||||
return false;
|
||||
}
|
||||
return card.getNetCombatDamage() + powerBonus > 0 && !card.hasKeyword(Keyword.DOUBLE_STRIKE)
|
||||
&& (ComputerUtilCombat.canAttackNextTurn(card) || CombatUtil.canBlock(card, true));
|
||||
} else if (keyword.startsWith("Flanking")) {
|
||||
if (card.getNetCombatDamage() + powerBonus <= 0
|
||||
|| !ComputerUtilCombat.canAttackNextTurn(card)
|
||||
|| !canBeBlocked) {
|
||||
return false;
|
||||
}
|
||||
return card.getNetCombatDamage() + powerBonus > 0
|
||||
&& ComputerUtilCombat.canAttackNextTurn(card)
|
||||
&& canBeBlocked;
|
||||
} else if (keyword.startsWith("Bushido")) {
|
||||
if ((!canBeBlocked || !ComputerUtilCombat.canAttackNextTurn(card))
|
||||
&& !CombatUtil.canBlock(card, true)) {
|
||||
return false;
|
||||
}
|
||||
return (canBeBlocked && ComputerUtilCombat.canAttackNextTurn(card))
|
||||
|| CombatUtil.canBlock(card, true);
|
||||
} else if (keyword.equals("Trample")) {
|
||||
if (card.getNetCombatDamage() + powerBonus <= 1
|
||||
|| !canBeBlocked
|
||||
|| !ComputerUtilCombat.canAttackNextTurn(card)) {
|
||||
return false;
|
||||
}
|
||||
return card.getNetCombatDamage() + powerBonus > 1
|
||||
&& canBeBlocked
|
||||
&& ComputerUtilCombat.canAttackNextTurn(card);
|
||||
} else if (keyword.equals("Infect")) {
|
||||
if (card.getNetCombatDamage() + powerBonus <= 0
|
||||
|| !ComputerUtilCombat.canAttackNextTurn(card)) {
|
||||
return false;
|
||||
}
|
||||
return card.getNetCombatDamage() + powerBonus > 0
|
||||
&& ComputerUtilCombat.canAttackNextTurn(card);
|
||||
} else if (keyword.equals("Vigilance")) {
|
||||
if (card.getNetCombatDamage() + powerBonus <= 0
|
||||
|| !ComputerUtilCombat.canAttackNextTurn(card)
|
||||
|| !CombatUtil.canBlock(card, true)) {
|
||||
return false;
|
||||
}
|
||||
return card.getNetCombatDamage() + powerBonus > 0
|
||||
&& ComputerUtilCombat.canAttackNextTurn(card)
|
||||
&& CombatUtil.canBlock(card, true);
|
||||
} else if (keyword.equals("Reach")) {
|
||||
if (card.hasKeyword(Keyword.FLYING) || !CombatUtil.canBlock(card, true)) {
|
||||
return false;
|
||||
}
|
||||
return !card.hasKeyword(Keyword.FLYING) && CombatUtil.canBlock(card, true);
|
||||
} else if (keyword.endsWith("CARDNAME can block an additional creature each combat.")) {
|
||||
if (!CombatUtil.canBlock(card, true) || card.hasKeyword("CARDNAME can block any number of creatures.")
|
||||
|| card.hasKeyword("CARDNAME can block an additional ninety-nine creatures each combat.")) {
|
||||
return false;
|
||||
}
|
||||
return CombatUtil.canBlock(card, true) && !card.hasKeyword("CARDNAME can block any number of creatures.")
|
||||
&& !card.hasKeyword("CARDNAME can block an additional ninety-nine creatures each combat.");
|
||||
} else if (keyword.equals("CARDNAME can attack as though it didn't have defender.")) {
|
||||
if (!card.hasKeyword(Keyword.DEFENDER) || card.getNetCombatDamage() + powerBonus <= 0) {
|
||||
return false;
|
||||
}
|
||||
return card.hasKeyword(Keyword.DEFENDER) && card.getNetCombatDamage() + powerBonus > 0;
|
||||
} else if (keyword.equals("Shroud") || keyword.equals("Hexproof")) {
|
||||
if (card.hasKeyword(Keyword.SHROUD) || card.hasKeyword(Keyword.HEXPROOF)) {
|
||||
return false;
|
||||
}
|
||||
} else if (keyword.equals("Defender")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !card.hasKeyword(Keyword.SHROUD) && !card.hasKeyword(Keyword.HEXPROOF);
|
||||
} else return !keyword.equals("Defender");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1657,17 +1620,11 @@ public class AttachAi extends SpellAbilityAi {
|
||||
|
||||
if (keyword.endsWith("CARDNAME can't attack.") || keyword.equals("Defender")
|
||||
|| keyword.endsWith("CARDNAME can't attack or block.")) {
|
||||
if (!ComputerUtilCombat.canAttackNextTurn(card) || card.getNetCombatDamage() < 1) {
|
||||
return false;
|
||||
}
|
||||
return ComputerUtilCombat.canAttackNextTurn(card) && card.getNetCombatDamage() >= 1;
|
||||
} else if (keyword.endsWith("CARDNAME attacks each turn if able.") || keyword.endsWith("CARDNAME attacks each combat if able.")) {
|
||||
if (!ComputerUtilCombat.canAttackNextTurn(card) || !CombatUtil.canBlock(card, true) || ai.getCreaturesInPlay().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return ComputerUtilCombat.canAttackNextTurn(card) && CombatUtil.canBlock(card, true) && !ai.getCreaturesInPlay().isEmpty();
|
||||
} else if (keyword.endsWith("CARDNAME can't block.") || keyword.contains("CantBlock")) {
|
||||
if (!CombatUtil.canBlock(card, true)) {
|
||||
return false;
|
||||
}
|
||||
return CombatUtil.canBlock(card, true);
|
||||
} else if (keyword.endsWith("CARDNAME's activated abilities can't be activated.")) {
|
||||
for (SpellAbility ability : card.getSpellAbilities()) {
|
||||
if (ability.isAbility()) {
|
||||
@@ -1676,18 +1633,12 @@ public class AttachAi extends SpellAbilityAi {
|
||||
}
|
||||
return false;
|
||||
} else if (keyword.endsWith("Prevent all combat damage that would be dealt by CARDNAME.")) {
|
||||
if (!ComputerUtilCombat.canAttackNextTurn(card) || card.getNetCombatDamage() < 1) {
|
||||
return false;
|
||||
}
|
||||
return ComputerUtilCombat.canAttackNextTurn(card) && card.getNetCombatDamage() >= 1;
|
||||
} else if (keyword.endsWith("Prevent all combat damage that would be dealt to and dealt by CARDNAME.")
|
||||
|| keyword.endsWith("Prevent all damage that would be dealt to and dealt by CARDNAME.")) {
|
||||
if (!ComputerUtilCombat.canAttackNextTurn(card) || card.getNetCombatDamage() < 2) {
|
||||
return false;
|
||||
}
|
||||
return ComputerUtilCombat.canAttackNextTurn(card) && card.getNetCombatDamage() >= 2;
|
||||
} else if (keyword.endsWith("CARDNAME doesn't untap during your untap step.")) {
|
||||
if (card.isUntapped()) {
|
||||
return false;
|
||||
}
|
||||
return !card.isUntapped();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -1711,12 +1662,8 @@ public class AttachAi extends SpellAbilityAi {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sa.getHostCard().isEquipment() && ComputerUtilCard.isUselessCreature(ai, c)) {
|
||||
// useless to equip a creature that can't attack or block.
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
// useless to equip a creature that can't attack or block.
|
||||
return !sa.getHostCard().isEquipment() || !ComputerUtilCard.isUselessCreature(ai, c);
|
||||
}
|
||||
|
||||
public static Card doPumpOrCurseAILogic(final Player ai, final SpellAbility sa, final List<Card> list, final String type) {
|
||||
|
||||
@@ -355,9 +355,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
if (c.getType().isLegendary()) {
|
||||
if (ai.isCardInPlay(c.getName())) {
|
||||
return false;
|
||||
}
|
||||
return !ai.isCardInPlay(c.getName());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -738,11 +736,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
final AbilitySub subAb = sa.getSubAbility();
|
||||
if (subAb != null && !SpellApiToAi.Converter.get(subAb.getApi()).chkDrawbackWithSubs(ai, subAb)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return subAb == null || SpellApiToAi.Converter.get(subAb.getApi()).chkDrawbackWithSubs(ai, subAb);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -864,7 +858,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
list = CardLists.getTargetableCards(list, sa);
|
||||
|
||||
// Filter AI-specific targets if provided
|
||||
list = ComputerUtil.filterAITgts(sa, ai, (CardCollection)list, true);
|
||||
list = ComputerUtil.filterAITgts(sa, ai, list, true);
|
||||
if (sa.hasParam("AITgtsOnlyBetterThanSelf")) {
|
||||
list = CardLists.filter(list, new Predicate<Card>() {
|
||||
@Override
|
||||
@@ -995,11 +989,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
for (Card aura : c.getEnchantedBy()) {
|
||||
if (aura.getController().isOpponentOf(ai)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return aura.getController().isOpponentOf(ai);
|
||||
}
|
||||
if (blink) {
|
||||
return c.isToken();
|
||||
@@ -1471,16 +1461,12 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
if (!list.isEmpty()) {
|
||||
final Card attachedTo = list.get(0);
|
||||
// This code is for the Dragon auras
|
||||
if (attachedTo.getController().isOpponentOf(ai)) {
|
||||
return false;
|
||||
}
|
||||
return !attachedTo.getController().isOpponentOf(ai);
|
||||
}
|
||||
}
|
||||
} else if (isPreferredTarget(ai, sa, mandatory, true)) {
|
||||
// do nothing
|
||||
} else if (!isUnpreferredTarget(ai, sa, mandatory)) {
|
||||
return false;
|
||||
}
|
||||
} else return isUnpreferredTarget(ai, sa, mandatory);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1532,9 +1518,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
if (c.getType().isLegendary()) {
|
||||
if (decider.isCardInPlay(c.getName())) {
|
||||
return false;
|
||||
}
|
||||
return !decider.isCardInPlay(c.getName());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -1543,10 +1527,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
fetchList = CardLists.filter(fetchList, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
if (ComputerUtilCard.isCardRemAIDeck(c) || ComputerUtilCard.isCardRemRandomDeck(c)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !ComputerUtilCard.isCardRemAIDeck(c) && !ComputerUtilCard.isCardRemRandomDeck(c);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1718,9 +1699,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
if (c.getType().isLegendary()) {
|
||||
if (ai.isCardInPlay(c.getName())) {
|
||||
return false;
|
||||
}
|
||||
return !ai.isCardInPlay(c.getName());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -1826,20 +1805,16 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
&& "Battlefield".equals(causeSub.getParam("Destination"))) {
|
||||
// A blink effect implemented using ChangeZone API
|
||||
return false;
|
||||
} else if (subApi == ApiType.DelayedTrigger) {
|
||||
} else // This is an intrinsic effect that blinks the card (e.g. Obzedat, Ghost Council), no need to
|
||||
// return the commander to the Command zone.
|
||||
if (subApi == ApiType.DelayedTrigger) {
|
||||
SpellAbility exec = causeSub.getAdditionalAbility("Execute");
|
||||
if (exec != null && exec.getApi() == ApiType.ChangeZone) {
|
||||
if ("Exile".equals(exec.getParam("Origin")) && "Battlefield".equals(exec.getParam("Destination"))) {
|
||||
// A blink effect implemented using a delayed trigger
|
||||
return false;
|
||||
}
|
||||
// A blink effect implemented using a delayed trigger
|
||||
return !"Exile".equals(exec.getParam("Origin")) || !"Battlefield".equals(exec.getParam("Destination"));
|
||||
}
|
||||
} else if (causeSa.getHostCard() != null && causeSa.getHostCard().equals((Card)sa.getReplacingObject("Card"))
|
||||
&& causeSa.getActivatingPlayer().equals(aiPlayer)) {
|
||||
// This is an intrinsic effect that blinks the card (e.g. Obzedat, Ghost Council), no need to
|
||||
// return the commander to the Command zone.
|
||||
return false;
|
||||
}
|
||||
} else return causeSa.getHostCard() == null || !causeSa.getHostCard().equals(sa.getReplacingObject("Card"))
|
||||
|| !causeSa.getActivatingPlayer().equals(aiPlayer);
|
||||
}
|
||||
|
||||
// Normally we want the commander back in Command zone to recast him later
|
||||
|
||||
@@ -335,11 +335,8 @@ public class ChangeZoneAllAi extends SpellAbilityAi {
|
||||
return true;
|
||||
|
||||
// if AI creature is better than Human Creature
|
||||
if (ComputerUtilCard.evaluateCreatureList(aiCards) >= ComputerUtilCard
|
||||
.evaluateCreatureList(humanCards)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return ComputerUtilCard.evaluateCreatureList(aiCards) >= ComputerUtilCard
|
||||
.evaluateCreatureList(humanCards);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -441,29 +438,21 @@ public class ChangeZoneAllAi extends SpellAbilityAi {
|
||||
if (sa.getParam("GainControl") != null) {
|
||||
// Check if the cards are valuable enough
|
||||
if ((CardLists.getNotType(humanType, "Creature").size() == 0) && (CardLists.getNotType(computerType, "Creature").size() == 0)) {
|
||||
if ((ComputerUtilCard.evaluateCreatureList(computerType) + ComputerUtilCard
|
||||
.evaluateCreatureList(humanType)) < 1) {
|
||||
return false;
|
||||
}
|
||||
return (ComputerUtilCard.evaluateCreatureList(computerType) + ComputerUtilCard
|
||||
.evaluateCreatureList(humanType)) >= 1;
|
||||
} // otherwise evaluate both lists by CMC and pass only if human
|
||||
// permanents are less valuable
|
||||
else if ((ComputerUtilCard.evaluatePermanentList(computerType) + ComputerUtilCard
|
||||
.evaluatePermanentList(humanType)) < 1) {
|
||||
return false;
|
||||
}
|
||||
else return (ComputerUtilCard.evaluatePermanentList(computerType) + ComputerUtilCard
|
||||
.evaluatePermanentList(humanType)) >= 1;
|
||||
} else {
|
||||
// don't activate if human gets more back than AI does
|
||||
if ((CardLists.getNotType(humanType, "Creature").isEmpty()) && (CardLists.getNotType(computerType, "Creature").isEmpty())) {
|
||||
if (ComputerUtilCard.evaluateCreatureList(computerType) <= ComputerUtilCard
|
||||
.evaluateCreatureList(humanType)) {
|
||||
return false;
|
||||
}
|
||||
return ComputerUtilCard.evaluateCreatureList(computerType) > ComputerUtilCard
|
||||
.evaluateCreatureList(humanType);
|
||||
} // otherwise evaluate both lists by CMC and pass only if human
|
||||
// permanents are less valuable
|
||||
else if (ComputerUtilCard.evaluatePermanentList(computerType) <= ComputerUtilCard
|
||||
.evaluatePermanentList(humanType)) {
|
||||
return false;
|
||||
}
|
||||
else return ComputerUtilCard.evaluatePermanentList(computerType) > ComputerUtilCard
|
||||
.evaluatePermanentList(humanType);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -71,21 +71,15 @@ public class ChooseCardAi extends SpellAbilityAi {
|
||||
choices = CardLists.filterControlledBy(choices, ai.getOpponents());
|
||||
}
|
||||
if (aiLogic.equals("AtLeast1") || aiLogic.equals("OppPreferred")) {
|
||||
if (choices.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return !choices.isEmpty();
|
||||
} else if (aiLogic.equals("AtLeast2") || aiLogic.equals("BestBlocker")) {
|
||||
if (choices.size() < 2) {
|
||||
return false;
|
||||
}
|
||||
return choices.size() >= 2;
|
||||
} else if (aiLogic.equals("Clone") || aiLogic.equals("Vesuva")) {
|
||||
final String filter = aiLogic.equals("Clone") ? "Permanent.YouDontCtrl,Permanent.nonLegendary"
|
||||
: "Permanent.YouDontCtrl+notnamedVesuva,Permanent.nonLegendary+notnamedVesuva";
|
||||
|
||||
choices = CardLists.getValidCards(choices, filter, host.getController(), host);
|
||||
if (choices.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return !choices.isEmpty();
|
||||
} else if (aiLogic.equals("Never")) {
|
||||
return false;
|
||||
} else if (aiLogic.equals("NeedsPrevention")) {
|
||||
@@ -103,9 +97,7 @@ public class ChooseCardAi extends SpellAbilityAi {
|
||||
return ComputerUtilCombat.damageIfUnblocked(c, ai, combat, true) > ref;
|
||||
}
|
||||
});
|
||||
if (choices.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return !choices.isEmpty();
|
||||
} else if (aiLogic.equals("Ashiok")) {
|
||||
final int loyalty = host.getCounters(CounterType.LOYALTY) - 1;
|
||||
for (int i = loyalty; i >= 0; i--) {
|
||||
@@ -117,13 +109,9 @@ public class ChooseCardAi extends SpellAbilityAi {
|
||||
}
|
||||
}
|
||||
|
||||
if (choices.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return !choices.isEmpty();
|
||||
} else if (aiLogic.equals("RandomNonLand")) {
|
||||
if (CardLists.getValidCards(choices, "Card.nonLand", host.getController(), host).isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return !CardLists.getValidCards(choices, "Card.nonLand", host.getController(), host).isEmpty();
|
||||
} else if (aiLogic.equals("Duneblast")) {
|
||||
CardCollection aiCreatures = ai.getCreaturesInPlay();
|
||||
CardCollection oppCreatures = ai.getWeakestOpponent().getCreaturesInPlay();
|
||||
@@ -139,10 +127,8 @@ public class ChooseCardAi extends SpellAbilityAi {
|
||||
aiCreatures.remove(chosen);
|
||||
int minGain = 200;
|
||||
|
||||
if ((ComputerUtilCard.evaluateCreatureList(aiCreatures) + minGain) >= ComputerUtilCard
|
||||
.evaluateCreatureList(oppCreatures)) {
|
||||
return false;
|
||||
}
|
||||
return (ComputerUtilCard.evaluateCreatureList(aiCreatures) + minGain) < ComputerUtilCard
|
||||
.evaluateCreatureList(oppCreatures);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -52,10 +52,7 @@ public class ChooseColorAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
if ("Addle".equals(sourceName)) {
|
||||
if (ph.getPhase().isBefore(PhaseType.COMBAT_DECLARE_ATTACKERS) || ai.getWeakestOpponent().getCardsIn(ZoneType.Hand).isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !ph.getPhase().isBefore(PhaseType.COMBAT_DECLARE_ATTACKERS) && !ai.getWeakestOpponent().getCardsIn(ZoneType.Hand).isEmpty();
|
||||
}
|
||||
|
||||
if (logic.equals("MostExcessOpponentControls")) {
|
||||
|
||||
@@ -33,9 +33,7 @@ public class ChooseDirectionAi extends SpellAbilityAi {
|
||||
CardCollection right = CardLists.filterControlledBy(all, game.getNextPlayerAfter(ai, Direction.Right));
|
||||
int leftValue = Aggregates.sum(left, CardPredicates.Accessors.fnGetCmc);
|
||||
int rightValue = Aggregates.sum(right, CardPredicates.Accessors.fnGetCmc);
|
||||
if (aiValue > leftValue || aiValue > rightValue) {
|
||||
return false;
|
||||
}
|
||||
return aiValue <= leftValue && aiValue <= rightValue;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -385,9 +385,7 @@ public class ChooseGenericEffectAi extends SpellAbilityAi {
|
||||
final Player opp = player.getWeakestOpponent();
|
||||
if (opp != null) {
|
||||
// TODO add predict Combat Damage?
|
||||
if (opp.getLife() < copy.getNetPower()) {
|
||||
return true;
|
||||
}
|
||||
return opp.getLife() < copy.getNetPower();
|
||||
}
|
||||
|
||||
// haste might not be good enough?
|
||||
|
||||
@@ -97,10 +97,7 @@ public class ChooseSourceAi extends SpellAbilityAi {
|
||||
return false;
|
||||
}
|
||||
int dmg = AbilityUtils.calculateAmount(threatSource, topStack.getParam("NumDmg"), topStack);
|
||||
if (ComputerUtilCombat.predictDamageTo(ai, dmg, threatSource, false) <= 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return ComputerUtilCombat.predictDamageTo(ai, dmg, threatSource, false) > 0;
|
||||
}
|
||||
if (game.getPhaseHandler().getPhase() != PhaseType.COMBAT_DECLARE_BLOCKERS) {
|
||||
return false;
|
||||
@@ -119,9 +116,7 @@ public class ChooseSourceAi extends SpellAbilityAi {
|
||||
return ComputerUtilCombat.damageIfUnblocked(c, ai, combat, true) > 0;
|
||||
}
|
||||
});
|
||||
if (choices.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return !choices.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -244,9 +244,6 @@ public class CloneAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
// don't activate during main2 unless this effect is permanent
|
||||
if (ph.is(PhaseType.MAIN2) && !sa.hasParam("Permanent")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !ph.is(PhaseType.MAIN2) || sa.hasParam("Permanent");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,9 +84,7 @@ public class ControlGainAi extends SpellAbilityAi {
|
||||
if (sa.hasParam("AllValid")) {
|
||||
CardCollectionView tgtCards = CardLists.filterControlledBy(game.getCardsIn(ZoneType.Battlefield), opponents);
|
||||
tgtCards = AbilityUtils.filterListByType(tgtCards, sa.getParam("AllValid"), sa);
|
||||
if (tgtCards.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return !tgtCards.isEmpty();
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
@@ -247,7 +245,7 @@ public class ControlGainAi extends SpellAbilityAi {
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if (t != null) {
|
||||
sa.getTargets().add(t);
|
||||
@@ -296,15 +294,12 @@ public class ControlGainAi extends SpellAbilityAi {
|
||||
lose.addAll(Lists.newArrayList(sa.getParam("LoseControl").split(",")));
|
||||
}
|
||||
|
||||
if (lose.contains("EOT")
|
||||
&& game.getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)) {
|
||||
return false;
|
||||
}
|
||||
return !lose.contains("EOT")
|
||||
|| !game.getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS);
|
||||
} else {
|
||||
return this.canPlayAI(ai, sa);
|
||||
}
|
||||
|
||||
return true;
|
||||
} // pumpDrawbackAI()
|
||||
|
||||
@Override
|
||||
|
||||
@@ -90,9 +90,7 @@ public class CountersMoveAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
// for Simic Fluxmage and other
|
||||
if (!ph.getNextTurn().equals(ai) || ph.getPhase().isBefore(PhaseType.END_OF_TURN)) {
|
||||
return false;
|
||||
}
|
||||
return ph.getNextTurn().equals(ai) && !ph.getPhase().isBefore(PhaseType.END_OF_TURN);
|
||||
|
||||
} else if (CounterType.P1P1.equals(cType) && sa.hasParam("Defined")) {
|
||||
// something like Cyptoplast Root-kin
|
||||
@@ -107,9 +105,7 @@ public class CountersMoveAi extends SpellAbilityAi {
|
||||
}
|
||||
// Make sure that removing the last counter doesn't kill the creature
|
||||
if ("Self".equals(sa.getParam("Source"))) {
|
||||
if (host != null && host.getNetToughness() - 1 <= 0) {
|
||||
return false;
|
||||
}
|
||||
return host == null || host.getNetToughness() - 1 > 0;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -193,9 +189,7 @@ public class CountersMoveAi extends SpellAbilityAi {
|
||||
|
||||
// check for some specific AI preferences
|
||||
if ("DontMoveCounterIfLethal".equals(sa.getParam("AILogic"))) {
|
||||
if (cType == CounterType.P1P1 && src.getNetToughness() - src.getTempToughnessBoost() - 1 <= 0) {
|
||||
return false;
|
||||
}
|
||||
return cType != CounterType.P1P1 || src.getNetToughness() - src.getTempToughnessBoost() - 1 > 0;
|
||||
}
|
||||
}
|
||||
// no target
|
||||
@@ -207,9 +201,7 @@ public class CountersMoveAi extends SpellAbilityAi {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player ai) {
|
||||
if (sa.usesTargeting()) {
|
||||
sa.resetTargets();
|
||||
if (!moveTgtAI(ai, sa)) {
|
||||
return false;
|
||||
}
|
||||
return moveTgtAI(ai, sa);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -287,10 +279,7 @@ public class CountersMoveAi extends SpellAbilityAi {
|
||||
// do not steal a P1P1 from Undying if it would die
|
||||
// this way
|
||||
if (CounterType.P1P1.equals(cType) && srcCardCpy.getNetToughness() <= 0) {
|
||||
if (srcCardCpy.getCounters(cType) > 0 || !card.hasKeyword(Keyword.UNDYING) || card.isToken()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return srcCardCpy.getCounters(cType) > 0 || !card.hasKeyword(Keyword.UNDYING) || card.isToken();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ public class CountersMultiplyAi extends SpellAbilityAi {
|
||||
if (!c.canReceiveCounters(counterType)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
} else {
|
||||
for (Map.Entry<CounterType, Integer> e : c.getCounters().entrySet()) {
|
||||
// has negative counter it would double
|
||||
@@ -96,10 +97,7 @@ public class CountersMultiplyAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
if (sa.usesTargeting() && !setTargets(ai, sa) && !mandatory) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !sa.usesTargeting() || setTargets(ai, sa) || mandatory;
|
||||
}
|
||||
|
||||
private CounterType getCounterType(SpellAbility sa) {
|
||||
|
||||
@@ -85,10 +85,7 @@ public class CountersProliferateAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
|
||||
if (cperms.isEmpty() && hperms.isEmpty() && !opponentPoison && !allyExpOrEnergy) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !cperms.isEmpty() || !hperms.isEmpty() || opponentPoison || allyExpOrEnergy;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -469,7 +469,7 @@ public class CountersPutAi extends SpellAbilityAi {
|
||||
int left = amount;
|
||||
for (Card c : list) {
|
||||
if (ComputerUtilCard.shouldPumpCard(ai, sa, c, i, i,
|
||||
Lists.<String>newArrayList())) {
|
||||
Lists.newArrayList())) {
|
||||
sa.getTargets().add(c);
|
||||
abTgt.addDividedAllocation(c, i);
|
||||
left -= i;
|
||||
@@ -506,7 +506,7 @@ public class CountersPutAi extends SpellAbilityAi {
|
||||
if (type.equals("P1P1") && !SpellAbilityAi.isSorcerySpeed(sa)) {
|
||||
for (Card c : list) {
|
||||
if (ComputerUtilCard.shouldPumpCard(ai, sa, c, amount, amount,
|
||||
Lists.<String>newArrayList())) {
|
||||
Lists.newArrayList())) {
|
||||
choice = c;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ public class CountersRemoveAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
// Filter AI-specific targets if provided
|
||||
list = ComputerUtil.filterAITgts(sa, ai, (CardCollection)list, false);
|
||||
list = ComputerUtil.filterAITgts(sa, ai, list, false);
|
||||
|
||||
boolean noLegendary = game.getStaticEffects().getGlobalRuleChange(GlobalRuleChange.noLegendRule);
|
||||
|
||||
|
||||
@@ -37,9 +37,7 @@ public abstract class DamageAiBase extends SpellAbilityAi {
|
||||
}
|
||||
if ("SelfDamage".equals(sa.getParam("AILogic"))) {
|
||||
if (comp.getLife() * 0.75 < enemy.getLife()) {
|
||||
if (!lifelink) {
|
||||
return true;
|
||||
}
|
||||
return !lifelink;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -80,10 +80,7 @@ public class DamageDealAi extends DamageAiBase {
|
||||
dmg--; // the card will be spent casting the spell, so actual damage is 1 less
|
||||
}
|
||||
}
|
||||
if (!this.damageTargetAI(ai, sa, dmg, true)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return this.damageTargetAI(ai, sa, dmg, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -490,9 +487,7 @@ public class DamageDealAi extends DamageAiBase {
|
||||
for (final Object o : objects) {
|
||||
if (o instanceof Card) {
|
||||
final Card c = (Card) o;
|
||||
if (hPlay.contains(c)) {
|
||||
hPlay.remove(c);
|
||||
}
|
||||
hPlay.remove(c);
|
||||
}
|
||||
}
|
||||
hPlay = CardLists.getTargetableCards(hPlay, sa);
|
||||
@@ -952,9 +947,7 @@ public class DamageDealAi extends DamageAiBase {
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
if (tgt == null) {
|
||||
// If it's not mandatory check a few things
|
||||
if (!mandatory && !this.damageChooseNontargeted(ai, sa, dmg)) {
|
||||
return false;
|
||||
}
|
||||
return mandatory || this.damageChooseNontargeted(ai, sa, dmg);
|
||||
} else {
|
||||
if (!this.damageChoosingTargets(ai, sa, tgt, dmg, mandatory, true) && !mandatory) {
|
||||
return false;
|
||||
|
||||
@@ -124,7 +124,7 @@ public class DebuffAi extends SpellAbilityAi {
|
||||
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
sa.resetTargets();
|
||||
CardCollection list = getCurseCreatures(ai, sa, kws == null ? Lists.<String>newArrayList() : kws);
|
||||
CardCollection list = getCurseCreatures(ai, sa, kws == null ? Lists.newArrayList() : kws);
|
||||
list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getHostCard(), sa);
|
||||
|
||||
// several uses here:
|
||||
|
||||
@@ -27,7 +27,7 @@ public class DelayedTriggerAi extends SpellAbilityAi {
|
||||
trigsa.setActivatingPlayer(ai);
|
||||
|
||||
if (trigsa instanceof AbilitySub) {
|
||||
return SpellApiToAi.Converter.get(((AbilitySub) trigsa).getApi()).chkDrawbackWithSubs(ai, (AbilitySub)trigsa);
|
||||
return SpellApiToAi.Converter.get(trigsa.getApi()).chkDrawbackWithSubs(ai, (AbilitySub)trigsa);
|
||||
} else {
|
||||
return AiPlayDecision.WillPlay == ((PlayerControllerAi)ai.getController()).getAi().canPlaySa(trigsa);
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class DestroyAi extends SpellAbilityAi {
|
||||
return false;
|
||||
}
|
||||
|
||||
hasXCost = abCost.getCostMana() != null ? abCost.getCostMana().getAmountOfX() > 0 : false;
|
||||
hasXCost = abCost.getCostMana() != null && abCost.getCostMana().getAmountOfX() > 0;
|
||||
}
|
||||
|
||||
if ("AtOpponentsCombatOrAfter".equals(sa.getParam("AILogic"))) {
|
||||
@@ -132,7 +132,7 @@ public class DestroyAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
// Filter AI-specific targets if provided
|
||||
list = ComputerUtil.filterAITgts(sa, ai, (CardCollection)list, true);
|
||||
list = ComputerUtil.filterAITgts(sa, ai, list, true);
|
||||
|
||||
list = CardLists.getNotKeyword(list, Keyword.INDESTRUCTIBLE);
|
||||
if (CardLists.getNotType(list, "Creature").isEmpty()) {
|
||||
@@ -296,8 +296,8 @@ public class DestroyAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
if (list.isEmpty()
|
||||
|| !CardLists.filterControlledBy(list, ai).isEmpty()
|
||||
|| CardLists.getNotKeyword(list, Keyword.INDESTRUCTIBLE).isEmpty()) {
|
||||
|| !CardLists.filterControlledBy(list, ai).isEmpty()
|
||||
|| CardLists.getNotKeyword(list, Keyword.INDESTRUCTIBLE).isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -342,7 +342,7 @@ public class DestroyAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
// Filter AI-specific targets if provided
|
||||
preferred = ComputerUtil.filterAITgts(sa, ai, (CardCollection)preferred, true);
|
||||
preferred = ComputerUtil.filterAITgts(sa, ai, preferred, true);
|
||||
|
||||
for (final Card c : preferred) {
|
||||
list.remove(c);
|
||||
@@ -400,16 +400,11 @@ public class DestroyAi extends SpellAbilityAi {
|
||||
}
|
||||
}
|
||||
|
||||
if (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa)) {
|
||||
return false;
|
||||
}
|
||||
return sa.getTargets().getNumTargeted() >= tgt.getMinTargets(sa.getHostCard(), sa);
|
||||
} else {
|
||||
if (!mandatory) {
|
||||
return false;
|
||||
}
|
||||
return mandatory;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean doLandForLandRemovalLogic(SpellAbility sa, Player ai, Card tgtLand, String logic) {
|
||||
|
||||
@@ -147,7 +147,7 @@ public class DestroyAllAi extends SpellAbilityAi {
|
||||
block.assignBlockersForCombat(combat);
|
||||
|
||||
if (ComputerUtilCombat.lifeInSeriousDanger(ai, combat)) {
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} // only lands involved
|
||||
@@ -171,7 +171,6 @@ public class DestroyAllAi extends SpellAbilityAi {
|
||||
else if ((ComputerUtilCard.evaluatePermanentList(ailist) + 3) >= ComputerUtilCard.evaluatePermanentList(opplist)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,12 +51,9 @@ public class DrainManaAi extends SpellAbilityAi {
|
||||
} else {
|
||||
final List<Player> defined = AbilityUtils.getDefinedPlayers(source, sa.getParam("Defined"), sa);
|
||||
|
||||
if (!defined.contains(opp)) {
|
||||
return false;
|
||||
}
|
||||
return defined.contains(opp);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
sa.resetTargets();
|
||||
sa.getTargets().add(opp);
|
||||
|
||||
@@ -69,7 +69,7 @@ public class DrawAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
if (!canLoot(ai, sa)) {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -283,11 +283,7 @@ public class EffectAi extends SpellAbilityAi {
|
||||
return false;
|
||||
}
|
||||
final SpellAbility topStack = game.getStack().peekAbility();
|
||||
if (topStack.getActivatingPlayer().isOpponentOf(ai) && topStack.getApi() == ApiType.GainLife) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return topStack.getActivatingPlayer().isOpponentOf(ai) && topStack.getApi() == ApiType.GainLife;
|
||||
} else if (logic.equals("Fight")) {
|
||||
return FightAi.canFightAi(ai, sa, 0, 0);
|
||||
} else if (logic.equals("Burn")) {
|
||||
@@ -301,11 +297,9 @@ public class EffectAi extends SpellAbilityAi {
|
||||
return false;
|
||||
}
|
||||
if (logic.contains(":")) {
|
||||
String k[] = logic.split(":");
|
||||
String[] k = logic.split(":");
|
||||
Integer i = Integer.valueOf(k[1]);
|
||||
if (ai.getCreaturesInPlay().size() < i) {
|
||||
return false;
|
||||
}
|
||||
return ai.getCreaturesInPlay().size() >= i;
|
||||
}
|
||||
return true;
|
||||
} else if (logic.equals("CastFromGraveThisTurn")) {
|
||||
|
||||
@@ -273,10 +273,10 @@ public class FightAi extends SpellAbilityAi {
|
||||
if (!canKill(opponent, fighter, -pumpDefense)) { // can survive
|
||||
return true;
|
||||
} else {
|
||||
if (MyRandom.getRandom().nextInt(20)<(opponent.getCMC() - fighter.getCMC())) { // trade
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (MyRandom.getRandom().nextInt(20)<(opponent.getCMC() - fighter.getCMC())) { // trade
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -20,9 +20,9 @@ public class FlipACoinAi extends SpellAbilityAi {
|
||||
if (AILogic.equals("Never")) {
|
||||
return false;
|
||||
} else if (AILogic.equals("PhaseOut")) {
|
||||
if (!ComputerUtil.predictThreatenedObjects(sa.getActivatingPlayer(), sa).contains(sa.getHostCard())) {
|
||||
if (!ComputerUtil.predictThreatenedObjects(sa.getActivatingPlayer(), sa).contains(sa.getHostCard())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else if (AILogic.equals("KillOrcs")) {
|
||||
if (ai.getGame().getPhaseHandler().getPhase().isBefore(PhaseType.END_OF_TURN) ) {
|
||||
return false;
|
||||
|
||||
@@ -11,9 +11,7 @@ public class GameWinAi extends SpellAbilityAi {
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
if (ai.cantWin()) {
|
||||
return false;
|
||||
}
|
||||
return !ai.cantWin();
|
||||
|
||||
// TODO Check conditions are met on card (e.g. Coalition Victory)
|
||||
|
||||
@@ -21,7 +19,6 @@ public class GameWinAi extends SpellAbilityAi {
|
||||
|
||||
// In general, don't return true.
|
||||
// But this card wins the game, I can make an exception for that
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -106,13 +106,9 @@ public class LifeGainAi extends SpellAbilityAi {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!lifeCritical && !activateForCost
|
||||
&& (!ph.getNextTurn().equals(ai) || ph.getPhase().isBefore(PhaseType.END_OF_TURN))
|
||||
&& !sa.hasParam("PlayerTurn") && !SpellAbilityAi.isSorcerySpeed(sa)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return lifeCritical || activateForCost
|
||||
|| (ph.getNextTurn().equals(ai) && !ph.getPhase().isBefore(PhaseType.END_OF_TURN))
|
||||
|| sa.hasParam("PlayerTurn") || SpellAbilityAi.isSorcerySpeed(sa);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -304,9 +300,7 @@ public class LifeGainAi extends SpellAbilityAi {
|
||||
hasTgt = true;
|
||||
}
|
||||
}
|
||||
if (!hasTgt) {
|
||||
return false;
|
||||
}
|
||||
return hasTgt;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -53,9 +53,7 @@ public class LifeLoseAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
if (sa.usesTargeting()) {
|
||||
if (!doTgt(ai, sa, false)) {
|
||||
return false;
|
||||
}
|
||||
return doTgt(ai, sa, false);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -187,12 +185,8 @@ public class LifeLoseAi extends SpellAbilityAi {
|
||||
? new FCollection<Player>(sa.getTargets().getTargetPlayers())
|
||||
: AbilityUtils.getDefinedPlayers(sa.getHostCard(), sa.getParam("Defined"), sa);
|
||||
|
||||
if (!mandatory && tgtPlayers.contains(ai) && amount > 0 && amount + 3 > ai.getLife()) {
|
||||
// For cards like Foul Imp, ETB you lose life
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
// For cards like Foul Imp, ETB you lose life
|
||||
return mandatory || !tgtPlayers.contains(ai) || amount <= 0 || amount + 3 <= ai.getLife();
|
||||
}
|
||||
|
||||
protected boolean doTgt(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
|
||||
@@ -81,11 +81,8 @@ public class ManaEffectAi extends SpellAbilityAi {
|
||||
return true; // handled elsewhere, does not meet the standard requirements
|
||||
}
|
||||
|
||||
if (!(sa.getPayCosts() != null && sa.getPayCosts().hasNoManaCost() && sa.getPayCosts().isReusuableResource()
|
||||
&& sa.getSubAbility() == null && ComputerUtil.playImmediately(ai, sa))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return sa.getPayCosts() != null && sa.getPayCosts().hasNoManaCost() && sa.getPayCosts().isReusuableResource()
|
||||
&& sa.getSubAbility() == null && ComputerUtil.playImmediately(ai, sa);
|
||||
// return super.checkApiLogic(ai, sa);
|
||||
}
|
||||
|
||||
|
||||
@@ -185,10 +185,7 @@ public class ManifestAi extends SpellAbilityAi {
|
||||
CardCollection filtered = CardLists.filter(options, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card input) {
|
||||
if (shouldManyfest(input, ai, sa)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !shouldManyfest(input, ai, sa);
|
||||
}
|
||||
});
|
||||
if (!filtered.isEmpty()) {
|
||||
|
||||
@@ -31,19 +31,13 @@ public class MillAi extends SpellAbilityAi {
|
||||
PhaseHandler ph = ai.getGame().getPhaseHandler();
|
||||
|
||||
if (aiLogic.equals("Main1")) {
|
||||
if (ph.getPhase().isBefore(PhaseType.MAIN2) && !sa.hasParam("ActivationPhases")
|
||||
&& !ComputerUtil.castSpellInMain1(ai, sa)) {
|
||||
return false;
|
||||
}
|
||||
return !ph.getPhase().isBefore(PhaseType.MAIN2) || sa.hasParam("ActivationPhases")
|
||||
|| ComputerUtil.castSpellInMain1(ai, sa);
|
||||
} else if (aiLogic.equals("EndOfOppTurn")) {
|
||||
if (!(ph.is(PhaseType.END_OF_TURN) && ph.getNextTurn().equals(ai))) {
|
||||
return false;
|
||||
}
|
||||
return ph.is(PhaseType.END_OF_TURN) && ph.getNextTurn().equals(ai);
|
||||
} else if (aiLogic.equals("LilianaMill")) {
|
||||
// Only mill if a "Raise Dead" target is available, in case of control decks with few creatures
|
||||
if (CardLists.filter(ai.getCardsIn(ZoneType.Graveyard), CardPredicates.Presets.CREATURES).size() < 1) {
|
||||
return false;
|
||||
}
|
||||
return CardLists.filter(ai.getCardsIn(ZoneType.Graveyard), CardPredicates.Presets.CREATURES).size() >= 1;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -62,11 +56,9 @@ public class MillAi extends SpellAbilityAi {
|
||||
}
|
||||
}
|
||||
if (sa.getHostCard().isCreature() && sa.getPayCosts().hasTapCost()) {
|
||||
if (!(ph.is(PhaseType.END_OF_TURN) && ph.getNextTurn().equals(ai))) {
|
||||
// creatures with a tap cost to mill (e.g. Doorkeeper) should be activated at the opponent's end step
|
||||
// because they are also potentially useful for combat
|
||||
return false;
|
||||
}
|
||||
// creatures with a tap cost to mill (e.g. Doorkeeper) should be activated at the opponent's end step
|
||||
// because they are also potentially useful for combat
|
||||
return ph.is(PhaseType.END_OF_TURN) && ph.getNextTurn().equals(ai);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -100,9 +92,7 @@ public class MillAi extends SpellAbilityAi {
|
||||
// Set PayX here to maximum value.
|
||||
final int cardsToDiscard = getNumToDiscard(ai, sa);
|
||||
source.setSVar("PayX", Integer.toString(cardsToDiscard));
|
||||
if (cardsToDiscard <= 0) {
|
||||
return false;
|
||||
}
|
||||
return cardsToDiscard > 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -24,10 +24,10 @@ public class PeekAndRevealAi extends SpellAbilityAi {
|
||||
return false;
|
||||
}
|
||||
if ("Main2".equals(sa.getParam("AILogic"))) {
|
||||
if (aiPlayer.getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (aiPlayer.getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// So far this only appears on Triggers, but will expand
|
||||
// once things get converted from Dig + NoMove
|
||||
return true;
|
||||
|
||||
@@ -38,10 +38,7 @@ public class PermanentAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
// Wait for Main2 if possible
|
||||
if (ph.is(PhaseType.MAIN1) && ph.isPlayerTurn(ai) && !ComputerUtil.castPermanentInMain1(ai, sa) && !sa.hasParam("WithoutManaCost")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !ph.is(PhaseType.MAIN1) || !ph.isPlayerTurn(ai) || ComputerUtil.castPermanentInMain1(ai, sa) || sa.hasParam("WithoutManaCost");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -259,9 +256,7 @@ public class PermanentAi extends SpellAbilityAi {
|
||||
}
|
||||
}
|
||||
|
||||
if (dontCast) {
|
||||
return false;
|
||||
}
|
||||
return !dontCast;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -40,9 +40,7 @@ public class PermanentCreatureAi extends PermanentAi {
|
||||
|
||||
ComputerUtilCard.applyStaticContPT(game, copy, null);
|
||||
|
||||
if (copy.getNetToughness() <= 0) {
|
||||
return false;
|
||||
}
|
||||
return copy.getNetToughness() > 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -225,13 +223,9 @@ public class PermanentCreatureAi extends PermanentAi {
|
||||
*/
|
||||
final Card copy = CardUtil.getLKICopy(sa.getHostCard());
|
||||
ComputerUtilCard.applyStaticContPT(game, copy, null);
|
||||
if (copy.getNetToughness() <= 0 && !copy.hasStartOfKeyword("etbCounter") && mana.countX() == 0
|
||||
&& !copy.hasETBTrigger(false) && !copy.hasETBReplacement() && !copy.hasSVar("NoZeroToughnessAI")) {
|
||||
// AiPlayDecision.WouldBecomeZeroToughnessCreature
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
// AiPlayDecision.WouldBecomeZeroToughnessCreature
|
||||
return copy.getNetToughness() > 0 || copy.hasStartOfKeyword("etbCounter") || mana.countX() != 0
|
||||
|| copy.hasETBTrigger(false) || copy.hasETBReplacement() || copy.hasSVar("NoZeroToughnessAI");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,10 +19,7 @@ public class PermanentNoncreatureAi extends PermanentAi {
|
||||
|
||||
@Override
|
||||
protected boolean checkAiLogic(final Player ai, final SpellAbility sa, final String aiLogic) {
|
||||
if ("Never".equals(aiLogic) || "DontCast".equals(aiLogic)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !"Never".equals(aiLogic) && !"DontCast".equals(aiLogic);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,10 +51,8 @@ public class PermanentNoncreatureAi extends PermanentAi {
|
||||
// TODO: consider replacing the condition with host.hasSVar("OblivionRing")
|
||||
targets = CardLists.filterControlledBy(targets, ai.getOpponents());
|
||||
}
|
||||
if (targets.isEmpty()) {
|
||||
// AiPlayDecision.AnotherTime
|
||||
return false;
|
||||
}
|
||||
// AiPlayDecision.AnotherTime
|
||||
return !targets.isEmpty();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -33,9 +33,7 @@ public class PhasesAi extends SpellAbilityAi {
|
||||
if (tgtCards.contains(source)) {
|
||||
// Protect it from something
|
||||
final boolean isThreatened = ComputerUtil.predictThreatenedObjects(aiPlayer, null, true).contains(source);
|
||||
if (isThreatened) {
|
||||
return true;
|
||||
}
|
||||
return isThreatened;
|
||||
} else {
|
||||
// Card def = tgtCards.get(0);
|
||||
// Phase this out if it might attack me, or before it can be
|
||||
|
||||
@@ -178,11 +178,7 @@ public class PlayAi extends SpellAbilityAi {
|
||||
// Before accepting, see if the spell has a valid number of targets (it should at this point).
|
||||
// Proceeding past this point if the spell is not correctly targeted will result
|
||||
// in "Failed to add to stack" error and the card disappearing from the game completely.
|
||||
if (!spell.isTargetNumberValid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return spell.isTargetNumberValid();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -24,11 +24,8 @@ public class PoisonAi extends SpellAbilityAi {
|
||||
*/
|
||||
@Override
|
||||
protected boolean checkPhaseRestrictions(final Player ai, final SpellAbility sa, final PhaseHandler ph) {
|
||||
if (ph.getPhase().isBefore(PhaseType.MAIN2)
|
||||
&& !sa.hasParam("ActivationPhases")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !ph.getPhase().isBefore(PhaseType.MAIN2)
|
||||
|| sa.hasParam("ActivationPhases");
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -83,7 +80,6 @@ public class PoisonAi extends SpellAbilityAi {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -99,7 +95,6 @@ public class PoisonAi extends SpellAbilityAi {
|
||||
} else if (!input.canReceiveCounters(CounterType.POISON)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -132,10 +127,7 @@ public class PoisonAi extends SpellAbilityAi {
|
||||
if (input.cantLose()) {
|
||||
return true;
|
||||
}
|
||||
if (!input.canReceiveCounters(CounterType.POISON)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return !input.canReceiveCounters(CounterType.POISON);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -162,11 +162,8 @@ public class ProtectAi extends SpellAbilityAi {
|
||||
@Override
|
||||
protected boolean checkPhaseRestrictions(final Player ai, final SpellAbility sa, final PhaseHandler ph) {
|
||||
final boolean notAiMain1 = !(ph.getPlayerTurn() == ai && ph.getPhase() == PhaseType.MAIN1);
|
||||
if (SpellAbilityAi.isSorcerySpeed(sa) && notAiMain1) {
|
||||
// sorceries can only give protection in order to create an unblockable attacker
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
// sorceries can only give protection in order to create an unblockable attacker
|
||||
return !SpellAbilityAi.isSorcerySpeed(sa) || !notAiMain1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -177,9 +174,7 @@ public class ProtectAi extends SpellAbilityAi {
|
||||
return false;
|
||||
} else if (cards.size() == 1) {
|
||||
// Affecting single card
|
||||
if ((getProtectCreatures(ai, sa)).contains(cards.get(0))) {
|
||||
return true;
|
||||
}
|
||||
return (getProtectCreatures(ai, sa)).contains(cards.get(0));
|
||||
}
|
||||
/*
|
||||
* when this happens we need to expand AI to consider if its ok
|
||||
|
||||
@@ -92,10 +92,7 @@ public class PumpAi extends PumpAiBase {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!ph.getNextTurn().equals(ai) || ph.getPhase().isBefore(PhaseType.END_OF_TURN)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return ph.getNextTurn().equals(ai) && !ph.getPhase().isBefore(PhaseType.END_OF_TURN);
|
||||
} else if (logic.equals("Aristocrat")) {
|
||||
final boolean isThreatened = ComputerUtil.predictThreatenedObjects(ai, null, true).contains(sa.getHostCard());
|
||||
if (!ph.is(PhaseType.COMBAT_DECLARE_BLOCKERS) && !isThreatened) {
|
||||
@@ -121,9 +118,7 @@ public class PumpAi extends PumpAiBase {
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS))) {
|
||||
// Instant-speed pumps should not be cast outside of combat when the
|
||||
// stack is empty
|
||||
if (!sa.isCurse() && !SpellAbilityAi.isSorcerySpeed(sa) && !main1Preferred) {
|
||||
return false;
|
||||
}
|
||||
return sa.isCurse() || SpellAbilityAi.isSorcerySpeed(sa) || main1Preferred;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -134,7 +129,7 @@ public class PumpAi extends PumpAiBase {
|
||||
final Card source = sa.getHostCard();
|
||||
final String sourceName = ComputerUtilAbility.getAbilitySourceName(sa);
|
||||
final List<String> keywords = sa.hasParam("KW") ? Arrays.asList(sa.getParam("KW").split(" & "))
|
||||
: Lists.<String>newArrayList();
|
||||
: Lists.newArrayList();
|
||||
final String numDefense = sa.hasParam("NumDef") ? sa.getParam("NumDef") : "";
|
||||
final String numAttack = sa.hasParam("NumAtt") ? sa.getParam("NumAtt") : "";
|
||||
|
||||
@@ -191,11 +186,8 @@ public class PumpAi extends PumpAiBase {
|
||||
srcCardCpy.setCounters(cType, srcCardCpy.getCounters(cType) - amount);
|
||||
|
||||
if (CounterType.P1P1.equals(cType) && srcCardCpy.getNetToughness() <= 0) {
|
||||
if (srcCardCpy.getCounters(cType) > 0 || !card.hasKeyword(Keyword.UNDYING)
|
||||
|| card.isToken()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return srcCardCpy.getCounters(cType) > 0 || !card.hasKeyword(Keyword.UNDYING)
|
||||
|| card.isToken();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -244,11 +236,8 @@ public class PumpAi extends PumpAiBase {
|
||||
srcCardCpy.setCounters(cType, srcCardCpy.getCounters(cType) - amount);
|
||||
|
||||
if (CounterType.P1P1.equals(cType) && srcCardCpy.getNetToughness() <= 0) {
|
||||
if (srcCardCpy.getCounters(cType) > 0 || !card.hasKeyword(Keyword.UNDYING)
|
||||
|| card.isToken()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return srcCardCpy.getCounters(cType) > 0 || !card.hasKeyword(Keyword.UNDYING)
|
||||
|| card.isToken();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -395,9 +384,7 @@ public class PumpAi extends PumpAiBase {
|
||||
Card pumped = ComputerUtilCard.getPumpedCreature(ai, sa, card, 0, 0, keywords);
|
||||
if (game.getPhaseHandler().is(PhaseType.COMBAT_DECLARE_ATTACKERS, ai)
|
||||
|| game.getPhaseHandler().is(PhaseType.COMBAT_BEGIN, ai)) {
|
||||
if (!ComputerUtilCard.doesSpecifiedCreatureAttackAI(ai, pumped)) {
|
||||
return false;
|
||||
}
|
||||
return ComputerUtilCard.doesSpecifiedCreatureAttackAI(ai, pumped);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -432,7 +419,7 @@ public class PumpAi extends PumpAiBase {
|
||||
private boolean pumpTgtAI(final Player ai, final SpellAbility sa, final int defense, final int attack, final boolean mandatory,
|
||||
boolean immediately) {
|
||||
final List<String> keywords = sa.hasParam("KW") ? Arrays.asList(sa.getParam("KW").split(" & "))
|
||||
: Lists.<String>newArrayList();
|
||||
: Lists.newArrayList();
|
||||
final Game game = ai.getGame();
|
||||
final Card source = sa.getHostCard();
|
||||
final boolean isFight = "Fight".equals(sa.getParam("AILogic")) || "PowerDmg".equals(sa.getParam("AILogic"));
|
||||
@@ -555,7 +542,7 @@ public class PumpAi extends PumpAiBase {
|
||||
}
|
||||
|
||||
// Filter AI-specific targets if provided
|
||||
list = ComputerUtil.filterAITgts(sa, ai, (CardCollection)list, true);
|
||||
list = ComputerUtil.filterAITgts(sa, ai, list, true);
|
||||
|
||||
if (list.isEmpty()) {
|
||||
if (ComputerUtil.activateForCost(sa, ai)) {
|
||||
@@ -788,15 +775,11 @@ public class PumpAi extends PumpAiBase {
|
||||
if (!source.hasKeyword(Keyword.INDESTRUCTIBLE) && source.getNetToughness() + defense <= source.getDamage()) {
|
||||
return false;
|
||||
}
|
||||
if (source.getNetToughness() + defense <= 0) {
|
||||
return false;
|
||||
}
|
||||
return source.getNetToughness() + defense > 0;
|
||||
}
|
||||
} else {
|
||||
//Targeted
|
||||
if (!pumpTgtAI(ai, sa, defense, attack, false, true)) {
|
||||
return false;
|
||||
}
|
||||
return pumpTgtAI(ai, sa, defense, attack, false, true);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -849,9 +832,7 @@ public class PumpAi extends PumpAiBase {
|
||||
}
|
||||
}
|
||||
);
|
||||
if (sacFodder.size() >= numCreatsToSac) {
|
||||
return true;
|
||||
}
|
||||
return sacFodder.size() >= numCreatsToSac;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,24 +56,17 @@ public abstract class PumpAiBase extends SpellAbilityAi {
|
||||
if (!CardUtil.isStackingKeyword(keyword) && card.hasKeyword(keyword)) {
|
||||
return false;
|
||||
} else if (keyword.equals("Defender") || keyword.endsWith("CARDNAME can't attack.")) {
|
||||
if (!ph.isPlayerTurn(card.getController()) || !CombatUtil.canAttack(card, ai)
|
||||
|| (card.getNetCombatDamage() <= 0)
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)) {
|
||||
return false;
|
||||
}
|
||||
return ph.isPlayerTurn(card.getController()) && CombatUtil.canAttack(card, ai)
|
||||
&& (card.getNetCombatDamage() > 0)
|
||||
&& !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS);
|
||||
} else if (keyword.endsWith("CARDNAME can't attack or block.")) {
|
||||
if (sa.hasParam("UntilYourNextTurn")) {
|
||||
if (CombatUtil.canAttack(card, ai) || CombatUtil.canBlock(card, true)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return CombatUtil.canAttack(card, ai) || CombatUtil.canBlock(card, true);
|
||||
}
|
||||
if (!ph.isPlayerTurn(ai)) {
|
||||
if (!CombatUtil.canAttack(card, ai)
|
||||
|| (card.getNetCombatDamage() <= 0)
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)) {
|
||||
return false;
|
||||
}
|
||||
return CombatUtil.canAttack(card, ai)
|
||||
&& (card.getNetCombatDamage() > 0)
|
||||
&& !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS);
|
||||
} else {
|
||||
if (ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS)
|
||||
|| ph.getPhase().isBefore(PhaseType.MAIN1)) {
|
||||
@@ -90,9 +83,7 @@ public abstract class PumpAiBase extends SpellAbilityAi {
|
||||
return CombatUtil.canAttack(c, card.getController()) || (combat != null && combat.isAttacking(c));
|
||||
}
|
||||
});
|
||||
if (!CombatUtil.canBlockAtLeastOne(card, attackers)) {
|
||||
return false;
|
||||
}
|
||||
return CombatUtil.canBlockAtLeastOne(card, attackers);
|
||||
}
|
||||
} else if (keyword.endsWith("CARDNAME can't block.")) {
|
||||
if (!ph.isPlayerTurn(ai) || ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS)
|
||||
@@ -112,24 +103,18 @@ public abstract class PumpAiBase extends SpellAbilityAi {
|
||||
&& card.getController().equals(combat.getDefenderPlayerByAttacker(c)));
|
||||
}
|
||||
});
|
||||
if (!CombatUtil.canBlockAtLeastOne(card, attackers)) {
|
||||
return false;
|
||||
}
|
||||
return CombatUtil.canBlockAtLeastOne(card, attackers);
|
||||
} else if (keyword.endsWith("CantBlockCardUIDSource")) { // can't block CARDNAME this turn
|
||||
if (!ph.isPlayerTurn(ai) || ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS)
|
||||
|| ph.getPhase().isBefore(PhaseType.MAIN1) || !CombatUtil.canBlock(sa.getHostCard(), card)) {
|
||||
return false;
|
||||
}
|
||||
// target needs to be a creature, controlled by the player which is attacked
|
||||
if (sa.getHostCard().isTapped() && (combat == null || !combat.isAttacking(sa.getHostCard())
|
||||
|| !card.getController().equals(combat.getDefenderPlayerByAttacker(sa.getHostCard())))) {
|
||||
return false;
|
||||
}
|
||||
return !sa.getHostCard().isTapped() || (combat != null && combat.isAttacking(sa.getHostCard())
|
||||
&& card.getController().equals(combat.getDefenderPlayerByAttacker(sa.getHostCard())));
|
||||
} else if (keyword.endsWith("This card doesn't untap during your next untap step.")) {
|
||||
if (ph.getPhase().isBefore(PhaseType.MAIN2) || card.isUntapped() || !ph.isPlayerTurn(ai)
|
||||
|| !Untap.canUntap(card)) {
|
||||
return false;
|
||||
}
|
||||
return !ph.getPhase().isBefore(PhaseType.MAIN2) && !card.isUntapped() && ph.isPlayerTurn(ai)
|
||||
&& Untap.canUntap(card);
|
||||
} else if (keyword.endsWith("Prevent all combat damage that would be dealt by CARDNAME.")
|
||||
|| keyword.endsWith("Prevent all damage that would be dealt by CARDNAME.")) {
|
||||
if (ph.isPlayerTurn(ai) && (!(CombatUtil.canBlock(card) || combat != null && combat.isBlocking(card))
|
||||
@@ -139,28 +124,18 @@ public abstract class PumpAiBase extends SpellAbilityAi {
|
||||
|| CardLists.getNotKeyword(ai.getCreaturesInPlay(), Keyword.DEFENDER).isEmpty())) {
|
||||
return false;
|
||||
}
|
||||
if (!ph.isPlayerTurn(ai) && (combat == null || !combat.isAttacking(card) || card.getNetCombatDamage() <= 0)) {
|
||||
return false;
|
||||
}
|
||||
return ph.isPlayerTurn(ai) || (combat != null && combat.isAttacking(card) && card.getNetCombatDamage() > 0);
|
||||
} else if (keyword.endsWith("CARDNAME attacks each turn if able.")
|
||||
|| keyword.endsWith("CARDNAME attacks each combat if able.")) {
|
||||
if (ph.isPlayerTurn(ai) || !CombatUtil.canAttack(card, ai) || !CombatUtil.canBeBlocked(card, ai)
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)) {
|
||||
return false;
|
||||
}
|
||||
return !ph.isPlayerTurn(ai) && CombatUtil.canAttack(card, ai) && CombatUtil.canBeBlocked(card, ai)
|
||||
&& !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS);
|
||||
} else if (keyword.endsWith("CARDNAME can't be regenerated.")) {
|
||||
if (card.getShieldCount() > 0) {
|
||||
return true;
|
||||
}
|
||||
if (card.hasKeyword("If CARDNAME would be destroyed, regenerate it.") && combat != null
|
||||
&& (combat.isBlocked(card) || combat.isBlocking(card))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} else if (keyword.endsWith("CARDNAME's activated abilities can't be activated.")) {
|
||||
return false; //too complex
|
||||
}
|
||||
return true;
|
||||
return card.hasKeyword("If CARDNAME would be destroyed, regenerate it.") && combat != null
|
||||
&& (combat.isBlocked(card) || combat.isBlocking(card));
|
||||
} else return !keyword.endsWith("CARDNAME's activated abilities can't be activated."); //too complex
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -187,12 +162,10 @@ public abstract class PumpAiBase extends SpellAbilityAi {
|
||||
final boolean evasive = (keyword.endsWith("Unblockable") || keyword.endsWith("Shadow") || keyword.startsWith("CantBeBlockedBy"));
|
||||
// give evasive keywords to creatures that can or do attack
|
||||
if (evasive) {
|
||||
if (ph.isPlayerTurn(opp) || !(CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card)))
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
|| newPower <= 0
|
||||
|| CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)).isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return !ph.isPlayerTurn(opp) && (CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card)))
|
||||
&& !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
&& newPower > 0
|
||||
&& !CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)).isEmpty();
|
||||
} else if (keyword.endsWith("Flying")) {
|
||||
CardCollectionView attackingFlyer = CardCollection.EMPTY;
|
||||
if (combat != null) {
|
||||
@@ -221,13 +194,11 @@ public abstract class PumpAiBase extends SpellAbilityAi {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ph.isPlayerTurn(opp) || !(CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card)))
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
|| newPower <= 0
|
||||
|| !Iterables.any(CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)),
|
||||
Predicates.not(flyingOrReach))) {
|
||||
return false;
|
||||
}
|
||||
return !ph.isPlayerTurn(opp) && (CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card)))
|
||||
&& !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
&& newPower > 0
|
||||
&& Iterables.any(CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)),
|
||||
Predicates.not(flyingOrReach));
|
||||
} else if (keyword.endsWith("Horsemanship")) {
|
||||
if (ph.isPlayerTurn(opp)
|
||||
&& ph.getPhase().equals(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
@@ -236,46 +207,35 @@ public abstract class PumpAiBase extends SpellAbilityAi {
|
||||
&& ComputerUtilCombat.lifeInDanger(ai, game.getCombat())) {
|
||||
return true;
|
||||
}
|
||||
if (ph.isPlayerTurn(opp) || !(CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card)))
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
|| newPower <= 0
|
||||
|| CardLists.getNotKeyword(CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)),
|
||||
Keyword.HORSEMANSHIP).isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return !ph.isPlayerTurn(opp) && (CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card)))
|
||||
&& !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
&& newPower > 0
|
||||
&& !CardLists.getNotKeyword(CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)),
|
||||
Keyword.HORSEMANSHIP).isEmpty();
|
||||
} else if (keyword.endsWith("Intimidate")) {
|
||||
if (ph.isPlayerTurn(opp) || !(CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card)))
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
|| newPower <= 0
|
||||
|| CardLists.getNotType(CardLists.filter(
|
||||
opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)), "Artifact").isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return !ph.isPlayerTurn(opp) && (CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card)))
|
||||
&& !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
&& newPower > 0
|
||||
&& !CardLists.getNotType(CardLists.filter(
|
||||
opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)), "Artifact").isEmpty();
|
||||
} else if (keyword.endsWith("Fear")) {
|
||||
if (ph.isPlayerTurn(opp) || !(CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card)))
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
|| newPower <= 0
|
||||
|| CardLists.getNotColor(CardLists.getNotType(CardLists.filter(
|
||||
opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)), "Artifact"), MagicColor.BLACK).isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return !ph.isPlayerTurn(opp) && (CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card)))
|
||||
&& !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
&& newPower > 0
|
||||
&& !CardLists.getNotColor(CardLists.getNotType(CardLists.filter(
|
||||
opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)), "Artifact"), MagicColor.BLACK).isEmpty();
|
||||
} else if (keyword.endsWith("Haste")) {
|
||||
if (!card.hasSickness() || ph.isPlayerTurn(opp) || card.isTapped()
|
||||
|| newPower <= 0
|
||||
|| card.hasKeyword("CARDNAME can attack as though it had haste.")
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
|| !ComputerUtilCombat.canAttackNextTurn(card)) {
|
||||
return false;
|
||||
}
|
||||
return card.hasSickness() && !ph.isPlayerTurn(opp) && !card.isTapped()
|
||||
&& newPower > 0
|
||||
&& !card.hasKeyword("CARDNAME can attack as though it had haste.")
|
||||
&& !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
&& ComputerUtilCombat.canAttackNextTurn(card);
|
||||
} else if (keyword.endsWith("Indestructible")) {
|
||||
// Predicting threatened objects in relevant non-combat situations happens elsewhere,
|
||||
// so we are only worrying about combat relevance of Indestructible at this point.
|
||||
if (combat == null
|
||||
|| !((combat.isBlocked(card) || combat.isBlocking(card))
|
||||
&& ComputerUtilCombat.combatantWouldBeDestroyed(ai, card, combat))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return combat != null
|
||||
&& ((combat.isBlocked(card) || combat.isBlocking(card))
|
||||
&& ComputerUtilCombat.combatantWouldBeDestroyed(ai, card, combat));
|
||||
} else if (keyword.endsWith("Deathtouch")) {
|
||||
if (ph.isPlayerTurn(opp) && ph.getPhase().equals(PhaseType.COMBAT_DECLARE_ATTACKERS)) {
|
||||
List<Card> attackers = combat.getAttackers();
|
||||
@@ -297,12 +257,10 @@ public abstract class PumpAiBase extends SpellAbilityAi {
|
||||
}
|
||||
return false;
|
||||
} else if (keyword.equals("Bushido")) {
|
||||
if (ph.isPlayerTurn(opp) || !(CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card)))
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS)
|
||||
|| opp.getCreaturesInPlay().isEmpty()
|
||||
|| CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)).isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return !ph.isPlayerTurn(opp) && (CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card)))
|
||||
&& !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS)
|
||||
&& !opp.getCreaturesInPlay().isEmpty()
|
||||
&& !CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)).isEmpty();
|
||||
} else if (keyword.equals("First Strike")) {
|
||||
if (card.hasKeyword(Keyword.DOUBLE_STRIKE)) {
|
||||
return false;
|
||||
@@ -321,40 +279,31 @@ public abstract class PumpAiBase extends SpellAbilityAi {
|
||||
if (!ComputerUtilCombat.canDestroyAttacker(ai, attacker, card, combat, true)
|
||||
&& ComputerUtilCombat.canDestroyAttacker(ai, attacker, card, combat, false))
|
||||
return true;
|
||||
if (ComputerUtilCombat.canDestroyBlocker(ai, card, attacker, combat, true)
|
||||
&& !ComputerUtilCombat.canDestroyBlocker(ai, card, attacker, combat, false))
|
||||
return true;
|
||||
return ComputerUtilCombat.canDestroyBlocker(ai, card, attacker, combat, true)
|
||||
&& !ComputerUtilCombat.canDestroyBlocker(ai, card, attacker, combat, false);
|
||||
}
|
||||
return false;
|
||||
} else if (keyword.equals("Double Strike")) {
|
||||
if (ph.isPlayerTurn(opp) || !(CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card)))
|
||||
|| newPower <= 0
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS)) {
|
||||
return false;
|
||||
}
|
||||
return !ph.isPlayerTurn(opp) && (CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card)))
|
||||
&& newPower > 0
|
||||
&& !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS);
|
||||
} else if (keyword.startsWith("Rampage")) {
|
||||
if (ph.isPlayerTurn(opp) || !(CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card)))
|
||||
|| newPower <= 0
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
|| CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)).size() < 2) {
|
||||
return false;
|
||||
}
|
||||
return !ph.isPlayerTurn(opp) && (CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card)))
|
||||
&& newPower > 0
|
||||
&& !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
&& CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)).size() >= 2;
|
||||
} else if (keyword.startsWith("Flanking")) {
|
||||
if (ph.isPlayerTurn(opp) || !(CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card)))
|
||||
|| newPower <= 0
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
|| CardLists.getNotKeyword(CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)),
|
||||
Keyword.FLANKING).isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return !ph.isPlayerTurn(opp) && (CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card)))
|
||||
&& newPower > 0
|
||||
&& !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
&& !CardLists.getNotKeyword(CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)),
|
||||
Keyword.FLANKING).isEmpty();
|
||||
} else if (keyword.startsWith("Trample")) {
|
||||
if (ph.isPlayerTurn(opp) || !(CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card)))
|
||||
|| !CombatUtil.canBeBlocked(card, opp)
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
|| newPower <= 1
|
||||
|| CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)).isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return !ph.isPlayerTurn(opp) && (CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card)))
|
||||
&& CombatUtil.canBeBlocked(card, opp)
|
||||
&& !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
&& newPower > 1
|
||||
&& !CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)).isEmpty();
|
||||
} else if (keyword.equals("Infect")) {
|
||||
if (newPower <= 0) {
|
||||
return false;
|
||||
@@ -362,11 +311,9 @@ public abstract class PumpAiBase extends SpellAbilityAi {
|
||||
if (combat != null && combat.isBlocking(card) && !card.hasKeyword(Keyword.WITHER)) {
|
||||
return true;
|
||||
}
|
||||
if ((ph.isPlayerTurn(opp))
|
||||
|| !(CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card)))
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS)) {
|
||||
return false;
|
||||
}
|
||||
return (!ph.isPlayerTurn(opp))
|
||||
&& (CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card)))
|
||||
&& !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS);
|
||||
} else if (keyword.endsWith("Wither")) {
|
||||
if (newPower <= 0 || card.hasKeyword(Keyword.INFECT)) {
|
||||
return false;
|
||||
@@ -378,20 +325,16 @@ public abstract class PumpAiBase extends SpellAbilityAi {
|
||||
}
|
||||
return combat != null && ( combat.isAttacking(card) || combat.isBlocking(card) );
|
||||
} else if (keyword.equals("Vigilance")) {
|
||||
if (ph.isPlayerTurn(opp) || !CombatUtil.canAttack(card, opp)
|
||||
|| newPower <= 0
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
|| CardLists.getNotKeyword(opp.getCreaturesInPlay(), Keyword.DEFENDER).isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return !ph.isPlayerTurn(opp) && CombatUtil.canAttack(card, opp)
|
||||
&& newPower > 0
|
||||
&& !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
&& !CardLists.getNotKeyword(opp.getCreaturesInPlay(), Keyword.DEFENDER).isEmpty();
|
||||
} else if (keyword.equals("Reach")) {
|
||||
if (ph.isPlayerTurn(ai)
|
||||
|| !ph.getPhase().equals(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
|| CardLists.getKeyword(game.getCombat().getAttackers(), Keyword.FLYING).isEmpty()
|
||||
|| card.hasKeyword(Keyword.FLYING)
|
||||
|| !CombatUtil.canBlock(card)) {
|
||||
return false;
|
||||
}
|
||||
return !ph.isPlayerTurn(ai)
|
||||
&& ph.getPhase().equals(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
&& !CardLists.getKeyword(game.getCombat().getAttackers(), Keyword.FLYING).isEmpty()
|
||||
&& !card.hasKeyword(Keyword.FLYING)
|
||||
&& CombatUtil.canBlock(card);
|
||||
} else if (keyword.endsWith("CARDNAME can block an additional creature each combat.")) {
|
||||
if (ph.isPlayerTurn(ai)
|
||||
|| !ph.getPhase().equals(PhaseType.COMBAT_DECLARE_ATTACKERS)) {
|
||||
@@ -407,63 +350,43 @@ public abstract class PumpAiBase extends SpellAbilityAi {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (possibleBlockNum <= canBlockNum) {
|
||||
return false;
|
||||
}
|
||||
return possibleBlockNum > canBlockNum;
|
||||
} else if (keyword.equals("Shroud") || keyword.equals("Hexproof")) {
|
||||
if (!ComputerUtil.predictThreatenedObjects(sa.getActivatingPlayer(), sa).contains(card)) {
|
||||
return false;
|
||||
}
|
||||
return ComputerUtil.predictThreatenedObjects(sa.getActivatingPlayer(), sa).contains(card);
|
||||
} else if (keyword.equals("Persist")) {
|
||||
if (card.getBaseToughness() <= 1 || card.hasKeyword(Keyword.UNDYING)) {
|
||||
return false;
|
||||
}
|
||||
return card.getBaseToughness() > 1 && !card.hasKeyword(Keyword.UNDYING);
|
||||
} else if (keyword.equals("Islandwalk")) {
|
||||
if (ph.isPlayerTurn(opp) || !(CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card)))
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
|| newPower <= 0
|
||||
|| CardLists.getType(opp.getLandsInPlay(), "Island").isEmpty()
|
||||
|| CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)).isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return !ph.isPlayerTurn(opp) && (CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card)))
|
||||
&& !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
&& newPower > 0
|
||||
&& !CardLists.getType(opp.getLandsInPlay(), "Island").isEmpty()
|
||||
&& !CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)).isEmpty();
|
||||
} else if (keyword.equals("Swampwalk")) {
|
||||
if (ph.isPlayerTurn(opp) || !(CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card)))
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
|| newPower <= 0
|
||||
|| CardLists.getType(opp.getLandsInPlay(), "Swamp").isEmpty()
|
||||
|| CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)).isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return !ph.isPlayerTurn(opp) && (CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card)))
|
||||
&& !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
&& newPower > 0
|
||||
&& !CardLists.getType(opp.getLandsInPlay(), "Swamp").isEmpty()
|
||||
&& !CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)).isEmpty();
|
||||
} else if (keyword.equals("Mountainwalk")) {
|
||||
if (ph.isPlayerTurn(opp) || !(CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card)))
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
|| newPower <= 0
|
||||
|| CardLists.getType(opp.getLandsInPlay(), "Mountain").isEmpty()
|
||||
|| CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)).isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return !ph.isPlayerTurn(opp) && (CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card)))
|
||||
&& !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
&& newPower > 0
|
||||
&& !CardLists.getType(opp.getLandsInPlay(), "Mountain").isEmpty()
|
||||
&& !CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)).isEmpty();
|
||||
} else if (keyword.equals("Forestwalk")) {
|
||||
if (ph.isPlayerTurn(opp) || !(CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card)))
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
|| newPower <= 0
|
||||
|| CardLists.getType(opp.getLandsInPlay(), "Forest").isEmpty()
|
||||
|| CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)).isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return !ph.isPlayerTurn(opp) && (CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card)))
|
||||
&& !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
&& newPower > 0
|
||||
&& !CardLists.getType(opp.getLandsInPlay(), "Forest").isEmpty()
|
||||
&& !CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)).isEmpty();
|
||||
} else if (keyword.endsWith("CARDNAME can attack as though it didn't have defender.")) {
|
||||
if (!ph.isPlayerTurn(ai) || !card.hasKeyword(Keyword.DEFENDER)
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_BEGIN)
|
||||
|| card.isTapped() || newPower <= 0) {
|
||||
return false;
|
||||
}
|
||||
return ph.isPlayerTurn(ai) && card.hasKeyword(Keyword.DEFENDER)
|
||||
&& !ph.getPhase().isAfter(PhaseType.COMBAT_BEGIN)
|
||||
&& !card.isTapped() && newPower > 0;
|
||||
} else if (keyword.equals("Prevent all combat damage that would be dealt to CARDNAME.")) {
|
||||
if (combat == null || !(combat.isBlocking(card) || combat.isBlocked(card))) {
|
||||
return false;
|
||||
}
|
||||
return combat != null && (combat.isBlocking(card) || combat.isBlocked(card));
|
||||
} else if (keyword.equals("Menace")) {
|
||||
if (combat == null || !combat.isAttacking(card)) {
|
||||
return false;
|
||||
}
|
||||
return combat != null && combat.isAttacking(card);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -547,10 +470,7 @@ public abstract class PumpAiBase extends SpellAbilityAi {
|
||||
return true;
|
||||
}
|
||||
//Don't waste a -7/-0 spell on a 1/1 creature
|
||||
if (c.getNetPower() + attack > -2 || c.getNetPower() > 3) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return c.getNetPower() + attack > -2 || c.getNetPower() > 3;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
||||
@@ -141,10 +141,7 @@ public class PumpAllAi extends PumpAiBase {
|
||||
|
||||
// evaluate both lists and pass only if human creatures are more
|
||||
// valuable
|
||||
if ((ComputerUtilCard.evaluateCreatureList(comp) + 200) >= ComputerUtilCard.evaluateCreatureList(human)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return (ComputerUtilCard.evaluateCreatureList(comp) + 200) < ComputerUtilCard.evaluateCreatureList(human);
|
||||
} // end Curse
|
||||
|
||||
return !CardLists.getValidCards(getPumpCreatures(ai, sa, defense, power, keywords, false), valid, source.getController(), source).isEmpty();
|
||||
|
||||
@@ -18,9 +18,7 @@ public class RemoveFromCombatAi extends SpellAbilityAi {
|
||||
// AI should only activate this during Human's turn
|
||||
|
||||
if ("RemoveBestAttacker".equals(sa.getParam("AILogic"))) {
|
||||
if (aiPlayer.getGame().getCombat() != null && aiPlayer.getGame().getCombat().getDefenders().contains(aiPlayer)) {
|
||||
return true;
|
||||
}
|
||||
return aiPlayer.getGame().getCombat() != null && aiPlayer.getGame().getCombat().getDefenders().contains(aiPlayer);
|
||||
}
|
||||
|
||||
// TODO - implement AI
|
||||
|
||||
@@ -32,9 +32,7 @@ public class RepeatAi extends SpellAbilityAi {
|
||||
// Set PayX here to maximum value.
|
||||
final int max = ComputerUtilMana.determineLeftoverMana(sa, ai);
|
||||
source.setSVar("PayX", Integer.toString(max));
|
||||
if (max <= 0) {
|
||||
return false;
|
||||
}
|
||||
return max > 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -35,9 +35,7 @@ public class RepeatEachAi extends SpellAbilityAi {
|
||||
List<Card> humTokenCreats = CardLists.filter(aiPlayer.getOpponents().getCreaturesInPlay(), Presets.TOKEN);
|
||||
List<Card> compTokenCreats = CardLists.filter(aiPlayer.getCreaturesInPlay(), Presets.TOKEN);
|
||||
|
||||
if (compTokenCreats.size() <= humTokenCreats.size()) {
|
||||
return false;
|
||||
}
|
||||
return compTokenCreats.size() > humTokenCreats.size();
|
||||
} else if ("BalanceLands".equals(logic)) {
|
||||
if (CardLists.filter(aiPlayer.getCardsIn(ZoneType.Battlefield), Presets.LANDS).size() >= 5) {
|
||||
return false;
|
||||
@@ -111,9 +109,7 @@ public class RepeatEachAi extends SpellAbilityAi {
|
||||
}
|
||||
}
|
||||
// would not hit oppoent, don't do that
|
||||
if (!hitOpp) {
|
||||
return false;
|
||||
}
|
||||
return hitOpp;
|
||||
}
|
||||
|
||||
// TODO Add some normal AI variability here
|
||||
|
||||
@@ -30,11 +30,7 @@ public class RevealHandAi extends RevealAiBase {
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
|
||||
if (!revealHandTargetAI(ai, sa/*, false, mandatory*/)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return revealHandTargetAI(ai, sa/*, false, mandatory*/);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ public class RollPlanarDiceAi extends SpellAbilityAi {
|
||||
}
|
||||
}
|
||||
|
||||
return decideToRoll ? true : false;
|
||||
return decideToRoll;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
@@ -136,9 +136,7 @@ public class SacrificeAi extends SpellAbilityAi {
|
||||
|
||||
// Since all of the cards have AI:RemoveDeck:All, I enabled 1 for 1
|
||||
// (or X for X) trades for special decks
|
||||
if (humanList.size() < amount) {
|
||||
return false;
|
||||
}
|
||||
return humanList.size() >= amount;
|
||||
} else if (defined.equals("You")) {
|
||||
List<Card> computerList =
|
||||
CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), valid.split(","), sa.getActivatingPlayer(), sa.getHostCard(), sa);
|
||||
|
||||
@@ -145,10 +145,10 @@ public class ScryAi extends SpellAbilityAi {
|
||||
if (maxToRemove <= 0) {
|
||||
return false;
|
||||
}
|
||||
sa.setSVar("ChosenX", "Number$" + Integer.toString(maxToRemove));
|
||||
sa.setSVar("ChosenX", "Number$" + maxToRemove);
|
||||
} else {
|
||||
// no Instant or Sorceries anymore, just scry
|
||||
sa.setSVar("ChosenX", "Number$" + Integer.toString(Math.min(counterNum, libsize)));
|
||||
sa.setSVar("ChosenX", "Number$" + Math.min(counterNum, libsize));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -92,9 +92,7 @@ public class SetStateAi extends SpellAbilityAi {
|
||||
}
|
||||
}
|
||||
|
||||
if (sa.getTargets().getNumTargeted() < tgt.getMinTargets(source, sa)) {
|
||||
return false;
|
||||
}
|
||||
return sa.getTargets().getNumTargeted() >= tgt.getMinTargets(source, sa);
|
||||
}
|
||||
} else if ("TurnFace".equals(mode)) {
|
||||
if (!sa.usesTargeting()) {
|
||||
@@ -123,9 +121,7 @@ public class SetStateAi extends SpellAbilityAi {
|
||||
}
|
||||
}
|
||||
|
||||
if (sa.getTargets().getNumTargeted() < tgt.getMinTargets(source, sa)) {
|
||||
return false;
|
||||
}
|
||||
return sa.getTargets().getNumTargeted() >= tgt.getMinTargets(source, sa);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -254,9 +250,7 @@ public class SetStateAi extends SpellAbilityAi {
|
||||
// for legendary KI counter creatures
|
||||
if (othercard.getCounters(CounterType.KI) >= source.getCounters(CounterType.KI)) {
|
||||
// if the other legendary is useless try to replace it
|
||||
if (!ComputerUtilCard.isUselessCreature(aiPlayer, othercard)) {
|
||||
return false;
|
||||
}
|
||||
return ComputerUtilCard.isUselessCreature(aiPlayer, othercard);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -266,10 +260,6 @@ public class SetStateAi extends SpellAbilityAi {
|
||||
|
||||
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) {
|
||||
// TODO: improve the AI for when it may want to transform something that's optional to transform
|
||||
if (!isSafeToTransformIntoLegendary(player, sa.getHostCard())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return isSafeToTransformIntoLegendary(player, sa.getHostCard());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,10 +11,7 @@ public class SkipTurnAi extends SpellAbilityAi {
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
if ("Always".equals(sa.getParam("AILogic"))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return "Always".equals(sa.getParam("AILogic"));
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
@@ -76,9 +76,7 @@ public class SurveilAi extends SpellAbilityAi {
|
||||
if ("Never".equals(aiLogic)) {
|
||||
return false;
|
||||
} else if ("Once".equals(aiLogic)) {
|
||||
if (AiCardMemory.isRememberedCard(ai, source, AiCardMemory.MemorySet.ACTIVATED_THIS_TURN)) {
|
||||
return false;
|
||||
}
|
||||
return !AiCardMemory.isRememberedCard(ai, source, AiCardMemory.MemorySet.ACTIVATED_THIS_TURN);
|
||||
}
|
||||
|
||||
// TODO: add card-specific Surveil AI logic here when/if necessary
|
||||
|
||||
@@ -64,9 +64,7 @@ public class TapAi extends TapAiBase {
|
||||
bFlag |= c.isUntapped();
|
||||
}
|
||||
|
||||
if (!bFlag) {
|
||||
return false;
|
||||
}
|
||||
return bFlag;
|
||||
} else {
|
||||
if ("TapForXCounters".equals(sa.getParam("AILogic"))) {
|
||||
// e.g. Waxmane Baku
|
||||
@@ -83,12 +81,9 @@ public class TapAi extends TapAiBase {
|
||||
}
|
||||
|
||||
sa.resetTargets();
|
||||
if (!tapPrefTargeting(ai, source, tgt, sa, false)) {
|
||||
return false;
|
||||
}
|
||||
return tapPrefTargeting(ai, source, tgt, sa, false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -248,12 +248,8 @@ public abstract class TapAiBase extends SpellAbilityAi {
|
||||
sa.getTargets().add(choice);
|
||||
}
|
||||
|
||||
if (sa.getTargets().getNumTargeted() == 0) {
|
||||
// Nothing was ever targeted, so we need to bail.
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
// Nothing was ever targeted, so we need to bail.
|
||||
return sa.getTargets().getNumTargeted() != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -307,11 +303,7 @@ public abstract class TapAiBase extends SpellAbilityAi {
|
||||
// just tap whatever we can
|
||||
tapList = list;
|
||||
|
||||
if (tapTargetList(ai, sa, tapList, mandatory)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return tapTargetList(ai, sa, tapList, mandatory);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -93,9 +93,7 @@ public class TapAllAi extends SpellAbilityAi {
|
||||
return CombatUtil.canAttack(c) && ComputerUtilCombat.canAttackNextTurn(c);
|
||||
}
|
||||
});
|
||||
if(!any) {
|
||||
return false;
|
||||
}
|
||||
return any;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -103,12 +103,9 @@ public class TokenAi extends SpellAbilityAi {
|
||||
|
||||
if (actualToken == null) {
|
||||
final AbilitySub sub = sa.getSubAbility();
|
||||
if (pwPlus || (sub != null && SpellApiToAi.Converter.get(sub.getApi()).chkAIDrawback(sub, ai))) {
|
||||
return true; // planeswalker plus ability or sub-ability is
|
||||
// useful
|
||||
} else {
|
||||
return false; // no token created
|
||||
}
|
||||
// useful
|
||||
// no token created
|
||||
return pwPlus || (sub != null && SpellApiToAi.Converter.get(sub.getApi()).chkAIDrawback(sub, ai)); // planeswalker plus ability or sub-ability is
|
||||
}
|
||||
|
||||
// X-cost spells
|
||||
@@ -154,10 +151,7 @@ public class TokenAi extends SpellAbilityAi {
|
||||
&& !haste && !pwMinus) {
|
||||
return false;
|
||||
}
|
||||
if ((ph.getPhase().isAfter(PhaseType.COMBAT_BEGIN) || !ph.isPlayerTurn(ai)) && oneShot) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return (!ph.getPhase().isAfter(PhaseType.COMBAT_BEGIN) && ph.isPlayerTurn(ai)) || !oneShot;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -269,10 +263,8 @@ public class TokenAi extends SpellAbilityAi {
|
||||
list.add(token);
|
||||
list = CardLists.getValidCards(list, valid.split(","), ai.getWeakestOpponent(), topStack.getHostCard(), sa);
|
||||
list = CardLists.filter(list, CardPredicates.canBeSacrificedBy(topStack));
|
||||
if (ComputerUtilCard.evaluateCreature(token) < ComputerUtilCard.evaluateCreature(list.get(0))
|
||||
&& list.contains(token)) {
|
||||
return true;
|
||||
}
|
||||
return ComputerUtilCard.evaluateCreature(token) < ComputerUtilCard.evaluateCreature(list.get(0))
|
||||
&& list.contains(token);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -82,9 +82,7 @@ public class UnattachAllAi extends SpellAbilityAi {
|
||||
//don't equip a worse creature
|
||||
if (card.isEquipping()) {
|
||||
Card oldTarget = card.getEquipping();
|
||||
if (ComputerUtilCard.evaluateCreature(oldTarget) > ComputerUtilCard.evaluateCreature(newTarget)) {
|
||||
return false;
|
||||
}
|
||||
return ComputerUtilCard.evaluateCreature(oldTarget) <= ComputerUtilCard.evaluateCreature(newTarget);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,11 +45,7 @@ public class UntapAi extends SpellAbilityAi {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ComputerUtilCost.checkDiscardCost(ai, cost, sa.getHostCard())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return ComputerUtilCost.checkDiscardCost(ai, cost, sa.getHostCard());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -63,16 +59,11 @@ public class UntapAi extends SpellAbilityAi {
|
||||
|
||||
if (tgt == null) {
|
||||
final List<Card> pDefined = AbilityUtils.getDefinedCards(source, sa.getParam("Defined"), sa);
|
||||
if (pDefined != null && pDefined.get(0).isUntapped() && pDefined.get(0).getController() == ai) {
|
||||
return false;
|
||||
}
|
||||
return pDefined == null || !pDefined.get(0).isUntapped() || pDefined.get(0).getController() != ai;
|
||||
} else {
|
||||
if (!untapPrefTargeting(ai, tgt, sa, false)) {
|
||||
return false;
|
||||
}
|
||||
return untapPrefTargeting(ai, tgt, sa, false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -86,11 +77,7 @@ public class UntapAi extends SpellAbilityAi {
|
||||
|
||||
// TODO: use Defined to determine, if this is an unfavorable result
|
||||
final List<Card> pDefined = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("Defined"), sa);
|
||||
if (pDefined != null && pDefined.get(0).isUntapped() && pDefined.get(0).getController() == ai) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return pDefined == null || !pDefined.get(0).isUntapped() || pDefined.get(0).getController() != ai;
|
||||
} else {
|
||||
if (untapPrefTargeting(ai, tgt, sa, mandatory)) {
|
||||
return true;
|
||||
@@ -271,11 +258,7 @@ public class UntapAi extends SpellAbilityAi {
|
||||
// just tap whatever we can
|
||||
tapList = list;
|
||||
|
||||
if (untapTargetList(source, tgt, sa, mandatory, tapList)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return untapTargetList(source, tgt, sa, mandatory, tapList);
|
||||
}
|
||||
|
||||
private boolean untapTargetList(final Card source, final TargetRestrictions tgt, final SpellAbility sa, final boolean mandatory,
|
||||
@@ -438,13 +421,10 @@ public class UntapAi extends SpellAbilityAi {
|
||||
|
||||
// no harm in doing this past declare blockers during the opponent's turn and right before our turn,
|
||||
// maybe we'll serendipitously untap into something like a removal spell or burn spell that'll help
|
||||
if (ph.getNextTurn() == ai
|
||||
&& (ph.is(PhaseType.COMBAT_DECLARE_BLOCKERS) || ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS))) {
|
||||
return true;
|
||||
}
|
||||
return ph.getNextTurn() == ai
|
||||
&& (ph.is(PhaseType.COMBAT_DECLARE_BLOCKERS) || ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS));
|
||||
|
||||
// haven't found any immediate playable options
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -277,10 +277,7 @@ public class GameCopier {
|
||||
// TODO: Copy the full list with timestamps.
|
||||
newCard.addNewPT(setPower, setToughness, newGame.getNextTimestamp());
|
||||
}
|
||||
newCard.addTempPowerBoost(c.getTempPowerBoost());
|
||||
newCard.setSemiPermanentPowerBoost(c.getSemiPermanentPowerBoost());
|
||||
newCard.addTempToughnessBoost(c.getTempToughnessBoost());
|
||||
newCard.setSemiPermanentToughnessBoost(c.getSemiPermanentToughnessBoost());
|
||||
newCard.setPTBoost(c.getPTBoostMap());
|
||||
newCard.setDamage(c.getDamage());
|
||||
|
||||
newCard.setChangedCardTypes(c.getChangedCardTypesMap());
|
||||
|
||||
@@ -161,17 +161,6 @@ public class GameStateEvaluator {
|
||||
}
|
||||
return super.addValue(value, text);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getEffectivePower(final Card c) {
|
||||
Card.StatBreakdown breakdown = c.getNetCombatDamageBreakdown();
|
||||
return breakdown.getTotal() - breakdown.tempBoost;
|
||||
}
|
||||
@Override
|
||||
protected int getEffectiveToughness(final Card c) {
|
||||
Card.StatBreakdown breakdown = c.getNetToughnessBreakdown();
|
||||
return breakdown.getTotal() - breakdown.tempBoost;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Score {
|
||||
|
||||
@@ -80,7 +80,7 @@ public class PossibleTargetSelector {
|
||||
}
|
||||
|
||||
private static class SimilarTargetSkipper {
|
||||
private ArrayListMultimap<String, Card> validTargetsMap = ArrayListMultimap.<String, Card>create();
|
||||
private ArrayListMultimap<String, Card> validTargetsMap = ArrayListMultimap.create();
|
||||
private HashMap<Card, String> cardTypeStrings = new HashMap<Card, String>();
|
||||
private HashMap<Card, Integer> creatureScores;
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ public class SpellAbilityChoicesIterator {
|
||||
// TODO: Do we need to do something special to support cards that have extra costs
|
||||
// when choosing more modes, like Blessed Alliance?
|
||||
if (!allowRepeat) {
|
||||
modeIterator = CombinatoricsUtils.combinationsIterator(choices.size(), num);;
|
||||
modeIterator = CombinatoricsUtils.combinationsIterator(choices.size(), num);
|
||||
} else {
|
||||
// Note: When allowRepeat is true, it does result in many possibilities being tried.
|
||||
// We should ideally prune some of those at a higher level.
|
||||
|
||||
@@ -308,9 +308,7 @@ public class SpellAbilityPicker {
|
||||
return true;
|
||||
}
|
||||
List<PhaseType> phases = conditions.getPhases();
|
||||
if (phases.isEmpty() || phases.contains(PhaseType.MAIN1)) {
|
||||
return true;
|
||||
}
|
||||
return phases.isEmpty() || phases.contains(PhaseType.MAIN1);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<artifactId>forge</artifactId>
|
||||
<groupId>forge</groupId>
|
||||
<version>1.6.28-SNAPSHOT</version>
|
||||
<version>1.6.29-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>forge-core</artifactId>
|
||||
|
||||
@@ -64,7 +64,7 @@ public class CardStorageReader {
|
||||
void report(int current, int total);
|
||||
|
||||
// does nothing, used when they pass null instead of an instance
|
||||
public final static ProgressObserver emptyObserver = new ProgressObserver() {
|
||||
ProgressObserver emptyObserver = new ProgressObserver() {
|
||||
@Override public void setOperationName(final String name, final boolean usePercents) {}
|
||||
@Override public void report(final int current, final int total) {}
|
||||
};
|
||||
|
||||
@@ -123,7 +123,7 @@ public final class ImageKeys {
|
||||
int index = filename.lastIndexOf('_');
|
||||
if (index != -1) {
|
||||
String setlessFilename = filename.substring(0, index);
|
||||
String setCode = filename.substring(index + 1, filename.length());
|
||||
String setCode = filename.substring(index + 1);
|
||||
// try with upper case set
|
||||
file = findFile(dir, setlessFilename + "_" + setCode.toUpperCase());
|
||||
if (file != null) { return file; }
|
||||
|
||||
@@ -41,7 +41,7 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
|
||||
public final static char NameSetSeparator = '|';
|
||||
|
||||
// need this to obtain cardReference by name+set+artindex
|
||||
private final ListMultimap<String, PaperCard> allCardsByName = Multimaps.newListMultimap(new TreeMap<String,Collection<PaperCard>>(String.CASE_INSENSITIVE_ORDER), CollectionSuppliers.<PaperCard>arrayLists());
|
||||
private final ListMultimap<String, PaperCard> allCardsByName = Multimaps.newListMultimap(new TreeMap<String,Collection<PaperCard>>(String.CASE_INSENSITIVE_ORDER), CollectionSuppliers.arrayLists());
|
||||
private final Map<String, PaperCard> uniqueCardsByName = Maps.newTreeMap(String.CASE_INSENSITIVE_ORDER);
|
||||
private final Map<String, CardRules> rulesByName;
|
||||
private final Map<String, ICardFace> facesByName = Maps.newTreeMap(String.CASE_INSENSITIVE_ORDER);
|
||||
@@ -62,7 +62,7 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
|
||||
Random(false);
|
||||
|
||||
final boolean filterSets;
|
||||
private SetPreference(boolean filterIrregularSets) {
|
||||
SetPreference(boolean filterIrregularSets) {
|
||||
filterSets = filterIrregularSets;
|
||||
}
|
||||
|
||||
|
||||
@@ -189,7 +189,7 @@ public final class CardEdition implements Comparable<CardEdition> { // immutable
|
||||
public String getBoosterMustContain() { return boosterMustContain; }
|
||||
public CardInSet[] getCards() { return cards; }
|
||||
|
||||
public Map<String, Integer> getTokens() { return tokenNormalized; };
|
||||
public Map<String, Integer> getTokens() { return tokenNormalized; }
|
||||
|
||||
public static final Function<CardEdition, String> FN_GET_CODE = new Function<CardEdition, String>() {
|
||||
@Override
|
||||
|
||||
@@ -20,7 +20,7 @@ final class CardFace implements ICardFace {
|
||||
public enum FaceSelectionMethod { //
|
||||
USE_ACTIVE_FACE,
|
||||
USE_PRIMARY_FACE,
|
||||
COMBINE;
|
||||
COMBINE
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ final class CardFace implements ICardFace {
|
||||
void setInitialLoyalty(String value) { this.initialLoyalty = value; }
|
||||
|
||||
void setPtText(String value) {
|
||||
final String k[] = value.split("/");
|
||||
final String[] k = value.split("/");
|
||||
|
||||
if (k.length != 2) {
|
||||
throw new RuntimeException("Creature '" + this.getName() + "' has bad p/t stats");
|
||||
|
||||
@@ -85,7 +85,7 @@ public final class CardFacePredicates {
|
||||
|
||||
@Override
|
||||
public boolean apply(ICardFace input) {
|
||||
String k[] = valid.split("\\.", 2);
|
||||
String[] k = valid.split("\\.", 2);
|
||||
|
||||
if ("Card".equals(k[0])) {
|
||||
// okay
|
||||
@@ -110,10 +110,7 @@ public final class CardFacePredicates {
|
||||
static protected boolean hasProperty(ICardFace input, final String v) {
|
||||
if (v.startsWith("non")) {
|
||||
return !hasProperty(input, v.substring(3));
|
||||
} else if (!input.getType().hasStringType(v)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} else return input.getType().hasStringType(v);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public enum CardRarity {
|
||||
|
||||
private final String shortName, longName;
|
||||
|
||||
private CardRarity(final String shortName0, final String longName0) {
|
||||
CardRarity(final String shortName0, final String longName0) {
|
||||
shortName = shortName0;
|
||||
longName = longName0;
|
||||
}
|
||||
|
||||
@@ -435,10 +435,10 @@ public final class CardRulesPredicates {
|
||||
return this.op(card.getManaCost().getGenericCost(), this.operand);
|
||||
case POWER:
|
||||
value = card.getIntPower();
|
||||
return value != Integer.MAX_VALUE ? this.op(value, this.operand) : false;
|
||||
return value != Integer.MAX_VALUE && this.op(value, this.operand);
|
||||
case TOUGHNESS:
|
||||
value = card.getIntToughness();
|
||||
return value != Integer.MAX_VALUE ? this.op(value, this.operand) : false;
|
||||
return value != Integer.MAX_VALUE && this.op(value, this.operand);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ public enum CardSplitType
|
||||
Split(FaceSelectionMethod.COMBINE, CardStateName.RightSplit),
|
||||
Flip(FaceSelectionMethod.USE_PRIMARY_FACE, CardStateName.Flipped);
|
||||
|
||||
private CardSplitType(FaceSelectionMethod calcMode, CardStateName stateName) {
|
||||
CardSplitType(FaceSelectionMethod calcMode, CardStateName stateName) {
|
||||
method = calcMode;
|
||||
this.changedStateName = stateName;
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public final class CardType implements Comparable<CardType>, CardTypeView {
|
||||
public final boolean isPermanent;
|
||||
private static final ImmutableList<String> allCoreTypeNames = EnumUtil.getNames(CoreType.class);
|
||||
|
||||
private CoreType(final boolean permanent) {
|
||||
CoreType(final boolean permanent) {
|
||||
isPermanent = permanent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,5 +5,5 @@ package forge.card;
|
||||
*
|
||||
*/
|
||||
public interface ICardFace extends ICardCharacteristics, ICardRawAbilites, Comparable<ICardFace> {
|
||||
public String getAltName();
|
||||
String getAltName();
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ public final class MagicColor {
|
||||
private final String name, symbol;
|
||||
private final byte colormask;
|
||||
|
||||
private Color(String name0, byte colormask0, String symbol0) {
|
||||
Color(String name0, byte colormask0, String symbol0) {
|
||||
name = name0;
|
||||
colormask = colormask0;
|
||||
symbol = symbol0;
|
||||
|
||||
@@ -44,7 +44,7 @@ public abstract class ManaAtom {
|
||||
if (s.length() == 2) { //if name is two characters, check for combination of two colors
|
||||
return (byte)(fromName(s.charAt(0)) | fromName(s.charAt(1)));
|
||||
} else if (s.length() == 1) {
|
||||
return (byte) fromName(s.charAt(0));
|
||||
return fromName(s.charAt(0));
|
||||
}
|
||||
s = s.toLowerCase();
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user