mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
Compare commits
1499 Commits
forge-1.5.
...
forge-1.5.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6d9e785aec | ||
|
|
e33be38fa6 | ||
|
|
734b6f748e | ||
|
|
104e6dc306 | ||
|
|
a336cd7b0e | ||
|
|
f62f83bdda | ||
|
|
08ec2cc9d9 | ||
|
|
4425029892 | ||
|
|
3b571cb7ec | ||
|
|
8edd870602 | ||
|
|
f81c3f40b8 | ||
|
|
0cd306d23b | ||
|
|
cafff3f379 | ||
|
|
04d336f674 | ||
|
|
4f8babf927 | ||
|
|
c2bbd84204 | ||
|
|
f87f3489d1 | ||
|
|
77329e8fe5 | ||
|
|
c947da28c2 | ||
|
|
de51f43301 | ||
|
|
bec8706fcf | ||
|
|
7b6026e17d | ||
|
|
1324b0754b | ||
|
|
7da1d97769 | ||
|
|
1b5ba15321 | ||
|
|
b299711be7 | ||
|
|
164490ffc9 | ||
|
|
eadba12739 | ||
|
|
e52e154774 | ||
|
|
878c037554 | ||
|
|
03cdddce6e | ||
|
|
f23f17be4f | ||
|
|
fa423233ab | ||
|
|
c9c15d0157 | ||
|
|
1b2e23b309 | ||
|
|
acaa61319f | ||
|
|
c476415bfc | ||
|
|
5e3786fe1c | ||
|
|
07915701c3 | ||
|
|
b69228e28b | ||
|
|
42fcd856d0 | ||
|
|
22be9fffb6 | ||
|
|
204f65faac | ||
|
|
7e2b336ecc | ||
|
|
df86422e1b | ||
|
|
89c2130ff6 | ||
|
|
9d90ca99cb | ||
|
|
f8224a0f7e | ||
|
|
eef2e004b3 | ||
|
|
4fda7abaff | ||
|
|
72aefc9152 | ||
|
|
2feac87574 | ||
|
|
adcceb74ee | ||
|
|
9d0db8580e | ||
|
|
7106098c91 | ||
|
|
51acbeeab2 | ||
|
|
77f7031f44 | ||
|
|
447f07ef7f | ||
|
|
83a1b4f35e | ||
|
|
8cbab3a5a7 | ||
|
|
8fdadd61d0 | ||
|
|
1c8b589b1f | ||
|
|
3d360d216b | ||
|
|
2194592016 | ||
|
|
7bccaa769a | ||
|
|
1982f73e3d | ||
|
|
4525633ad8 | ||
|
|
6c75215113 | ||
|
|
d841ed5858 | ||
|
|
255d508437 | ||
|
|
ee2da8d8cd | ||
|
|
c4e4bc1871 | ||
|
|
45ce34ff0b | ||
|
|
f7256824bb | ||
|
|
06f33d21ee | ||
|
|
60ae9a110b | ||
|
|
dbabf696ce | ||
|
|
bcac77bd0d | ||
|
|
030f6c3939 | ||
|
|
9fbf9903ef | ||
|
|
0b67f989b9 | ||
|
|
68e8b47838 | ||
|
|
52965b233f | ||
|
|
a239710a6b | ||
|
|
4f86ee6025 | ||
|
|
102468d2e3 | ||
|
|
ee8f8def8e | ||
|
|
4bc8a89544 | ||
|
|
e66a776f9f | ||
|
|
0961590f20 | ||
|
|
8bf4345ac3 | ||
|
|
e7f0776098 | ||
|
|
35d8ea0949 | ||
|
|
59979056b9 | ||
|
|
dbbb3741d7 | ||
|
|
7ace65b8c9 | ||
|
|
dcccae1f7c | ||
|
|
fa3a140470 | ||
|
|
d9b657acf4 | ||
|
|
b9046d8326 | ||
|
|
5b70f38a9c | ||
|
|
f94fcfc997 | ||
|
|
73e835df10 | ||
|
|
3dc4594173 | ||
|
|
1606bfa2c5 | ||
|
|
b39e0f4052 | ||
|
|
f61ac6b361 | ||
|
|
b447b4ab6b | ||
|
|
968a035672 | ||
|
|
d976bed702 | ||
|
|
720a44b4fd | ||
|
|
fb2287b8c2 | ||
|
|
6468dcc712 | ||
|
|
c5923c31e9 | ||
|
|
7ab28b5226 | ||
|
|
f862a01a78 | ||
|
|
875d019b1c | ||
|
|
a4271de319 | ||
|
|
4d00ab3ecf | ||
|
|
bebe569d10 | ||
|
|
1c147936d7 | ||
|
|
7e9220d414 | ||
|
|
01867e5352 | ||
|
|
09b638075c | ||
|
|
79a61f2e12 | ||
|
|
ed39723ab6 | ||
|
|
b22ce18572 | ||
|
|
9b55d3c36b | ||
|
|
02bb5942b3 | ||
|
|
a72655fc79 | ||
|
|
30fda0e7a8 | ||
|
|
9957c12ff8 | ||
|
|
bfee22e968 | ||
|
|
485aa06339 | ||
|
|
bd5471cb30 | ||
|
|
39c83b4870 | ||
|
|
d32858b4c4 | ||
|
|
de0348592b | ||
|
|
804a8801e5 | ||
|
|
dd34a3aa9b | ||
|
|
0f37de9627 | ||
|
|
14a0e6e3ac | ||
|
|
2f2d24eb3e | ||
|
|
06484f81f6 | ||
|
|
b3f019420f | ||
|
|
2487f7ee93 | ||
|
|
e9c4f0913d | ||
|
|
81c5912add | ||
|
|
767524fb57 | ||
|
|
40f7d164bf | ||
|
|
1ff23dcc56 | ||
|
|
a4e9aa6243 | ||
|
|
50c40311a7 | ||
|
|
d331c87ab5 | ||
|
|
c4e1552b8b | ||
|
|
94783575cc | ||
|
|
a54a0ba985 | ||
|
|
e9da0ec519 | ||
|
|
8a9a13c5d7 | ||
|
|
85d967e5a5 | ||
|
|
453bf76d63 | ||
|
|
72bb290215 | ||
|
|
6230b6f28b | ||
|
|
0f5228259a | ||
|
|
4b5bd3d619 | ||
|
|
1ad1714388 | ||
|
|
f10fd27869 | ||
|
|
1f883c993b | ||
|
|
319b470acd | ||
|
|
e09ec6c165 | ||
|
|
1fa0a2c81c | ||
|
|
a8e54c5052 | ||
|
|
f17fa767c0 | ||
|
|
c8eed79a2a | ||
|
|
537f95c79d | ||
|
|
c923a7d976 | ||
|
|
b0939aeed8 | ||
|
|
a7d359fa10 | ||
|
|
862d8ed857 | ||
|
|
83cebd7e82 | ||
|
|
1eeab52cdf | ||
|
|
686807b0d2 | ||
|
|
f0464395ab | ||
|
|
87de44dd04 | ||
|
|
5fe65ad74b | ||
|
|
58600fbfad | ||
|
|
c92be334ae | ||
|
|
8276b5c51a | ||
|
|
d7224d7515 | ||
|
|
96ff2dc09e | ||
|
|
a40da18132 | ||
|
|
8cb889da68 | ||
|
|
08d2d7f4e8 | ||
|
|
e9c273e40f | ||
|
|
9500b3d951 | ||
|
|
2b4e935373 | ||
|
|
4f9fd821ec | ||
|
|
b221b7eaab | ||
|
|
4b8ed1df67 | ||
|
|
9399097069 | ||
|
|
337f5b7320 | ||
|
|
80c70d321e | ||
|
|
676fee32c6 | ||
|
|
715ee1f9ab | ||
|
|
c5a791f361 | ||
|
|
1ec656f2ed | ||
|
|
97b579a68d | ||
|
|
59f75710dc | ||
|
|
c7e74b2ddc | ||
|
|
6380b4c8fe | ||
|
|
3d4f9e7297 | ||
|
|
bfe48d2611 | ||
|
|
3c08718b4b | ||
|
|
2f033f795f | ||
|
|
acd2ca2f23 | ||
|
|
de2731c21f | ||
|
|
5e0a8a6331 | ||
|
|
b34ca7b951 | ||
|
|
1422748447 | ||
|
|
186f7f70e4 | ||
|
|
4b1eb98e5b | ||
|
|
f7e185be3b | ||
|
|
ea6da0b7dc | ||
|
|
ae23652c0c | ||
|
|
54b86b4db2 | ||
|
|
f45779d2c3 | ||
|
|
480ebbb121 | ||
|
|
427e8c7059 | ||
|
|
86cf1b63f4 | ||
|
|
27ee03494b | ||
|
|
2f5799f453 | ||
|
|
7c419d875d | ||
|
|
d7d87b5c5d | ||
|
|
a11e7bbcb8 | ||
|
|
028e4bc196 | ||
|
|
2252b9908b | ||
|
|
02353704ca | ||
|
|
2bde0ac099 | ||
|
|
2543aabbd4 | ||
|
|
d01c22b5f9 | ||
|
|
08896bdb8e | ||
|
|
46d7491c78 | ||
|
|
9437ea5d90 | ||
|
|
184943da83 | ||
|
|
66e53ad1ed | ||
|
|
6595893e48 | ||
|
|
14ac5860f8 | ||
|
|
4554d94f32 | ||
|
|
737b2eb0f7 | ||
|
|
cb318eb8b9 | ||
|
|
557035e340 | ||
|
|
86bd570e2c | ||
|
|
d406114118 | ||
|
|
e4dd0faf5e | ||
|
|
83aa60a77c | ||
|
|
acfe00d6db | ||
|
|
d4a2ae07df | ||
|
|
926bdc1d5a | ||
|
|
ffee3af0ac | ||
|
|
42e6dffda2 | ||
|
|
c9db375d7c | ||
|
|
06de741370 | ||
|
|
a2287aff5b | ||
|
|
444aad2034 | ||
|
|
0de852043e | ||
|
|
9df1102514 | ||
|
|
8eaa535d6b | ||
|
|
b5e7de67a2 | ||
|
|
f4db8078b8 | ||
|
|
21db65e9ab | ||
|
|
1d0b60427d | ||
|
|
1760b10940 | ||
|
|
ce54805981 | ||
|
|
6df75248d8 | ||
|
|
21331d4189 | ||
|
|
c1e72c380b | ||
|
|
b38346e00c | ||
|
|
9e5cbbb9d1 | ||
|
|
f767ca34ce | ||
|
|
d4bc720dd0 | ||
|
|
1d1950d3cb | ||
|
|
038418ca0d | ||
|
|
4aa2dd4471 | ||
|
|
075a01e3ae | ||
|
|
35ea4c2a50 | ||
|
|
bc851d0b51 | ||
|
|
c11d353540 | ||
|
|
32e6da4a78 | ||
|
|
a96f9be77a | ||
|
|
04a38b79ac | ||
|
|
a1886d51f8 | ||
|
|
9cd2bc595d | ||
|
|
e592d3bc56 | ||
|
|
1da213b157 | ||
|
|
3f349d0eb3 | ||
|
|
84cac99a59 | ||
|
|
de1b198f4c | ||
|
|
5954e7053c | ||
|
|
1b4b9ad32b | ||
|
|
394e96d051 | ||
|
|
2c6151996e | ||
|
|
5c195f3cea | ||
|
|
1af6d101e8 | ||
|
|
b6b220496b | ||
|
|
ff92c4cf31 | ||
|
|
12ed04a7cc | ||
|
|
6575000c28 | ||
|
|
43f4e45827 | ||
|
|
4b6e58ddf0 | ||
|
|
0abdf7a3b5 | ||
|
|
53e0a2ad37 | ||
|
|
7e22527164 | ||
|
|
7e6928d700 | ||
|
|
4fa37ac4b9 | ||
|
|
bbe5e3c556 | ||
|
|
4c7f16baf4 | ||
|
|
cec3d26493 | ||
|
|
86edf9fd66 | ||
|
|
0adcfe55aa | ||
|
|
5a22e6a15d | ||
|
|
4d833b6f38 | ||
|
|
d05ecdf840 | ||
|
|
1f66ec432d | ||
|
|
2fcc5943fa | ||
|
|
08e909ca00 | ||
|
|
4c48e3e089 | ||
|
|
d9d32f7508 | ||
|
|
691c52fff9 | ||
|
|
c3d7a9f075 | ||
|
|
da3b2c1dc1 | ||
|
|
2ea69dde48 | ||
|
|
7c66069ee3 | ||
|
|
fd9ee6f4e1 | ||
|
|
6314550377 | ||
|
|
738fc7f52d | ||
|
|
4c129ffee4 | ||
|
|
c1750989b7 | ||
|
|
2b685348ab | ||
|
|
070fd7695a | ||
|
|
7cf1a52405 | ||
|
|
096f41172d | ||
|
|
59665029d2 | ||
|
|
3249e844f9 | ||
|
|
187c90c7df | ||
|
|
d779034da8 | ||
|
|
429d8dbf30 | ||
|
|
c5d35c9596 | ||
|
|
23265d2623 | ||
|
|
4810518d74 | ||
|
|
1e389fdef8 | ||
|
|
f31550732e | ||
|
|
29876aeb28 | ||
|
|
a90c34aac4 | ||
|
|
78456d6333 | ||
|
|
44edc80abc | ||
|
|
3f6e6f54a1 | ||
|
|
1e576cfde6 | ||
|
|
07c4ab24e7 | ||
|
|
915a6a42c2 | ||
|
|
5216b35688 | ||
|
|
3c53eec798 | ||
|
|
db080d8b10 | ||
|
|
04d129b8d8 | ||
|
|
059e7f7920 | ||
|
|
3bbfe87868 | ||
|
|
8cdc76427e | ||
|
|
11976bf964 | ||
|
|
a5f4f78018 | ||
|
|
0621f2e242 | ||
|
|
5538480862 | ||
|
|
07f126cb52 | ||
|
|
a5263b1375 | ||
|
|
6a52bdf10d | ||
|
|
ad38be34b7 | ||
|
|
a7785b0d1b | ||
|
|
26743d0ca0 | ||
|
|
fccc8f129f | ||
|
|
c1a11dd89a | ||
|
|
0730e2d774 | ||
|
|
a8bf257391 | ||
|
|
86f6a9e3f1 | ||
|
|
41f3b22237 | ||
|
|
7ad5bfb581 | ||
|
|
75e5c8d0ca | ||
|
|
1b9437ad32 | ||
|
|
d5bde7570a | ||
|
|
a0d13578f3 | ||
|
|
ed48547f36 | ||
|
|
73b97fe151 | ||
|
|
f21e1c3f8a | ||
|
|
aa230be806 | ||
|
|
26bb8e5009 | ||
|
|
5322d5a9c2 | ||
|
|
0f5eb7d5f8 | ||
|
|
9379f7283c | ||
|
|
29025cce61 | ||
|
|
7fd201d5e3 | ||
|
|
1f947d5781 | ||
|
|
8dea53bcda | ||
|
|
f5d43d0986 | ||
|
|
cf67fb456e | ||
|
|
308814bdca | ||
|
|
149a9bd7b2 | ||
|
|
e16998beb5 | ||
|
|
a9e12e38ef | ||
|
|
9c7d25f49d | ||
|
|
a52a1f5820 | ||
|
|
e0c3244667 | ||
|
|
32bf18781a | ||
|
|
5bd88d468e | ||
|
|
e758e07658 | ||
|
|
eb0ac0dde9 | ||
|
|
c81a4d50dd | ||
|
|
ae28b04615 | ||
|
|
471623cd10 | ||
|
|
4378bfdbea | ||
|
|
8ff6cbd98e | ||
|
|
f4ffe22d61 | ||
|
|
4573e30e73 | ||
|
|
832b40e235 | ||
|
|
aec0bad678 | ||
|
|
aeedde578d | ||
|
|
dfebb08e1e | ||
|
|
dbf77d8548 | ||
|
|
003c252d8a | ||
|
|
1986df1961 | ||
|
|
11c205f0c9 | ||
|
|
7d2cc8fac5 | ||
|
|
863e7733e6 | ||
|
|
e657a1b07d | ||
|
|
2f29cf7755 | ||
|
|
6d34dbc286 | ||
|
|
28f7f7baaf | ||
|
|
f3b78b1aa3 | ||
|
|
ce82a93afe | ||
|
|
fe9a35b706 | ||
|
|
febba22f45 | ||
|
|
2981668172 | ||
|
|
ed7369c98f | ||
|
|
b6409b11c7 | ||
|
|
98c51e45b4 | ||
|
|
9e6b82d10a | ||
|
|
ee49314502 | ||
|
|
29e73367a6 | ||
|
|
80aa655164 | ||
|
|
f8d7d060b9 | ||
|
|
b198e8a40e | ||
|
|
a3fb6de6b3 | ||
|
|
5252cca5c5 | ||
|
|
4cab5da076 | ||
|
|
2cdf7030f8 | ||
|
|
e30f8d0fb6 | ||
|
|
22fe17048d | ||
|
|
3d70e2e9f6 | ||
|
|
f35dc1f30d | ||
|
|
34b36a8ef2 | ||
|
|
7c105ca398 | ||
|
|
2ec4873552 | ||
|
|
aa4f3de30c | ||
|
|
e4fb939e91 | ||
|
|
68acaf77c5 | ||
|
|
308039739f | ||
|
|
7687637783 | ||
|
|
7b799eb531 | ||
|
|
9c37156906 | ||
|
|
32d6eb3ed5 | ||
|
|
faa2cef0bb | ||
|
|
7e999ea4b3 | ||
|
|
69c569c82b | ||
|
|
bcc5f2c526 | ||
|
|
35bff6a89b | ||
|
|
a26d45793e | ||
|
|
d6577d1d72 | ||
|
|
e8aeec7f87 | ||
|
|
0b75a0ee8e | ||
|
|
4163c56502 | ||
|
|
37d45ffbeb | ||
|
|
f03a1397f1 | ||
|
|
410b23974e | ||
|
|
3366843ca1 | ||
|
|
9bcc6cbc64 | ||
|
|
9636e3d2e4 | ||
|
|
140e44a3bd | ||
|
|
9f76a78b0a | ||
|
|
dd6e8d0884 | ||
|
|
66b1a795c1 | ||
|
|
8b8b9f0cf5 | ||
|
|
d5647c9e98 | ||
|
|
5d1d77f4df | ||
|
|
7a193c0618 | ||
|
|
1709ed07c7 | ||
|
|
23586a027e | ||
|
|
97c74ec2b1 | ||
|
|
961461aa19 | ||
|
|
713a9ecb3b | ||
|
|
8a46d38914 | ||
|
|
423033d2ac | ||
|
|
d01925107f | ||
|
|
47a719147c | ||
|
|
556bb2caa7 | ||
|
|
ec3813fb13 | ||
|
|
926152940e | ||
|
|
7cf186952e | ||
|
|
b2ccb5c689 | ||
|
|
3da6e688e4 | ||
|
|
567ffe84cd | ||
|
|
d97495ed41 | ||
|
|
ceab176d9f | ||
|
|
050887c53c | ||
|
|
2bc61a9e68 | ||
|
|
6b1d9356f3 | ||
|
|
1dbc34fe62 | ||
|
|
d93b041397 | ||
|
|
ecd14e1de4 | ||
|
|
923bddc90d | ||
|
|
97297f291f | ||
|
|
84850c76a9 | ||
|
|
ca8c8d35d9 | ||
|
|
18e96a1028 | ||
|
|
f27b3e469a | ||
|
|
7b47938062 | ||
|
|
d9f3bb8bdd | ||
|
|
8919532b84 | ||
|
|
481ac50726 | ||
|
|
731b3c8c36 | ||
|
|
8393bc02e4 | ||
|
|
85e5b0ff13 | ||
|
|
3b8d779b27 | ||
|
|
89dcef5b67 | ||
|
|
6ced3d38a4 | ||
|
|
7fc97562b2 | ||
|
|
80372f40b5 | ||
|
|
d9a5a27391 | ||
|
|
8c73aa93c8 | ||
|
|
59997f5cf2 | ||
|
|
3ab7db6061 | ||
|
|
3d2ba5a182 | ||
|
|
d7cb5165ef | ||
|
|
3a89700d95 | ||
|
|
f0ce722aa4 | ||
|
|
95709401a3 | ||
|
|
06f030ab73 | ||
|
|
bd0dc07c43 | ||
|
|
0d354f679c | ||
|
|
7ed37ec5f8 | ||
|
|
fa40deaa11 | ||
|
|
117d25b686 | ||
|
|
7491eb0076 | ||
|
|
1acb9f8ab1 | ||
|
|
f87b262194 | ||
|
|
6c82cabe3a | ||
|
|
7e7969988a | ||
|
|
4b51c24b66 | ||
|
|
5e0ad38ffc | ||
|
|
56557101f3 | ||
|
|
1d0cf99e48 | ||
|
|
2f5b534de6 | ||
|
|
00ae4d4824 | ||
|
|
af2a87a207 | ||
|
|
72fe5ad996 | ||
|
|
d00da28a3c | ||
|
|
81363bc537 | ||
|
|
1e98cd4939 | ||
|
|
814a8976fb | ||
|
|
86cea92ca1 | ||
|
|
f9178dcff2 | ||
|
|
fcc4b92efe | ||
|
|
44f79a5db2 | ||
|
|
034f235196 | ||
|
|
a1e16543b2 | ||
|
|
8578e2a538 | ||
|
|
092d3dac40 | ||
|
|
e9ddf8400b | ||
|
|
22b78255bb | ||
|
|
2985b48432 | ||
|
|
b249028b8e | ||
|
|
4cb2077e1a | ||
|
|
88b6223820 | ||
|
|
0b4ef6b1e3 | ||
|
|
8921ce16e6 | ||
|
|
f4606da30f | ||
|
|
41a5727a93 | ||
|
|
19cec963d2 | ||
|
|
156bc84c73 | ||
|
|
eb98eaf5af | ||
|
|
fb6d86af8a | ||
|
|
39aa6bfda1 | ||
|
|
ba59dfb01c | ||
|
|
dd044c30e6 | ||
|
|
f1fcc2c26b | ||
|
|
c0e9d82ff6 | ||
|
|
89598ab48c | ||
|
|
586de9321a | ||
|
|
ae7244a10f | ||
|
|
d95fc7352f | ||
|
|
e4b7c92c6a | ||
|
|
a52a88e0cb | ||
|
|
2ec3c08e72 | ||
|
|
b57e0a9848 | ||
|
|
eabcc78815 | ||
|
|
1b7a2730f0 | ||
|
|
caac7dc2ed | ||
|
|
d8eb3a5c7a | ||
|
|
5973d0d944 | ||
|
|
a512a7ab33 | ||
|
|
e44cada50e | ||
|
|
49e734b66d | ||
|
|
5c4efbcd04 | ||
|
|
f131aafa44 | ||
|
|
f4263e943d | ||
|
|
45cd72f7dc | ||
|
|
634289407b | ||
|
|
01ff93375a | ||
|
|
c64ef5deed | ||
|
|
a5a0c510b5 | ||
|
|
d7f8231717 | ||
|
|
f0f7cfc839 | ||
|
|
03870821c5 | ||
|
|
726084bc06 | ||
|
|
cbbc341472 | ||
|
|
664b707330 | ||
|
|
a47bba59d4 | ||
|
|
e84544afe4 | ||
|
|
cd505adc3d | ||
|
|
5b1dd964ae | ||
|
|
86ef4d0820 | ||
|
|
966e593617 | ||
|
|
eb4a355dc7 | ||
|
|
d65b645a64 | ||
|
|
f899c6e58c | ||
|
|
a554599fd7 | ||
|
|
6046860e15 | ||
|
|
1dda7d72a9 | ||
|
|
3e2f3ab1c5 | ||
|
|
286d7d043c | ||
|
|
563c089b9d | ||
|
|
ca103655bd | ||
|
|
666fb6b35c | ||
|
|
d234975cde | ||
|
|
13a6310ac0 | ||
|
|
62bfb66e11 | ||
|
|
b776929fe8 | ||
|
|
273b7286cf | ||
|
|
5bd450e0c9 | ||
|
|
777dff3c4b | ||
|
|
e3ddb00eee | ||
|
|
870ffe3437 | ||
|
|
b8ea837204 | ||
|
|
4a611fcf58 | ||
|
|
91be7b5a32 | ||
|
|
42cf0def0f | ||
|
|
10fd05478d | ||
|
|
9fbc7a17c3 | ||
|
|
3cd105bac0 | ||
|
|
559c96412a | ||
|
|
ee5187c7e7 | ||
|
|
0cb7573494 | ||
|
|
0f514be363 | ||
|
|
ca07a8103a | ||
|
|
4837bb5740 | ||
|
|
fc7cc33111 | ||
|
|
ce341302a3 | ||
|
|
4cb27c40ac | ||
|
|
84e3fc1be9 | ||
|
|
2522450930 | ||
|
|
e3e761ddc0 | ||
|
|
c95ee53137 | ||
|
|
7f9ef96178 | ||
|
|
95cbb2870c | ||
|
|
17891a62fa | ||
|
|
f1ff893962 | ||
|
|
ce6d092b16 | ||
|
|
f6577217ff | ||
|
|
283af44c48 | ||
|
|
1ea839f5d4 | ||
|
|
4a3e07bbae | ||
|
|
9ba8866b19 | ||
|
|
5dbe15e7e0 | ||
|
|
cbf38aed9c | ||
|
|
a8eb34d201 | ||
|
|
496b12913d | ||
|
|
be47a4bad3 | ||
|
|
9d28e88a24 | ||
|
|
d937a397a7 | ||
|
|
c9daed2056 | ||
|
|
804c36e8b7 | ||
|
|
7274d46865 | ||
|
|
feaec2eb6d | ||
|
|
753c0731a3 | ||
|
|
9a6b1822a9 | ||
|
|
db5e8316ec | ||
|
|
513b9db9b5 | ||
|
|
04248f0166 | ||
|
|
c60c041012 | ||
|
|
f10ec1751f | ||
|
|
561d4deb32 | ||
|
|
3e552ac655 | ||
|
|
12d8b289e5 | ||
|
|
bcf2abdbbc | ||
|
|
8747c163ee | ||
|
|
458bd8f964 | ||
|
|
19a34ba730 | ||
|
|
16294fe54a | ||
|
|
76cdfa9759 | ||
|
|
fc508b3a27 | ||
|
|
a4c2fa3797 | ||
|
|
d1575996b4 | ||
|
|
75293299ed | ||
|
|
e50f31fb5f | ||
|
|
e47cdebf14 | ||
|
|
85eaf866d9 | ||
|
|
800a9b6854 | ||
|
|
94eb94508c | ||
|
|
02a49149fa | ||
|
|
80308ab621 | ||
|
|
cb055269d3 | ||
|
|
1c6ccbb20a | ||
|
|
764310e08b | ||
|
|
673fd2dae3 | ||
|
|
5fe57fcb11 | ||
|
|
0a9617b0c4 | ||
|
|
6b06a6f274 | ||
|
|
e5c3d4595c | ||
|
|
ab0a18cc64 | ||
|
|
b534c4bbcd | ||
|
|
0ee95fae76 | ||
|
|
dcb8c54e4c | ||
|
|
802aed63df | ||
|
|
ba7cd330e6 | ||
|
|
adeec5d6a9 | ||
|
|
8b0e20aa9e | ||
|
|
a22a3dc849 | ||
|
|
f220aef52a | ||
|
|
0175cc1a26 | ||
|
|
59b6e092c9 | ||
|
|
ceb7b13a8e | ||
|
|
f68f8ba157 | ||
|
|
19a58c309e | ||
|
|
62479e1de6 | ||
|
|
04dde1c18d | ||
|
|
c7450034f5 | ||
|
|
9140dab9f1 | ||
|
|
8f4d3792c6 | ||
|
|
9d73236812 | ||
|
|
fbc0404f94 | ||
|
|
a2050ed3e6 | ||
|
|
0d2c13bf80 | ||
|
|
39061439dc | ||
|
|
d9e5d93265 | ||
|
|
b3bec906ef | ||
|
|
6d969373b9 | ||
|
|
c8ac6b9f2d | ||
|
|
45d7b43aa6 | ||
|
|
e954b40d3c | ||
|
|
07f94f9d42 | ||
|
|
18809bc918 | ||
|
|
85d32d49e2 | ||
|
|
64459b414e | ||
|
|
f0ffeefe24 | ||
|
|
df022d5df7 | ||
|
|
a2b75c2072 | ||
|
|
e7a9492200 | ||
|
|
3133dbf8b4 | ||
|
|
8fd2ffc93e | ||
|
|
39675d465d | ||
|
|
6e969ddaaa | ||
|
|
a9f4009e43 | ||
|
|
b28b5e1ec9 | ||
|
|
f4b9dd2f34 | ||
|
|
40c651cd04 | ||
|
|
b6d6da88e8 | ||
|
|
7f95e5f583 | ||
|
|
e179aa404c | ||
|
|
4235a6906e | ||
|
|
618cd6415d | ||
|
|
9d458ce8c5 | ||
|
|
311306e986 | ||
|
|
a1688a7404 | ||
|
|
da421bc5f8 | ||
|
|
db8a71cca2 | ||
|
|
c8352e4968 | ||
|
|
1d8aec2c3b | ||
|
|
459c2cfae4 | ||
|
|
32c52578e2 | ||
|
|
eccadbf6fc | ||
|
|
8d99d2032d | ||
|
|
121db288c1 | ||
|
|
b8b3fff684 | ||
|
|
33a08f67ec | ||
|
|
dffc1b2a42 | ||
|
|
55aa4350b9 | ||
|
|
40bfde20fa | ||
|
|
8ceda2b07b | ||
|
|
a592a44647 | ||
|
|
2a9b59f935 | ||
|
|
5ed0549dc4 | ||
|
|
158da7f60f | ||
|
|
58e529097f | ||
|
|
2de5beb6d1 | ||
|
|
cb5df407fd | ||
|
|
8fd0e873c7 | ||
|
|
fe9ff2f4f9 | ||
|
|
bf05d850fb | ||
|
|
266cbd5dde | ||
|
|
e222c0f7a9 | ||
|
|
12e80be6d1 | ||
|
|
5efb2c2e40 | ||
|
|
2e574caac6 | ||
|
|
74b7a40763 | ||
|
|
1ede72b64a | ||
|
|
c45fe42129 | ||
|
|
ddaffcf7a5 | ||
|
|
0d28620ee3 | ||
|
|
bbab149d3c | ||
|
|
d4e193f39a | ||
|
|
bd4dd064be | ||
|
|
2efb70e3b5 | ||
|
|
92668c3a2a | ||
|
|
3915c3ac2c | ||
|
|
51e521fbb3 | ||
|
|
a81a666b81 | ||
|
|
69a9f0fe43 | ||
|
|
9262ad4d82 | ||
|
|
b6270a71bb | ||
|
|
e31d2ae0d1 | ||
|
|
77510ac6e3 | ||
|
|
0f1e88bb25 | ||
|
|
c5a42f03e6 | ||
|
|
de1124c19e | ||
|
|
60ba4bfec6 | ||
|
|
6372242b0b | ||
|
|
9a8c4a1c8c | ||
|
|
891db98700 | ||
|
|
f7d1b73a6c | ||
|
|
7a906fdc03 | ||
|
|
e7046c9bf5 | ||
|
|
8d87b0256b | ||
|
|
802aa167a9 | ||
|
|
b83bd41716 | ||
|
|
7c8cb3053a | ||
|
|
7c9fb9f6b4 | ||
|
|
68989d3e31 | ||
|
|
51a0745348 | ||
|
|
3505a2bcd5 | ||
|
|
0581a5e42b | ||
|
|
7ea839334c | ||
|
|
be7cce4300 | ||
|
|
c78251a90e | ||
|
|
c3c8fd7186 | ||
|
|
3d97768f71 | ||
|
|
f2c93cb5dd | ||
|
|
689ef0cf8a | ||
|
|
77de4abfd1 | ||
|
|
dc16b75c94 | ||
|
|
3a0fdb4d4f | ||
|
|
32b0f8333d | ||
|
|
446dfd2257 | ||
|
|
faa9947974 | ||
|
|
c75971e8c5 | ||
|
|
2c850cbe53 | ||
|
|
a060f5f322 | ||
|
|
5367811a33 | ||
|
|
7d41ae1331 | ||
|
|
f55abfa576 | ||
|
|
79b8340b80 | ||
|
|
e0b7034f97 | ||
|
|
b79876c959 | ||
|
|
e159c25f6d | ||
|
|
d16eedd1b3 | ||
|
|
a062d61c8d | ||
|
|
471e5b5399 | ||
|
|
577f94a67f | ||
|
|
f7e05491da | ||
|
|
2771b4fe1f | ||
|
|
b5830fac6e | ||
|
|
d8511c92c0 | ||
|
|
1ea41edd6a | ||
|
|
4f79f92940 | ||
|
|
e13865a966 | ||
|
|
05e1161632 | ||
|
|
feae947742 | ||
|
|
9ef69149ee | ||
|
|
04ca668807 | ||
|
|
489af75669 | ||
|
|
c8e1aff861 | ||
|
|
373bcd0351 | ||
|
|
c08e984e35 | ||
|
|
5dee59e8e5 | ||
|
|
350dbeb12f | ||
|
|
fdc2eb66aa | ||
|
|
ef332e4568 | ||
|
|
93c7d28714 | ||
|
|
5d8225f041 | ||
|
|
b501c76f7c | ||
|
|
97526110d0 | ||
|
|
f8a4c5db92 | ||
|
|
2093d23e24 | ||
|
|
7e32b752a0 | ||
|
|
4b02708bb0 | ||
|
|
9684d69bd1 | ||
|
|
f6d07944d8 | ||
|
|
46796041c7 | ||
|
|
196a782f8c | ||
|
|
4839d05b70 | ||
|
|
d8b6140692 | ||
|
|
040e51f124 | ||
|
|
a24161db2b | ||
|
|
117501c511 | ||
|
|
1c122b99e9 | ||
|
|
6970c1e7cf | ||
|
|
d56cecdba4 | ||
|
|
8ebf514dab | ||
|
|
1376f0dde2 | ||
|
|
dbacf597da | ||
|
|
87eaf96fa1 | ||
|
|
13db59aac8 | ||
|
|
9a46768de6 | ||
|
|
3c5010cebf | ||
|
|
d25b197c09 | ||
|
|
b892cfa029 | ||
|
|
23a012364b | ||
|
|
ed0f3600f5 | ||
|
|
dd4e250432 | ||
|
|
2ffb71e053 | ||
|
|
be25cf699c | ||
|
|
1cc15fe50c | ||
|
|
a04e5c1da2 | ||
|
|
5b18ba9058 | ||
|
|
753f4d989b | ||
|
|
8960fa20c3 | ||
|
|
38344027ca | ||
|
|
90ff1abab8 | ||
|
|
7fe3799ea6 | ||
|
|
5ed6fba085 | ||
|
|
6c3573d854 | ||
|
|
d00aeffbda | ||
|
|
e247b8e368 | ||
|
|
3d54fd3b7b | ||
|
|
b19b5daf48 | ||
|
|
f48952aa94 | ||
|
|
e8d4433bb3 | ||
|
|
84b0e17572 | ||
|
|
e4ba6f56dd | ||
|
|
bdfd2e9adf | ||
|
|
849655cb2f | ||
|
|
1c391a7c7e | ||
|
|
cf1990ddf7 | ||
|
|
fad3ea497d | ||
|
|
f586525a61 | ||
|
|
832a290778 | ||
|
|
ecbba9f1c0 | ||
|
|
afeb4eb815 | ||
|
|
d0b5e78f7a | ||
|
|
1837234650 | ||
|
|
c65031ea31 | ||
|
|
14a7176325 | ||
|
|
a0c3a1eb05 | ||
|
|
f7af3865b7 | ||
|
|
51a0c08042 | ||
|
|
abc2118a77 | ||
|
|
776ac3ee2b | ||
|
|
63eaec8348 | ||
|
|
ddb8464c1c | ||
|
|
29ef7a7d3b | ||
|
|
49aa0cc459 | ||
|
|
cdf1b44cb0 | ||
|
|
61fe9f2282 | ||
|
|
0b9d254e12 | ||
|
|
77b241eb68 | ||
|
|
b98ae5844c | ||
|
|
507ce6f220 | ||
|
|
4d2a27f7e8 | ||
|
|
a90841a6b6 | ||
|
|
e9bb6e42f6 | ||
|
|
ed4b11d9ef | ||
|
|
c115f01edf | ||
|
|
8fd6bbef3b | ||
|
|
8fa68731d1 | ||
|
|
b6b586a865 | ||
|
|
457ba444f1 | ||
|
|
31a367c434 | ||
|
|
e83eb92948 | ||
|
|
5ee779846d | ||
|
|
7a3ecf8e38 | ||
|
|
9e2c96a18e | ||
|
|
6550fa28ca | ||
|
|
de9ce7ebb9 | ||
|
|
caae78b6ee | ||
|
|
495701c46c | ||
|
|
ed99ce1694 | ||
|
|
51a37e896d | ||
|
|
b431315e88 | ||
|
|
ea59f120da | ||
|
|
9bd30e8d5d | ||
|
|
39d1ef7e13 | ||
|
|
83a1b70efe | ||
|
|
01b4f803a8 | ||
|
|
5c31890066 | ||
|
|
be7f4e5192 | ||
|
|
4124c45875 | ||
|
|
06e785c75a | ||
|
|
2f384c079c | ||
|
|
e4adada542 | ||
|
|
efa86891cc | ||
|
|
bcc20bb774 | ||
|
|
937a095209 | ||
|
|
1661228168 | ||
|
|
b17b9eb4e1 | ||
|
|
2ffa1510ed | ||
|
|
d1ef107b48 | ||
|
|
aa48e9cacc | ||
|
|
3c0bfa7843 | ||
|
|
803b6331f4 | ||
|
|
fe8af8705d | ||
|
|
624365cda3 | ||
|
|
4fb59b6071 | ||
|
|
d15948e44b | ||
|
|
bf629ff518 | ||
|
|
ee9ee7f207 | ||
|
|
311d4091ff | ||
|
|
4e79f508c0 | ||
|
|
90828e6eab | ||
|
|
7d3afc35cc | ||
|
|
6f4c046732 | ||
|
|
503a8da70f | ||
|
|
1cf9a005d9 | ||
|
|
fe04d56568 | ||
|
|
93b6ac15dd | ||
|
|
500632515c | ||
|
|
598d2da9d6 | ||
|
|
05f7a9b30a | ||
|
|
0b6be04428 | ||
|
|
dcb9553807 | ||
|
|
c9c9be68b1 | ||
|
|
53e6671143 | ||
|
|
3d063d8188 | ||
|
|
8d3633fe63 | ||
|
|
ee7d64c533 | ||
|
|
5009ebe0ab | ||
|
|
9b2f3f3108 | ||
|
|
9ca9dc797e | ||
|
|
2ffc18cc89 | ||
|
|
cfeeda3c93 | ||
|
|
a2277bc2d4 | ||
|
|
694e4e7988 | ||
|
|
1c0e786489 | ||
|
|
7420e94876 | ||
|
|
73c921bb95 | ||
|
|
7a22f4f74a | ||
|
|
cdb76d344e | ||
|
|
6cbded92cb | ||
|
|
bc032a074c | ||
|
|
89a4afdc08 | ||
|
|
be6266d633 | ||
|
|
705264ba9a | ||
|
|
a0b181e6fe | ||
|
|
df50a0a38d | ||
|
|
abd182e17f | ||
|
|
312c15d824 | ||
|
|
3f0cdc9b19 | ||
|
|
5d5c42c843 | ||
|
|
1a8fe19c88 | ||
|
|
7e37495b49 | ||
|
|
3210f06931 | ||
|
|
a457ff539d | ||
|
|
afbcd90ffc | ||
|
|
8acdc6c458 | ||
|
|
4ed8f69da1 | ||
|
|
90fe657da6 | ||
|
|
91fe7b516c | ||
|
|
e3851e3f1d | ||
|
|
301014285f | ||
|
|
e467f44bf2 | ||
|
|
e8e5ac2ca7 | ||
|
|
ebb0a4b2bc | ||
|
|
d21e2666ec | ||
|
|
43140b2db3 | ||
|
|
c898e1321f | ||
|
|
4f04cbbcc8 | ||
|
|
f17e857710 | ||
|
|
2401b9b1ff | ||
|
|
e646ff1d1f | ||
|
|
9bb800ce43 | ||
|
|
6859ad2ad9 | ||
|
|
19152790b2 | ||
|
|
05751dbe1b | ||
|
|
f35f6b3edd | ||
|
|
8af7fadbf6 | ||
|
|
9190ce038f | ||
|
|
bda47748f2 | ||
|
|
96084d7b26 | ||
|
|
e96ff73b50 | ||
|
|
fcb8c4bdd6 | ||
|
|
c7c1d2d302 | ||
|
|
21ea8e377c | ||
|
|
e9409d01a6 | ||
|
|
a8c70a903f | ||
|
|
c66ca97dfc | ||
|
|
5b5517ad29 | ||
|
|
c8de886967 | ||
|
|
2ef19583a6 | ||
|
|
9e0ff5e635 | ||
|
|
427cef758f | ||
|
|
1cc1516feb | ||
|
|
daafa3f5c2 | ||
|
|
9e20af7603 | ||
|
|
306a160df0 | ||
|
|
b5686bcd2f | ||
|
|
33dd245131 | ||
|
|
25334c27f1 | ||
|
|
3f20ebb15b | ||
|
|
37849b88e2 | ||
|
|
800b3f8272 | ||
|
|
b2ecb3cb52 | ||
|
|
8a794f2e02 | ||
|
|
3c05e1674f | ||
|
|
a15b3c2a69 | ||
|
|
10c138d64e | ||
|
|
99d1718498 | ||
|
|
515985dead | ||
|
|
e30c4532b8 | ||
|
|
2ab5f19f79 | ||
|
|
f5054558c2 | ||
|
|
b726053164 | ||
|
|
cc433b6708 | ||
|
|
e95e251161 | ||
|
|
75edc751f3 | ||
|
|
b4ba84a0d1 | ||
|
|
38074a1660 | ||
|
|
ca5e20b1a9 | ||
|
|
c4db463338 | ||
|
|
34c2cb604f | ||
|
|
f058e38004 | ||
|
|
b38a8b5830 | ||
|
|
8e76829a27 | ||
|
|
f3bf092898 | ||
|
|
4dd2b87538 | ||
|
|
4d6930e903 | ||
|
|
3fecd16efd | ||
|
|
29a535c71a | ||
|
|
3fd72f35df | ||
|
|
bb3d637738 | ||
|
|
02fe620360 | ||
|
|
ebe0e350ff | ||
|
|
6dbe638a59 | ||
|
|
31b5f4181a | ||
|
|
72d0cfdbbc | ||
|
|
f934764290 | ||
|
|
e28f809a58 | ||
|
|
a88dd00a0d | ||
|
|
5d9de47fd5 | ||
|
|
7add28ad7d | ||
|
|
17b97aca28 | ||
|
|
86b422230e | ||
|
|
0193671453 | ||
|
|
c4be1b8697 | ||
|
|
52f8880627 | ||
|
|
f537e8cf78 | ||
|
|
482af12b67 | ||
|
|
2f85d50778 | ||
|
|
b51663c130 | ||
|
|
7ebc54352e | ||
|
|
6703e62823 | ||
|
|
e860e9e1af | ||
|
|
de3303abc9 | ||
|
|
a0695c08cc | ||
|
|
c5aeb0785e | ||
|
|
21b376848f | ||
|
|
f8fe7e41b4 | ||
|
|
22caa0a408 | ||
|
|
4d3945f5a4 | ||
|
|
0786012ed8 | ||
|
|
6e9a316460 | ||
|
|
fd7d0e1d99 | ||
|
|
65199c7a81 | ||
|
|
851094c523 | ||
|
|
9b31032016 | ||
|
|
a7fa173e52 | ||
|
|
de4d83372c | ||
|
|
c7f24490f3 | ||
|
|
fabc7a3a27 | ||
|
|
e830527f74 | ||
|
|
5fc5feb636 | ||
|
|
384af0001c | ||
|
|
2abc9b3f7c | ||
|
|
9242f3439c | ||
|
|
b1ba8f0aa2 | ||
|
|
20b3775280 | ||
|
|
c2bb321e17 | ||
|
|
b0160287ba | ||
|
|
284e2257f3 | ||
|
|
ec06d07f35 | ||
|
|
5eca8807d8 | ||
|
|
5b3ee63299 | ||
|
|
a6ffa3ae36 | ||
|
|
e021e66387 | ||
|
|
eb70985551 | ||
|
|
cd6dc5158e | ||
|
|
942f30557c | ||
|
|
1486d61e65 | ||
|
|
eb082d2f49 | ||
|
|
7e6e691771 | ||
|
|
8e4962ceb1 | ||
|
|
414d82bd37 | ||
|
|
4091f1d1d9 | ||
|
|
fe0f4ddf99 | ||
|
|
b0845c5795 | ||
|
|
aeddb37d9d | ||
|
|
1ff1c35486 | ||
|
|
6e585a7afa | ||
|
|
e0df16ee17 | ||
|
|
ae5cb7a17a | ||
|
|
8d79ed527f | ||
|
|
d4bc84c6bd | ||
|
|
9743a7d1b7 | ||
|
|
e5cffc623a | ||
|
|
9c0a559bce | ||
|
|
b794bc5ee0 | ||
|
|
55c71d77e1 | ||
|
|
6914e30443 | ||
|
|
1c52e8e38a | ||
|
|
c38f169d1d | ||
|
|
8f4b8dbf88 | ||
|
|
b68f28b621 | ||
|
|
a23eb2f869 | ||
|
|
8dfbf2b3b6 | ||
|
|
70b0fab66a | ||
|
|
082e2ff2cd | ||
|
|
12af50d473 | ||
|
|
b1cde02dd4 | ||
|
|
2d737ab092 | ||
|
|
8cd9220f36 | ||
|
|
838d4a98aa | ||
|
|
d32bfea94e | ||
|
|
181a7f5b9c | ||
|
|
ee00b544f7 | ||
|
|
5548c71bda | ||
|
|
ae7a6b79b7 | ||
|
|
96d2338bea | ||
|
|
21217e030b | ||
|
|
1d63f4b4a1 | ||
|
|
8843e5bfe7 | ||
|
|
48b97f8632 | ||
|
|
20184fb4c0 | ||
|
|
76000a90fb | ||
|
|
4aebd350ee | ||
|
|
13f4a0abb4 | ||
|
|
35ea297090 | ||
|
|
f11909d6da | ||
|
|
5df82652b6 | ||
|
|
8fde8ebe5f | ||
|
|
6bc20a8830 | ||
|
|
0bbd9c103a | ||
|
|
0b68e2ade6 | ||
|
|
1ca79539b6 | ||
|
|
1c2c3d6d51 | ||
|
|
bdb1243409 | ||
|
|
812d4ca519 | ||
|
|
4e7e14cbf3 | ||
|
|
2064b6517e | ||
|
|
c9f491a483 | ||
|
|
be2ec80f0c | ||
|
|
1c13e8dc10 | ||
|
|
4748aa2262 | ||
|
|
a3376b0502 | ||
|
|
c073d39cd6 | ||
|
|
b508f78f04 | ||
|
|
8424da8311 | ||
|
|
cfd9d55668 | ||
|
|
417e3bb104 | ||
|
|
320d4f62d9 | ||
|
|
6c712d86fb | ||
|
|
a0479f9610 | ||
|
|
374a744a44 | ||
|
|
81416d49de | ||
|
|
31ebd62c83 | ||
|
|
93dd4af6ed | ||
|
|
9f0308dd66 | ||
|
|
f9298703d4 | ||
|
|
3992032e8e | ||
|
|
58dacc0789 | ||
|
|
b3280923d9 | ||
|
|
e83da9ff9c | ||
|
|
8b1d0fc759 | ||
|
|
ff869933be | ||
|
|
fb0af4dc18 | ||
|
|
6f5551d78d | ||
|
|
a90efe4939 | ||
|
|
46c37b9d82 | ||
|
|
3e23eb517b | ||
|
|
9cf75ea844 | ||
|
|
5565b4a4d0 | ||
|
|
bde5967ef4 | ||
|
|
f3560238fe | ||
|
|
f97f489aba | ||
|
|
454b7715c0 | ||
|
|
ac1e279235 | ||
|
|
5950162663 | ||
|
|
6a52b46192 | ||
|
|
f5558eec7f | ||
|
|
0c39f596a3 | ||
|
|
ba3c544484 | ||
|
|
e0063727a9 | ||
|
|
7b68821a8c | ||
|
|
4a84b408d4 | ||
|
|
b9aec4ffb8 | ||
|
|
1a958e758f | ||
|
|
74527319aa | ||
|
|
a66e7ad14f | ||
|
|
e4b91416dd | ||
|
|
7735c705c0 | ||
|
|
31ab48d0d4 | ||
|
|
e5cf9da31d | ||
|
|
9eac64ab7b | ||
|
|
7131cebf7d | ||
|
|
bfb4a5ee57 | ||
|
|
21e250bf36 | ||
|
|
f5b1ac970b | ||
|
|
c85f14f27c | ||
|
|
c0cf6198a4 | ||
|
|
4d3012fee7 | ||
|
|
75726dc272 | ||
|
|
260724af80 | ||
|
|
2b37cf217f | ||
|
|
669ff579c5 | ||
|
|
d0e65fe1bc | ||
|
|
4485e46801 | ||
|
|
2265687c75 | ||
|
|
f70523bf14 | ||
|
|
48013b9339 | ||
|
|
e9e1caf9d1 | ||
|
|
5b17e2beda | ||
|
|
19bc74f88d | ||
|
|
ae0069652a | ||
|
|
5ec7f01b7a | ||
|
|
691f798f90 | ||
|
|
d5bef0861b | ||
|
|
87dd938cde | ||
|
|
c4e0d3e7ce | ||
|
|
c705722bdc | ||
|
|
6424fa151a | ||
|
|
0646e49359 | ||
|
|
6ddae9e9da | ||
|
|
efc7be1637 | ||
|
|
1de80be872 | ||
|
|
f8740f1268 | ||
|
|
d6f30c9220 | ||
|
|
f2d7004b02 | ||
|
|
6ecf800bab | ||
|
|
6f92a834da | ||
|
|
a7a85d22d5 | ||
|
|
178024e248 | ||
|
|
798e93af46 | ||
|
|
3cb125ae4a | ||
|
|
30aed49e87 | ||
|
|
d0173a2341 | ||
|
|
fb7a61ab30 | ||
|
|
13e09c73bc | ||
|
|
6fdaf4fda4 | ||
|
|
ba79089bed | ||
|
|
a8670467be | ||
|
|
4dd84cdb2e | ||
|
|
028d6c0a1f | ||
|
|
ca2584f598 | ||
|
|
17e96250f7 | ||
|
|
79fdd21817 | ||
|
|
a0daa7c4be | ||
|
|
000d0d3119 | ||
|
|
3b01b4f3dd | ||
|
|
f0613e9660 | ||
|
|
1c51ed37c2 | ||
|
|
2bfcd92da9 | ||
|
|
0bf676448b | ||
|
|
5bceff414e | ||
|
|
1b65231e30 | ||
|
|
8b39b69bb7 | ||
|
|
4dfab45544 | ||
|
|
f046dbf3cc | ||
|
|
2e5f9350eb | ||
|
|
938784d6e8 | ||
|
|
02c582a695 | ||
|
|
2851d49c3b | ||
|
|
e88af1f6ba | ||
|
|
da3b6bf19e | ||
|
|
da28e10ac7 | ||
|
|
e6b260cc60 | ||
|
|
2cea9debcf | ||
|
|
768a26a5d4 | ||
|
|
0e251ffb6a | ||
|
|
74c04ea561 | ||
|
|
e92cc2735b | ||
|
|
6a94535b78 | ||
|
|
17ad490f97 | ||
|
|
704e4c4ef7 | ||
|
|
36a301275e | ||
|
|
bb2a01512e | ||
|
|
ad73c9391d | ||
|
|
ce33d146d0 | ||
|
|
055695890e | ||
|
|
028579eed4 | ||
|
|
5c836228f7 | ||
|
|
0663eee49a | ||
|
|
4d9205699b | ||
|
|
d8a5993a28 | ||
|
|
6e7e19fd34 | ||
|
|
9e55ee9be1 | ||
|
|
ae93665645 | ||
|
|
7eb84bb6a3 | ||
|
|
3006cc9431 | ||
|
|
480629953b | ||
|
|
c54ed09d38 | ||
|
|
a098b56339 | ||
|
|
7a9f8d9788 | ||
|
|
7bd822b96a | ||
|
|
d20e9d5629 | ||
|
|
9b61a99dc3 | ||
|
|
4c1f670147 | ||
|
|
c05d299fe4 | ||
|
|
0ba8b530fe | ||
|
|
0a6f7afeff | ||
|
|
483f274bac | ||
|
|
1fd36a4623 | ||
|
|
3b1ab80c1c | ||
|
|
abe0cec346 | ||
|
|
6e1e22d6cb | ||
|
|
7650ec9323 | ||
|
|
fe3fedaf64 | ||
|
|
f21f187890 | ||
|
|
41e164d131 | ||
|
|
adb6a0b7f0 | ||
|
|
31618c1611 | ||
|
|
6eba60638b | ||
|
|
e4040d4a47 | ||
|
|
c53cd32291 | ||
|
|
172ca340ae | ||
|
|
a8451abea4 | ||
|
|
cdf67a3865 | ||
|
|
e2f2fc4804 | ||
|
|
db9a451e32 | ||
|
|
a8cf682f71 | ||
|
|
0c721f1776 | ||
|
|
f8194aac7a | ||
|
|
15dd60ff3e | ||
|
|
d54441a9b2 | ||
|
|
4e75bfb4d0 | ||
|
|
3e350d03c6 | ||
|
|
2fa44e1ae2 | ||
|
|
1e5244cee0 | ||
|
|
6043c2738d | ||
|
|
013cf5eb13 | ||
|
|
a413fe2dc1 | ||
|
|
a2bf02eb82 | ||
|
|
229485494a | ||
|
|
4ea3439667 | ||
|
|
4154d31143 | ||
|
|
30b660f802 | ||
|
|
b79cf45778 | ||
|
|
c6e9cbd69b | ||
|
|
7e493ed129 | ||
|
|
c3ed6ebe79 | ||
|
|
27e33ec1b1 | ||
|
|
7601d5a2bd | ||
|
|
a9fb42eb15 | ||
|
|
cd9cdbf1be | ||
|
|
e68a716587 | ||
|
|
bab5672669 | ||
|
|
80f083e141 | ||
|
|
91d37b38cc | ||
|
|
9349fa9217 | ||
|
|
748523f9cf | ||
|
|
e64336abe9 | ||
|
|
15450a7fba | ||
|
|
ad2f63cd8f | ||
|
|
dbd3d956fb | ||
|
|
aabb4399ed | ||
|
|
a99386ac1d | ||
|
|
b400f22d15 | ||
|
|
8843054b89 | ||
|
|
8c8bde0799 | ||
|
|
109a990b28 | ||
|
|
8e9ac2e3e7 | ||
|
|
c0ad9b1b71 | ||
|
|
01609a1f29 | ||
|
|
2f5219615d | ||
|
|
91cd93783f | ||
|
|
2d8e4e9053 | ||
|
|
9500b3a5ae | ||
|
|
84e124bbf5 | ||
|
|
0d0377ae4a | ||
|
|
9e1ec67253 | ||
|
|
4f8ee5ea52 | ||
|
|
56654ffcb1 | ||
|
|
ac48d3634b | ||
|
|
934e4cbb2c | ||
|
|
53e631d65f | ||
|
|
1483d7c969 | ||
|
|
71ddee1033 | ||
|
|
480bba7a8c | ||
|
|
9c4c529c62 |
@@ -1,8 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.testng.TESTNG_CONTAINER"/>
|
||||
|
||||
31550
.gitattributes
vendored
31550
.gitattributes
vendored
File diff suppressed because it is too large
Load Diff
30
.gitignore
vendored
30
.gitignore
vendored
@@ -2,20 +2,32 @@
|
||||
/*.iml
|
||||
/*.tmp
|
||||
/.metadata
|
||||
forge-ai/forge-ai.iml
|
||||
forge-ai/target
|
||||
forge-core/forge-core.iml
|
||||
forge-core/target
|
||||
forge-game/target
|
||||
forge-gui/forge-gui.iml
|
||||
forge-gui/forge.profile.properties
|
||||
forge-gui/res/*.log
|
||||
forge-gui/res/PerSetTrackingResults
|
||||
forge-gui/res/cardsfolder/*.bat
|
||||
forge-gui/res/decks
|
||||
forge-gui/res/layouts
|
||||
forge-gui/res/pics*
|
||||
forge-gui/res/pics_product
|
||||
forge-gui/target
|
||||
forge-gui/tools/PerSetTrackingResults
|
||||
forge-gui/tools/oracleScript.log
|
||||
forge-m-android/bin
|
||||
forge-m-base/bin
|
||||
forge-m-desktop/bin
|
||||
forge-net/target
|
||||
/forge.profile.properties
|
||||
/nbactions.xml
|
||||
/pom.xml.next
|
||||
/pom.xml.releaseBackup
|
||||
/pom.xml.tag
|
||||
/release.properties
|
||||
res/*.log
|
||||
res/PerSetTrackingResults
|
||||
res/cardsfolder/*.bat
|
||||
res/decks
|
||||
res/layouts
|
||||
res/pics*
|
||||
res/pics_product
|
||||
/target
|
||||
/test-output
|
||||
tools/PerSetTrackingResults
|
||||
tools/oracleScript.log
|
||||
|
||||
29
.project
29
.project
@@ -4,36 +4,7 @@
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
|
||||
101
CHANGES.txt
101
CHANGES.txt
@@ -1,101 +0,0 @@
|
||||
Forge Beta: 10-01-2013 ver 1.5.1
|
||||
|
||||
|
||||
13328 cards in total.
|
||||
|
||||
|
||||
-------------
|
||||
Release Notes
|
||||
-------------
|
||||
|
||||
- Forge freezing during a match bug -
|
||||
A number of people have reported this bug and we now feel that it may have been fixed in this version. Please play test this version and let us know.
|
||||
|
||||
|
||||
- Skinned titlebar for main window -
|
||||
Titlebar is now skinned instead of displaying using standard OS window titlebar
|
||||
Maximizing window now displays full-screen
|
||||
Can use Layout > View > Titlebar (F11) to toggle visibility of titlebar (will also open full-screen if hiding titlebar)
|
||||
|
||||
|
||||
- Forge now requires Java 7 -
|
||||
Please update your Java runtime environment. At this point Forge versions 1.4.2 and above will no longer run under Java 6. Those who are using Mac OS should install the JDK version rather than the JRE version.
|
||||
|
||||
|
||||
- The Mac OS X application -
|
||||
At this time Forge now requires Java 7 and will no longer run under Java 6.
|
||||
|
||||
Unfortunately, the Mac OS X builder that we were using does not support Java 7. We hope to find and to use a different Mac OS X builder in order to continue releasing a Mac OS bundled application like we have in the past.
|
||||
|
||||
Currently, the windows/unix release of Forge includes a launcher file named "forge.command". Double click on the "forge.command" launcher command file and this will in turn launch the Forge jar file via the terminal application while increasing the Java heap space. This should be a temporary inconvenience.
|
||||
|
||||
|
||||
---------
|
||||
New Cards
|
||||
---------
|
||||
|
||||
Chaos Moon
|
||||
Deep Water
|
||||
Infernal Darkness
|
||||
Mana Reflection
|
||||
Mausoleum Turnkey
|
||||
Naked Singularity
|
||||
Pale Moon
|
||||
Pulse of Llanowar
|
||||
Reality Twist
|
||||
Ritual of Subdual
|
||||
|
||||
|
||||
-----------
|
||||
New Schemes
|
||||
-----------
|
||||
|
||||
Nature Demands an Offering
|
||||
|
||||
|
||||
--------------------
|
||||
New Vanguard Avatars
|
||||
--------------------
|
||||
|
||||
Mirri
|
||||
|
||||
|
||||
------------
|
||||
Known Issues
|
||||
------------
|
||||
|
||||
Several people have noticed that the cards displayed on the battlefield will fail to be displayed when the number of cards on the battlefield increases. Maximizing the human panel can help to re-display the cards.
|
||||
|
||||
Some time was spent turning the static ETB triggers into the proper ETB replacement effects they should be, mainly to interact correctly with each other. This work is not yet finished. As a result there is currently some inconsistencies with "Enters the battlefield with counters" (Not incredibly noticeable).
|
||||
|
||||
A recent contribution to the code base should fix some of the bugs that people noticed with cloning type abilities. At this time there is one remaining issue that we hope will be addressed in the near future:
|
||||
Copies of cards that setup Zone Change triggers via addComesIntoPlayCommand and addLeavesPlayCommand will not function correctly.
|
||||
|
||||
The Forge archive includes a readme.txt file and we ask that you spend a few minutes reading this file as it contains some information that may prove useful. We do tend to update this file at times and you should quickly read this file and look for new information for each and every new release. Thank you.
|
||||
|
||||
The archive format used for the Forge distribution is ".tar.bz2". There are utilities for Windows, Mac OS and the various *nix's that can be used to extract/decompress these ".tar.bz2" archives. We recommend that you extract/decompress the Forge archive into a new and unused folder.
|
||||
|
||||
Some people use the Windows application 7zip. This utility can be found at http://www.7-zip.org/download.html. Mac users can double click on the archive and the application Archive Utility will launch and extract the archive. Mac users do not need to download a separate utility.
|
||||
|
||||
|
||||
----------------------------
|
||||
Contributors to This Release
|
||||
----------------------------
|
||||
|
||||
DrDev
|
||||
Dripton
|
||||
Gos
|
||||
Hellfish
|
||||
Max
|
||||
Sloth
|
||||
spr
|
||||
Swordshine
|
||||
Chris H
|
||||
|
||||
|
||||
(Quest icons used created by Teekatas, from his Legendora set http://raindropmemory.deviantart.com)
|
||||
(Thanks to the MAGE team for permission to use their targeting arrows.)
|
||||
(Thanks to http://www.freesound.org/browse/ for providing some sound files.)
|
||||
|
||||
|
||||
end
|
||||
9
forge-ai/.classpath
Normal file
9
forge-ai/.classpath
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.testng.TESTNG_CONTAINER"/>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
23
forge-ai/.project
Normal file
23
forge-ai/.project
Normal file
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>forge-ai</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
4
forge-ai/.settings/org.eclipse.core.resources.prefs
Normal file
4
forge-ai/.settings/org.eclipse.core.resources.prefs
Normal file
@@ -0,0 +1,4 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding//src/main/java=ISO-8859-1
|
||||
encoding//src/test/java=ISO-8859-1
|
||||
encoding/<project>=ISO-8859-1
|
||||
5
forge-ai/.settings/org.eclipse.jdt.core.prefs
Normal file
5
forge-ai/.settings/org.eclipse.jdt.core.prefs
Normal file
@@ -0,0 +1,5 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
||||
4
forge-ai/.settings/org.eclipse.m2e.core.prefs
Normal file
4
forge-ai/.settings/org.eclipse.m2e.core.prefs
Normal file
@@ -0,0 +1,4 @@
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
||||
28
forge-ai/pom.xml
Normal file
28
forge-ai/pom.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<artifactId>forge</artifactId>
|
||||
<groupId>forge</groupId>
|
||||
<version>1.5.13</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>forge-ai</artifactId>
|
||||
<name>Forge AI</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>forge</groupId>
|
||||
<artifactId>forge-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>forge</groupId>
|
||||
<artifactId>forge-game</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -15,25 +15,26 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package forge.game.ai;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
package forge.ai;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CounterType;
|
||||
import forge.GameEntity;
|
||||
import forge.card.trigger.Trigger;
|
||||
import forge.card.trigger.TriggerType;
|
||||
import forge.game.GameEntity;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.card.CounterType;
|
||||
import forge.game.combat.Combat;
|
||||
import forge.game.combat.CombatUtil;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.trigger.Trigger;
|
||||
import forge.game.trigger.TriggerType;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
|
||||
//doesHumanAttackAndWin() uses the global variable AllZone.getComputerPlayer()
|
||||
@@ -58,6 +59,7 @@ public class AiAttackController {
|
||||
private List<Card> myList; // holds computer creatures
|
||||
|
||||
private final Player ai;
|
||||
private Player defendingOpponent;
|
||||
|
||||
private int aiAggression = 0; // added by Masher, how aggressive the ai is
|
||||
// attack will be depending on circumstances
|
||||
@@ -75,22 +77,34 @@ public class AiAttackController {
|
||||
*/
|
||||
public AiAttackController(final Player ai) {
|
||||
this.ai = ai;
|
||||
Player opponent = ai.getOpponent();
|
||||
this.defendingOpponent = choosePreferredDefenderPlayer();
|
||||
|
||||
this.oppList = Lists.newArrayList();
|
||||
this.oppList.addAll(opponent.getCreaturesInPlay());
|
||||
this.oppList.addAll(this.defendingOpponent.getCreaturesInPlay());
|
||||
this.myList = ai.getCreaturesInPlay();
|
||||
|
||||
|
||||
this.attackers = new ArrayList<Card>();
|
||||
for (Card c : myList) {
|
||||
if (CombatUtil.canAttack(c, opponent)) {
|
||||
if (CombatUtil.canAttack(c, this.defendingOpponent)) {
|
||||
attackers.add(c);
|
||||
}
|
||||
}
|
||||
this.blockers = this.getPossibleBlockers(oppList, this.attackers);
|
||||
} // constructor
|
||||
|
||||
/** Choose opponent for AI to attack here. Expand as necessary. */
|
||||
private Player choosePreferredDefenderPlayer() {
|
||||
Player defender = ai.getWeakestOpponent(); //Gets opponent with the least life
|
||||
|
||||
if (defender.getLife() < 8) { //Concentrate on opponent within easy kill range
|
||||
return defender;
|
||||
} else { //Otherwise choose a random opponent to ensure no ganging up on players
|
||||
defender = ai.getOpponents().get(MyRandom.getRandom().nextInt(ai.getOpponents().size()));
|
||||
}
|
||||
return defender;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* sortAttackers.
|
||||
@@ -129,7 +143,7 @@ public class AiAttackController {
|
||||
* </p>
|
||||
*
|
||||
* @param attacker
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param combat
|
||||
* a {@link forge.game.combat.Combat} object.
|
||||
* @return a boolean.
|
||||
@@ -141,7 +155,7 @@ public class AiAttackController {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Player opp = ai.getOpponent();
|
||||
final Player opp = this.defendingOpponent;
|
||||
if (ComputerUtilCombat.damageIfUnblocked(attacker, opp, combat) > 0) {
|
||||
return true;
|
||||
}
|
||||
@@ -192,7 +206,7 @@ public class AiAttackController {
|
||||
* </p>
|
||||
*
|
||||
* @param c
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param attackers
|
||||
* a {@link forge.CardList} object.
|
||||
* @return a boolean.
|
||||
@@ -277,7 +291,7 @@ public class AiAttackController {
|
||||
return notNeededAsBlockers;
|
||||
}
|
||||
|
||||
final Player opp = ai.getOpponent();
|
||||
final Player opp = this.defendingOpponent;
|
||||
|
||||
// Increase the total number of blockers needed by 1 if Finest Hour in
|
||||
// play
|
||||
@@ -385,11 +399,11 @@ public class AiAttackController {
|
||||
final List<Card> unblockedAttackers = new ArrayList<Card>();
|
||||
final List<Card> remainingAttackers = new ArrayList<Card>(this.attackers);
|
||||
final List<Card> remainingBlockers = new ArrayList<Card>(this.blockers);
|
||||
final Player opp = ai.getOpponent();
|
||||
final Player opp = this.defendingOpponent;
|
||||
|
||||
|
||||
for (Card attacker : attackers) {
|
||||
if (!CombatUtil.canBeBlocked(attacker, this.blockers)
|
||||
if (!CombatUtil.canBeBlocked(attacker, this.blockers, null)
|
||||
|| attacker.hasKeyword("You may have CARDNAME assign its combat damage as though it weren't blocked.")) {
|
||||
unblockedAttackers.add(attacker);
|
||||
}
|
||||
@@ -449,27 +463,28 @@ public class AiAttackController {
|
||||
if (defs.size() == 1) {
|
||||
return defs.get(0);
|
||||
}
|
||||
Player prefDefender = (Player) (defs.contains(this.defendingOpponent) ? this.defendingOpponent : defs.get(0));
|
||||
|
||||
final GameEntity entity = ai.getMustAttackEntity();
|
||||
if (null != entity) {
|
||||
int n = defs.indexOf(entity);
|
||||
if (-1 == n) {
|
||||
System.out.println("getMustAttackEntity() returned something not in defenders.");
|
||||
return defs.get(0);
|
||||
return prefDefender;
|
||||
} else {
|
||||
return entity;
|
||||
}
|
||||
} else {
|
||||
// 1. assault the opponent if you can kill him
|
||||
if (bAssault) {
|
||||
return getDefendingPlayers(c).get(0);
|
||||
return prefDefender;
|
||||
}
|
||||
// 2. attack planeswalkers
|
||||
List<Card> pwDefending = c.getDefendingPlaneswalkers();
|
||||
if (!pwDefending.isEmpty()) {
|
||||
return pwDefending.get(0);
|
||||
} else {
|
||||
return defs.get(0);
|
||||
return prefDefender;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -623,7 +638,7 @@ public class AiAttackController {
|
||||
aiLifeToPlayerDamageRatio = (double) ai.getLife() / candidateCounterAttackDamage;
|
||||
}
|
||||
|
||||
final Player opp = ai.getOpponent();
|
||||
final Player opp = this.defendingOpponent;
|
||||
// get the potential damage and strength of the AI forces
|
||||
final List<Card> candidateAttackers = new ArrayList<Card>();
|
||||
int candidateUnblockedDamage = 0;
|
||||
@@ -792,7 +807,7 @@ public class AiAttackController {
|
||||
for (int i = 0; i < attackersLeft.size(); i++) {
|
||||
final Card attacker = attackersLeft.get(i);
|
||||
if (this.aiAggression < 5 && !attacker.hasFirstStrike() && !attacker.hasDoubleStrike()
|
||||
&& ComputerUtilCombat.getTotalFirstStrikeBlockPower(attacker, ai.getOpponent())
|
||||
&& ComputerUtilCombat.getTotalFirstStrikeBlockPower(attacker, this.defendingOpponent)
|
||||
>= ComputerUtilCombat.getDamageToKill(attacker)) {
|
||||
continue;
|
||||
}
|
||||
@@ -808,9 +823,9 @@ public class AiAttackController {
|
||||
List<Card> attacking = combat.getAttackersOf(defender);
|
||||
CardLists.sortByPowerAsc(attacking);
|
||||
for (Card atta : attacking) {
|
||||
if (attackNum >= blockNum || !CombatUtil.canBeBlocked(attacker, this.blockers)) {
|
||||
if (attackNum >= blockNum || !CombatUtil.canBeBlocked(attacker, this.blockers, combat)) {
|
||||
damage += ComputerUtilCombat.damageIfUnblocked(atta, opp, null);
|
||||
} else if (CombatUtil.canBeBlocked(attacker, this.blockers)) {
|
||||
} else if (CombatUtil.canBeBlocked(attacker, this.blockers, combat)) {
|
||||
attackNum++;
|
||||
}
|
||||
}
|
||||
@@ -859,7 +874,7 @@ public class AiAttackController {
|
||||
* </p>
|
||||
*
|
||||
* @param c
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @return a int.
|
||||
*/
|
||||
public final int getAttack(final Card c) {
|
||||
@@ -878,7 +893,7 @@ public class AiAttackController {
|
||||
* </p>
|
||||
*
|
||||
* @param attacker
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param defenders
|
||||
* a {@link forge.CardList} object.
|
||||
* @param combat
|
||||
@@ -961,7 +976,7 @@ public class AiAttackController {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (numberOfPossibleBlockers > 1 || (numberOfPossibleBlockers == 1 && CombatUtil.canAttackerBeBlockedWithAmount(attacker, 1))) {
|
||||
if (numberOfPossibleBlockers > 1 || (numberOfPossibleBlockers == 1 && CombatUtil.canAttackerBeBlockedWithAmount(attacker, 1, combat))) {
|
||||
canBeBlocked = true;
|
||||
}
|
||||
/*System.out.println(attacker + " canBeKilledByOne: " + canBeKilledByOne + " canKillAll: "
|
||||
@@ -15,26 +15,25 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package forge.game.ai;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
package forge.ai;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CardPredicates;
|
||||
import forge.CounterType;
|
||||
import forge.GameEntity;
|
||||
import forge.card.TriggerReplacementBase;
|
||||
import forge.card.trigger.Trigger;
|
||||
import forge.card.trigger.TriggerType;
|
||||
import forge.game.CardTraitBase;
|
||||
import forge.game.GameEntity;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.card.CardPredicates;
|
||||
import forge.game.card.CounterType;
|
||||
import forge.game.combat.Combat;
|
||||
import forge.game.combat.CombatUtil;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.trigger.Trigger;
|
||||
import forge.game.trigger.TriggerType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
@@ -137,7 +136,7 @@ public class AiBlockController {
|
||||
|
||||
|
||||
// Begin with the attackers that pose the biggest threat
|
||||
CardLists.sortByEvaluateCreature(firstAttacker);
|
||||
ComputerUtilCard.sortByEvaluateCreature(firstAttacker);
|
||||
CardLists.sortByPowerDesc(firstAttacker);
|
||||
|
||||
// If I don't have any planeswalkers than sorting doesn't really matter
|
||||
@@ -186,7 +185,9 @@ public class AiBlockController {
|
||||
|
||||
for (final Card attacker : attackersLeft) {
|
||||
|
||||
if (attacker.hasStartOfKeyword("CantBeBlockedByAmount LT")) {
|
||||
if (attacker.hasStartOfKeyword("CantBeBlockedByAmount LT")
|
||||
|| attacker.hasKeyword("CARDNAME can't be blocked unless " +
|
||||
"all creatures defending player controls block it.")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -225,7 +226,7 @@ public class AiBlockController {
|
||||
|
||||
// check for triggers when unblocked
|
||||
for (Trigger trigger : attacker.getTriggers()) {
|
||||
final HashMap<String, String> trigParams = trigger.getMapParams();
|
||||
final Map<String, String> trigParams = trigger.getMapParams();
|
||||
TriggerType mode = trigger.getMode();
|
||||
|
||||
if (!trigger.requirementsCheck(attacker.getGame())) {
|
||||
@@ -234,14 +235,14 @@ public class AiBlockController {
|
||||
|
||||
if (mode == TriggerType.DamageDone) {
|
||||
if ((!trigParams.containsKey("ValidSource")
|
||||
|| TriggerReplacementBase.matchesValid(attacker, trigParams.get("ValidSource").split(","), attacker))
|
||||
|| CardTraitBase.matchesValid(attacker, trigParams.get("ValidSource").split(","), attacker))
|
||||
&& attacker.getNetCombatDamage() > 0
|
||||
&& (!trigParams.containsKey("ValidTarget")
|
||||
|| TriggerReplacementBase.matchesValid(combat.getDefenderByAttacker(attacker), trigParams.get("ValidTarget").split(","), attacker))) {
|
||||
|| CardTraitBase.matchesValid(combat.getDefenderByAttacker(attacker), trigParams.get("ValidTarget").split(","), attacker))) {
|
||||
value += 50;
|
||||
}
|
||||
} else if (mode == TriggerType.AttackerUnblocked) {
|
||||
if (TriggerReplacementBase.matchesValid(attacker, trigParams.get("ValidCard").split(","), attacker)) {
|
||||
if (CardTraitBase.matchesValid(attacker, trigParams.get("ValidCard").split(","), attacker)) {
|
||||
value += 50;
|
||||
}
|
||||
}
|
||||
@@ -402,7 +403,9 @@ public class AiBlockController {
|
||||
|
||||
for (final Card attacker : attackersLeft) {
|
||||
|
||||
if (attacker.hasStartOfKeyword("CantBeBlockedByAmount LT")) {
|
||||
if (attacker.hasStartOfKeyword("CantBeBlockedByAmount LT")
|
||||
|| attacker.hasKeyword("CARDNAME can't be blocked unless " +
|
||||
"all creatures defending player controls block it.")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -437,7 +440,8 @@ public class AiBlockController {
|
||||
|
||||
Card attacker = attackers.get(0);
|
||||
|
||||
if (attacker.hasStartOfKeyword("CantBeBlockedByAmount LT") || attacker.hasKeyword("You may have CARDNAME assign its combat damage as though it weren't blocked.")) {
|
||||
if (attacker.hasStartOfKeyword("CantBeBlockedByAmount LT") || attacker.hasKeyword("You may have CARDNAME assign its combat damage as though it weren't blocked.")
|
||||
|| attacker.hasKeyword("CARDNAME can't be blocked unless all creatures defending player controls block it.")) {
|
||||
attackers.remove(0);
|
||||
makeChumpBlocks(combat, attackers);
|
||||
return;
|
||||
@@ -481,14 +485,15 @@ public class AiBlockController {
|
||||
private void makeMultiChumpBlocks(final Combat combat) {
|
||||
|
||||
List<Card> currentAttackers = new ArrayList<Card>(attackersLeft);
|
||||
|
||||
|
||||
for (final Card attacker : currentAttackers) {
|
||||
|
||||
if (!attacker.hasStartOfKeyword("CantBeBlockedByAmount LT")) {
|
||||
if (!attacker.hasStartOfKeyword("CantBeBlockedByAmount LT")
|
||||
&& !attacker.hasKeyword("CARDNAME can't be blocked unless all creatures defending player controls block it.")) {
|
||||
continue;
|
||||
}
|
||||
List<Card> possibleBlockers = getPossibleBlockers(combat, attacker, blockersLeft, true);
|
||||
if (!CombatUtil.canAttackerBeBlockedWithAmount(attacker, possibleBlockers.size())) {
|
||||
if (!CombatUtil.canAttackerBeBlockedWithAmount(attacker, possibleBlockers.size(), combat)) {
|
||||
continue;
|
||||
}
|
||||
List<Card> usedBlockers = new ArrayList<Card>();
|
||||
@@ -496,12 +501,12 @@ public class AiBlockController {
|
||||
if (CombatUtil.canBlock(attacker, blocker, combat)) {
|
||||
combat.addBlocker(attacker, blocker);
|
||||
usedBlockers.add(blocker);
|
||||
if (CombatUtil.canAttackerBeBlockedWithAmount(attacker, usedBlockers.size())) {
|
||||
if (CombatUtil.canAttackerBeBlockedWithAmount(attacker, usedBlockers.size(), combat)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CombatUtil.canAttackerBeBlockedWithAmount(attacker, usedBlockers.size())) {
|
||||
if (CombatUtil.canAttackerBeBlockedWithAmount(attacker, usedBlockers.size(), combat)) {
|
||||
attackersLeft.remove(attacker);
|
||||
} else {
|
||||
for (Card blocker : usedBlockers) {
|
||||
@@ -526,7 +531,8 @@ public class AiBlockController {
|
||||
for (final Card attacker : tramplingAttackers) {
|
||||
|
||||
if ((attacker.hasStartOfKeyword("CantBeBlockedByAmount LT") && !combat.isBlocked(attacker))
|
||||
|| attacker.hasKeyword("You may have CARDNAME assign its combat damage as though it weren't blocked.")) {
|
||||
|| attacker.hasKeyword("You may have CARDNAME assign its combat damage as though it weren't blocked.")
|
||||
|| attacker.hasKeyword("CARDNAME can't be blocked unless all creatures defending player controls block it.")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -756,7 +762,7 @@ public class AiBlockController {
|
||||
public static List<Card> orderBlockers(Card attacker, List<Card> blockers) {
|
||||
// ordering of blockers, sort by evaluate, then try to kill the best
|
||||
int damage = attacker.getNetCombatDamage();
|
||||
CardLists.sortByEvaluateCreature(blockers);
|
||||
ComputerUtilCard.sortByEvaluateCreature(blockers);
|
||||
final List<Card> first = new ArrayList<Card>();
|
||||
final List<Card> last = new ArrayList<Card>();
|
||||
for (Card blocker : blockers) {
|
||||
@@ -780,7 +786,7 @@ public class AiBlockController {
|
||||
// This shouldn't really take trample into account, but otherwise should be pretty similar to orderBlockers
|
||||
// ordering of blockers, sort by evaluate, then try to kill the best
|
||||
int damage = blocker.getNetCombatDamage();
|
||||
CardLists.sortByEvaluateCreature(attackers);
|
||||
ComputerUtilCard.sortByEvaluateCreature(attackers);
|
||||
final List<Card> first = new ArrayList<Card>();
|
||||
final List<Card> last = new ArrayList<Card>();
|
||||
for (Card attacker : attackers) {
|
||||
1458
forge-ai/src/main/java/forge/ai/AiController.java
Normal file
1458
forge-ai/src/main/java/forge/ai/AiController.java
Normal file
File diff suppressed because it is too large
Load Diff
591
forge-ai/src/main/java/forge/ai/AiCostDecision.java
Normal file
591
forge-ai/src/main/java/forge/ai/AiCostDecision.java
Normal file
@@ -0,0 +1,591 @@
|
||||
package forge.ai;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.card.CardType;
|
||||
import forge.game.Game;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.card.CardPredicates;
|
||||
import forge.game.card.CardPredicates.Presets;
|
||||
import forge.game.card.CounterType;
|
||||
import forge.game.cost.*;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class AiCostDecision extends CostDecisionMakerBase implements ICostVisitor<PaymentDecision> {
|
||||
|
||||
|
||||
private final SpellAbility ability;
|
||||
private final Card source;
|
||||
|
||||
public AiCostDecision(Player ai0, SpellAbility sa) {
|
||||
super(ai0);
|
||||
ability = sa;
|
||||
source = ability.getHostCard();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaymentDecision visit(CostAddMana cost) {
|
||||
Integer c = cost.convertAmount();
|
||||
|
||||
if (c == null) {
|
||||
c = AbilityUtils.calculateAmount(source, cost.getAmount(), ability);
|
||||
}
|
||||
|
||||
return PaymentDecision.number(c);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PaymentDecision visit(CostChooseCreatureType cost) {
|
||||
String choice = player.getController().chooseSomeType("Creature", ability, new ArrayList<String>(CardType.getCreatureTypes()), new ArrayList<String>());
|
||||
return PaymentDecision.type(choice);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaymentDecision visit(CostDiscard cost) {
|
||||
final String type = cost.getType();
|
||||
|
||||
final List<Card> hand = player.getCardsIn(ZoneType.Hand);
|
||||
if (type.equals("LastDrawn")) {
|
||||
if (!hand.contains(player.getLastDrawnCard())) {
|
||||
return null;
|
||||
}
|
||||
return PaymentDecision.card(player.getLastDrawnCard());
|
||||
}
|
||||
else if (cost.payCostFromSource()) {
|
||||
if (!hand.contains(source)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return PaymentDecision.card(source);
|
||||
}
|
||||
else if (type.equals("Hand")) {
|
||||
return PaymentDecision.card(hand);
|
||||
}
|
||||
|
||||
if (type.contains("WithSameName")) {
|
||||
return null;
|
||||
}
|
||||
Integer c = cost.convertAmount();
|
||||
if (c == null) {
|
||||
final String sVar = ability.getSVar(cost.getAmount());
|
||||
if (sVar.equals("XChoice")) {
|
||||
return null;
|
||||
}
|
||||
c = AbilityUtils.calculateAmount(source, cost.getAmount(), ability);
|
||||
}
|
||||
|
||||
if (type.equals("Random")) {
|
||||
return PaymentDecision.card(CardLists.getRandomSubList(hand, c));
|
||||
}
|
||||
else {
|
||||
final AiController aic = ((PlayerControllerAi)player.getController()).getAi();
|
||||
return PaymentDecision.card(aic.getCardsToDiscard(c, type.split(";"), ability));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaymentDecision visit(CostDamage cost) {
|
||||
Integer c = cost.convertAmount();
|
||||
|
||||
if (c == null) {
|
||||
final String sVar = ability.getSVar(cost.getAmount());
|
||||
// Generalize cost
|
||||
if (sVar.equals("XChoice")) {
|
||||
return null; // cannot pay
|
||||
} else {
|
||||
c = AbilityUtils.calculateAmount(source, cost.getAmount(), ability);
|
||||
}
|
||||
}
|
||||
|
||||
return PaymentDecision.number(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaymentDecision visit(CostDraw cost) {
|
||||
Integer c = cost.convertAmount();
|
||||
|
||||
if (c == null) {
|
||||
c = AbilityUtils.calculateAmount(source, cost.getAmount(), ability);
|
||||
}
|
||||
|
||||
return PaymentDecision.number(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaymentDecision visit(CostExile cost) {
|
||||
if (cost.payCostFromSource()) {
|
||||
return PaymentDecision.card(source);
|
||||
}
|
||||
|
||||
if (cost.getType().equals("All")) {
|
||||
return PaymentDecision.card(player.getCardsIn(cost.getFrom()));
|
||||
}
|
||||
else if (cost.getType().contains("FromTopGrave")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Integer c = cost.convertAmount();
|
||||
if (c == null) {
|
||||
final String sVar = ability.getSVar(cost.getAmount());
|
||||
// Generalize cost
|
||||
if (sVar.equals("XChoice")) {
|
||||
return null;
|
||||
}
|
||||
c = AbilityUtils.calculateAmount(source, cost.getAmount(), ability);
|
||||
}
|
||||
|
||||
if (cost.getFrom().equals(ZoneType.Library)) {
|
||||
return PaymentDecision.card(player.getCardsIn(ZoneType.Library, c));
|
||||
}
|
||||
else if (cost.sameZone) {
|
||||
// TODO Determine exile from same zone for AI
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
List<Card> chosen = ComputerUtil.chooseExileFrom(player, cost.getFrom(), cost.getType(), source, ability.getTargetCard(), c);
|
||||
return null == chosen ? null : PaymentDecision.card(chosen);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PaymentDecision visit(CostExiledMoveToGrave cost) {
|
||||
Integer c = cost.convertAmount();
|
||||
List<Card> chosen = new ArrayList<Card>();
|
||||
|
||||
if (c == null) {
|
||||
c = AbilityUtils.calculateAmount(source, cost.getAmount(), ability);
|
||||
}
|
||||
|
||||
List<Card> typeList = player.getGame().getCardsIn(ZoneType.Exile);
|
||||
|
||||
typeList = CardLists.getValidCards(typeList, cost.getType().split(";"), player, source);
|
||||
|
||||
if (typeList.size() < c) {
|
||||
return null;
|
||||
}
|
||||
|
||||
CardLists.sortByPowerAsc(typeList);
|
||||
Collections.reverse(typeList);
|
||||
|
||||
for (int i = 0; i < c; i++) {
|
||||
chosen.add(typeList.get(i));
|
||||
}
|
||||
|
||||
return chosen.isEmpty() ? null : PaymentDecision.card(chosen);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaymentDecision visit(CostFlipCoin cost) {
|
||||
Integer c = cost.convertAmount();
|
||||
if (c == null) {
|
||||
final String sVar = ability.getSVar(cost.getAmount());
|
||||
// Generalize cost
|
||||
if (sVar.equals("XChoice")) {
|
||||
return null;
|
||||
}
|
||||
c = AbilityUtils.calculateAmount(source, cost.getAmount(), ability);
|
||||
}
|
||||
return PaymentDecision.number(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaymentDecision visit(CostGainControl cost) {
|
||||
if (cost.payCostFromSource())
|
||||
return PaymentDecision.card(source);
|
||||
|
||||
Integer c = cost.convertAmount();
|
||||
if (c == null) {
|
||||
c = AbilityUtils.calculateAmount(source, cost.getAmount(), ability);
|
||||
}
|
||||
|
||||
final List<Card> typeList = CardLists.getValidCards(player.getGame().getCardsIn(ZoneType.Battlefield), cost.getType().split(";"), player, source);
|
||||
|
||||
|
||||
if (typeList.size() < c) {
|
||||
return null;
|
||||
}
|
||||
|
||||
CardLists.sortByPowerAsc(typeList);
|
||||
final List<Card> res = new ArrayList<Card>();
|
||||
|
||||
for (int i = 0; i < c; i++) {
|
||||
res.add(typeList.get(i));
|
||||
}
|
||||
return res.isEmpty() ? null : PaymentDecision.card(res);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PaymentDecision visit(CostGainLife cost) {
|
||||
final List<Player> oppsThatCanGainLife = new ArrayList<Player>();
|
||||
|
||||
for (final Player opp : cost.getPotentialTargets(player, source)) {
|
||||
if (opp.canGainLife()) {
|
||||
oppsThatCanGainLife.add(opp);
|
||||
}
|
||||
}
|
||||
|
||||
if (oppsThatCanGainLife.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return PaymentDecision.players(oppsThatCanGainLife);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PaymentDecision visit(CostMill cost) {
|
||||
Integer c = cost.convertAmount();
|
||||
if (c == null) {
|
||||
final String sVar = ability.getSVar(cost.getAmount());
|
||||
// Generalize cost
|
||||
if (sVar.equals("XChoice")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
c = AbilityUtils.calculateAmount(source, cost.getAmount(), ability);
|
||||
}
|
||||
|
||||
List<Card> topLib = player.getCardsIn(ZoneType.Library, c);
|
||||
return topLib.size() < c ? null : PaymentDecision.card(topLib);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaymentDecision visit(CostPartMana cost) {
|
||||
return PaymentDecision.number(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaymentDecision visit(CostPayLife cost) {
|
||||
Integer c = cost.convertAmount();
|
||||
if (c == null) {
|
||||
final String sVar = ability.getSVar(cost.getAmount());
|
||||
// Generalize cost
|
||||
if (sVar.equals("XChoice")) {
|
||||
return null;
|
||||
} else {
|
||||
c = AbilityUtils.calculateAmount(source, cost.getAmount(), ability);
|
||||
}
|
||||
}
|
||||
if (!player.canPayLife(c)) {
|
||||
return null;
|
||||
}
|
||||
// activator.payLife(c, null);
|
||||
return PaymentDecision.number(c);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PaymentDecision visit(CostPutCardToLib cost) {
|
||||
Integer c = cost.convertAmount();
|
||||
final Game game = player.getGame();
|
||||
List<Card> chosen = new ArrayList<Card>();
|
||||
List<Card> list;
|
||||
|
||||
if (cost.isSameZone()) {
|
||||
list = new ArrayList<Card>(game.getCardsIn(cost.getFrom()));
|
||||
} else {
|
||||
list = new ArrayList<Card>(player.getCardsIn(cost.getFrom()));
|
||||
}
|
||||
|
||||
if (c == null) {
|
||||
final String sVar = ability.getSVar(cost.getAmount());
|
||||
// Generalize cost
|
||||
if (sVar.equals("XChoice")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
c = AbilityUtils.calculateAmount(source, cost.getAmount(), ability);
|
||||
}
|
||||
|
||||
list = CardLists.getValidCards(list, cost.getType().split(";"), player, source);
|
||||
|
||||
if (cost.isSameZone()) {
|
||||
// Jotun Grunt
|
||||
// TODO: improve AI
|
||||
final List<Player> players = game.getPlayers();
|
||||
for (Player p : players) {
|
||||
List<Card> enoughType = CardLists.filter(list, CardPredicates.isOwner(p));
|
||||
if (enoughType.size() >= c) {
|
||||
chosen.addAll(enoughType);
|
||||
break;
|
||||
}
|
||||
}
|
||||
chosen = chosen.subList(0, c);
|
||||
} else {
|
||||
chosen = ComputerUtil.choosePutToLibraryFrom(player, cost.getFrom(), cost.getType(), source, ability.getTargetCard(), c);
|
||||
}
|
||||
return chosen.isEmpty() ? null : PaymentDecision.card(chosen);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaymentDecision visit(CostPutCounter cost) {
|
||||
|
||||
if (cost.payCostFromSource()) {
|
||||
return PaymentDecision.card(source);
|
||||
|
||||
}
|
||||
|
||||
final List<Card> typeList = CardLists.getValidCards(player.getGame().getCardsIn(ZoneType.Battlefield), cost.getType().split(";"), player, source);
|
||||
|
||||
Card card = null;
|
||||
if (cost.getType().equals("Creature.YouCtrl")) {
|
||||
card = ComputerUtilCard.getWorstCreatureAI(typeList);
|
||||
} else {
|
||||
card = ComputerUtilCard.getWorstPermanentAI(typeList, false, false, false, false);
|
||||
}
|
||||
return PaymentDecision.card(card);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PaymentDecision visit(CostTap cost) {
|
||||
return PaymentDecision.number(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaymentDecision visit(CostTapType cost) {
|
||||
final String amount = cost.getAmount();
|
||||
Integer c = cost.convertAmount();
|
||||
if (c == null) {
|
||||
final String sVar = ability.getSVar(amount);
|
||||
if (sVar.equals("XChoice")) {
|
||||
List<Card> typeList =
|
||||
CardLists.getValidCards(player.getCardsIn(ZoneType.Battlefield), cost.getType().split(";"), ability.getActivatingPlayer(), ability.getHostCard());
|
||||
typeList = CardLists.filter(typeList, Presets.UNTAPPED);
|
||||
c = typeList.size();
|
||||
source.setSVar("ChosenX", "Number$" + Integer.toString(c));
|
||||
} else {
|
||||
c = AbilityUtils.calculateAmount(source, amount, ability);
|
||||
}
|
||||
}
|
||||
if (cost.getType().contains("sharesCreatureTypeWith") || cost.getType().contains("withTotalPowerGE")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<Card> totap = ComputerUtil.chooseTapType(player, cost.getType(), source, !cost.canTapSource, c);
|
||||
|
||||
|
||||
if (totap == null) {
|
||||
System.out.println("Couldn't find a valid card to tap for: " + source.getName());
|
||||
return null;
|
||||
}
|
||||
|
||||
return PaymentDecision.card(totap);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PaymentDecision visit(CostSacrifice cost) {
|
||||
if (cost.payCostFromSource()) {
|
||||
return PaymentDecision.card(source);
|
||||
}
|
||||
if (cost.getAmount().equals("All")) {
|
||||
/*List<Card> typeList = new ArrayList<Card>(activator.getCardsIn(ZoneType.Battlefield));
|
||||
typeList = CardLists.getValidCards(typeList, cost.getType().split(";"), activator, source);
|
||||
if (activator.hasKeyword("You can't sacrifice creatures to cast spells or activate abilities.")) {
|
||||
typeList = CardLists.getNotType(typeList, "Creature");
|
||||
}*/
|
||||
// Does the AI want to use Sacrifice All?
|
||||
return null;
|
||||
}
|
||||
|
||||
Integer c = cost.convertAmount();
|
||||
if (c == null) {
|
||||
if (ability.getSVar(cost.getAmount()).equals("XChoice")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
c = AbilityUtils.calculateAmount(source, cost.getAmount(), ability);
|
||||
}
|
||||
List<Card> list = ComputerUtil.chooseSacrificeType(player, cost.getType(), source, ability.getTargetCard(), c);
|
||||
return PaymentDecision.card(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaymentDecision visit(CostReturn cost) {
|
||||
if (cost.payCostFromSource())
|
||||
return PaymentDecision.card(source);
|
||||
|
||||
Integer c = cost.convertAmount();
|
||||
if (c == null) {
|
||||
c = AbilityUtils.calculateAmount(source, cost.getAmount(), ability);
|
||||
}
|
||||
|
||||
List<Card> res = ComputerUtil.chooseReturnType(player, cost.getType(), source, ability.getTargetCard(), c);
|
||||
return res.isEmpty() ? null : PaymentDecision.card(res);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaymentDecision visit(CostReveal cost) {
|
||||
|
||||
final String type = cost.getType();
|
||||
List<Card> hand = new ArrayList<Card>(player.getCardsIn(ZoneType.Hand));
|
||||
|
||||
if (cost.payCostFromSource()) {
|
||||
if (!hand.contains(source)) {
|
||||
return null;
|
||||
}
|
||||
return PaymentDecision.card(source);
|
||||
}
|
||||
|
||||
if (cost.getType().equals("Hand"))
|
||||
return PaymentDecision.card(player.getCardsIn(ZoneType.Hand));
|
||||
|
||||
if (cost.getType().equals("SameColor")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
hand = CardLists.getValidCards(hand, type.split(";"), player, source);
|
||||
Integer c = cost.convertAmount();
|
||||
if (c == null) {
|
||||
final String sVar = ability.getSVar(cost.getAmount());
|
||||
if (sVar.equals("XChoice")) {
|
||||
c = hand.size();
|
||||
} else {
|
||||
c = AbilityUtils.calculateAmount(source, cost.getAmount(), ability);
|
||||
}
|
||||
}
|
||||
|
||||
final AiController aic = ((PlayerControllerAi)player.getController()).getAi();
|
||||
return PaymentDecision.card(aic.getCardsToDiscard(c, type.split(";"), ability));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaymentDecision visit(CostRemoveAnyCounter cost) {
|
||||
final String amount = cost.getAmount();
|
||||
final int c = AbilityUtils.calculateAmount(source, amount, ability);
|
||||
final String type = cost.getType();
|
||||
|
||||
List<Card> typeList = CardLists.getValidCards(player.getCardsIn(ZoneType.Battlefield), type.split(";"), player, source);
|
||||
List<Card> hperms = CardLists.filter(typeList, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card crd) {
|
||||
for (final CounterType c1 : CounterType.values()) {
|
||||
if (crd.getCounters(c1) >= c && ComputerUtil.isNegativeCounter(c1, crd)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
if(hperms.isEmpty())
|
||||
return null;
|
||||
|
||||
PaymentDecision result = PaymentDecision.card(hperms);
|
||||
Card valid = hperms.get(0);
|
||||
for (CounterType c1 : valid.getCounters().keySet()) {
|
||||
if (valid.getCounters(c1) >= c && ComputerUtil.isNegativeCounter(c1, valid)) {
|
||||
result.ct = c1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Only find cards with enough negative counters
|
||||
// TODO: add ai for Chisei, Heart of Oceans
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaymentDecision visit(CostRemoveCounter cost) {
|
||||
final String amount = cost.getAmount();
|
||||
Integer c = cost.convertAmount();
|
||||
final String type = cost.getType();
|
||||
|
||||
if (c == null) {
|
||||
final String sVar = ability.getSVar(amount);
|
||||
if (sVar.equals("XChoice")) {
|
||||
return null;
|
||||
}
|
||||
if (amount.equals("All")) {
|
||||
c = source.getCounters(cost.counter);
|
||||
} else {
|
||||
c = AbilityUtils.calculateAmount(source, amount, ability);
|
||||
}
|
||||
}
|
||||
|
||||
if (!cost.payCostFromSource()) {
|
||||
List<Card> typeList;
|
||||
if (type.equals("OriginalHost")) {
|
||||
typeList = Lists.newArrayList(ability.getOriginalHost());
|
||||
} else {
|
||||
typeList = CardLists.getValidCards(player.getCardsIn(cost.zone), type.split(";"), player, source);
|
||||
}
|
||||
for (Card card : typeList) {
|
||||
if (card.getCounters(cost.counter) >= c) {
|
||||
return PaymentDecision.card(card, c);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
if (c > source.getCounters(cost.counter)) {
|
||||
System.out.println("Not enough " + cost.counter + " on " + source.getName());
|
||||
return null;
|
||||
}
|
||||
|
||||
return PaymentDecision.card(source, c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaymentDecision visit(CostUntapType cost) {
|
||||
final String amount = cost.getAmount();
|
||||
Integer c = cost.convertAmount();
|
||||
if (c == null) {
|
||||
final String sVar = ability.getSVar(amount);
|
||||
if (sVar.equals("XChoice")) {
|
||||
List<Card> typeList = player.getGame().getCardsIn(ZoneType.Battlefield);
|
||||
typeList = CardLists.getValidCards(typeList, cost.getType().split(";"), player, ability.getHostCard());
|
||||
if (!cost.canUntapSource) {
|
||||
typeList.remove(source);
|
||||
}
|
||||
typeList = CardLists.filter(typeList, Presets.TAPPED);
|
||||
c = typeList.size();
|
||||
source.setSVar("ChosenX", "Number$" + Integer.toString(c));
|
||||
} else {
|
||||
c = AbilityUtils.calculateAmount(source, amount, ability);
|
||||
}
|
||||
}
|
||||
|
||||
List<Card> list = ComputerUtil.chooseUntapType(player, cost.getType(), source, cost.canUntapSource, c);
|
||||
|
||||
if (list == null) {
|
||||
System.out.println("Couldn't find a valid card to untap for: " + source.getName());
|
||||
return null;
|
||||
}
|
||||
|
||||
return PaymentDecision.card(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaymentDecision visit(CostUntap cost) {
|
||||
return PaymentDecision.number(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaymentDecision visit(CostUnattach cost) {
|
||||
Card cardToUnattach = cost.findCardToUnattach(source, (Player) player, ability);
|
||||
if (cardToUnattach == null) {
|
||||
// We really shouldn't be able to get here if there's nothing to unattach
|
||||
return null;
|
||||
}
|
||||
return PaymentDecision.card(cardToUnattach);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean paysRightAfterDecision() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
20
forge-ai/src/main/java/forge/ai/AiPlayDecision.java
Normal file
20
forge-ai/src/main/java/forge/ai/AiPlayDecision.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package forge.ai;
|
||||
|
||||
public enum AiPlayDecision {
|
||||
WillPlay,
|
||||
CantPlaySa,
|
||||
CantPlayAi,
|
||||
CantAfford,
|
||||
CantAffordX,
|
||||
WaitForMain2,
|
||||
AnotherTime,
|
||||
MissingNeededCards,
|
||||
NeedsToPlayCriteriaNotMet,
|
||||
TargetingFailed,
|
||||
CostNotAcceptable,
|
||||
WouldDestroyLegend,
|
||||
WouldDestroyOtherPlaneswalker,
|
||||
WouldBecomeZeroToughnessCreature,
|
||||
WouldDestroyWorldEnchantment,
|
||||
BadEtbEffects;
|
||||
}
|
||||
@@ -15,20 +15,19 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package forge.game.ai;
|
||||
package forge.ai;
|
||||
|
||||
import forge.game.player.LobbyPlayer;
|
||||
import forge.game.player.LobbyPlayerAi;
|
||||
import forge.util.Aggregates;
|
||||
import forge.util.FileUtil;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
|
||||
/**
|
||||
* Holds default AI personality profile values in an enum.
|
||||
@@ -15,7 +15,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package forge.game.ai;
|
||||
package forge.ai;
|
||||
|
||||
/**
|
||||
* AI personality profile settings identifiers, and their default values.
|
||||
@@ -28,7 +28,8 @@ public enum AiProps { /** */
|
||||
DEFAULT_MIN_TURN_TO_ROLL_PLANAR_DIE ("3"), /** */
|
||||
DEFAULT_PLANAR_DIE_ROLL_CHANCE ("50"), /** */
|
||||
MULLIGAN_THRESHOLD ("5"), /** */
|
||||
PLANAR_DIE_ROLL_HESITATION_CHANCE ("10"); /** */
|
||||
PLANAR_DIE_ROLL_HESITATION_CHANCE ("10"),
|
||||
CHEAT_WITH_MANA_ON_SHUFFLE ("FALSE"); /** */
|
||||
|
||||
private final String strDefaultVal;
|
||||
|
||||
@@ -15,60 +15,44 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package forge.game.ai;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
package forge.ai;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CardPredicates;
|
||||
import forge.Constant;
|
||||
import forge.CounterType;
|
||||
import forge.CardPredicates.Presets;
|
||||
import forge.CardUtil;
|
||||
import forge.ITargetable;
|
||||
import forge.card.CardType;
|
||||
import forge.card.CardType.Constant;
|
||||
import forge.card.MagicColor;
|
||||
import forge.card.ability.AbilityFactory;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.ApiType;
|
||||
import forge.card.ability.effects.CharmEffect;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.cost.CostDiscard;
|
||||
import forge.card.cost.CostPart;
|
||||
import forge.card.cost.CostPayment;
|
||||
import forge.card.cost.CostSacrifice;
|
||||
import forge.card.spellability.AbilityManaPart;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.SpellAbilityStackInstance;
|
||||
import forge.card.spellability.TargetRestrictions;
|
||||
import forge.card.staticability.StaticAbility;
|
||||
import forge.card.trigger.Trigger;
|
||||
import forge.card.trigger.TriggerType;
|
||||
import forge.error.BugReporter;
|
||||
import forge.game.Game;
|
||||
import forge.game.GameObject;
|
||||
import forge.game.ability.AbilityFactory;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.ability.ApiType;
|
||||
import forge.game.ability.effects.CharmEffect;
|
||||
import forge.game.card.*;
|
||||
import forge.game.card.CardPredicates.Presets;
|
||||
import forge.game.combat.Combat;
|
||||
import forge.game.combat.CombatUtil;
|
||||
import forge.game.cost.*;
|
||||
import forge.game.phase.PhaseHandler;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.PlayerControllerAi;
|
||||
import forge.game.spellability.AbilityManaPart;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.SpellAbilityStackInstance;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
import forge.game.staticability.StaticAbility;
|
||||
import forge.game.trigger.Trigger;
|
||||
import forge.game.trigger.TriggerType;
|
||||
import forge.game.zone.Zone;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.gui.GuiChoose;
|
||||
import forge.util.Aggregates;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -86,24 +70,28 @@ public class ComputerUtil {
|
||||
* </p>
|
||||
*
|
||||
* @param sa
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
* @return a boolean.
|
||||
*/
|
||||
public static boolean handlePlayingSpellAbility(final Player ai, final SpellAbility sa, final Game game) {
|
||||
|
||||
game.getStack().freezeStack();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
if (sa.isSpell() && !source.isCopiedSpell()) {
|
||||
sa.setSourceCard(game.getAction().moveToStack(source));
|
||||
sa.setHostCard(game.getAction().moveToStack(source));
|
||||
}
|
||||
|
||||
if (sa.getApi() == ApiType.Charm && !sa.isWrapper()) {
|
||||
CharmEffect.makeChoices(sa);
|
||||
}
|
||||
|
||||
final Cost cost = sa.getPayCosts();
|
||||
if (sa.hasParam("Bestow")) {
|
||||
sa.getHostCard().animateBestow();
|
||||
}
|
||||
|
||||
final Cost cost = sa.getPayCosts();
|
||||
// TODO: update mana color conversion for Daxos of Meletis
|
||||
if (cost == null) {
|
||||
if (ComputerUtilMana.payManaCost(ai, sa)) {
|
||||
game.getStack().addAndUnfreeze(sa);
|
||||
@@ -111,18 +99,16 @@ public class ComputerUtil {
|
||||
}
|
||||
} else {
|
||||
final CostPayment pay = new CostPayment(cost, sa);
|
||||
if (pay.payComputerCosts(ai, game)) {
|
||||
if (pay.payComputerCosts(new AiCostDecision(ai, sa))) {
|
||||
game.getStack().addAndUnfreeze(sa);
|
||||
if (sa.getSplicedCards() != null && !sa.getSplicedCards().isEmpty()) {
|
||||
GuiChoose.oneOrNone("Computer reveals spliced cards:", sa.getSplicedCards());
|
||||
game.getAction().reveal(sa.getSplicedCards(), ai, true, "Computer reveals spliced cards from ");
|
||||
}
|
||||
return true;
|
||||
// TODO: solve problems with TapsForMana triggers by adding
|
||||
// sources tapped here if possible (ArsenalNut)
|
||||
}
|
||||
}
|
||||
//Should not arrive here
|
||||
System.out.println("AI failed to play " + sa.getSourceCard());
|
||||
System.out.println("AI failed to play " + sa.getHostCard());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -147,7 +133,7 @@ public class ComputerUtil {
|
||||
* </p>
|
||||
*
|
||||
* @param sa
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
* @return a int.
|
||||
*/
|
||||
public static int counterSpellRestriction(final Player ai, final SpellAbility sa) {
|
||||
@@ -156,7 +142,7 @@ public class ComputerUtil {
|
||||
|
||||
int restrict = 0;
|
||||
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
|
||||
|
||||
@@ -204,8 +190,9 @@ public class ComputerUtil {
|
||||
|
||||
// And lastly give some bonus points to least restrictive TargetType
|
||||
// (Spell,Ability,Triggered)
|
||||
final String tgtType = tgt.getTargetSpellAbilityType();
|
||||
restrict -= (5 * tgtType.split(",").length);
|
||||
final String tgtType = sa.getParam("TargetType");
|
||||
if (tgtType != null)
|
||||
restrict -= (5 * tgtType.split(",").length);
|
||||
|
||||
return restrict;
|
||||
}
|
||||
@@ -217,16 +204,16 @@ public class ComputerUtil {
|
||||
* </p>
|
||||
*
|
||||
* @param sa
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
*/
|
||||
public static final void playStack(final SpellAbility sa, final Player ai, final Game game) {
|
||||
sa.setActivatingPlayer(ai);
|
||||
if (!ComputerUtilCost.canPayCost(sa, ai))
|
||||
return;
|
||||
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
if (sa.isSpell() && !source.isCopiedSpell()) {
|
||||
sa.setSourceCard(game.getAction().moveToStack(source));
|
||||
sa.setHostCard(game.getAction().moveToStack(source));
|
||||
}
|
||||
final Cost cost = sa.getPayCosts();
|
||||
if (cost == null) {
|
||||
@@ -234,7 +221,7 @@ public class ComputerUtil {
|
||||
game.getStack().add(sa);
|
||||
} else {
|
||||
final CostPayment pay = new CostPayment(cost, sa);
|
||||
if (pay.payComputerCosts(ai, game)) {
|
||||
if (pay.payComputerCosts(new AiCostDecision(ai, sa))) {
|
||||
game.getStack().add(sa);
|
||||
}
|
||||
}
|
||||
@@ -246,14 +233,14 @@ public class ComputerUtil {
|
||||
* </p>
|
||||
*
|
||||
* @param sa
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
*/
|
||||
public static final void playSpellAbilityForFree(final Player ai, final SpellAbility sa) {
|
||||
sa.setActivatingPlayer(ai);
|
||||
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
if (sa.isSpell() && !source.isCopiedSpell()) {
|
||||
sa.setSourceCard(ai.getGame().getAction().moveToStack(source));
|
||||
sa.setHostCard(ai.getGame().getAction().moveToStack(source));
|
||||
}
|
||||
|
||||
ai.getGame().getStack().add(sa);
|
||||
@@ -265,7 +252,7 @@ public class ComputerUtil {
|
||||
* </p>
|
||||
*
|
||||
* @param sa
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
*/
|
||||
public static final void playSpellAbilityWithoutPayingManaCost(final Player ai, final SpellAbility sa, final Game game) {
|
||||
final SpellAbility newSA = sa.copyWithNoManaCost();
|
||||
@@ -275,13 +262,13 @@ public class ComputerUtil {
|
||||
return;
|
||||
}
|
||||
|
||||
final Card source = newSA.getSourceCard();
|
||||
final Card source = newSA.getHostCard();
|
||||
if (newSA.isSpell() && !source.isCopiedSpell()) {
|
||||
newSA.setSourceCard(game.getAction().moveToStack(source));
|
||||
newSA.setHostCard(game.getAction().moveToStack(source));
|
||||
}
|
||||
|
||||
final CostPayment pay = new CostPayment(newSA.getPayCosts(), newSA);
|
||||
pay.payComputerCosts(ai, game);
|
||||
pay.payComputerCosts(new AiCostDecision(ai, sa));
|
||||
|
||||
game.getStack().add(newSA);
|
||||
}
|
||||
@@ -292,15 +279,15 @@ public class ComputerUtil {
|
||||
* </p>
|
||||
*
|
||||
* @param sa
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
*/
|
||||
public static final void playNoStack(final Player ai, final SpellAbility sa, final Game game) {
|
||||
sa.setActivatingPlayer(ai);
|
||||
// TODO: We should really restrict what doesn't use the Stack
|
||||
if (ComputerUtilCost.canPayCost(sa, ai)) {
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
if (sa.isSpell() && !source.isCopiedSpell()) {
|
||||
sa.setSourceCard(game.getAction().moveToStack(source));
|
||||
sa.setHostCard(game.getAction().moveToStack(source));
|
||||
}
|
||||
|
||||
final Cost cost = sa.getPayCosts();
|
||||
@@ -308,7 +295,7 @@ public class ComputerUtil {
|
||||
ComputerUtilMana.payManaCost(ai, sa);
|
||||
} else {
|
||||
final CostPayment pay = new CostPayment(cost, sa);
|
||||
pay.payComputerCosts(ai, game);
|
||||
pay.payComputerCosts(new AiCostDecision(ai, sa));
|
||||
}
|
||||
|
||||
AbilityUtils.resolve(sa);
|
||||
@@ -324,12 +311,12 @@ public class ComputerUtil {
|
||||
* </p>
|
||||
*
|
||||
* @param activate
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param pref
|
||||
* a {@link java.lang.String} object.
|
||||
* @param typeList
|
||||
* a {@link forge.CardList} object.
|
||||
* @return a {@link forge.Card} object.
|
||||
* @return a {@link forge.game.card.Card} object.
|
||||
*/
|
||||
public static Card getCardPreference(final Player ai, final Card activate, final String pref, final List<Card> typeList) {
|
||||
|
||||
@@ -414,9 +401,9 @@ public class ComputerUtil {
|
||||
* @param type
|
||||
* a {@link java.lang.String} object.
|
||||
* @param source
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param target
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param amount
|
||||
* a int.
|
||||
* @return a {@link forge.CardList} object.
|
||||
@@ -463,9 +450,9 @@ public class ComputerUtil {
|
||||
* @param type
|
||||
* a {@link java.lang.String} object.
|
||||
* @param activate
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param target
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param amount
|
||||
* a int.
|
||||
* @return a {@link forge.CardList} object.
|
||||
@@ -510,9 +497,9 @@ public class ComputerUtil {
|
||||
* @param type
|
||||
* a {@link java.lang.String} object.
|
||||
* @param activate
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param target
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param amount
|
||||
* a int.
|
||||
* @return a {@link forge.CardList} object.
|
||||
@@ -553,7 +540,7 @@ public class ComputerUtil {
|
||||
* @param type
|
||||
* a {@link java.lang.String} object.
|
||||
* @param activate
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param tap
|
||||
* a boolean.
|
||||
* @param amount
|
||||
@@ -593,7 +580,7 @@ public class ComputerUtil {
|
||||
* @param type
|
||||
* a {@link java.lang.String} object.
|
||||
* @param activate
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param untap
|
||||
* a boolean.
|
||||
* @param amount
|
||||
@@ -633,9 +620,9 @@ public class ComputerUtil {
|
||||
* @param type
|
||||
* a {@link java.lang.String} object.
|
||||
* @param activate
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param target
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param amount
|
||||
* a int.
|
||||
* @return a {@link forge.CardList} object.
|
||||
@@ -763,7 +750,7 @@ public class ComputerUtil {
|
||||
* @param ai
|
||||
*
|
||||
* @param card
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @return a boolean.
|
||||
*/
|
||||
public static boolean canRegenerate(Player ai, final Card card) {
|
||||
@@ -807,16 +794,16 @@ public class ComputerUtil {
|
||||
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
if (tgt != null) {
|
||||
if (CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), controller, sa.getSourceCard()).contains(card)) {
|
||||
if (CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), controller, sa.getHostCard()).contains(card)) {
|
||||
return true;
|
||||
}
|
||||
} else if (AbilityUtils.getDefinedCards(sa.getSourceCard(), sa.getParam("Defined"), sa).contains(card)) {
|
||||
} else if (AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("Defined"), sa).contains(card)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
} catch (final Exception ex) {
|
||||
BugReporter.reportException(ex, "There is an error in the card code for %s:%n", c.getName(), ex.getMessage());
|
||||
}
|
||||
} catch (final Exception ex) {
|
||||
throw new RuntimeException(String.format("There is an error in the card code for %s:%n", c.getName(), ex.getMessage()), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -828,7 +815,7 @@ public class ComputerUtil {
|
||||
* </p>
|
||||
*
|
||||
* @param card
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @return a int.
|
||||
*/
|
||||
public static int possibleDamagePrevention(final Card card) {
|
||||
@@ -850,20 +837,19 @@ public class ComputerUtil {
|
||||
|
||||
if (sa.getApi() == ApiType.PreventDamage && sa.canPlay()
|
||||
&& ComputerUtilCost.canPayCost(sa, controller)) {
|
||||
if (AbilityUtils.getDefinedCards(sa.getSourceCard(), sa.getParam("Defined"), sa).contains(card)) {
|
||||
prevented += AbilityUtils.calculateAmount(sa.getSourceCard(), sa.getParam("Amount"), sa);
|
||||
if (AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("Defined"), sa).contains(card)) {
|
||||
prevented += AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("Amount"), sa);
|
||||
}
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
if (tgt != null) {
|
||||
if (CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), controller, sa.getSourceCard()).contains(card)) {
|
||||
prevented += AbilityUtils.calculateAmount(sa.getSourceCard(), sa.getParam("Amount"), sa);
|
||||
if (CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), controller, sa.getHostCard()).contains(card)) {
|
||||
prevented += AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("Amount"), sa);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} catch (final Exception ex) {
|
||||
BugReporter.reportException(ex, "There is an error in the card code for %s:%n", c.getName(),
|
||||
ex.getMessage());
|
||||
throw new RuntimeException(String.format("There is an error in the card code for %s:%n", c.getName(), ex.getMessage()), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -880,7 +866,7 @@ public class ComputerUtil {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public static boolean castPermanentInMain1(final Player ai, final SpellAbility sa) {
|
||||
final Card card = sa.getSourceCard();
|
||||
final Card card = sa.getHostCard();
|
||||
if ("True".equals(card.getSVar("NonStackingEffect")) && card.getController().isCardInPlay(card.getName())) {
|
||||
return false;
|
||||
}
|
||||
@@ -1044,19 +1030,19 @@ public class ComputerUtil {
|
||||
* </p>
|
||||
*
|
||||
* @param sa
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
* @return a boolean (returns true if it's better to wait until blockers are declared).
|
||||
*/
|
||||
public static boolean waitForBlocking(final SpellAbility sa) {
|
||||
final Game game = sa.getActivatingPlayer().getGame();
|
||||
final PhaseHandler ph = game.getPhaseHandler();
|
||||
|
||||
return (sa.getSourceCard().isCreature()
|
||||
return (sa.getHostCard().isCreature()
|
||||
&& sa.getPayCosts().hasTapCost()
|
||||
&& (ph.getPhase().isBefore(PhaseType.COMBAT_DECLARE_BLOCKERS)
|
||||
|| !ph.getNextTurn().equals(sa.getActivatingPlayer()))
|
||||
&& !sa.getSourceCard().hasKeyword("At the beginning of the end step, exile CARDNAME.")
|
||||
&& !sa.getSourceCard().hasKeyword("At the beginning of the end step, sacrifice CARDNAME."));
|
||||
&& !sa.getHostCard().hasKeyword("At the beginning of the end step, exile CARDNAME.")
|
||||
&& !sa.getHostCard().hasKeyword("At the beginning of the end step, sacrifice CARDNAME."));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1065,11 +1051,11 @@ public class ComputerUtil {
|
||||
* </p>
|
||||
*
|
||||
* @param sa
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
* @return a boolean (returns true if it's better to wait until blockers are declared).
|
||||
*/
|
||||
public static boolean castSpellInMain1(final Player ai, final SpellAbility sa) {
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final SpellAbility sub = sa.getSubAbility();
|
||||
|
||||
// Cipher spells
|
||||
@@ -1086,7 +1072,7 @@ public class ComputerUtil {
|
||||
}
|
||||
}
|
||||
final List<Card> buffed = ai.getCardsIn(ZoneType.Battlefield);
|
||||
boolean checkThreshold = sa.isSpell() && !ai.hasThreshold() && !sa.getSourceCard().isInZone(ZoneType.Graveyard);
|
||||
boolean checkThreshold = sa.isSpell() && !ai.hasThreshold() && !sa.getHostCard().isInZone(ZoneType.Graveyard);
|
||||
for (Card buffedCard : buffed) {
|
||||
if (buffedCard.hasSVar("BuffedBy")) {
|
||||
final String buffedby = buffedCard.getSVar("BuffedBy");
|
||||
@@ -1131,17 +1117,23 @@ public class ComputerUtil {
|
||||
* </p>
|
||||
*
|
||||
* @param sa
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
* @return a boolean (returns true if the AI should stop using the ability).
|
||||
*/
|
||||
public static boolean preventRunAwayActivations(final SpellAbility sa) {
|
||||
final int activations = sa.getRestrictions().getNumberTurnActivations();
|
||||
int activations = sa.getRestrictions().getNumberTurnActivations();
|
||||
|
||||
if (sa.isTemporary()) {
|
||||
final Random r = MyRandom.getRandom();
|
||||
return r.nextFloat() >= .95; // Abilities created by static abilities have no memory
|
||||
}
|
||||
|
||||
if (activations < 10) { //10 activations per turn should still be acceptable
|
||||
return false;
|
||||
}
|
||||
final Random r = MyRandom.getRandom();
|
||||
|
||||
return r.nextFloat() <= Math.pow(.95, activations);
|
||||
final Random r = MyRandom.getRandom();
|
||||
return r.nextFloat() >= Math.pow(.95, activations);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1151,7 +1143,7 @@ public class ComputerUtil {
|
||||
*/
|
||||
public static boolean activateForCost(SpellAbility sa, final Player ai) {
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
if (abCost == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -1163,6 +1155,12 @@ public class ComputerUtil {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (sa.hasParam("Planeswalker") && ai.getGame().getPhaseHandler().is(PhaseType.MAIN2)) {
|
||||
for (final CostPart part : abCost.getCostParts()) {
|
||||
if (part instanceof CostPutCounter) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (final CostPart part : abCost.getCostParts()) {
|
||||
if (part instanceof CostSacrifice) {
|
||||
@@ -1202,7 +1200,7 @@ public class ComputerUtil {
|
||||
for (final Card c : all) {
|
||||
if (c.isEquipment()) {
|
||||
for (StaticAbility stAb : c.getStaticAbilities()) {
|
||||
HashMap<String, String> params = stAb.getMapParams();
|
||||
Map<String, String> params = stAb.getMapParams();
|
||||
if ("Continuous".equals(params.get("Mode")) && params.containsKey("AddKeyword")
|
||||
&& params.get("AddKeyword").contains("Haste") && c.getEquippingCard() == null) {
|
||||
return true;
|
||||
@@ -1241,7 +1239,7 @@ public class ComputerUtil {
|
||||
continue;
|
||||
}
|
||||
final String numDam = sa.getParam("NumDmg");
|
||||
int dmg = AbilityUtils.calculateAmount(sa.getSourceCard(), numDam, sa);
|
||||
int dmg = AbilityUtils.calculateAmount(sa.getHostCard(), numDam, sa);
|
||||
if (dmg <= damage) {
|
||||
continue;
|
||||
}
|
||||
@@ -1272,9 +1270,9 @@ public class ComputerUtil {
|
||||
* @return a {@link java.util.ArrayList} object.
|
||||
* @since 1.0.15
|
||||
*/
|
||||
public static List<ITargetable> predictThreatenedObjects(final Player aiPlayer, final SpellAbility sa) {
|
||||
public static List<GameObject> predictThreatenedObjects(final Player aiPlayer, final SpellAbility sa) {
|
||||
final Game game = aiPlayer.getGame();
|
||||
final List<ITargetable> objects = new ArrayList<ITargetable>();
|
||||
final List<GameObject> objects = new ArrayList<GameObject>();
|
||||
if (game.getStack().isEmpty()) {
|
||||
return objects;
|
||||
}
|
||||
@@ -1294,21 +1292,21 @@ public class ComputerUtil {
|
||||
* @param saviourAf
|
||||
* a AbilityFactory object
|
||||
* @param topStack
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
* @return a {@link java.util.ArrayList} object.
|
||||
* @since 1.0.15
|
||||
*/
|
||||
private static Iterable<? extends ITargetable> predictThreatenedObjects(final Player aiPlayer, final SpellAbility saviour,
|
||||
private static Iterable<? extends GameObject> predictThreatenedObjects(final Player aiPlayer, final SpellAbility saviour,
|
||||
final SpellAbility topStack) {
|
||||
Iterable<? extends ITargetable> objects = new ArrayList<ITargetable>();
|
||||
final List<ITargetable> threatened = new ArrayList<ITargetable>();
|
||||
Iterable<? extends GameObject> objects = new ArrayList<GameObject>();
|
||||
final List<GameObject> threatened = new ArrayList<GameObject>();
|
||||
ApiType saviourApi = saviour == null ? null : saviour.getApi();
|
||||
|
||||
if (topStack == null) {
|
||||
return objects;
|
||||
}
|
||||
|
||||
final Card source = topStack.getSourceCard();
|
||||
final Card source = topStack.getHostCard();
|
||||
final ApiType threatApi = topStack.getApi();
|
||||
|
||||
// Can only Predict things from AFs
|
||||
@@ -1334,7 +1332,7 @@ public class ComputerUtil {
|
||||
// Lethal Damage => prevent damage/regeneration/bounce/shroud
|
||||
if (threatApi == ApiType.DealDamage || threatApi == ApiType.DamageAll) {
|
||||
// If PredictDamage is >= Lethal Damage
|
||||
final int dmg = AbilityUtils.calculateAmount(topStack.getSourceCard(),
|
||||
final int dmg = AbilityUtils.calculateAmount(topStack.getHostCard(),
|
||||
topStack.getParam("NumDmg"), topStack);
|
||||
for (final Object o : objects) {
|
||||
if (o instanceof Card) {
|
||||
@@ -1346,7 +1344,7 @@ public class ComputerUtil {
|
||||
}
|
||||
|
||||
// already regenerated
|
||||
if (c.getShield() > 0) {
|
||||
if (!c.getShield().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1398,7 +1396,7 @@ public class ComputerUtil {
|
||||
}
|
||||
|
||||
// already regenerated
|
||||
if (c.getShield() > 0) {
|
||||
if (!c.getShield().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1453,7 +1451,7 @@ public class ComputerUtil {
|
||||
}
|
||||
|
||||
public static boolean playImmediately(Player ai, SpellAbility sa) {
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final Zone zone = source.getZone();
|
||||
|
||||
if (zone.getZoneType() == ZoneType.Battlefield) {
|
||||
@@ -1615,6 +1613,22 @@ public class ComputerUtil {
|
||||
// based on whether it needs a creature or land,
|
||||
// otherwise, lib search for most common type left
|
||||
// then, reveal chosenType to Human
|
||||
if (game.getPhaseHandler().is(PhaseType.UNTAP) && logic == null) { // Storage Matrix
|
||||
double amount = 0;
|
||||
for (String type : Constant.CARD_TYPES) {
|
||||
if (!invalidTypes.contains(type)) {
|
||||
List<Card> list = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), CardPredicates.isType(type), Presets.TAPPED);
|
||||
double i = type.equals("Creature") ? list.size() * 1.5 : list.size();
|
||||
if (i > amount) {
|
||||
amount = i;
|
||||
chosen = type;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (StringUtils.isEmpty(chosen)) {
|
||||
chosen = "Creature";
|
||||
}
|
||||
} else if (kindOfType.equals("Creature")) {
|
||||
Player opp = ai.getOpponent();
|
||||
if (logic != null ) {
|
||||
@@ -1646,7 +1660,7 @@ public class ComputerUtil {
|
||||
if (logic.equals("MostNeededType")) {
|
||||
// Choose a type that is in the deck, but not in hand or on the battlefield
|
||||
final ArrayList<String> basics = new ArrayList<String>();
|
||||
basics.addAll(Constant.CardTypes.BASIC_TYPES);
|
||||
basics.addAll(CardType.Constant.BASIC_TYPES);
|
||||
List<Card> presentCards = ai.getCardsIn(ZoneType.Battlefield);
|
||||
presentCards.addAll(ai.getCardsIn(ZoneType.Hand));
|
||||
List<Card> possibleCards = ai.getAllCards();
|
||||
@@ -1696,8 +1710,6 @@ public class ComputerUtil {
|
||||
chosen = "Island";
|
||||
}
|
||||
|
||||
|
||||
GuiChoose.one("Computer picked: ", new String[]{chosen});
|
||||
return chosen;
|
||||
}
|
||||
|
||||
@@ -1725,7 +1737,7 @@ public class ComputerUtil {
|
||||
theTriggers.addAll(card.getTriggers());
|
||||
}
|
||||
for (Trigger trigger : theTriggers) {
|
||||
HashMap<String, String> trigParams = trigger.getMapParams();
|
||||
Map<String, String> trigParams = trigger.getMapParams();
|
||||
final Card source = trigger.getHostCard();
|
||||
|
||||
|
||||
@@ -1782,7 +1794,6 @@ public class ComputerUtil {
|
||||
return damage;
|
||||
}
|
||||
|
||||
// although this should be in AI's code
|
||||
public static boolean isNegativeCounter(CounterType type, Card c) {
|
||||
return type == CounterType.AGE || type == CounterType.BLAZE || type == CounterType.BRIBERY || type == CounterType.DOOM
|
||||
|| type == CounterType.ICE || type == CounterType.M1M1 || type == CounterType.M0M2 || type == CounterType.M0M1
|
||||
@@ -1,40 +1,31 @@
|
||||
package forge.game.ai;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.apache.commons.lang3.tuple.MutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
package forge.ai;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CardPredicates;
|
||||
import forge.CardUtil;
|
||||
import forge.Constant;
|
||||
import forge.card.CardType;
|
||||
import forge.card.ColorSet;
|
||||
import forge.card.MagicColor;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.deck.CardPool;
|
||||
import forge.deck.Deck;
|
||||
import forge.deck.DeckSection;
|
||||
import forge.game.Game;
|
||||
import forge.game.card.*;
|
||||
import forge.game.combat.Combat;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.item.PaperCard;
|
||||
import forge.util.Aggregates;
|
||||
|
||||
import org.apache.commons.lang3.tuple.MutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this type.
|
||||
*
|
||||
@@ -49,10 +40,10 @@ public class ComputerUtilCard {
|
||||
* @param list
|
||||
* a {@link forge.CardList} object.
|
||||
* @param spell
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param targeted
|
||||
* a boolean.
|
||||
* @return a {@link forge.Card} object.
|
||||
* @return a {@link forge.game.card.Card} object.
|
||||
*/
|
||||
public static Card getMostExpensivePermanentAI(final List<Card> list, final SpellAbility spell, final boolean targeted) {
|
||||
List<Card> all = list;
|
||||
@@ -68,6 +59,20 @@ public class ComputerUtilCard {
|
||||
return ComputerUtilCard.getMostExpensivePermanentAI(all);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Sorts a List<Card> by "best" using the EvaluateCreature function.
|
||||
* the best creatures will be first in the list.
|
||||
* </p>
|
||||
*
|
||||
* @param list
|
||||
* a {@link forge.CardList} object.
|
||||
*/
|
||||
public static void sortByEvaluateCreature(final List<Card> list) {
|
||||
Collections.sort(list, ComputerUtilCard.EvaluateCreatureComparator);
|
||||
} // sortByEvaluateCreature()
|
||||
|
||||
// The AI doesn't really pick the best artifact, just the most expensive.
|
||||
/**
|
||||
* <p>
|
||||
@@ -76,7 +81,7 @@ public class ComputerUtilCard {
|
||||
*
|
||||
* @param list
|
||||
* a {@link forge.CardList} object.
|
||||
* @return a {@link forge.Card} object.
|
||||
* @return a {@link forge.game.card.Card} object.
|
||||
*/
|
||||
public static Card getBestArtifactAI(final List<Card> list) {
|
||||
List<Card> all = CardLists.filter(list, CardPredicates.Presets.ARTIFACTS);
|
||||
@@ -96,10 +101,10 @@ public class ComputerUtilCard {
|
||||
* @param list
|
||||
* a {@link forge.CardList} object.
|
||||
* @param spell
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param targeted
|
||||
* a boolean.
|
||||
* @return a {@link forge.Card} object.
|
||||
* @return a {@link forge.game.card.Card} object.
|
||||
*/
|
||||
public static Card getBestEnchantmentAI(final List<Card> list, final SpellAbility spell, final boolean targeted) {
|
||||
List<Card> all = CardLists.filter(list, CardPredicates.Presets.ENCHANTMENTS);
|
||||
@@ -124,7 +129,7 @@ public class ComputerUtilCard {
|
||||
*
|
||||
* @param list
|
||||
* a {@link forge.CardList} object.
|
||||
* @return a {@link forge.Card} object.
|
||||
* @return a {@link forge.game.card.Card} object.
|
||||
*/
|
||||
public static Card getBestLandAI(final Collection<Card> list) {
|
||||
final List<Card> land = CardLists.filter(list, CardPredicates.Presets.LANDS);
|
||||
@@ -145,7 +150,7 @@ public class ComputerUtilCard {
|
||||
int iminBL = 20000; // hopefully no one will ever have more than 20000
|
||||
// lands of one type....
|
||||
int n = 0;
|
||||
for (String name : Constant.Color.BASIC_LANDS) {
|
||||
for (String name : MagicColor.Constant.BASIC_LANDS) {
|
||||
n = CardLists.getType(land, name).size();
|
||||
if ((n < iminBL) && (n > 0)) {
|
||||
// if two or more are tied, only the
|
||||
@@ -177,10 +182,10 @@ public class ComputerUtilCard {
|
||||
* @param list
|
||||
* a {@link forge.CardList} object.
|
||||
* @param spell
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param targeted
|
||||
* a boolean.
|
||||
* @return a {@link forge.Card} object.
|
||||
* @return a {@link forge.game.card.Card} object.
|
||||
*/
|
||||
public static Card getCheapestPermanentAI(Collection<Card> all, final SpellAbility spell, final boolean targeted) {
|
||||
if (targeted) {
|
||||
@@ -216,7 +221,7 @@ public class ComputerUtilCard {
|
||||
*
|
||||
* @param list
|
||||
* a {@link forge.CardList} object.
|
||||
* @return a {@link forge.Card} object.
|
||||
* @return a {@link forge.game.card.Card} object.
|
||||
*/
|
||||
public static Card getBestAI(final Collection<Card> list) {
|
||||
// Get Best will filter by appropriate getBest list if ALL of the list
|
||||
@@ -250,9 +255,9 @@ public class ComputerUtilCard {
|
||||
*
|
||||
* @param list
|
||||
* a {@link forge.CardList} object.
|
||||
* @return a {@link forge.Card} object.
|
||||
* @return a {@link forge.game.card.Card} object.
|
||||
*/
|
||||
public static Card getWorstCreatureAI(final List<Card> list) {
|
||||
public static Card getWorstCreatureAI(final Collection<Card> list) {
|
||||
return Aggregates.itemWithMin(Iterables.filter(list, CardPredicates.Presets.CREATURES), ComputerUtilCard.fnEvaluateCreature);
|
||||
}
|
||||
|
||||
@@ -264,7 +269,7 @@ public class ComputerUtilCard {
|
||||
*
|
||||
* @param list
|
||||
* a {@link forge.CardList} object.
|
||||
* @return a {@link forge.Card} object.
|
||||
* @return a {@link forge.game.card.Card} object.
|
||||
*/
|
||||
public static Card getBestCreatureToBounceAI(final List<Card> list) {
|
||||
final int tokenBonus = 60;
|
||||
@@ -290,7 +295,7 @@ public class ComputerUtilCard {
|
||||
*
|
||||
* @param list
|
||||
* a {@link forge.CardList} object.
|
||||
* @return a {@link forge.Card} object.
|
||||
* @return a {@link forge.game.card.Card} object.
|
||||
*/
|
||||
public static Card getWorstAI(final Collection<Card> list) {
|
||||
return ComputerUtilCard.getWorstPermanentAI(list, false, false, false, false);
|
||||
@@ -311,7 +316,7 @@ public class ComputerUtilCard {
|
||||
* a boolean.
|
||||
* @param biasCreature
|
||||
* a boolean.
|
||||
* @return a {@link forge.Card} object.
|
||||
* @return a {@link forge.game.card.Card} object.
|
||||
*/
|
||||
public static Card getWorstPermanentAI(final Collection<Card> list, final boolean biasEnch, final boolean biasLand,
|
||||
final boolean biasArt, final boolean biasCreature) {
|
||||
@@ -375,7 +380,7 @@ public class ComputerUtilCard {
|
||||
* </p>
|
||||
*
|
||||
* @param c
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @return a int.
|
||||
*/
|
||||
public static int evaluateCreature(final Card c) {
|
||||
@@ -503,7 +508,7 @@ public class ComputerUtilCard {
|
||||
value -= toughness * 5;
|
||||
}
|
||||
|
||||
if (c.hasStartOfKeyword("When CARDNAME is dealt damage, destroy it.")) {
|
||||
if (c.hasSVar("DestroyWhenDamaged")) {
|
||||
value -= (toughness - 1) * 9;
|
||||
}
|
||||
|
||||
@@ -523,8 +528,7 @@ public class ComputerUtilCard {
|
||||
value -= 50;
|
||||
} else if (c.hasStartOfKeyword("Cumulative upkeep")) {
|
||||
value -= 30;
|
||||
} else if (c.hasStartOfKeyword("At the beginning of your upkeep, sacrifice CARDNAME unless you pay")
|
||||
|| c.hasStartOfKeyword("Upkeep:")) {
|
||||
} else if (c.hasStartOfKeyword("At the beginning of your upkeep, sacrifice CARDNAME unless you pay")) {
|
||||
value -= 20;
|
||||
} else if (c.hasStartOfKeyword("(Echo unpaid)")) {
|
||||
value -= 10;
|
||||
@@ -532,7 +536,7 @@ public class ComputerUtilCard {
|
||||
|
||||
if (c.hasStartOfKeyword("At the beginning of your upkeep, CARDNAME deals")) {
|
||||
value -= 20;
|
||||
}
|
||||
}
|
||||
if (c.hasStartOfKeyword("Fading")) {
|
||||
value -= 20;
|
||||
}
|
||||
@@ -608,7 +612,7 @@ public class ComputerUtilCard {
|
||||
* @param ai
|
||||
* the AI player
|
||||
* @param card
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @return a boolean.
|
||||
*/
|
||||
public static boolean doesCreatureAttackAI(final Player ai, final Card card) {
|
||||
@@ -745,7 +749,7 @@ public class ComputerUtilCard {
|
||||
if ( (colors & c) != 0 )
|
||||
return MagicColor.toLongString(c);
|
||||
}
|
||||
return Constant.Color.WHITE; // no difference, there was no prominent color
|
||||
return MagicColor.Constant.WHITE; // no difference, there was no prominent color
|
||||
}
|
||||
|
||||
public static String getMostProminentColor(final List<Card> list, final List<String> restrictedToColors) {
|
||||
@@ -797,7 +801,7 @@ public class ComputerUtilCard {
|
||||
*
|
||||
* @param lands
|
||||
* a {@link forge.CardList} object.
|
||||
* @return a {@link forge.Card} object.
|
||||
* @return a {@link forge.game.card.Card} object.
|
||||
*/
|
||||
public static Card getWorstLand(final List<Card> lands) {
|
||||
Card worstLand = null;
|
||||
@@ -827,5 +831,67 @@ public class ComputerUtilCard {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
public static List<String> chooseColor(SpellAbility sa, int min, int max, List<String> colorChoices) {
|
||||
List<String> chosen = new ArrayList<String>();
|
||||
Player ai = sa.getActivatingPlayer();
|
||||
final Game game = ai.getGame();
|
||||
Player opp = ai.getOpponent();
|
||||
if (sa.hasParam("AILogic")) {
|
||||
final String logic = sa.getParam("AILogic");
|
||||
if (logic.equals("MostProminentInHumanDeck")) {
|
||||
chosen.add(ComputerUtilCard.getMostProminentColor(CardLists.filterControlledBy(game.getCardsInGame(), opp), colorChoices));
|
||||
} else if (logic.equals("MostProminentInComputerDeck")) {
|
||||
chosen.add(ComputerUtilCard.getMostProminentColor(CardLists.filterControlledBy(game.getCardsInGame(), ai), colorChoices));
|
||||
} else if (logic.equals("MostProminentDualInComputerDeck")) {
|
||||
List<String> prominence = ComputerUtilCard.getColorByProminence(CardLists.filterControlledBy(game.getCardsInGame(), ai));
|
||||
chosen.add(prominence.get(0));
|
||||
chosen.add(prominence.get(1));
|
||||
}
|
||||
else if (logic.equals("MostProminentInGame")) {
|
||||
chosen.add(ComputerUtilCard.getMostProminentColor(game.getCardsInGame(), colorChoices));
|
||||
}
|
||||
else if (logic.equals("MostProminentHumanCreatures")) {
|
||||
List<Card> list = opp.getCreaturesInPlay();
|
||||
if (list.isEmpty()) {
|
||||
list = CardLists.filter(CardLists.filterControlledBy(game.getCardsInGame(), opp), CardPredicates.Presets.CREATURES);
|
||||
}
|
||||
chosen.add(ComputerUtilCard.getMostProminentColor(list, colorChoices));
|
||||
}
|
||||
else if (logic.equals("MostProminentComputerControls")) {
|
||||
chosen.add(ComputerUtilCard.getMostProminentColor(ai.getCardsIn(ZoneType.Battlefield), colorChoices));
|
||||
}
|
||||
else if (logic.equals("MostProminentHumanControls")) {
|
||||
chosen.add(ComputerUtilCard.getMostProminentColor(ai.getOpponent().getCardsIn(ZoneType.Battlefield), colorChoices));
|
||||
}
|
||||
else if (logic.equals("MostProminentPermanent")) {
|
||||
final List<Card> list = game.getCardsIn(ZoneType.Battlefield);
|
||||
chosen.add(ComputerUtilCard.getMostProminentColor(list, colorChoices));
|
||||
}
|
||||
else if (logic.equals("MostProminentAttackers") && game.getPhaseHandler().inCombat()) {
|
||||
chosen.add(ComputerUtilCard.getMostProminentColor(game.getCombat().getAttackers(), colorChoices));
|
||||
}
|
||||
else if (logic.equals("MostProminentInActivePlayerHand")) {
|
||||
chosen.add(ComputerUtilCard.getMostProminentColor(game.getPhaseHandler().getPlayerTurn().getCardsIn(ZoneType.Hand), colorChoices));
|
||||
}
|
||||
else if (logic.equals("MostProminentKeywordInComputerDeck")) {
|
||||
List<Card> list = ai.getAllCards();
|
||||
int m1 = 0;
|
||||
String chosenColor = MagicColor.Constant.WHITE;
|
||||
|
||||
for (final String c : MagicColor.Constant.ONLY_COLORS) {
|
||||
final int cmp = CardLists.filter(list, CardPredicates.containsKeyword(c)).size();
|
||||
if (cmp > m1) {
|
||||
m1 = cmp;
|
||||
chosenColor = c;
|
||||
}
|
||||
}
|
||||
chosen.add(chosenColor);
|
||||
}
|
||||
}
|
||||
if (chosen.size() == 0) {
|
||||
chosen.add(MagicColor.Constant.GREEN);
|
||||
}
|
||||
return chosen;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,38 +15,37 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package forge.game.ai;
|
||||
package forge.ai;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import forge.game.CardTraitBase;
|
||||
import forge.game.Game;
|
||||
import forge.game.GameEntity;
|
||||
import forge.game.GlobalRuleChange;
|
||||
import forge.game.ability.AbilityFactory;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.ability.ApiType;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardFactoryUtil;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.card.CounterType;
|
||||
import forge.game.combat.Combat;
|
||||
import forge.game.combat.CombatUtil;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.replacement.ReplacementEffect;
|
||||
import forge.game.spellability.AbilityActivated;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.staticability.StaticAbility;
|
||||
import forge.game.trigger.Trigger;
|
||||
import forge.game.trigger.TriggerHandler;
|
||||
import forge.game.trigger.TriggerType;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CounterType;
|
||||
import forge.GameEntity;
|
||||
import forge.card.TriggerReplacementBase;
|
||||
import forge.card.ability.AbilityFactory;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.ApiType;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.card.replacement.ReplacementEffect;
|
||||
import forge.card.spellability.AbilityActivated;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.staticability.StaticAbility;
|
||||
import forge.card.trigger.Trigger;
|
||||
import forge.card.trigger.TriggerHandler;
|
||||
import forge.card.trigger.TriggerType;
|
||||
import forge.game.Game;
|
||||
import forge.game.GlobalRuleChange;
|
||||
import forge.game.combat.Combat;
|
||||
import forge.game.combat.CombatUtil;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -64,7 +63,7 @@ public class ComputerUtilCombat {
|
||||
* </p>
|
||||
*
|
||||
* @param attacker
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param player
|
||||
* a {@link forge.game.player.Player} object.
|
||||
* @return a int.
|
||||
@@ -91,7 +90,7 @@ public class ComputerUtilCombat {
|
||||
* </p>
|
||||
*
|
||||
* @param c
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @return a int.
|
||||
*/
|
||||
public static int getAttack(final Card c) {
|
||||
@@ -112,7 +111,7 @@ public class ComputerUtilCombat {
|
||||
* </p>
|
||||
*
|
||||
* @param attacker
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param attacked
|
||||
* a {@link forge.game.player.Player} object.
|
||||
* @param combat
|
||||
@@ -142,7 +141,7 @@ public class ComputerUtilCombat {
|
||||
* </p>
|
||||
*
|
||||
* @param attacker
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param attacked
|
||||
* a {@link forge.game.player.Player} object.
|
||||
* @param combat
|
||||
@@ -373,7 +372,7 @@ public class ComputerUtilCombat {
|
||||
public static boolean lifeInSeriousDanger(final Player ai, final Combat combat) {
|
||||
// life in danger only cares about the player's life. Not about a
|
||||
// Planeswalkers life
|
||||
if (ai.cantLose()) {
|
||||
if (ai.cantLose() || combat == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -412,7 +411,7 @@ public class ComputerUtilCombat {
|
||||
* </p>
|
||||
*
|
||||
* @param attacker
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param defenders
|
||||
* a {@link forge.CardList} object.
|
||||
* @return a int.
|
||||
@@ -434,9 +433,9 @@ public class ComputerUtilCombat {
|
||||
* </p>
|
||||
*
|
||||
* @param attacker
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param defender
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @return a int.
|
||||
*/
|
||||
public static int dealsDamageAsBlocker(final Card attacker, final Card defender) {
|
||||
@@ -487,7 +486,7 @@ public class ComputerUtilCombat {
|
||||
* </p>
|
||||
*
|
||||
* @param attacker
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param defenders
|
||||
* a {@link forge.CardList} object.
|
||||
* @return a int.
|
||||
@@ -511,9 +510,9 @@ public class ComputerUtilCombat {
|
||||
* </p>
|
||||
*
|
||||
* @param attacker
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param defender
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @return a int.
|
||||
*/
|
||||
public static int shieldDamage(final Card attacker, final Card defender) {
|
||||
@@ -548,7 +547,7 @@ public class ComputerUtilCombat {
|
||||
* @param ai
|
||||
*
|
||||
* @param combatant
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @return a boolean.
|
||||
*/
|
||||
public static boolean combatantWouldBeDestroyed(Player ai, final Card combatant, Combat combat) {
|
||||
@@ -570,7 +569,7 @@ public class ComputerUtilCombat {
|
||||
* @param ai
|
||||
*
|
||||
* @param attacker
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @return a boolean.
|
||||
*/
|
||||
public static boolean attackerWouldBeDestroyed(Player ai, final Card attacker, Combat combat) {
|
||||
@@ -593,11 +592,11 @@ public class ComputerUtilCombat {
|
||||
* </p>
|
||||
*
|
||||
* @param attacker
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param defender
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param trigger
|
||||
* a {@link forge.card.trigger.Trigger} object.
|
||||
* a {@link forge.game.trigger.Trigger} object.
|
||||
* @param combat
|
||||
* a {@link forge.game.combat.Combat} object.
|
||||
* @return a boolean.
|
||||
@@ -605,7 +604,7 @@ public class ComputerUtilCombat {
|
||||
public static boolean combatTriggerWillTrigger(final Card attacker, final Card defender, final Trigger trigger,
|
||||
Combat combat) {
|
||||
final Game game = attacker.getGame();
|
||||
final HashMap<String, String> trigParams = trigger.getMapParams();
|
||||
final Map<String, String> trigParams = trigger.getMapParams();
|
||||
boolean willTrigger = false;
|
||||
final Card source = trigger.getHostCard();
|
||||
if (combat == null) {
|
||||
@@ -629,9 +628,9 @@ public class ComputerUtilCombat {
|
||||
return false; // The trigger should have triggered already
|
||||
}
|
||||
if (trigParams.containsKey("ValidCard")) {
|
||||
if (!TriggerReplacementBase.matchesValid(attacker, trigParams.get("ValidCard").split(","), source)
|
||||
&& !(combat.isAttacking(source) && TriggerReplacementBase.matchesValid(source,
|
||||
trigParams.get("ValidCard").split(","), source)
|
||||
if (!CardTraitBase.matchesValid(attacker, trigParams.get("ValidCard").split(","), source)
|
||||
&& !(combat.isAttacking(source) && CardTraitBase.matchesValid(source,
|
||||
trigParams.get("ValidCard").split(","), source)
|
||||
&& !trigParams.containsKey("Alone"))) {
|
||||
return false;
|
||||
}
|
||||
@@ -642,7 +641,7 @@ public class ComputerUtilCombat {
|
||||
if ((defender == null) && mode == TriggerType.AttackerUnblocked) {
|
||||
willTrigger = true;
|
||||
if (trigParams.containsKey("ValidCard")) {
|
||||
if (!TriggerReplacementBase.matchesValid(attacker, trigParams.get("ValidCard").split(","), source)) {
|
||||
if (!CardTraitBase.matchesValid(attacker, trigParams.get("ValidCard").split(","), source)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -664,7 +663,7 @@ public class ComputerUtilCombat {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!TriggerReplacementBase.matchesValid(attacker, validBlocked.split(","), source)) {
|
||||
if (!CardTraitBase.matchesValid(attacker, validBlocked.split(","), source)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -678,35 +677,35 @@ public class ComputerUtilCombat {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!TriggerReplacementBase.matchesValid(defender, validBlocker.split(","), source)) {
|
||||
if (!CardTraitBase.matchesValid(defender, validBlocker.split(","), source)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else if (mode == TriggerType.AttackerBlocked) {
|
||||
willTrigger = true;
|
||||
if (trigParams.containsKey("ValidBlocker")) {
|
||||
if (!TriggerReplacementBase.matchesValid(defender, trigParams.get("ValidBlocker").split(","), source)) {
|
||||
if (!CardTraitBase.matchesValid(defender, trigParams.get("ValidBlocker").split(","), source)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (trigParams.containsKey("ValidCard")) {
|
||||
if (!TriggerReplacementBase.matchesValid(attacker, trigParams.get("ValidCard").split(","), source)) {
|
||||
if (!CardTraitBase.matchesValid(attacker, trigParams.get("ValidCard").split(","), source)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else if (mode == TriggerType.DamageDone) {
|
||||
willTrigger = true;
|
||||
if (trigParams.containsKey("ValidSource")) {
|
||||
if (TriggerReplacementBase.matchesValid(defender, trigParams.get("ValidSource").split(","), source)
|
||||
if (CardTraitBase.matchesValid(defender, trigParams.get("ValidSource").split(","), source)
|
||||
&& defender.getNetCombatDamage() > 0
|
||||
&& (!trigParams.containsKey("ValidTarget")
|
||||
|| TriggerReplacementBase.matchesValid(attacker, trigParams.get("ValidTarget").split(","), source))) {
|
||||
|| CardTraitBase.matchesValid(attacker, trigParams.get("ValidTarget").split(","), source))) {
|
||||
return true;
|
||||
}
|
||||
if (TriggerReplacementBase.matchesValid(attacker, trigParams.get("ValidSource").split(","), source)
|
||||
if (CardTraitBase.matchesValid(attacker, trigParams.get("ValidSource").split(","), source)
|
||||
&& attacker.getNetCombatDamage() > 0
|
||||
&& (!trigParams.containsKey("ValidTarget")
|
||||
|| TriggerReplacementBase.matchesValid(defender, trigParams.get("ValidTarget").split(","), source))) {
|
||||
|| CardTraitBase.matchesValid(defender, trigParams.get("ValidTarget").split(","), source))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -724,9 +723,9 @@ public class ComputerUtilCombat {
|
||||
* </p>
|
||||
*
|
||||
* @param attacker
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param defender
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @return a int.
|
||||
*/
|
||||
public static int predictPowerBonusOfBlocker(final Card attacker, final Card defender, boolean withoutAbilities) {
|
||||
@@ -735,6 +734,13 @@ public class ComputerUtilCombat {
|
||||
if (attacker.hasKeyword("Flanking") && !defender.hasKeyword("Flanking")) {
|
||||
power -= attacker.getAmountOfKeyword("Flanking");
|
||||
}
|
||||
|
||||
// Serene Master switches power with attacker
|
||||
if (defender.getName().equals("Serene Master")) {
|
||||
power += attacker.getNetAttack() - defender.getNetAttack();
|
||||
} else if (defender.getName().equals("Shape Stealer")) {
|
||||
power += attacker.getNetAttack() - defender.getNetAttack();
|
||||
}
|
||||
|
||||
// if the attacker has first strike and wither the blocker will deal
|
||||
// less damage than expected
|
||||
@@ -753,7 +759,7 @@ public class ComputerUtilCombat {
|
||||
final List<Card> cardList = game.getCardsIn(ZoneType.Battlefield);
|
||||
for (final Card card : cardList) {
|
||||
for (final StaticAbility stAb : card.getStaticAbilities()) {
|
||||
final HashMap<String, String> params = stAb.getMapParams();
|
||||
final Map<String, String> params = stAb.getMapParams();
|
||||
if (!params.get("Mode").equals("Continuous")) {
|
||||
continue;
|
||||
}
|
||||
@@ -782,7 +788,7 @@ public class ComputerUtilCombat {
|
||||
}
|
||||
theTriggers.addAll(attacker.getTriggers());
|
||||
for (final Trigger trigger : theTriggers) {
|
||||
final HashMap<String, String> trigParams = trigger.getMapParams();
|
||||
final Map<String, String> trigParams = trigger.getMapParams();
|
||||
final Card source = trigger.getHostCard();
|
||||
|
||||
if (!ComputerUtilCombat.combatTriggerWillTrigger(attacker, defender, trigger, null)
|
||||
@@ -842,7 +848,7 @@ public class ComputerUtilCombat {
|
||||
}
|
||||
|
||||
if (ComputerUtilCost.canPayCost(ability, defender.getController())) {
|
||||
int pBonus = AbilityUtils.calculateAmount(ability.getSourceCard(), ability.getParam("NumAtt"), ability);
|
||||
int pBonus = AbilityUtils.calculateAmount(ability.getHostCard(), ability.getParam("NumAtt"), ability);
|
||||
if (pBonus > 0) {
|
||||
power += pBonus;
|
||||
}
|
||||
@@ -853,7 +859,7 @@ public class ComputerUtilCombat {
|
||||
}
|
||||
|
||||
if (ComputerUtilCost.canPayCost(ability, defender.getController())) {
|
||||
int pBonus = AbilityUtils.calculateAmount(ability.getSourceCard(), ability.getParam("CounterNum"), ability);
|
||||
int pBonus = AbilityUtils.calculateAmount(ability.getHostCard(), ability.getParam("CounterNum"), ability);
|
||||
if (pBonus > 0) {
|
||||
power += pBonus;
|
||||
}
|
||||
@@ -871,9 +877,9 @@ public class ComputerUtilCombat {
|
||||
* </p>
|
||||
*
|
||||
* @param attacker
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param defender
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @return a int.
|
||||
*/
|
||||
public static int predictToughnessBonusOfBlocker(final Card attacker, final Card defender, boolean withoutAbilities) {
|
||||
@@ -882,6 +888,10 @@ public class ComputerUtilCombat {
|
||||
if (attacker.hasKeyword("Flanking") && !defender.hasKeyword("Flanking")) {
|
||||
toughness -= attacker.getAmountOfKeyword("Flanking");
|
||||
}
|
||||
|
||||
if (defender.getName().equals("Shape Stealer")) {
|
||||
toughness += attacker.getNetDefense() - defender.getNetDefense();
|
||||
}
|
||||
|
||||
toughness += defender.getKeywordMagnitude("Bushido");
|
||||
final Game game = attacker.getGame();
|
||||
@@ -891,7 +901,7 @@ public class ComputerUtilCombat {
|
||||
}
|
||||
theTriggers.addAll(attacker.getTriggers());
|
||||
for (final Trigger trigger : theTriggers) {
|
||||
final HashMap<String, String> trigParams = trigger.getMapParams();
|
||||
final Map<String, String> trigParams = trigger.getMapParams();
|
||||
final Card source = trigger.getHostCard();
|
||||
|
||||
if (!ComputerUtilCombat.combatTriggerWillTrigger(attacker, defender, trigger, null)
|
||||
@@ -967,7 +977,7 @@ public class ComputerUtilCombat {
|
||||
|
||||
if (ability.getApi() != ApiType.Pump || !ability.hasParam("NumDef")) {
|
||||
if (ComputerUtilCost.canPayCost(ability, defender.getController())) {
|
||||
int tBonus = AbilityUtils.calculateAmount(ability.getSourceCard(), ability.getParam("NumDef"), ability);
|
||||
int tBonus = AbilityUtils.calculateAmount(ability.getHostCard(), ability.getParam("NumDef"), ability);
|
||||
if (tBonus > 0) {
|
||||
toughness += tBonus;
|
||||
}
|
||||
@@ -978,7 +988,7 @@ public class ComputerUtilCombat {
|
||||
}
|
||||
|
||||
if (ComputerUtilCost.canPayCost(ability, defender.getController())) {
|
||||
int tBonus = AbilityUtils.calculateAmount(ability.getSourceCard(), ability.getParam("CounterNum"), ability);
|
||||
int tBonus = AbilityUtils.calculateAmount(ability.getHostCard(), ability.getParam("CounterNum"), ability);
|
||||
if (tBonus > 0) {
|
||||
toughness += tBonus;
|
||||
}
|
||||
@@ -996,9 +1006,9 @@ public class ComputerUtilCombat {
|
||||
* </p>
|
||||
*
|
||||
* @param attacker
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param defender
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param combat
|
||||
* a {@link forge.game.combat.Combat} object.
|
||||
* @return a int.
|
||||
@@ -1015,6 +1025,13 @@ public class ComputerUtilCombat {
|
||||
}
|
||||
}
|
||||
|
||||
// Serene Master switches power with attacker
|
||||
if (defender!= null && defender.getName().equals("Serene Master")) {
|
||||
power += defender.getNetAttack() - attacker.getNetAttack();
|
||||
} else if (defender != null && attacker.getName().equals("Shape Stealer")) {
|
||||
power += defender.getNetAttack() - attacker.getNetAttack();
|
||||
}
|
||||
|
||||
final Game game = attacker.getGame();
|
||||
final ArrayList<Trigger> theTriggers = new ArrayList<Trigger>();
|
||||
for (Card card : game.getCardsIn(ZoneType.Battlefield)) {
|
||||
@@ -1037,7 +1054,7 @@ public class ComputerUtilCombat {
|
||||
final List<Card> cardList = game.getCardsIn(ZoneType.Battlefield);
|
||||
for (final Card card : cardList) {
|
||||
for (final StaticAbility stAb : card.getStaticAbilities()) {
|
||||
final HashMap<String, String> params = stAb.getMapParams();
|
||||
final Map<String, String> params = stAb.getMapParams();
|
||||
if (!params.get("Mode").equals("Continuous")) {
|
||||
continue;
|
||||
}
|
||||
@@ -1061,7 +1078,7 @@ public class ComputerUtilCombat {
|
||||
}
|
||||
|
||||
for (final Trigger trigger : theTriggers) {
|
||||
final HashMap<String, String> trigParams = trigger.getMapParams();
|
||||
final Map<String, String> trigParams = trigger.getMapParams();
|
||||
final Card source = trigger.getHostCard();
|
||||
|
||||
if (!ComputerUtilCombat.combatTriggerWillTrigger(attacker, defender, trigger, combat)
|
||||
@@ -1137,7 +1154,7 @@ public class ComputerUtilCombat {
|
||||
}
|
||||
|
||||
if (!ability.getPayCosts().hasTapCost() && ComputerUtilCost.canPayCost(ability, attacker.getController())) {
|
||||
int pBonus = AbilityUtils.calculateAmount(ability.getSourceCard(), ability.getParam("NumAtt"), ability);
|
||||
int pBonus = AbilityUtils.calculateAmount(ability.getHostCard(), ability.getParam("NumAtt"), ability);
|
||||
if (pBonus > 0) {
|
||||
power += pBonus;
|
||||
}
|
||||
@@ -1148,7 +1165,7 @@ public class ComputerUtilCombat {
|
||||
}
|
||||
|
||||
if (!ability.getPayCosts().hasTapCost() && ComputerUtilCost.canPayCost(ability, attacker.getController())) {
|
||||
int pBonus = AbilityUtils.calculateAmount(ability.getSourceCard(), ability.getParam("CounterNum"), ability);
|
||||
int pBonus = AbilityUtils.calculateAmount(ability.getHostCard(), ability.getParam("CounterNum"), ability);
|
||||
if (pBonus > 0) {
|
||||
power += pBonus;
|
||||
}
|
||||
@@ -1166,9 +1183,9 @@ public class ComputerUtilCombat {
|
||||
* </p>
|
||||
*
|
||||
* @param attacker
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param defender
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param combat
|
||||
* a {@link forge.game.combat.Combat} object.
|
||||
* @return a int.
|
||||
@@ -1184,6 +1201,10 @@ public class ComputerUtilCombat {
|
||||
}
|
||||
}
|
||||
|
||||
if (defender != null && attacker.getName().equals("Shape Stealer")) {
|
||||
toughness += defender.getNetDefense() - attacker.getNetDefense();
|
||||
}
|
||||
|
||||
final Game game = attacker.getGame();
|
||||
final ArrayList<Trigger> theTriggers = new ArrayList<Trigger>();
|
||||
for (Card card : game.getCardsIn(ZoneType.Battlefield)) {
|
||||
@@ -1199,7 +1220,7 @@ public class ComputerUtilCombat {
|
||||
final List<Card> cardList = game.getCardsIn(ZoneType.Battlefield);
|
||||
for (final Card card : cardList) {
|
||||
for (final StaticAbility stAb : card.getStaticAbilities()) {
|
||||
final HashMap<String, String> params = stAb.getMapParams();
|
||||
final Map<String, String> params = stAb.getMapParams();
|
||||
if (!params.get("Mode").equals("Continuous")) {
|
||||
continue;
|
||||
}
|
||||
@@ -1223,7 +1244,7 @@ public class ComputerUtilCombat {
|
||||
}
|
||||
|
||||
for (final Trigger trigger : theTriggers) {
|
||||
final HashMap<String, String> trigParams = trigger.getMapParams();
|
||||
final Map<String, String> trigParams = trigger.getMapParams();
|
||||
final Card source = trigger.getHostCard();
|
||||
|
||||
if (!ComputerUtilCombat.combatTriggerWillTrigger(attacker, defender, trigger, combat)
|
||||
@@ -1314,7 +1335,7 @@ public class ComputerUtilCombat {
|
||||
|
||||
if (ability.getApi() != ApiType.Pump || !ability.hasParam("NumDef")) {
|
||||
if (!ability.getPayCosts().hasTapCost() && ComputerUtilCost.canPayCost(ability, attacker.getController())) {
|
||||
int tBonus = AbilityUtils.calculateAmount(ability.getSourceCard(), ability.getParam("NumDef"), ability);
|
||||
int tBonus = AbilityUtils.calculateAmount(ability.getHostCard(), ability.getParam("NumDef"), ability);
|
||||
if (tBonus > 0) {
|
||||
toughness += tBonus;
|
||||
}
|
||||
@@ -1325,7 +1346,7 @@ public class ComputerUtilCombat {
|
||||
}
|
||||
|
||||
if (!ability.getPayCosts().hasTapCost() && ComputerUtilCost.canPayCost(ability, attacker.getController())) {
|
||||
int tBonus = AbilityUtils.calculateAmount(ability.getSourceCard(), ability.getParam("CounterNum"), ability);
|
||||
int tBonus = AbilityUtils.calculateAmount(ability.getHostCard(), ability.getParam("CounterNum"), ability);
|
||||
if (tBonus > 0) {
|
||||
toughness += tBonus;
|
||||
}
|
||||
@@ -1342,9 +1363,9 @@ public class ComputerUtilCombat {
|
||||
* </p>
|
||||
*
|
||||
* @param attacker
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param defender
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @return a boolean.
|
||||
*/
|
||||
public static boolean checkDestroyBlockerTrigger(final Card attacker, final Card defender) {
|
||||
@@ -1354,7 +1375,7 @@ public class ComputerUtilCombat {
|
||||
theTriggers.addAll(card.getTriggers());
|
||||
}
|
||||
for (Trigger trigger : theTriggers) {
|
||||
HashMap<String, String> trigParams = trigger.getMapParams();
|
||||
Map<String, String> trigParams = trigger.getMapParams();
|
||||
final Card source = trigger.getHostCard();
|
||||
|
||||
if (!ComputerUtilCombat.combatTriggerWillTrigger(attacker, defender, trigger, null)) {
|
||||
@@ -1398,9 +1419,9 @@ public class ComputerUtilCombat {
|
||||
* </p>
|
||||
*
|
||||
* @param attacker
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param defender
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @return a boolean.
|
||||
*/
|
||||
public static boolean checkDestroyAttackerTrigger(final Card attacker, final Card defender) {
|
||||
@@ -1409,7 +1430,7 @@ public class ComputerUtilCombat {
|
||||
theTriggers.addAll(card.getTriggers());
|
||||
}
|
||||
for (Trigger trigger : theTriggers) {
|
||||
HashMap<String, String> trigParams = trigger.getMapParams();
|
||||
Map<String, String> trigParams = trigger.getMapParams();
|
||||
final Card source = trigger.getHostCard();
|
||||
|
||||
if (!ComputerUtilCombat.combatTriggerWillTrigger(attacker, defender, trigger, null)) {
|
||||
@@ -1454,9 +1475,9 @@ public class ComputerUtilCombat {
|
||||
* @param ai
|
||||
*
|
||||
* @param attacker
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param defender
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param combat
|
||||
* a {@link forge.game.combat.Combat} object.
|
||||
* @param withoutAbilities
|
||||
@@ -1528,7 +1549,7 @@ public class ComputerUtilCombat {
|
||||
|
||||
if (defender.hasKeyword("Double Strike")) {
|
||||
if (defenderDamage > 0 && (defender.hasKeyword("Deathtouch")
|
||||
|| attacker.hasStartOfKeyword("When CARDNAME is dealt damage, destroy it."))) {
|
||||
|| attacker.hasSVar("DestroyWhenDamaged"))) {
|
||||
return true;
|
||||
}
|
||||
if (defenderDamage >= attackerLife) {
|
||||
@@ -1542,7 +1563,7 @@ public class ComputerUtilCombat {
|
||||
return false;
|
||||
}
|
||||
if (attackerDamage > 0 && (attacker.hasKeyword("Deathtouch")
|
||||
|| defender.hasStartOfKeyword("When CARDNAME is dealt damage, destroy it."))) {
|
||||
|| defender.hasSVar("DestroyWhenDamaged"))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1560,13 +1581,13 @@ public class ComputerUtilCombat {
|
||||
return false;
|
||||
}
|
||||
if (attackerDamage > 0 && (attacker.hasKeyword("Deathtouch")
|
||||
|| defender.hasStartOfKeyword("When CARDNAME is dealt damage, destroy it."))) {
|
||||
|| defender.hasSVar("DestroyWhenDamaged"))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (defenderDamage > 0 && (defender.hasKeyword("Deathtouch")
|
||||
|| attacker.hasStartOfKeyword("When CARDNAME is dealt damage, destroy it."))) {
|
||||
|| attacker.hasSVar("DestroyWhenDamaged"))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1584,7 +1605,7 @@ public class ComputerUtilCombat {
|
||||
* @param ai
|
||||
*
|
||||
* @param blocker
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @return a boolean.
|
||||
*/
|
||||
public static boolean blockerWouldBeDestroyed(Player ai, final Card blocker, Combat combat) {
|
||||
@@ -1609,9 +1630,9 @@ public class ComputerUtilCombat {
|
||||
* @param ai
|
||||
*
|
||||
* @param defender
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param attacker
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param combat
|
||||
* a {@link forge.game.combat.Combat} object.
|
||||
* @param withoutAbilities
|
||||
@@ -1684,7 +1705,7 @@ public class ComputerUtilCombat {
|
||||
|
||||
if (attacker.hasKeyword("Double Strike")) {
|
||||
if (attackerDamage > 0 && (attacker.hasKeyword("Deathtouch")
|
||||
|| defender.hasStartOfKeyword("When CARDNAME is dealt damage, destroy it."))) {
|
||||
|| defender.hasSVar("DestroyWhenDamaged"))) {
|
||||
return true;
|
||||
}
|
||||
if (attackerDamage >= defenderLife) {
|
||||
@@ -1698,7 +1719,7 @@ public class ComputerUtilCombat {
|
||||
return false;
|
||||
}
|
||||
if (defenderDamage > 0 && (defender.hasKeyword("Deathtouch")
|
||||
|| attacker.hasStartOfKeyword("When CARDNAME is dealt damage, destroy it."))) {
|
||||
|| attacker.hasSVar("DestroyWhenDamaged"))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1716,13 +1737,13 @@ public class ComputerUtilCombat {
|
||||
return false;
|
||||
}
|
||||
if (defenderDamage > 0 && (defender.hasKeyword("Deathtouch")
|
||||
|| attacker.hasStartOfKeyword("When CARDNAME is dealt damage, destroy it."))) {
|
||||
|| attacker.hasSVar("DestroyWhenDamaged"))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (attackerDamage > 0 && (attacker.hasKeyword("Deathtouch")
|
||||
|| defender.hasStartOfKeyword("When CARDNAME is dealt damage, destroy it."))) {
|
||||
|| defender.hasSVar("DestroyWhenDamaged"))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1739,7 +1760,7 @@ public class ComputerUtilCombat {
|
||||
* </p>
|
||||
*
|
||||
* @param attacker
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param block
|
||||
* a {@link forge.CardList} object.
|
||||
* @param dmgCanDeal
|
||||
@@ -1834,7 +1855,7 @@ public class ComputerUtilCombat {
|
||||
* @param maxDamage
|
||||
* a int.
|
||||
* @param source
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param isCombat
|
||||
* a boolean.
|
||||
* @return a int.
|
||||
@@ -1851,7 +1872,7 @@ public class ComputerUtilCombat {
|
||||
* @param maxDamage
|
||||
* a int.
|
||||
* @param source
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param isCombat
|
||||
* a boolean.
|
||||
* @param noPrevention
|
||||
@@ -1862,7 +1883,7 @@ public class ComputerUtilCombat {
|
||||
final boolean noPrevention) {
|
||||
final int killDamage = ComputerUtilCombat.getDamageToKill(c);
|
||||
|
||||
if (c.hasKeyword("Indestructible") || (c.getShield() > 0)) {
|
||||
if (c.hasKeyword("Indestructible") || !c.getShield().isEmpty()) {
|
||||
if (!(source.hasKeyword("Wither") || source.hasKeyword("Infect"))) {
|
||||
return maxDamage + 1;
|
||||
}
|
||||
@@ -1904,7 +1925,7 @@ public class ComputerUtilCombat {
|
||||
public final static int getDamageToKill(final Card c) {
|
||||
int killDamage = c.getLethalDamage() + c.getPreventNextDamageTotalShields();
|
||||
if ((killDamage > c.getPreventNextDamageTotalShields())
|
||||
&& c.hasStartOfKeyword("When CARDNAME is dealt damage, destroy it.")) {
|
||||
&& c.hasSVar("DestroyWhenDamaged")) {
|
||||
killDamage = 1 + c.getPreventNextDamageTotalShields();
|
||||
}
|
||||
|
||||
@@ -1920,7 +1941,7 @@ public class ComputerUtilCombat {
|
||||
* @param damage
|
||||
* a int.
|
||||
* @param source
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param isCombat
|
||||
* a boolean.
|
||||
* @return a int.
|
||||
@@ -1981,7 +2002,7 @@ public class ComputerUtilCombat {
|
||||
* @param damage
|
||||
* a int.
|
||||
* @param source
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param isCombat
|
||||
* a boolean.
|
||||
* @return a int.
|
||||
@@ -2011,7 +2032,7 @@ public class ComputerUtilCombat {
|
||||
* @param possiblePrevention
|
||||
* a int.
|
||||
* @param source
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param isCombat
|
||||
* a boolean.
|
||||
* @return a int.
|
||||
@@ -1,29 +1,20 @@
|
||||
package forge.game.ai;
|
||||
package forge.ai;
|
||||
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.card.CounterType;
|
||||
import forge.game.cost.*;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.Spell;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.TextUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CounterType;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.cost.CostDamage;
|
||||
import forge.card.cost.CostDiscard;
|
||||
import forge.card.cost.CostPart;
|
||||
import forge.card.cost.CostPayLife;
|
||||
import forge.card.cost.CostPayment;
|
||||
import forge.card.cost.CostPutCounter;
|
||||
import forge.card.cost.CostRemoveCounter;
|
||||
import forge.card.cost.CostSacrifice;
|
||||
import forge.card.spellability.Spell;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.TextUtil;
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this type.
|
||||
*
|
||||
@@ -73,7 +64,7 @@ public class ComputerUtilCost {
|
||||
if (part instanceof CostRemoveCounter) {
|
||||
final CostRemoveCounter remCounter = (CostRemoveCounter) part;
|
||||
|
||||
final CounterType type = remCounter.getCounter();
|
||||
final CounterType type = remCounter.counter;
|
||||
if (!part.payCostFromSource()) {
|
||||
if (type.name().equals("P1P1")) {
|
||||
return false;
|
||||
@@ -287,7 +278,7 @@ public class ComputerUtilCost {
|
||||
* </p>
|
||||
*
|
||||
* @param hostCard
|
||||
* a {@link forge.Card} object.
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param costString
|
||||
* a {@link java.lang.String} object.
|
||||
* @return a boolean.
|
||||
@@ -315,7 +306,7 @@ public class ComputerUtilCost {
|
||||
* </p>
|
||||
*
|
||||
* @param sa
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
* @param player
|
||||
* a {@link forge.game.player.Player} object.
|
||||
* @return a boolean.
|
||||
@@ -358,7 +349,7 @@ public class ComputerUtilCost {
|
||||
} // canPayCost()
|
||||
|
||||
public static boolean willPayUnlessCost(SpellAbility sa, Player payer, Cost cost, boolean alreadyPaid, List<Player> payers) {
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
boolean payForOwnOnly = "OnlyOwn".equals(sa.getParam("UnlessAI"));
|
||||
boolean payOwner = sa.hasParam("UnlessAI") ? sa.getParam("UnlessAI").startsWith("Defined") : false;
|
||||
boolean payNever = "Never".equals(sa.getParam("UnlessAI"));
|
||||
@@ -395,6 +386,10 @@ public class ComputerUtilCost {
|
||||
if (payerCreatures > sourceCreatures + 1) {
|
||||
return false;
|
||||
}
|
||||
} else if ("LifeLE2".equals(sa.getParam("UnlessAI"))) {
|
||||
if (payer.getLife() < 3) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// AI will only pay when it's not already payed and only opponents abilities
|
||||
911
forge-ai/src/main/java/forge/ai/ComputerUtilMana.java
Normal file
911
forge-ai/src/main/java/forge/ai/ComputerUtilMana.java
Normal file
@@ -0,0 +1,911 @@
|
||||
package forge.ai;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import forge.card.MagicColor;
|
||||
import forge.card.mana.ManaAtom;
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.card.mana.ManaCostShard;
|
||||
import forge.game.Game;
|
||||
import forge.game.GameActionUtil;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.ability.ApiType;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.card.CardUtil;
|
||||
import forge.game.cost.Cost;
|
||||
import forge.game.cost.CostPartMana;
|
||||
import forge.game.cost.CostPayment;
|
||||
import forge.game.mana.Mana;
|
||||
import forge.game.mana.ManaCostBeingPaid;
|
||||
import forge.game.mana.ManaPool;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.replacement.ReplacementEffect;
|
||||
import forge.game.spellability.AbilityManaPart;
|
||||
import forge.game.spellability.AbilitySub;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.TextUtil;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this type.
|
||||
*
|
||||
*/
|
||||
public class ComputerUtilMana {
|
||||
private final static boolean DEBUG_MANA_PAYMENT = false;
|
||||
|
||||
public static boolean canPayManaCost(ManaCostBeingPaid cost, final SpellAbility sa, final Player ai) {
|
||||
cost = new ManaCostBeingPaid(cost); //check copy of cost so it doesn't modify the exist cost being paid
|
||||
return payManaCost(cost, sa, ai, true, 0, true);
|
||||
}
|
||||
|
||||
public static boolean payManaCost(ManaCostBeingPaid cost, final SpellAbility sa, final Player ai) {
|
||||
return payManaCost(cost, sa, ai, false, 0, true);
|
||||
}
|
||||
|
||||
public static boolean canPayManaCost(final SpellAbility sa, final Player ai, final int extraMana) {
|
||||
return payManaCost(sa, ai, true, extraMana, true);
|
||||
}
|
||||
|
||||
// Does not check if mana sources can be used right now, just checks for potential chance.
|
||||
public static boolean hasEnoughManaSourcesToCast(final SpellAbility sa, final Player ai) {
|
||||
sa.setActivatingPlayer(ai);
|
||||
return payManaCost(sa, ai, true, 0, false);
|
||||
}
|
||||
|
||||
public static boolean payManaCost(final Player ai, final SpellAbility sa) {
|
||||
return payManaCost(sa, ai, false, 0, true);
|
||||
}
|
||||
|
||||
private static void refundMana(List<Mana> manaSpent, Player ai, SpellAbility sa) {
|
||||
if (sa.getHostCard() != null) {
|
||||
sa.getHostCard().setCanCounter(true);
|
||||
}
|
||||
for (final Mana m : manaSpent) {
|
||||
ai.getManaPool().addMana(m);
|
||||
}
|
||||
manaSpent.clear();
|
||||
}
|
||||
|
||||
|
||||
private static boolean payManaCost(final SpellAbility sa, final Player ai, final boolean test, final int extraMana, boolean checkPlayable) {
|
||||
ManaCostBeingPaid cost = ComputerUtilMana.calculateManaCost(sa, test, extraMana);
|
||||
return payManaCost(cost, sa, ai, test, extraMana, checkPlayable);
|
||||
}
|
||||
|
||||
private static boolean payManaCost(final ManaCostBeingPaid cost, final SpellAbility sa, final Player ai, final boolean test, final int extraMana, boolean checkPlayable) {
|
||||
adjustManaCostToAvoidNegEffects(cost, sa.getHostCard(), ai);
|
||||
List<Mana> manaSpentToPay = test ? new ArrayList<Mana>() : sa.getPayingMana();
|
||||
|
||||
final ManaPool manapool = ai.getManaPool();
|
||||
List<ManaCostShard> unpaidShards = cost.getUnpaidShards();
|
||||
Collections.sort(unpaidShards); // most difficult shards must come first
|
||||
for (ManaCostShard part : unpaidShards) {
|
||||
if (part != ManaCostShard.X) {
|
||||
if (cost.isPaid()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// get a mana of this type from floating, bail if none available
|
||||
final Mana mana = getMana(ai, part, sa, cost.getSourceRestriction());
|
||||
if (mana == null) {
|
||||
continue; // no matching mana in the pool
|
||||
}
|
||||
else {
|
||||
if (ai.getManaPool().tryPayCostWithMana(sa, cost, mana)) {
|
||||
manaSpentToPay.add(0, mana);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cost.isPaid()) {
|
||||
// refund any mana taken from mana pool when test
|
||||
if(test)
|
||||
refundMana(manaSpentToPay, ai, sa);
|
||||
|
||||
handleOfferingsAI(sa, test, cost.isPaid());
|
||||
return true;
|
||||
}
|
||||
|
||||
// arrange all mana abilities by color produced.
|
||||
final Multimap<Integer, SpellAbility> manaAbilityMap = ComputerUtilMana.groupSourcesByManaColor(ai, checkPlayable);
|
||||
if (manaAbilityMap.isEmpty()) {
|
||||
refundMana(manaSpentToPay, ai, sa);
|
||||
|
||||
handleOfferingsAI(sa, test, cost.isPaid());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (DEBUG_MANA_PAYMENT) {
|
||||
System.out.println("DEBUG_MANA_PAYMENT: manaAbilityMap = " + manaAbilityMap);
|
||||
}
|
||||
|
||||
// select which abilities may be used for each shard
|
||||
Multimap<ManaCostShard, SpellAbility> sourcesForShards = ComputerUtilMana.groupAndOrderToPayShards(ai, manaAbilityMap, cost);
|
||||
|
||||
// if (DEBUG_MANA_PAYMENT) {
|
||||
// System.out.println((test ? "test -- " : "PROD -- ") + FThreads.debugGetStackTraceItem(5, true));
|
||||
// for (Entry<ManaCostShard, Collection<SpellAbility>> src : sourcesForShards.entrySet()) {
|
||||
// System.out.println("\t" +src.getKey() + " : " + src.getValue().size() + " source(s)");
|
||||
// for (SpellAbility sss : src.getValue()) {
|
||||
// System.out.printf("\t\t%s - %s%n", sss.getHostCard(), sss);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
List<String> paymentPlan = new ArrayList<String>();
|
||||
|
||||
ManaCostShard toPay = null;
|
||||
// Loop over mana needed
|
||||
while (!cost.isPaid()) {
|
||||
toPay = getNextShardToPay(cost, sourcesForShards);
|
||||
|
||||
Collection<SpellAbility> saList = sourcesForShards.get(toPay);
|
||||
SpellAbility saPayment = null;
|
||||
if (saList != null) {
|
||||
for (final SpellAbility ma : saList) {
|
||||
if (ma.getHostCard() == sa.getHostCard()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final String typeRes = cost.getSourceRestriction();
|
||||
if (StringUtils.isNotBlank(typeRes) && !ma.getHostCard().isType(typeRes)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (canPayShardWithSpellAbility(toPay, ai, ma, sa, checkPlayable || !test)) {
|
||||
saPayment = ma;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
if (DEBUG_MANA_PAYMENT) {
|
||||
paymentPlan.add(String.format("%s : (%s) %s", toPay, saPayment == null ? "LIFE" : saPayment.getHostCard(), saPayment));
|
||||
}
|
||||
|
||||
if (saPayment == null) {
|
||||
if (!toPay.isPhyrexian() || !ai.canPayLife(2)) {
|
||||
break; // cannot pay
|
||||
}
|
||||
|
||||
cost.payPhyrexian();
|
||||
if (!test) {
|
||||
ai.payLife(2, sa.getHostCard());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
setExpressColorChoice(sa, ai, cost, toPay, saPayment);
|
||||
|
||||
if (test) {
|
||||
String manaProduced = toPay.isSnow() ? "S" : GameActionUtil.generatedMana(saPayment);
|
||||
manaProduced = AbilityManaPart.applyManaReplacement(saPayment, manaProduced);
|
||||
//System.out.println(manaProduced);
|
||||
payMultipleMana(cost, manaProduced, ai);
|
||||
|
||||
// remove from available lists
|
||||
Iterator<SpellAbility> itSa = sourcesForShards.values().iterator();
|
||||
while (itSa.hasNext()) {
|
||||
SpellAbility srcSa = itSa.next();
|
||||
if (srcSa.getHostCard().equals(saPayment.getHostCard())) {
|
||||
itSa.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (saPayment.getPayCosts() != null) {
|
||||
final CostPayment pay = new CostPayment(saPayment.getPayCosts(), saPayment);
|
||||
if (!pay.payComputerCosts(new AiCostDecision(ai, saPayment))) {
|
||||
saList.remove(saPayment);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
System.err.println("Ability " + saPayment + " from " + saPayment.getHostCard() + " had NULL as payCost");
|
||||
saPayment.getHostCard().tap();
|
||||
}
|
||||
|
||||
ai.getGame().getStack().addAndUnfreeze(saPayment);
|
||||
// subtract mana from mana pool
|
||||
manapool.payManaFromAbility(sa, cost, saPayment);
|
||||
|
||||
// no need to remove abilities from resource map,
|
||||
// once their costs are paid and consume resources, they can not be used again
|
||||
}
|
||||
}
|
||||
|
||||
handleOfferingsAI(sa, test, cost.isPaid());
|
||||
|
||||
// if (DEBUG_MANA_PAYMENT) {
|
||||
// System.err.printf("%s > [%s] payment has %s (%s +%d) for (%s) %s:%n\t%s%n%n",
|
||||
// FThreads.debugGetCurrThreadId(), test ? "test" : "PROD", cost.isPaid() ? "*PAID*" : "failed", originalCost,
|
||||
// extraMana, sa.getHostCard(), sa.toUnsuppressedString(), StringUtils.join(paymentPlan, "\n\t"));
|
||||
// }
|
||||
|
||||
if (!cost.isPaid()) {
|
||||
refundMana(manaSpentToPay, ai, sa);
|
||||
if (test) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
System.out.println("ComputerUtil : payManaCost() cost was not paid for " + sa.getHostCard().getName() + ". Didn't find what to pay for " + toPay);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (test)
|
||||
refundMana(manaSpentToPay, ai, sa);
|
||||
|
||||
sa.getHostCard().setColorsPaid(cost.getColorsPaid());
|
||||
// if (sa instanceof Spell_Permanent) // should probably add this
|
||||
sa.getHostCard().setSunburstValue(cost.getSunburst());
|
||||
return true;
|
||||
} // payManaCost()
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* getManaFrom.
|
||||
* </p>
|
||||
*
|
||||
* @param saBeingPaidFor
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
* @return a {@link forge.game.mana.Mana} object.
|
||||
*/
|
||||
private static Mana getMana(final Player ai, final ManaCostShard shard, final SpellAbility saBeingPaidFor, String restriction) {
|
||||
final List<Pair<Mana, Integer>> weightedOptions = selectManaToPayFor(ai.getManaPool(), shard, saBeingPaidFor, restriction);
|
||||
|
||||
// Exclude border case
|
||||
if (weightedOptions.isEmpty()) {
|
||||
return null; // There is no matching mana in the pool
|
||||
}
|
||||
|
||||
// select equal weight possibilities
|
||||
List<Mana> manaChoices = new ArrayList<Mana>();
|
||||
int bestWeight = Integer.MIN_VALUE;
|
||||
for (Pair<Mana, Integer> option : weightedOptions) {
|
||||
int thisWeight = option.getRight();
|
||||
Mana thisMana = option.getLeft();
|
||||
|
||||
if (thisWeight > bestWeight) {
|
||||
manaChoices.clear();
|
||||
bestWeight = thisWeight;
|
||||
}
|
||||
|
||||
if (thisWeight == bestWeight) {
|
||||
// add only distinct Mana-s
|
||||
boolean haveDuplicate = false;
|
||||
for (Mana m : manaChoices) {
|
||||
if (m.equals(thisMana)) {
|
||||
haveDuplicate = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!haveDuplicate) {
|
||||
manaChoices.add(thisMana);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// got an only one best option?
|
||||
if (manaChoices.size() == 1) {
|
||||
return manaChoices.get(0);
|
||||
}
|
||||
|
||||
// Let them choose then
|
||||
return ai.getController().chooseManaFromPool(manaChoices);
|
||||
}
|
||||
|
||||
private static List<Pair<Mana, Integer>> selectManaToPayFor(final ManaPool manapool, final ManaCostShard shard, final SpellAbility saBeingPaidFor, String restriction) {
|
||||
final List<Pair<Mana, Integer>> weightedOptions = new ArrayList<Pair<Mana, Integer>>();
|
||||
for (final Mana thisMana : manapool) {
|
||||
if (!manapool.canPayForShardWithColor(shard, thisMana.getColor())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (thisMana.getManaAbility() != null && !thisMana.getManaAbility().meetsManaRestrictions(saBeingPaidFor)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean canPay = manapool.canPayForShardWithColor(shard, thisMana.getColor());
|
||||
if (!canPay || (shard.isSnow() && !thisMana.isSnow())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(restriction) && !thisMana.getSourceCard().isType(restriction)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// prefer colorless mana to spend
|
||||
int weight = thisMana.isColorless() ? 5 : 0;
|
||||
|
||||
// prefer restricted mana to spend
|
||||
if (thisMana.isRestricted()) {
|
||||
weight += 2;
|
||||
}
|
||||
|
||||
// Spend non-snow mana first
|
||||
if (!thisMana.isSnow()) {
|
||||
weight += 1;
|
||||
}
|
||||
|
||||
weightedOptions.add(Pair.of(thisMana, weight));
|
||||
}
|
||||
return weightedOptions;
|
||||
}
|
||||
|
||||
private static void setExpressColorChoice(final SpellAbility sa, final Player ai, ManaCostBeingPaid cost,
|
||||
ManaCostShard toPay, SpellAbility saPayment) {
|
||||
|
||||
AbilityManaPart m = saPayment.getManaPart();
|
||||
if (m.isComboMana())
|
||||
getComboManaChoice(ai, saPayment, sa, cost);
|
||||
else if (saPayment.getApi() == ApiType.ManaReflected) {
|
||||
System.out.println("Evaluate reflected mana of: " + saPayment.getHostCard());
|
||||
Set<String> reflected = CardUtil.getReflectableManaColors(saPayment);
|
||||
|
||||
for (byte c : MagicColor.WUBRG) {
|
||||
if (ai.getManaPool().canPayForShardWithColor(toPay, c) && reflected.contains(MagicColor.toLongString(c))) {
|
||||
m.setExpressChoice(MagicColor.toShortString(c));
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (m.isAnyMana()) {
|
||||
byte colorChoice = 0;
|
||||
if (toPay.isOr2Colorless())
|
||||
colorChoice = toPay.getColorMask();
|
||||
else {
|
||||
for (byte c : MagicColor.WUBRG) {
|
||||
if (ai.getManaPool().canPayForShardWithColor(toPay, c)) {
|
||||
colorChoice = c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
m.setExpressChoice(MagicColor.toShortString(colorChoice));
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean canPayShardWithSpellAbility(ManaCostShard toPay, Player ai, SpellAbility ma, SpellAbility sa, boolean checkCosts) {
|
||||
final Card sourceCard = ma.getHostCard();
|
||||
|
||||
if (toPay.isSnow() && !sourceCard.isSnow()) { return false; }
|
||||
|
||||
AbilityManaPart m = ma.getManaPart();
|
||||
if (!m.meetsManaRestrictions(sa)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (checkCosts) {
|
||||
// Check if AI can still play this mana ability
|
||||
ma.setActivatingPlayer(ai);
|
||||
if (ma.getPayCosts() != null) { // if the AI can't pay the additional costs skip the mana ability
|
||||
if (!CostPayment.canPayAdditionalCosts(ma.getPayCosts(), ma)) {
|
||||
return false;
|
||||
}
|
||||
} else if (sourceCard.isTapped()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (m.isComboMana()) {
|
||||
for (String s : m.getComboColors().split(" ")) {
|
||||
if ("Any".equals(s) || ai.getManaPool().canPayForShardWithColor(toPay, MagicColor.fromName(s)))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
} else if (ma.getApi() == ApiType.ManaReflected) {
|
||||
Set<String> reflected = CardUtil.getReflectableManaColors(ma);
|
||||
|
||||
for (byte c : MagicColor.WUBRG) {
|
||||
if (ai.getManaPool().canPayForShardWithColor(toPay, c) && reflected.contains(MagicColor.toLongString(c))) {
|
||||
m.setExpressChoice(MagicColor.toShortString(c));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private static ManaCostShard getNextShardToPay(ManaCostBeingPaid cost, Multimap<ManaCostShard, SpellAbility> sourcesForShards) {
|
||||
// mind the priorities
|
||||
// * Pay mono-colored first,
|
||||
// * Pay 2/C with matching colors
|
||||
// * pay hybrids
|
||||
// * pay phyrexian, keep mana for colorless
|
||||
// * pay colorless
|
||||
|
||||
for (ManaCostShard s : cost.getDistinctShards()) { // should check in which order EnumMap enumerates keys. If it's same as enum member declaration, nothing else needs to be done.
|
||||
return s;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void adjustManaCostToAvoidNegEffects(ManaCostBeingPaid cost, final Card card, Player ai) {
|
||||
// Make mana needed to avoid negative effect a mandatory cost for the AI
|
||||
for (String manaPart : card.getSVar("ManaNeededToAvoidNegativeEffect").split(",")) {
|
||||
// convert long color strings to short color strings
|
||||
byte mask = MagicColor.fromName(manaPart);
|
||||
|
||||
// make mana mandatory for AI
|
||||
if (!cost.needsColor(mask, ai.getManaPool()) && cost.getColorlessManaAmount() > 0) {
|
||||
ManaCostShard shard = ManaCostShard.valueOf(mask);
|
||||
cost.increaseShard(shard, 1);
|
||||
cost.decreaseColorlessMana(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* getComboManaChoice.
|
||||
* </p>
|
||||
*
|
||||
* @param abMana
|
||||
* a {@link forge.card.spellability.AbilityMana} object.
|
||||
* @param saRoot
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
* @param cost
|
||||
* a {@link forge.game.mana.ManaCostBeingPaid} object.
|
||||
* @return String
|
||||
*/
|
||||
private static void getComboManaChoice(final Player ai, final SpellAbility manaAb, final SpellAbility saRoot, final ManaCostBeingPaid cost) {
|
||||
final StringBuilder choiceString = new StringBuilder();
|
||||
final Card source = manaAb.getHostCard();
|
||||
final AbilityManaPart abMana = manaAb.getManaPart();
|
||||
|
||||
if (abMana.isComboMana()) {
|
||||
int amount = manaAb.hasParam("Amount") ? AbilityUtils.calculateAmount(source, manaAb.getParam("Amount"), saRoot) : 1;
|
||||
final ManaCostBeingPaid testCost = new ManaCostBeingPaid(cost);
|
||||
final String[] comboColors = abMana.getComboColors().split(" ");
|
||||
for (int nMana = 1; nMana <= amount; nMana++) {
|
||||
String choice = "";
|
||||
// Use expressChoice first
|
||||
if (!abMana.getExpressChoice().isEmpty()) {
|
||||
choice = abMana.getExpressChoice();
|
||||
abMana.clearExpressChoice();
|
||||
byte colorMask = MagicColor.fromName(choice);
|
||||
if (abMana.canProduce(choice, manaAb) && testCost.isAnyPartPayableWith(colorMask, ai.getManaPool())) {
|
||||
choiceString.append(choice);
|
||||
payMultipleMana(testCost, choice, ai);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// check colors needed for cost
|
||||
if (!testCost.isPaid()) {
|
||||
// Loop over combo colors
|
||||
for (String color : comboColors) {
|
||||
if (testCost.isAnyPartPayableWith(MagicColor.fromName(color), ai.getManaPool())) {
|
||||
payMultipleMana(testCost, color, ai);
|
||||
if (nMana != 1) {
|
||||
choiceString.append(" ");
|
||||
}
|
||||
choiceString.append(color);
|
||||
choice = color;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!choice.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// check if combo mana can produce most common color in hand
|
||||
String commonColor = ComputerUtilCard.getMostProminentColor(ai.getCardsIn(
|
||||
ZoneType.Hand));
|
||||
if (!commonColor.isEmpty() && abMana.getComboColors().contains(MagicColor.toShortString(commonColor))) {
|
||||
choice = MagicColor.toShortString(commonColor);
|
||||
}
|
||||
else {
|
||||
// default to first color
|
||||
choice = comboColors[0];
|
||||
}
|
||||
if (nMana != 1) {
|
||||
choiceString.append(" ");
|
||||
}
|
||||
choiceString.append(choice);
|
||||
}
|
||||
}
|
||||
if (choiceString.toString().isEmpty()) {
|
||||
choiceString.append("0");
|
||||
}
|
||||
|
||||
abMana.setExpressChoice(choiceString.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* payMultipleMana.
|
||||
* </p>
|
||||
* @param testCost
|
||||
*
|
||||
* @param mana
|
||||
* a {@link java.lang.String} object.
|
||||
* @return a boolean.
|
||||
*/
|
||||
private final static String payMultipleMana(ManaCostBeingPaid testCost, String mana, final Player p) {
|
||||
List<String> unused = new ArrayList<String>(4);
|
||||
for (String manaPart : TextUtil.split(mana, ' ')) {
|
||||
if (StringUtils.isNumeric(manaPart)) {
|
||||
for (int i = Integer.parseInt(manaPart); i > 0; i--) {
|
||||
boolean wasNeeded = testCost.ai_payMana("1", p.getManaPool());
|
||||
if (!wasNeeded) {
|
||||
unused.add(Integer.toString(i));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
String color = MagicColor.toShortString(manaPart);
|
||||
boolean wasNeeded = testCost.ai_payMana(color, p.getManaPool());
|
||||
if (!wasNeeded) {
|
||||
unused.add(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
return unused.isEmpty() ? null : StringUtils.join(unused, ' ');
|
||||
}
|
||||
|
||||
/**
|
||||
* Find all mana sources.
|
||||
* @param manaAbilityMap
|
||||
* @param partSources
|
||||
* @param partPriority
|
||||
* @param costParts
|
||||
* @param foundAllSources
|
||||
* @return Were all mana sources found?
|
||||
*/
|
||||
private static Multimap<ManaCostShard, SpellAbility> groupAndOrderToPayShards(final Player ai, final Multimap<Integer, SpellAbility> manaAbilityMap,
|
||||
final ManaCostBeingPaid cost) {
|
||||
Multimap<ManaCostShard, SpellAbility> res = ArrayListMultimap.create();
|
||||
|
||||
// loop over cost parts
|
||||
for (ManaCostShard shard : cost.getDistinctShards()) {
|
||||
if (shard == ManaCostShard.S) {
|
||||
res.putAll(shard, manaAbilityMap.get(ManaAtom.IS_SNOW));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (shard.isOr2Colorless()) {
|
||||
Integer colorKey = Integer.valueOf(shard.getColorMask());
|
||||
if (manaAbilityMap.containsKey(colorKey))
|
||||
res.putAll(shard, manaAbilityMap.get(colorKey));
|
||||
if (manaAbilityMap.containsKey(ManaAtom.COLORLESS))
|
||||
res.putAll(shard, manaAbilityMap.get(ManaAtom.COLORLESS));
|
||||
continue;
|
||||
}
|
||||
|
||||
for (Entry<Integer, SpellAbility> kv : manaAbilityMap.entries()) {
|
||||
// apply mana color change matrix here
|
||||
if (ai.getManaPool().canPayForShardWithColor(shard, kv.getKey().byteValue())) {
|
||||
res.put(shard, kv.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cost.getColorlessManaAmount() > 0 && manaAbilityMap.containsKey(ManaAtom.COLORLESS)) {
|
||||
res.putAll(ManaCostShard.COLORLESS, manaAbilityMap.get(ManaAtom.COLORLESS));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the ManaCost for the given SpellAbility.
|
||||
* @param sa
|
||||
* @param test
|
||||
* @param extraMana
|
||||
* @return ManaCost
|
||||
*/
|
||||
static ManaCostBeingPaid calculateManaCost(final SpellAbility sa, final boolean test, final int extraMana) {
|
||||
ZoneType castFromBackup = null;
|
||||
if (test && sa.isSpell()) {
|
||||
castFromBackup = sa.getHostCard().getCastFrom();
|
||||
sa.getHostCard().setCastFrom(sa.getHostCard().getZone().getZoneType());
|
||||
}
|
||||
|
||||
Cost payCosts = sa.getPayCosts();
|
||||
CostPartMana manapart = payCosts != null ? payCosts.getCostMana() : null;
|
||||
final ManaCost mana = payCosts != null ? ( manapart == null ? ManaCost.ZERO : manapart.getManaCostFor(sa) ) : ManaCost.NO_COST;
|
||||
|
||||
String restriction = null;
|
||||
if (payCosts != null && payCosts.getCostMana() != null) {
|
||||
restriction = payCosts.getCostMana().getRestiction();
|
||||
}
|
||||
ManaCostBeingPaid cost = new ManaCostBeingPaid(mana, restriction);
|
||||
cost.applySpellCostChange(sa, test);
|
||||
|
||||
final Card card = sa.getHostCard();
|
||||
// Tack xMana Payments into mana here if X is a set value
|
||||
if ((sa.getPayCosts() != null) && (cost.getXcounter() > 0 || extraMana > 0)) {
|
||||
int manaToAdd = 0;
|
||||
if (test && extraMana > 0) {
|
||||
final int multiplicator = Math.max(cost.getXcounter(), 1);
|
||||
manaToAdd = extraMana * multiplicator;
|
||||
} else {
|
||||
// For Count$xPaid set PayX in the AFs then use that here
|
||||
// Else calculate it as appropriate.
|
||||
final String xSvar = card.getSVar("X").startsWith("Count$xPaid") ? "PayX" : "X";
|
||||
if (!card.getSVar(xSvar).equals("")) {
|
||||
if (xSvar.equals("PayX")) {
|
||||
manaToAdd = Integer.parseInt(card.getSVar(xSvar)) * cost.getXcounter(); // X
|
||||
} else {
|
||||
manaToAdd = AbilityUtils.calculateAmount(card, xSvar, sa) * cost.getXcounter();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String manaXColor = sa.getParam("XColor");
|
||||
ManaCostShard shardToGrow = ManaCostShard.parseNonGeneric(manaXColor == null ? "1" : manaXColor);
|
||||
cost.increaseShard(shardToGrow, manaToAdd);
|
||||
|
||||
if (!test) {
|
||||
card.setXManaCostPaid(manaToAdd / cost.getXcounter());
|
||||
}
|
||||
}
|
||||
|
||||
if (test && sa.isSpell()) {
|
||||
sa.getHostCard().setCastFrom(castFromBackup);
|
||||
}
|
||||
|
||||
return cost;
|
||||
}
|
||||
|
||||
//This method is currently used by AI to estimate available mana
|
||||
public static List<Card> getAvailableMana(final Player ai, final boolean checkPlayable) {
|
||||
final List<Card> list = ai.getCardsIn(ZoneType.Battlefield);
|
||||
list.addAll(ai.getCardsIn(ZoneType.Hand));
|
||||
final List<Card> manaSources = CardLists.filter(list, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
for (final SpellAbility am : getAIPlayableMana(c)) {
|
||||
am.setActivatingPlayer(ai);
|
||||
if (!checkPlayable || am.canPlay()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}); // CardListFilter
|
||||
|
||||
final List<Card> sortedManaSources = new ArrayList<Card>();
|
||||
final List<Card> otherManaSources = new ArrayList<Card>();
|
||||
final List<Card> colorlessManaSources = new ArrayList<Card>();
|
||||
final List<Card> oneManaSources = new ArrayList<Card>();
|
||||
final List<Card> twoManaSources = new ArrayList<Card>();
|
||||
final List<Card> threeManaSources = new ArrayList<Card>();
|
||||
final List<Card> fourManaSources = new ArrayList<Card>();
|
||||
final List<Card> fiveManaSources = new ArrayList<Card>();
|
||||
final List<Card> anyColorManaSources = new ArrayList<Card>();
|
||||
|
||||
// Sort mana sources
|
||||
// 1. Use lands that can only produce colorless mana without
|
||||
// drawback/cost first
|
||||
// 2. Search for mana sources that have a certain number of abilities
|
||||
// 3. Use lands that produce any color many
|
||||
// 4. all other sources (creature, costs, drawback, etc.)
|
||||
for (Card card : manaSources) {
|
||||
if (card.isCreature() || card.isEnchanted()) {
|
||||
otherManaSources.add(card);
|
||||
continue; // don't use creatures before other permanents
|
||||
}
|
||||
|
||||
int usableManaAbilities = 0;
|
||||
boolean needsLimitedResources = false;
|
||||
boolean producesAnyColor = false;
|
||||
final ArrayList<SpellAbility> manaAbilities = getAIPlayableMana(card);
|
||||
|
||||
for (final SpellAbility m : manaAbilities) {
|
||||
if (m.getManaPart().isAnyMana()) {
|
||||
producesAnyColor = true;
|
||||
}
|
||||
|
||||
final Cost cost = m.getPayCosts();
|
||||
if (cost != null) {
|
||||
needsLimitedResources |= !cost.isReusuableResource();
|
||||
}
|
||||
|
||||
// if the AI can't pay the additional costs skip the mana ability
|
||||
if (cost != null) {
|
||||
m.setActivatingPlayer(ai);
|
||||
if (!CostPayment.canPayAdditionalCosts(m.getPayCosts(), m)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// don't use abilities with dangerous drawbacks
|
||||
AbilitySub sub = m.getSubAbility();
|
||||
if (sub != null && !card.getName().equals("Pristine Talisman") && !card.getName().equals("Zhur-Taa Druid")) {
|
||||
if (!SpellApiToAi.Converter.get(sub.getApi()).chkDrawbackWithSubs(ai, sub)) {
|
||||
continue;
|
||||
}
|
||||
needsLimitedResources = true; // TODO: check for good drawbacks (gainLife)
|
||||
}
|
||||
usableManaAbilities++;
|
||||
}
|
||||
|
||||
if (needsLimitedResources) {
|
||||
otherManaSources.add(card);
|
||||
} else if (producesAnyColor) {
|
||||
anyColorManaSources.add(card);
|
||||
} else if (usableManaAbilities == 1) {
|
||||
if (manaAbilities.get(0).getManaPart().mana().equals("1")) {
|
||||
colorlessManaSources.add(card);
|
||||
} else {
|
||||
oneManaSources.add(card);
|
||||
}
|
||||
} else if (usableManaAbilities == 2) {
|
||||
twoManaSources.add(card);
|
||||
} else if (usableManaAbilities == 3) {
|
||||
threeManaSources.add(card);
|
||||
} else if (usableManaAbilities == 4) {
|
||||
fourManaSources.add(card);
|
||||
} else {
|
||||
fiveManaSources.add(card);
|
||||
}
|
||||
}
|
||||
sortedManaSources.addAll(colorlessManaSources);
|
||||
sortedManaSources.addAll(oneManaSources);
|
||||
sortedManaSources.addAll(twoManaSources);
|
||||
sortedManaSources.addAll(threeManaSources);
|
||||
sortedManaSources.addAll(fourManaSources);
|
||||
sortedManaSources.addAll(fiveManaSources);
|
||||
sortedManaSources.addAll(anyColorManaSources);
|
||||
//use better creatures later
|
||||
ComputerUtilCard.sortByEvaluateCreature(otherManaSources);
|
||||
Collections.reverse(otherManaSources);
|
||||
sortedManaSources.addAll(otherManaSources);
|
||||
return sortedManaSources;
|
||||
} // getAvailableMana()
|
||||
|
||||
//This method is currently used by AI to estimate mana available
|
||||
private static Multimap<Integer, SpellAbility> groupSourcesByManaColor(final Player ai, boolean checkPlayable) {
|
||||
final Multimap<Integer, SpellAbility> manaMap = ArrayListMultimap.create();
|
||||
final Game game = ai.getGame();
|
||||
|
||||
// Loop over all current available mana sources
|
||||
for (final Card sourceCard : getAvailableMana(ai, checkPlayable)) {
|
||||
for (final SpellAbility m : getAIPlayableMana(sourceCard)) {
|
||||
m.setActivatingPlayer(ai);
|
||||
if (checkPlayable && !m.canPlay()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// don't use abilities with dangerous drawbacks
|
||||
AbilitySub sub = m.getSubAbility();
|
||||
if (sub != null) {
|
||||
if (!SpellApiToAi.Converter.get(sub.getApi()).chkDrawbackWithSubs(ai, sub)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
manaMap.put(ManaAtom.COLORLESS, m); // add to colorless source list
|
||||
AbilityManaPart mp = m.getManaPart();
|
||||
|
||||
// setup produce mana replacement effects
|
||||
final Map<String, Object> repParams = new HashMap<String, Object>();
|
||||
repParams.put("Event", "ProduceMana");
|
||||
repParams.put("Mana", mp.getOrigProduced());
|
||||
repParams.put("Affected", sourceCard);
|
||||
repParams.put("Player", ai);
|
||||
repParams.put("AbilityMana", m);
|
||||
|
||||
for (final Player p : game.getPlayers()) {
|
||||
for (final Card crd : p.getAllCards()) {
|
||||
for (final ReplacementEffect replacementEffect : crd.getReplacementEffects()) {
|
||||
if (replacementEffect.requirementsCheck(game)
|
||||
&& replacementEffect.canReplace(repParams)
|
||||
&& replacementEffect.getMapParams().containsKey("ManaReplacement")
|
||||
&& replacementEffect.zonesCheck(game.getZoneOf(crd))) {
|
||||
String repType = crd.getSVar(replacementEffect.getMapParams().get("ManaReplacement"));
|
||||
if (repType.contains("Chosen")) {
|
||||
repType = repType.replace("Chosen", MagicColor.toShortString(crd.getChosenColor().get(0)));
|
||||
}
|
||||
mp.setManaReplaceType(repType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Set<String> reflectedColors = CardUtil.getReflectableManaColors(m);
|
||||
// find possible colors
|
||||
if (mp.canProduce("W", m) || reflectedColors.contains(MagicColor.Constant.WHITE)) {
|
||||
manaMap.put(ManaAtom.WHITE, m);
|
||||
}
|
||||
if (mp.canProduce("U", m) || reflectedColors.contains(MagicColor.Constant.BLUE)) {
|
||||
manaMap.put(ManaAtom.BLUE, m);
|
||||
}
|
||||
if (mp.canProduce("B", m) || reflectedColors.contains(MagicColor.Constant.BLACK)) {
|
||||
manaMap.put(ManaAtom.BLACK, m);
|
||||
}
|
||||
if (mp.canProduce("R", m) || reflectedColors.contains(MagicColor.Constant.RED)) {
|
||||
manaMap.put(ManaAtom.RED, m);
|
||||
}
|
||||
if (mp.canProduce("G", m) || reflectedColors.contains(MagicColor.Constant.GREEN)) {
|
||||
manaMap.put(ManaAtom.GREEN, m);
|
||||
}
|
||||
if (mp.isSnow()) {
|
||||
manaMap.put(ManaAtom.IS_SNOW, m);
|
||||
}
|
||||
} // end of mana abilities loop
|
||||
} // end of mana sources loop
|
||||
|
||||
return manaMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* determineLeftoverMana.
|
||||
* </p>
|
||||
*
|
||||
* @param sa
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
* @param player
|
||||
* a {@link forge.game.player.Player} object.
|
||||
* @return a int.
|
||||
* @since 1.0.15
|
||||
*/
|
||||
public static int determineLeftoverMana(final SpellAbility sa, final Player player) {
|
||||
for (int i = 1; i < 100; i++)
|
||||
if (!canPayManaCost(sa, player, i))
|
||||
return i - 1;
|
||||
|
||||
return 99;
|
||||
}
|
||||
|
||||
// Returns basic mana abilities plus "reflected mana" abilities
|
||||
/**
|
||||
* <p>
|
||||
* getAIPlayableMana.
|
||||
* </p>
|
||||
*
|
||||
* @return a {@link java.util.ArrayList} object.
|
||||
*/
|
||||
public static final ArrayList<SpellAbility> getAIPlayableMana(Card c) {
|
||||
final ArrayList<SpellAbility> res = new ArrayList<SpellAbility>();
|
||||
for (final SpellAbility a : c.getManaAbility()) {
|
||||
// if a mana ability has a mana cost the AI will miscalculate
|
||||
// if there is a parent ability the AI can't use it
|
||||
final Cost cost = a.getPayCosts();
|
||||
if (!cost.hasNoManaCost() || (a.getApi() != ApiType.Mana && a.getApi() != ApiType.ManaReflected)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!res.contains(a)) {
|
||||
res.add(a);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
private static void handleOfferingsAI(final SpellAbility sa, boolean test, boolean costIsPaid) {
|
||||
if (sa.isOffering() && sa.getSacrificedAsOffering() != null) {
|
||||
final Card offering = sa.getSacrificedAsOffering();
|
||||
offering.setUsedToPay(false);
|
||||
if (costIsPaid && !test) {
|
||||
sa.getHostCard().getController().getGame().getAction().sacrifice(offering, sa);
|
||||
}
|
||||
sa.resetSacrificedAsOffering();
|
||||
}
|
||||
}
|
||||
}
|
||||
63
forge-ai/src/main/java/forge/ai/LobbyPlayerAi.java
Normal file
63
forge-ai/src/main/java/forge/ai/LobbyPlayerAi.java
Normal file
@@ -0,0 +1,63 @@
|
||||
package forge.ai;
|
||||
|
||||
import forge.game.Game;
|
||||
import forge.game.player.LobbyPlayer;
|
||||
import forge.game.player.Player;
|
||||
|
||||
public class LobbyPlayerAi extends LobbyPlayer {
|
||||
public LobbyPlayerAi(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
private String aiProfile = "";
|
||||
private boolean rotateProfileEachGame;
|
||||
private boolean allowCheatShuffle;
|
||||
|
||||
public boolean isAllowCheatShuffle() {
|
||||
return allowCheatShuffle;
|
||||
}
|
||||
|
||||
|
||||
public void setAllowCheatShuffle(boolean allowCheatShuffle) {
|
||||
this.allowCheatShuffle = allowCheatShuffle;
|
||||
}
|
||||
|
||||
public void setAiProfile(String profileName) {
|
||||
aiProfile = profileName;
|
||||
}
|
||||
|
||||
public String getAiProfile() {
|
||||
return aiProfile;
|
||||
}
|
||||
|
||||
public void setRotateProfileEachGame(boolean rotateProfileEachGame) {
|
||||
this.rotateProfileEachGame = rotateProfileEachGame;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PlayerType getType() {
|
||||
return PlayerType.COMPUTER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerControllerAi createControllerFor(Player ai) {
|
||||
PlayerControllerAi result = new PlayerControllerAi(ai.getGame(), ai, this);
|
||||
result.allowCheatShuffle(allowCheatShuffle);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player createIngamePlayer(Game game) {
|
||||
Player ai = new Player(getName(), game);
|
||||
ai.setFirstController(createControllerFor(ai));
|
||||
|
||||
if( rotateProfileEachGame ) {
|
||||
setAiProfile(AiProfileUtil.getRandomProfile());
|
||||
System.out.println(String.format("AI profile %s was chosen for the lobby player %s.", getAiProfile(), getName()));
|
||||
}
|
||||
return ai;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hear(LobbyPlayer player, String message) { /* Local AI is deaf. */ }
|
||||
}
|
||||
765
forge-ai/src/main/java/forge/ai/PlayerControllerAi.java
Normal file
765
forge-ai/src/main/java/forge/ai/PlayerControllerAi.java
Normal file
@@ -0,0 +1,765 @@
|
||||
package forge.ai;
|
||||
|
||||
import com.esotericsoftware.minlog.Log;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import forge.ai.ability.ChangeZoneAi;
|
||||
import forge.ai.ability.CharmAi;
|
||||
import forge.card.ColorSet;
|
||||
import forge.card.MagicColor;
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.card.mana.ManaCostShard;
|
||||
import forge.deck.Deck;
|
||||
import forge.game.Game;
|
||||
import forge.game.GameEntity;
|
||||
import forge.game.GameObject;
|
||||
import forge.game.GameType;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.ability.ApiType;
|
||||
import forge.game.card.*;
|
||||
import forge.game.card.CardPredicates.Presets;
|
||||
import forge.game.combat.Combat;
|
||||
import forge.game.cost.Cost;
|
||||
import forge.game.cost.CostPart;
|
||||
import forge.game.cost.CostPartMana;
|
||||
import forge.game.mana.Mana;
|
||||
import forge.game.mana.ManaCostBeingPaid;
|
||||
import forge.game.player.LobbyPlayer;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.PlayerActionConfirmMode;
|
||||
import forge.game.player.PlayerController;
|
||||
import forge.game.replacement.ReplacementEffect;
|
||||
import forge.game.spellability.*;
|
||||
import forge.game.trigger.Trigger;
|
||||
import forge.game.trigger.WrappedAbility;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.item.PaperCard;
|
||||
import forge.util.Aggregates;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.security.InvalidParameterException;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
/**
|
||||
* A prototype for player controller class
|
||||
*
|
||||
* Handles phase skips for now.
|
||||
*/
|
||||
public class PlayerControllerAi extends PlayerController {
|
||||
private final AiController brains;
|
||||
|
||||
public PlayerControllerAi(Game game, Player p, LobbyPlayer lp) {
|
||||
super(game, p, lp);
|
||||
|
||||
brains = new AiController(p, game);
|
||||
}
|
||||
|
||||
public void allowCheatShuffle(boolean value){
|
||||
brains.allowCheatShuffle(value);
|
||||
}
|
||||
|
||||
|
||||
public SpellAbility getAbilityToPlay(List<SpellAbility> abilities, MouseEvent triggerEvent) {
|
||||
if (abilities.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
return abilities.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this method.
|
||||
* @param c
|
||||
*/
|
||||
/**public void playFromSuspend(Card c) {
|
||||
final List<SpellAbility> choices = c.getBasicSpells();
|
||||
c.setSuspendCast(true);
|
||||
getAi().chooseAndPlaySa(choices, true, true);
|
||||
}**/
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this method.
|
||||
* @return
|
||||
*/
|
||||
public AiController getAi() {
|
||||
return brains;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PaperCard> sideboard(Deck deck, GameType gameType) {
|
||||
// AI does not know how to sideboard
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Card, Integer> assignCombatDamage(Card attacker, List<Card> blockers, int damageDealt, GameEntity defender, boolean overrideOrder) {
|
||||
return ComputerUtilCombat.distributeAIDamage(attacker, blockers, damageDealt, defender, overrideOrder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer announceRequirements(SpellAbility ability, String announce, boolean allowZero) {
|
||||
// For now, these "announcements" are made within the AI classes of the appropriate SA effects
|
||||
return null; // return incorrect value to indicate that
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Card> choosePermanentsToSacrifice(SpellAbility sa, int min, int max, List<Card> validTargets, String message) {
|
||||
return ComputerUtil.choosePermanentsToSacrifice(player, validTargets, max, sa, false, min == 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Card> choosePermanentsToDestroy(SpellAbility sa, int min, int max, List<Card> validTargets, String message) {
|
||||
return ComputerUtil.choosePermanentsToSacrifice(player, validTargets, max, sa, true, min == 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Card> chooseCardsForEffect(List<Card> sourceList, SpellAbility sa, String title, int min, int max, boolean isOptional) {
|
||||
return brains.chooseCardsForEffect(sourceList, sa, min, max, isOptional);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends GameEntity> T chooseSingleEntityForEffect(Collection<T> options, SpellAbility sa, String title, boolean isOptional, Player targetedPlayer) {
|
||||
ApiType api = sa.getApi();
|
||||
if (null == api) {
|
||||
throw new InvalidParameterException("SA is not api-based, this is not supported yet");
|
||||
}
|
||||
return SpellApiToAi.Converter.get(api).chooseSingleEntity(player, sa, options, isOptional, targetedPlayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpellAbility chooseSingleSpellForEffect(java.util.List<SpellAbility> spells, SpellAbility sa, String title) {
|
||||
ApiType api = sa.getApi();
|
||||
if (null == api) {
|
||||
throw new InvalidParameterException("SA is not api-based, this is not supported yet");
|
||||
}
|
||||
return SpellApiToAi.Converter.get(api).chooseSingleSpellAbility(player, sa, spells);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean confirmAction(SpellAbility sa, PlayerActionConfirmMode mode, String message) {
|
||||
return getAi().confirmAction(sa, mode, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean confirmStaticApplication(Card hostCard, GameEntity affected, String logic, String message) {
|
||||
return getAi().confirmStaticApplication(hostCard, affected, logic, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean confirmTrigger(SpellAbility sa, Trigger regtrig, Map<String, String> triggerParams, boolean isMandatory) {
|
||||
if (triggerParams.containsKey("DelayedTrigger")) {
|
||||
//TODO: The only card with an optional delayed trigger is Shirei, Shizo's Caretaker,
|
||||
// needs to be expanded when a more difficult cards comes up
|
||||
return true;
|
||||
}
|
||||
// Store/replace target choices more properly to get this SA cleared.
|
||||
TargetChoices tc = null;
|
||||
TargetChoices subtc = null;
|
||||
boolean storeChoices = sa.getTargetRestrictions() != null;
|
||||
final SpellAbility sub = sa.getSubAbility();
|
||||
boolean storeSubChoices = sub != null && sub.getTargetRestrictions() != null;
|
||||
boolean ret = true;
|
||||
|
||||
if (storeChoices) {
|
||||
tc = sa.getTargets();
|
||||
sa.resetTargets();
|
||||
}
|
||||
if (storeSubChoices) {
|
||||
subtc = sub.getTargets();
|
||||
sub.resetTargets();
|
||||
}
|
||||
// There is no way this doTrigger here will have the same target as stored above
|
||||
// So it's possible it's making a different decision here than will actually happen
|
||||
if (!brains.doTrigger(sa, isMandatory)) {
|
||||
ret = false;
|
||||
}
|
||||
if (storeChoices) {
|
||||
sa.resetTargets();
|
||||
sa.setTargets(tc);
|
||||
}
|
||||
if (storeSubChoices) {
|
||||
sub.resetTargets();
|
||||
sub.setTargets(subtc);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getWillPlayOnFirstTurn(boolean isFirstGame) {
|
||||
return true; // AI is brave :)
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Card> orderBlockers(Card attacker, List<Card> blockers) {
|
||||
return AiBlockController.orderBlockers(attacker, blockers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Card> orderAttackers(Card blocker, List<Card> attackers) {
|
||||
return AiBlockController.orderAttackers(blocker, attackers);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.game.player.PlayerController#reveal(java.lang.String, java.util.List)
|
||||
*/
|
||||
@Override
|
||||
public void reveal(Collection<Card> cards, ZoneType zone, Player owner, String messagePrefix) {
|
||||
// We don't know how to reveal cards to AI
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutablePair<List<Card>, List<Card>> arrangeForScry(List<Card> topN) {
|
||||
List<Card> toBottom = new ArrayList<Card>();
|
||||
List<Card> toTop = new ArrayList<Card>();
|
||||
|
||||
for (Card c: topN) {
|
||||
if (ComputerUtil.scryWillMoveCardToBottomOfLibrary(player, c)) {
|
||||
toBottom.add(c);
|
||||
}
|
||||
else {
|
||||
toTop.add(c);
|
||||
}
|
||||
}
|
||||
|
||||
// put the rest on top in random order
|
||||
Collections.shuffle(toTop);
|
||||
return ImmutablePair.of(toTop, toBottom);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean willPutCardOnTop(Card c) {
|
||||
return true; // AI does not know what will happen next (another clash or that would become his topdeck)
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Card> orderMoveToZoneList(List<Card> cards, ZoneType destinationZone) {
|
||||
//TODO Add logic for AI ordering here
|
||||
return cards;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Card> chooseCardsToDiscardFrom(Player p, SpellAbility sa, List<Card> validCards, int min, int max) {
|
||||
if (p == player) {
|
||||
return brains.getCardsToDiscard(min, max, validCards, sa);
|
||||
}
|
||||
|
||||
boolean isTargetFriendly = !p.isOpponentOf(player);
|
||||
|
||||
return isTargetFriendly
|
||||
? ComputerUtil.getCardsToDiscardFromFriend(player, p, sa, validCards, min, max)
|
||||
: ComputerUtil.getCardsToDiscardFromOpponent(player, p, sa, validCards, min, max);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.game.player.PlayerController#mayPlaySpellAbilityForFree(forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
public void playSpellAbilityForFree(SpellAbility copySA, boolean mayChooseNewTargets) {
|
||||
// Ai is known to set targets in doTrigger, so if it cannot choose new targets, we won't call canPlays
|
||||
if (mayChooseNewTargets) {
|
||||
if (copySA instanceof Spell) {
|
||||
Spell spell = (Spell) copySA;
|
||||
((PlayerControllerAi) player.getController()).getAi().canPlayFromEffectAI(spell, true, true);
|
||||
}
|
||||
else {
|
||||
getAi().canPlaySa(copySA);
|
||||
}
|
||||
}
|
||||
ComputerUtil.playSpellAbilityForFree(player, copySA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSpellAbilityNoStack(SpellAbility effectSA, boolean canSetupTargets) {
|
||||
if (canSetupTargets)
|
||||
brains.doTrigger(effectSA, true); // first parameter does not matter, since return value won't be used
|
||||
ComputerUtil.playNoStack(player, effectSA, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playMiracle(SpellAbility miracle, Card card) {
|
||||
getAi().chooseAndPlaySa(false, false, miracle);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.game.player.PlayerController#chooseCardsToDelve(int, java.util.List)
|
||||
*/
|
||||
@Override
|
||||
public List<Card> chooseCardsToDelve(int colorlessCost, List<Card> grave) {
|
||||
return getAi().chooseCardsToDelve(colorlessCost, grave);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.game.player.PlayerController#chooseTargets(forge.card.spellability.SpellAbility, forge.card.spellability.SpellAbilityStackInstance)
|
||||
*/
|
||||
@Override
|
||||
public TargetChoices chooseNewTargetsFor(SpellAbility ability) {
|
||||
// AI currently can't do this. But when it can it will need to be based on Ability API
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.game.player.PlayerController#chooseCardsToDiscardUnlessType(int, java.util.List, java.lang.String, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
public List<Card> chooseCardsToDiscardUnlessType(int num, List<Card> hand, String uType, SpellAbility sa) {
|
||||
final List<Card> cardsOfType = CardLists.getType(hand, uType);
|
||||
if (!cardsOfType.isEmpty()) {
|
||||
Card toDiscard = Aggregates.itemWithMin(cardsOfType, CardPredicates.Accessors.fnGetCmc);
|
||||
return Lists.newArrayList(toDiscard);
|
||||
}
|
||||
return getAi().getCardsToDiscard(num, (String[])null, sa);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Mana chooseManaFromPool(List<Mana> manaChoices) {
|
||||
return manaChoices.get(0); // no brains used
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.game.player.PlayerController#ChooseSomeType(java.lang.String, java.util.List, java.util.List)
|
||||
*/
|
||||
@Override
|
||||
public String chooseSomeType(String kindOfType, SpellAbility sa, List<String> validTypes, List<String> invalidTypes, boolean isOptional) {
|
||||
String chosen = ComputerUtil.chooseSomeType(player, kindOfType, sa.getParam("AILogic"), invalidTypes);
|
||||
if (StringUtils.isBlank(chosen) && !validTypes.isEmpty())
|
||||
{
|
||||
chosen = validTypes.get(0);
|
||||
Log.warn("AI has no idea how to choose " + kindOfType +", defaulting to 1st element: chosen");
|
||||
}
|
||||
game.getAction().nofityOfValue(sa, null, "Computer picked: " + chosen, player);
|
||||
return chosen;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.game.player.PlayerController#confirmReplacementEffect(forge.card.replacement.ReplacementEffect, forge.card.spellability.SpellAbility, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public boolean confirmReplacementEffect(ReplacementEffect replacementEffect, SpellAbility effectSA, String question) {
|
||||
return brains.aiShouldRun(replacementEffect, effectSA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Card> getCardsToMulligan(boolean isCommander, Player firstPlayer) {
|
||||
if (!ComputerUtil.wantMulligan(player)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!isCommander) {
|
||||
return player.getCardsIn(ZoneType.Hand);
|
||||
}
|
||||
else {
|
||||
return ComputerUtil.getPartialParisCandidates(player);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void declareAttackers(Player attacker, Combat combat) {
|
||||
brains.declareAttackers(attacker, combat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void declareBlockers(Player defender, Combat combat) {
|
||||
brains.declareBlockersFor(defender, combat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpellAbility chooseSpellAbilityToPlay() {
|
||||
return brains.choooseSpellAbilityToPlay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playChosenSpellAbility(SpellAbility sa)
|
||||
{
|
||||
// System.out.println("Playing sa: " + sa);
|
||||
if ( sa == Ability.PLAY_LAND_SURROGATE )
|
||||
player.playLand(sa.getHostCard(), false);
|
||||
else
|
||||
ComputerUtil.handlePlayingSpellAbility(player, sa, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Card> chooseCardsToDiscardToMaximumHandSize(int numDiscard) {
|
||||
return brains.getCardsToDiscard(numDiscard, (String[])null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Card> chooseCardsToRevealFromHand(int min, int max, List<Card> valid) {
|
||||
int numCardsToReveal = Math.min(max, valid.size());
|
||||
return numCardsToReveal == 0 ? Lists.<Card>newArrayList() : valid.subList(0, numCardsToReveal);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean payManaOptional(Card c, Cost cost, SpellAbility sa, String prompt, ManaPaymentPurpose purpose) {
|
||||
final Ability ability = new AbilityStatic(c, cost, null) { @Override public void resolve() {} };
|
||||
ability.setActivatingPlayer(c.getController());
|
||||
|
||||
if (ComputerUtilCost.canPayCost(ability, c.getController())) {
|
||||
ComputerUtil.playNoStack(c.getController(), ability, game);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SpellAbility> chooseSaToActivateFromOpeningHand(List<SpellAbility> usableFromOpeningHand) {
|
||||
// AI would play everything. But limits to one copy of (Leyline of Singularity) and (Gemstone Caverns)
|
||||
return brains.chooseSaToActivateFromOpeningHand(usableFromOpeningHand);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int chooseNumber(SpellAbility sa, String title, int min, int max) {
|
||||
return brains.chooseNumber(sa, title, min, max);
|
||||
}
|
||||
|
||||
public int chooseNumber(SpellAbility sa, String title, List<Integer> options, Player relatedPlayer) {
|
||||
return brains.chooseNumber(sa, title, options, relatedPlayer);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.game.player.PlayerController#chooseFlipResult(forge.Card, forge.game.player.Player, java.lang.String[], boolean)
|
||||
*/
|
||||
@Override
|
||||
public boolean chooseFlipResult(SpellAbility sa, Player flipper, boolean[] results, boolean call) {
|
||||
if (call) {
|
||||
// Win if possible
|
||||
boolean result = false;
|
||||
for (boolean s : results) {
|
||||
if (s) {
|
||||
result = s;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
// heads or tails, AI doesn't know which is better now
|
||||
int i = MyRandom.getRandom().nextInt(results.length);
|
||||
return results[i];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<SpellAbilityStackInstance, GameObject> chooseTarget(SpellAbility saSrc, List<Pair<SpellAbilityStackInstance, GameObject>> allTargets) {
|
||||
// TODO Teach AI how to use Spellskite
|
||||
return allTargets.get(0);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void notifyOfValue(SpellAbility saSource, GameObject realtedTarget, String value) {
|
||||
// AI should take into consideration creature types, numbers and other information (mostly choices) arriving through this channel
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chooseBinary(SpellAbility sa, String question, BinaryChoiceType kindOfChoice, Boolean defaultVal) {
|
||||
switch(kindOfChoice) {
|
||||
case TapOrUntap: return true;
|
||||
case UntapOrLeaveTapped: return defaultVal != null && defaultVal.booleanValue();
|
||||
case UntapTimeVault: return false; // TODO Should AI skip his turn for time vault?
|
||||
default:
|
||||
return MyRandom.getRandom().nextBoolean();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Card chooseProtectionShield(GameEntity entityBeingDamaged, List<String> options, Map<String, Card> choiceMap) {
|
||||
int i = MyRandom.getRandom().nextInt(options.size());
|
||||
return choiceMap.get(options.get(i));
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.game.player.PlayerController#chooseModeForAbility(forge.card.spellability.SpellAbility, java.util.List, int, int)
|
||||
*/
|
||||
@Override
|
||||
public List<AbilitySub> chooseModeForAbility(SpellAbility sa, int min, int num) {
|
||||
return CharmAi.chooseOptionsAi(sa, player, sa.isTrigger(), num, min, !player.equals(sa.getActivatingPlayer()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<CounterType,String> chooseAndRemoveOrPutCounter(Card cardWithCounter) {
|
||||
if (!cardWithCounter.hasCounters()) {
|
||||
System.out.println("chooseCounterType was reached with a card with no counters on it. Consider filtering this card out earlier");
|
||||
return null;
|
||||
}
|
||||
|
||||
final Player controller = cardWithCounter.getController();
|
||||
final List<Player> enemies = player.getOpponents();
|
||||
final List<Player> allies = player.getAllies();
|
||||
allies.add(player);
|
||||
|
||||
List<CounterType> countersToIncrease = new ArrayList<CounterType>();
|
||||
List<CounterType> countersToDecrease = new ArrayList<CounterType>();
|
||||
|
||||
for (final CounterType counter : cardWithCounter.getCounters().keySet()) {
|
||||
if ((!ComputerUtil.isNegativeCounter(counter, cardWithCounter) && allies.contains(controller))
|
||||
|| (ComputerUtil.isNegativeCounter(counter, cardWithCounter) && enemies.contains(controller))) {
|
||||
countersToIncrease.add(counter);
|
||||
} else {
|
||||
countersToDecrease.add(counter);
|
||||
}
|
||||
}
|
||||
|
||||
if (!countersToIncrease.isEmpty()) {
|
||||
int random = MyRandom.getRandom().nextInt(countersToIncrease.size());
|
||||
return new ImmutablePair<CounterType,String>(countersToIncrease.get(random),"Put");
|
||||
}
|
||||
else if (!countersToDecrease.isEmpty()) {
|
||||
int random = MyRandom.getRandom().nextInt(countersToDecrease.size());
|
||||
return new ImmutablePair<CounterType,String>(countersToDecrease.get(random),"Remove");
|
||||
}
|
||||
|
||||
// shouldn't reach here but just in case, remove random counter
|
||||
List<CounterType> countersOnCard = new ArrayList<CounterType>();
|
||||
int random = MyRandom.getRandom().nextInt(countersOnCard.size());
|
||||
return new ImmutablePair<CounterType,String>(countersOnCard.get(random),"Remove");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public byte chooseColorAllowColorless(String message, Card card, ColorSet colors) {
|
||||
final String c = ComputerUtilCard.getMostProminentColor(player.getCardsIn(ZoneType.Hand));
|
||||
byte chosenColorMask = MagicColor.fromName(c);
|
||||
if ((colors.getColor() & chosenColorMask) != 0) {
|
||||
return chosenColorMask;
|
||||
} else {
|
||||
return Iterables.getFirst(colors, (byte)0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte chooseColor(String message, SpellAbility sa, ColorSet colors) {
|
||||
// You may switch on sa.getApi() here and use sa.getParam("AILogic")
|
||||
List<Card> hand = new ArrayList<Card>(player.getCardsIn(ZoneType.Hand));
|
||||
if( sa.getApi() == ApiType.Mana )
|
||||
hand.addAll(player.getCardsIn(ZoneType.Stack));
|
||||
final String c = ComputerUtilCard.getMostProminentColor(hand);
|
||||
byte chosenColorMask = MagicColor.fromName(c);
|
||||
|
||||
|
||||
if ((colors.getColor() & chosenColorMask) != 0) {
|
||||
return chosenColorMask;
|
||||
} else {
|
||||
return Iterables.getFirst(colors, MagicColor.WHITE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaperCard chooseSinglePaperCard(SpellAbility sa, String message,
|
||||
Predicate<PaperCard> cpp, String name) {
|
||||
throw new UnsupportedOperationException("Should not be called for AI"); // or implement it if you know how
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> chooseColors(String message, SpellAbility sa, int min, int max, List<String> options) {
|
||||
return ComputerUtilCard.chooseColor(sa, min, max, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CounterType chooseCounterType(Collection<CounterType> options, SpellAbility sa, String prompt) {
|
||||
// may write a smarter AI if you need to (with calls to AI-clas for given API ability)
|
||||
|
||||
// TODO: ArsenalNut (06 Feb 12)computer needs
|
||||
// better logic to pick a counter type and probably
|
||||
// an initial target
|
||||
// find first nonzero counter on target
|
||||
return Iterables.getFirst(options, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean confirmPayment(CostPart costPart, String prompt) {
|
||||
return brains.confirmPayment(costPart); // AI is expected to know what it is paying for at the moment (otherwise add another parameter to this method)
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReplacementEffect chooseSingleReplacementEffect(String prompt, List<ReplacementEffect> possibleReplacers, HashMap<String, Object> runParams) {
|
||||
// AI logic for choosing which replacement effect to apply
|
||||
// happens here.
|
||||
return possibleReplacers.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String chooseProtectionType(String string, SpellAbility sa, List<String> choices) {
|
||||
String choice = choices.get(0);
|
||||
final String logic = sa.getParam("AILogic");
|
||||
if (logic == null || logic.equals("MostProminentHumanCreatures")) {
|
||||
List<Card> list = new ArrayList<Card>();
|
||||
for (Player opp : player.getOpponents()) {
|
||||
list.addAll(opp.getCreaturesInPlay());
|
||||
}
|
||||
if (list.isEmpty()) {
|
||||
list = CardLists.filterControlledBy(game.getCardsInGame(), player.getOpponents());
|
||||
}
|
||||
if (!list.isEmpty()) {
|
||||
choice = ComputerUtilCard.getMostProminentColor(list);
|
||||
}
|
||||
}
|
||||
return choice;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean payCostToPreventEffect(Cost cost, SpellAbility sa, boolean alreadyPaid, List<Player> allPayers) {
|
||||
final Card source = sa.getHostCard();
|
||||
final Ability emptyAbility = new AbilityStatic(source, cost, sa.getTargetRestrictions()) { @Override public void resolve() { } };
|
||||
emptyAbility.setActivatingPlayer(player);
|
||||
if (ComputerUtilCost.willPayUnlessCost(sa, player, cost, alreadyPaid, allPayers) && ComputerUtilCost.canPayCost(emptyAbility, player)) {
|
||||
ComputerUtil.playNoStack(player, emptyAbility, game); // AI needs something to resolve to pay that cost
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void orderAndPlaySimultaneousSa(List<SpellAbility> activePlayerSAs) {
|
||||
for (final SpellAbility sa : activePlayerSAs) {
|
||||
prepareSingleSa(sa.getHostCard(),sa,true);
|
||||
ComputerUtil.playStack(sa, player, game);
|
||||
}
|
||||
}
|
||||
|
||||
private void prepareSingleSa(final Card host, final SpellAbility sa, boolean isMandatory){
|
||||
if (sa.hasParam("TargetingPlayer")) {
|
||||
Player targetingPlayer = AbilityUtils.getDefinedPlayers(host, sa.getParam("TargetingPlayer"), sa).get(0);
|
||||
targetingPlayer.getController().chooseTargetsFor(sa);
|
||||
} else {
|
||||
brains.doTrigger(sa, isMandatory);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playTrigger(Card host, WrappedAbility wrapperAbility, boolean isMandatory) {
|
||||
prepareSingleSa(host, wrapperAbility, isMandatory);
|
||||
ComputerUtil.playNoStack(wrapperAbility.getActivatingPlayer(), wrapperAbility, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playSaFromPlayEffect(SpellAbility tgtSA) {
|
||||
boolean optional = tgtSA.hasParam("Optional");
|
||||
boolean noManaCost = tgtSA.hasParam("WithoutManaCost");
|
||||
if (tgtSA instanceof Spell) { // Isn't it ALWAYS a spell?
|
||||
Spell spell = (Spell) tgtSA;
|
||||
if (brains.canPlayFromEffectAI(spell, !optional, noManaCost) == AiPlayDecision.WillPlay || !optional) {
|
||||
if (noManaCost) {
|
||||
ComputerUtil.playSpellAbilityWithoutPayingManaCost(player, tgtSA, game);
|
||||
} else {
|
||||
ComputerUtil.playStack(tgtSA, player, game);
|
||||
}
|
||||
} else
|
||||
return false; // didn't play spell
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<GameEntity, CounterType> chooseProliferation() {
|
||||
return brains.chooseProliferation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chooseTargetsFor(SpellAbility currentAbility) {
|
||||
return brains.doTrigger(currentAbility, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chooseCardsPile(SpellAbility sa, List<Card> pile1, List<Card> pile2, boolean faceUp) {
|
||||
if (!faceUp) {
|
||||
// AI will choose the first pile if it is larger or the same
|
||||
// TODO Improve this to be slightly more random to not be so predictable
|
||||
return pile1.size() >= pile2.size();
|
||||
} else {
|
||||
boolean allCreatures = Iterables.all(Iterables.concat(pile1, pile2), CardPredicates.Presets.CREATURES);
|
||||
int cmc1 = allCreatures ? ComputerUtilCard.evaluateCreatureList(pile1) : ComputerUtilCard.evaluatePermanentList(pile1);
|
||||
int cmc2 = allCreatures ? ComputerUtilCard.evaluateCreatureList(pile2) : ComputerUtilCard.evaluatePermanentList(pile2);
|
||||
System.out.println("value:" + cmc1 + " " + cmc2);
|
||||
|
||||
// for now, this assumes that the outcome will be bad
|
||||
// TODO: This should really have a ChooseLogic param to
|
||||
// figure this out
|
||||
return "Worst".equals(sa.getParam("AILogic")) ^ (cmc1 >= cmc2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void revealAnte(String message, Multimap<Player, PaperCard> removedAnteCards) {
|
||||
// Ai won't understand that anyway
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<? extends PaperCard> complainCardsCantPlayWell(Deck myDeck) {
|
||||
return brains.complainCardsCantPlayWell(myDeck);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Card> cheatShuffle(List<Card> list) {
|
||||
return brains.getBooleanProperty(AiProps.CHEAT_WITH_MANA_ON_SHUFFLE) ? brains.cheatShuffle(list) : list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CardShields chooseRegenerationShield(Card c) {
|
||||
return Iterables.getFirst(c.getShield(), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PaperCard> chooseCardsYouWonToAddToDeck(List<PaperCard> losses) {
|
||||
// TODO AI takes all by default
|
||||
return losses;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean payManaCost(ManaCost toPay, CostPartMana costPartMana, SpellAbility sa, String prompt /* ai needs hints as well */ ) {
|
||||
// TODO Auto-generated method stub
|
||||
ManaCostBeingPaid cost = ComputerUtilMana.calculateManaCost(sa, false, 0);
|
||||
return ComputerUtilMana.payManaCost(cost, sa, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Card, ManaCostShard> chooseCardsForConvoke(SpellAbility sa, ManaCost manaCost,
|
||||
List<Card> untappedCreats) {
|
||||
// TODO: AI to choose a creature to tap would go here
|
||||
// Probably along with deciding how many creatures to tap
|
||||
return new HashMap<Card, ManaCostShard>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String chooseCardName(SpellAbility sa, Predicate<PaperCard> cpp, String valid, String message) {
|
||||
if (sa.hasParam("AILogic")) {
|
||||
final String logic = sa.getParam("AILogic");
|
||||
if (logic.equals("MostProminentInComputerDeck")) {
|
||||
return ComputerUtilCard.getMostProminentCardName(player.getCardsIn(ZoneType.Library));
|
||||
} else if (logic.equals("MostProminentInHumanDeck")) {
|
||||
return ComputerUtilCard.getMostProminentCardName(player.getOpponent().getCardsIn(ZoneType.Library));
|
||||
} else if (logic.equals("BestCreatureInComputerDeck")) {
|
||||
return ComputerUtilCard.getBestCreatureAI(player.getCardsIn(ZoneType.Library)).getName();
|
||||
} else if (logic.equals("RandomInComputerDeck")) {
|
||||
return Aggregates.random(player.getCardsIn(ZoneType.Library)).getName();
|
||||
}
|
||||
} else {
|
||||
List<Card> list = CardLists.filterControlledBy(game.getCardsInGame(), player.getOpponent());
|
||||
list = CardLists.filter(list, Predicates.not(Presets.LANDS));
|
||||
if (!list.isEmpty()) {
|
||||
return list.get(0).getName();
|
||||
}
|
||||
}
|
||||
return "Morphling";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Card chooseSingleCardForZoneChange(ZoneType destination,
|
||||
List<ZoneType> origin, SpellAbility sa, List<Card> fetchList,
|
||||
String selectPrompt, boolean b, Player decider) {
|
||||
|
||||
return ChangeZoneAi.chooseCardToHiddenOriginChangeZone(destination, origin, sa, fetchList, player, decider);
|
||||
}
|
||||
|
||||
}
|
||||
175
forge-ai/src/main/java/forge/ai/SpellAbilityAi.java
Normal file
175
forge-ai/src/main/java/forge/ai/SpellAbilityAi.java
Normal file
@@ -0,0 +1,175 @@
|
||||
package forge.ai;
|
||||
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import forge.game.GameEntity;
|
||||
import forge.game.ability.SaTargetRoutines;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.phase.PhaseHandler;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.PlayerActionConfirmMode;
|
||||
import forge.game.spellability.AbilitySub;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class SpellAbilityAi extends SaTargetRoutines {
|
||||
|
||||
public final boolean canPlayAIWithSubs(final Player aiPlayer, final SpellAbility sa) {
|
||||
if (!canPlayAI(aiPlayer, sa)) {
|
||||
return false;
|
||||
}
|
||||
final AbilitySub subAb = sa.getSubAbility();
|
||||
return subAb == null || chkDrawbackWithSubs(aiPlayer, subAb);
|
||||
}
|
||||
|
||||
protected abstract boolean canPlayAI(final Player aiPlayer, final SpellAbility sa);
|
||||
|
||||
public final boolean doTriggerAI(final Player aiPlayer, final SpellAbility sa, final boolean mandatory) {
|
||||
if (!ComputerUtilCost.canPayCost(sa, aiPlayer) && !mandatory) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return doTriggerNoCostWithSubs(aiPlayer, sa, mandatory);
|
||||
}
|
||||
|
||||
public final boolean doTriggerNoCostWithSubs(final Player aiPlayer, final SpellAbility sa, final boolean mandatory)
|
||||
{
|
||||
if (!doTriggerAINoCost(aiPlayer, sa, mandatory)) {
|
||||
return false;
|
||||
}
|
||||
final AbilitySub subAb = sa.getSubAbility();
|
||||
return subAb == null || chkDrawbackWithSubs(aiPlayer, subAb) || mandatory;
|
||||
}
|
||||
|
||||
protected boolean doTriggerAINoCost(final Player aiPlayer, final SpellAbility sa, final boolean mandatory) {
|
||||
if (canPlayAI(aiPlayer, sa)) {
|
||||
return true;
|
||||
}
|
||||
if (mandatory) {
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
final Player opp = aiPlayer.getOpponent();
|
||||
if (tgt != null) {
|
||||
if (opp.canBeTargetedBy(sa)) {
|
||||
sa.resetTargets();
|
||||
sa.getTargets().add(opp);
|
||||
} else if (mandatory) {
|
||||
if (aiPlayer.canBeTargetedBy(sa)) {
|
||||
sa.resetTargets();
|
||||
sa.getTargets().add(opp);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean chkAIDrawback(final SpellAbility sa, final Player aiPlayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* isSorcerySpeed.
|
||||
* </p>
|
||||
*
|
||||
* @param sa
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
* @return a boolean.
|
||||
*/
|
||||
protected static boolean isSorcerySpeed(final SpellAbility sa) {
|
||||
return ( sa.isSpell() && sa.getHostCard().isSorcery() )
|
||||
|| ( sa.isAbility() && sa.getRestrictions().isSorcerySpeed() );
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* playReusable.
|
||||
* </p>
|
||||
*
|
||||
* @param sa
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
* @return a boolean.
|
||||
*/
|
||||
protected static boolean playReusable(final Player ai, final SpellAbility sa) {
|
||||
// TODO probably also consider if winter orb or similar are out
|
||||
|
||||
if (sa.getPayCosts() == null || sa instanceof AbilitySub) {
|
||||
return true; // This is only true for Drawbacks and triggers
|
||||
}
|
||||
|
||||
if (ComputerUtil.playImmediately(ai, sa)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!sa.getPayCosts().isReusuableResource()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sa.getRestrictions().getPlaneswalker() && ai.getGame().getPhaseHandler().is(PhaseType.MAIN2)) {
|
||||
return true;
|
||||
}
|
||||
if (sa.isTrigger()) {
|
||||
return true;
|
||||
}
|
||||
if (sa.isSpell() && !sa.isBuyBackAbility()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PhaseHandler phase = ai.getGame().getPhaseHandler();
|
||||
return phase.is(PhaseType.END_OF_TURN) && phase.getNextTurn().equals(ai);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this method.
|
||||
* @param ai
|
||||
* @param subAb
|
||||
* @return
|
||||
*/
|
||||
public boolean chkDrawbackWithSubs(Player aiPlayer, AbilitySub ab) {
|
||||
final AbilitySub subAb = ab.getSubAbility();
|
||||
return SpellApiToAi.Converter.get(ab.getApi()).chkAIDrawback(ab, aiPlayer) && (subAb == null || chkDrawbackWithSubs(aiPlayer, subAb));
|
||||
}
|
||||
|
||||
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) {
|
||||
System.err.println("Warning: default (ie. inherited from base class) implementation of confirmAction is used for " + this.getClass().getName() + ". Consider declaring an overloaded method");
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends GameEntity> T chooseSingleEntity(Player ai, SpellAbility sa, Collection<T> options, boolean isOptional, Player targetedPlayer) {
|
||||
T firstOption = Iterables.getFirst(options, null);
|
||||
|
||||
if( firstOption instanceof Card)
|
||||
return (T) chooseSingleCard(ai, sa, (Collection<Card>) options, isOptional, targetedPlayer);
|
||||
else if ( firstOption instanceof Player)
|
||||
return (T) chooseSinglePlayer(ai, sa, (Collection<Player>) options);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public SpellAbility chooseSingleSpellAbility(Player player, SpellAbility sa, List<SpellAbility> spells) {
|
||||
System.err.println("Warning: default (ie. inherited from base class) implementation of chooseSingleSpellAbility is used for " + this.getClass().getName() + ". Consider declaring an overloaded method");
|
||||
return spells.get(0);
|
||||
}
|
||||
|
||||
protected Card chooseSingleCard(Player ai, SpellAbility sa, Collection<Card> options, boolean isOptional, Player targetedPlayer) {
|
||||
System.err.println("Warning: default (ie. inherited from base class) implementation of chooseSingleEntity is used for " + this.getClass().getName() + ". Consider declaring an overloaded method");
|
||||
return Iterables.getFirst(options, null);
|
||||
|
||||
}
|
||||
|
||||
protected Player chooseSinglePlayer(Player ai, SpellAbility sa, Collection<Player> options) {
|
||||
System.err.println("Warning: default (ie. inherited from base class) implementation of chooseSingleEntity is used for " + this.getClass().getName() + ". Consider declaring an overloaded method");
|
||||
return Iterables.getFirst(options, null);
|
||||
}
|
||||
}
|
||||
153
forge-ai/src/main/java/forge/ai/SpellApiToAi.java
Normal file
153
forge-ai/src/main/java/forge/ai/SpellApiToAi.java
Normal file
@@ -0,0 +1,153 @@
|
||||
package forge.ai;
|
||||
|
||||
import java.util.EnumMap;
|
||||
|
||||
import forge.ai.ability.*;
|
||||
import forge.game.ability.ApiType;
|
||||
import forge.util.ReflectionUtil;
|
||||
|
||||
public enum SpellApiToAi {
|
||||
Converter;
|
||||
|
||||
private final static EnumMap<ApiType, Class<? extends SpellAbilityAi>> apiToClass = new EnumMap<>(ApiType.class);
|
||||
private final EnumMap<ApiType, SpellAbilityAi> apiToInstance = new EnumMap<>(ApiType.class);
|
||||
|
||||
static {
|
||||
apiToClass.put(ApiType.Abandon, AlwaysPlayAi.class);
|
||||
apiToClass.put(ApiType.AddOrRemoveCounter, CountersPutOrRemoveAi.class);
|
||||
apiToClass.put(ApiType.AddPhase, AddPhaseAi.class);
|
||||
apiToClass.put(ApiType.AddTurn, AddTurnAi.class);
|
||||
apiToClass.put(ApiType.Animate, AnimateAi.class);
|
||||
apiToClass.put(ApiType.AnimateAll, AnimateAllAi.class);
|
||||
apiToClass.put(ApiType.Attach, AttachAi.class);
|
||||
apiToClass.put(ApiType.Balance, BalanceAi.class);
|
||||
apiToClass.put(ApiType.BecomesBlocked, BecomesBlockedAi.class);
|
||||
apiToClass.put(ApiType.Bond, BondAi.class);
|
||||
apiToClass.put(ApiType.ChangeTargets, ChangeTargetsAi.class);
|
||||
apiToClass.put(ApiType.ChangeZone, ChangeZoneAi.class);
|
||||
apiToClass.put(ApiType.ChangeZoneAll, ChangeZoneAllAi.class);
|
||||
|
||||
apiToClass.put(ApiType.Charm, CharmAi.class);
|
||||
apiToClass.put(ApiType.ChooseCard, ChooseCardAi.class);
|
||||
apiToClass.put(ApiType.ChooseColor, ChooseColorAi.class);
|
||||
apiToClass.put(ApiType.ChooseNumber, CannotPlayAi.class);
|
||||
apiToClass.put(ApiType.ChoosePlayer, ChoosePlayerAi.class);
|
||||
apiToClass.put(ApiType.ChooseSource, ChooseSourceAi.class);
|
||||
apiToClass.put(ApiType.ChooseType, ChooseTypeAi.class);
|
||||
apiToClass.put(ApiType.Clash, ClashAi.class);
|
||||
apiToClass.put(ApiType.Cleanup, AlwaysPlayAi.class);
|
||||
apiToClass.put(ApiType.Clone, CloneAi.class);
|
||||
apiToClass.put(ApiType.CopyPermanent, CopyPermanentAi.class);
|
||||
apiToClass.put(ApiType.CopySpellAbility, CanPlayAsDrawbackAi.class);
|
||||
apiToClass.put(ApiType.ControlPlayer, CannotPlayAi.class);
|
||||
apiToClass.put(ApiType.ControlSpell, CannotPlayAi.class);
|
||||
apiToClass.put(ApiType.Counter, CounterAi.class);
|
||||
apiToClass.put(ApiType.DamageAll, DamageAllAi.class);
|
||||
|
||||
apiToClass.put(ApiType.DealDamage, DamageDealAi.class);
|
||||
apiToClass.put(ApiType.Debuff, DebuffAi.class);
|
||||
apiToClass.put(ApiType.DebuffAll, DebuffAllAi.class);
|
||||
apiToClass.put(ApiType.DeclareCombatants, CannotPlayAi.class);
|
||||
apiToClass.put(ApiType.DelayedTrigger, DelayedTriggerAi.class);
|
||||
apiToClass.put(ApiType.Destroy, DestroyAi.class);
|
||||
apiToClass.put(ApiType.DestroyAll, DestroyAllAi.class);
|
||||
apiToClass.put(ApiType.Dig, DigAi.class);
|
||||
apiToClass.put(ApiType.DigUntil, DigUntilAi.class);
|
||||
apiToClass.put(ApiType.Discard, DiscardAi.class);
|
||||
apiToClass.put(ApiType.DrainMana, DrainManaAi.class);
|
||||
apiToClass.put(ApiType.Draw, DrawAi.class);
|
||||
apiToClass.put(ApiType.EachDamage, DamageEachAi.class);
|
||||
apiToClass.put(ApiType.Effect, EffectAi.class);
|
||||
apiToClass.put(ApiType.Encode, EncodeAi.class);
|
||||
apiToClass.put(ApiType.EndTurn, EndTurnAi.class);
|
||||
apiToClass.put(ApiType.ExchangeLife, LifeExchangeAi.class);
|
||||
apiToClass.put(ApiType.ExchangeControl, ControlExchangeAi.class);
|
||||
apiToClass.put(ApiType.ExchangePower, PowerExchangeAi.class);
|
||||
apiToClass.put(ApiType.ExchangeZone, ZoneExchangeAi.class);
|
||||
apiToClass.put(ApiType.Fight, FightAi.class);
|
||||
apiToClass.put(ApiType.FlipACoin, FlipACoinAi.class);
|
||||
apiToClass.put(ApiType.Fog, FogAi.class);
|
||||
apiToClass.put(ApiType.GainControl, ControlGainAi.class);
|
||||
apiToClass.put(ApiType.GainLife, LifeGainAi.class);
|
||||
apiToClass.put(ApiType.GainOwnership, CannotPlayAi.class);
|
||||
apiToClass.put(ApiType.GenericChoice, ChooseGenericEffectAi.class);
|
||||
apiToClass.put(ApiType.LoseLife, LifeLoseAi.class);
|
||||
apiToClass.put(ApiType.LosesGame, GameLossAi.class);
|
||||
apiToClass.put(ApiType.Mana, ManaEffectAi.class);
|
||||
apiToClass.put(ApiType.ManaReflected, CannotPlayAi.class);
|
||||
apiToClass.put(ApiType.Mill, MillAi.class);
|
||||
apiToClass.put(ApiType.MoveCounter, CountersMoveAi.class);
|
||||
apiToClass.put(ApiType.MultiplePiles, CannotPlayAi.class);
|
||||
apiToClass.put(ApiType.MustAttack, MustAttackAi.class);
|
||||
apiToClass.put(ApiType.MustBlock, MustBlockAi.class);
|
||||
apiToClass.put(ApiType.NameCard, ChooseCardNameAi.class);
|
||||
apiToClass.put(ApiType.PeekAndReveal, PeekAndRevealAi.class);
|
||||
apiToClass.put(ApiType.PermanentCreature, PermanentCreatureAi.class);
|
||||
apiToClass.put(ApiType.PermanentNoncreature, PermanentNoncreatureAi.class);
|
||||
apiToClass.put(ApiType.Phases, PhasesAi.class);
|
||||
apiToClass.put(ApiType.Planeswalk, AlwaysPlayAi.class);
|
||||
apiToClass.put(ApiType.Play, PlayAi.class);
|
||||
apiToClass.put(ApiType.Poison, PoisonAi.class);
|
||||
apiToClass.put(ApiType.PreventDamage, DamagePreventAi.class);
|
||||
apiToClass.put(ApiType.PreventDamageAll, DamagePreventAllAi.class);
|
||||
apiToClass.put(ApiType.Proliferate, CountersProliferateAi.class);
|
||||
apiToClass.put(ApiType.Protection, ProtectAi.class);
|
||||
apiToClass.put(ApiType.ProtectionAll, ProtectAllAi.class);
|
||||
apiToClass.put(ApiType.Pump, PumpAi.class);
|
||||
apiToClass.put(ApiType.PumpAll, PumpAllAi.class);
|
||||
apiToClass.put(ApiType.PutCounter, CountersPutAi.class);
|
||||
apiToClass.put(ApiType.PutCounterAll, CountersPutAllAi.class);
|
||||
apiToClass.put(ApiType.RearrangeTopOfLibrary, RearrangeTopOfLibraryAi.class);
|
||||
apiToClass.put(ApiType.Regenerate, RegenerateAi.class);
|
||||
apiToClass.put(ApiType.RegenerateAll, RegenerateAllAi.class);
|
||||
apiToClass.put(ApiType.RemoveCounter, CountersRemoveAi.class);
|
||||
apiToClass.put(ApiType.RemoveCounterAll, CannotPlayAi.class);
|
||||
apiToClass.put(ApiType.RemoveFromCombat, RemoveFromCombatAi.class);
|
||||
apiToClass.put(ApiType.ReorderZone, AlwaysPlayAi.class);
|
||||
apiToClass.put(ApiType.Repeat, RepeatAi.class);
|
||||
apiToClass.put(ApiType.RepeatEach, RepeatEachAi.class);
|
||||
apiToClass.put(ApiType.RestartGame, RestartGameAi.class);
|
||||
apiToClass.put(ApiType.Reveal, RevealAi.class);
|
||||
apiToClass.put(ApiType.RevealHand, RevealHandAi.class);
|
||||
apiToClass.put(ApiType.RollPlanarDice, RollPlanarDiceAi.class);
|
||||
apiToClass.put(ApiType.RunSVarAbility, AlwaysPlayAi.class);
|
||||
apiToClass.put(ApiType.Sacrifice, SacrificeAi.class);
|
||||
apiToClass.put(ApiType.SacrificeAll, SacrificeAllAi.class);
|
||||
apiToClass.put(ApiType.Scry, ScryAi.class);
|
||||
apiToClass.put(ApiType.SetInMotion, AlwaysPlayAi.class);
|
||||
apiToClass.put(ApiType.SetLife, LifeSetAi.class);
|
||||
apiToClass.put(ApiType.SetState, SetStateAi.class);
|
||||
apiToClass.put(ApiType.Shuffle, ShuffleAi.class);
|
||||
apiToClass.put(ApiType.SkipTurn, CannotPlayAi.class);
|
||||
apiToClass.put(ApiType.StoreSVar, StoreSVarAi.class);
|
||||
apiToClass.put(ApiType.Tap, TapAi.class);
|
||||
apiToClass.put(ApiType.TapAll, TapAllAi.class);
|
||||
apiToClass.put(ApiType.TapOrUntap, TapOrUntapAi.class);
|
||||
apiToClass.put(ApiType.TapOrUntapAll, TapOrUntapAllAi.class);
|
||||
apiToClass.put(ApiType.Token, TokenAi.class);
|
||||
apiToClass.put(ApiType.TwoPiles, TwoPilesAi.class);
|
||||
apiToClass.put(ApiType.Unattach, CannotPlayAi.class);
|
||||
apiToClass.put(ApiType.UnattachAll, UnattachAllAi.class);
|
||||
apiToClass.put(ApiType.Untap, UntapAi.class);
|
||||
apiToClass.put(ApiType.UntapAll, UntapAllAi.class);
|
||||
apiToClass.put(ApiType.WinsGame, GameWinAi.class);
|
||||
|
||||
apiToClass.put(ApiType.InternalEtbReplacement, CanPlayAsDrawbackAi.class);
|
||||
apiToClass.put(ApiType.InternalLegendaryRule, LegendaryRuleAi.class);
|
||||
apiToClass.put(ApiType.InternalHaunt, HauntAi.class);
|
||||
}
|
||||
|
||||
public SpellAbilityAi get(ApiType api) {
|
||||
SpellAbilityAi result = apiToInstance.get(api);
|
||||
if( null == result ) {
|
||||
Class<? extends SpellAbilityAi> clz = apiToClass.get(api);
|
||||
if(null == clz) {
|
||||
System.err.println("No AI assigned for API: " + api);
|
||||
clz = CannotPlayAi.class;
|
||||
}
|
||||
result = ReflectionUtil.makeDefaultInstanceOf(clz);
|
||||
apiToInstance.put(api, result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
18
forge-ai/src/main/java/forge/ai/ability/AddPhaseAi.java
Normal file
18
forge-ai/src/main/java/forge/ai/ability/AddPhaseAi.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package forge.ai.ability;
|
||||
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this type.
|
||||
*
|
||||
*/
|
||||
public class AddPhaseAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,15 +15,15 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.player.Player;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* AbilityFactory_Turns class.
|
||||
@@ -50,14 +50,14 @@ public class AddTurnAi extends SpellAbilityAi {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!sa.getTargetRestrictions().isMinTargetsChosen(sa.getSourceCard(), sa) && sa.canTarget(opp)) {
|
||||
if (!sa.getTargetRestrictions().isMinTargetsChosen(sa.getHostCard(), sa) && sa.canTarget(opp)) {
|
||||
sa.getTargets().add(opp);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
final List<Player> tgtPlayers = AbilityUtils.getDefinedPlayers(sa.getSourceCard(), sa.getParam("Defined"), sa);
|
||||
final List<Player> tgtPlayers = AbilityUtils.getDefinedPlayers(sa.getHostCard(), sa.getParam("Defined"), sa);
|
||||
for (final Player p : tgtPlayers) {
|
||||
if (p.isOpponentOf(ai) && !mandatory) {
|
||||
return false;
|
||||
16
forge-ai/src/main/java/forge/ai/ability/AlwaysPlayAi.java
Normal file
16
forge-ai/src/main/java/forge/ai/ability/AlwaysPlayAi.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package forge.ai.ability;
|
||||
|
||||
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
|
||||
public class AlwaysPlayAi extends SpellAbilityAi {
|
||||
/* (non-Javadoc)
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,20 @@
|
||||
package forge.card.ability.ai;
|
||||
|
||||
import java.util.List;
|
||||
package forge.ai.ability;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardPredicates;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.TargetRestrictions;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.Game;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardPredicates;
|
||||
import forge.game.phase.PhaseHandler;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* AbilityFactoryAnimate class.
|
||||
@@ -33,7 +32,7 @@ public class AnimateAi extends SpellAbilityAi {
|
||||
@Override
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final Game game = aiPlayer.getGame();
|
||||
final PhaseHandler ph = game.getPhaseHandler();
|
||||
|
||||
@@ -141,11 +140,11 @@ public class AnimateAi extends SpellAbilityAi {
|
||||
* animateTriggerAI.
|
||||
* </p>
|
||||
* @param sa
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
* @param mandatory
|
||||
* a boolean.
|
||||
* @param af
|
||||
* a {@link forge.card.ability.AbilityFactory} object.
|
||||
* a {@link forge.game.ability.AbilityFactory} object.
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
@@ -172,9 +171,9 @@ public class AnimateAi extends SpellAbilityAi {
|
||||
* </p>
|
||||
*
|
||||
* @param af
|
||||
* a {@link forge.card.ability.AbilityFactory} object.
|
||||
* a {@link forge.game.ability.AbilityFactory} object.
|
||||
* @param sa
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
* @return a boolean.
|
||||
*/
|
||||
private boolean animateTgtAI(final SpellAbility sa) {
|
||||
19
forge-ai/src/main/java/forge/ai/ability/AnimateAllAi.java
Normal file
19
forge-ai/src/main/java/forge/ai/ability/AnimateAllAi.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package forge.ai.ability;
|
||||
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
|
||||
public class AnimateAllAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
return false;
|
||||
} // end animateAllCanPlayAI()
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, SpellAbility sa, boolean mandatory) {
|
||||
return false;
|
||||
}
|
||||
|
||||
} // end class AbilityFactoryAnimate
|
||||
@@ -1,42 +1,27 @@
|
||||
package forge.card.ability.ai;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
package forge.ai.ability;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CardPredicates;
|
||||
import forge.CardUtil;
|
||||
import forge.ITargetable;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.ApiType;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.TargetRestrictions;
|
||||
import forge.card.staticability.StaticAbility;
|
||||
import forge.card.trigger.Trigger;
|
||||
import forge.card.trigger.TriggerType;
|
||||
import forge.game.ai.ComputerUtil;
|
||||
import forge.game.ai.ComputerUtilCard;
|
||||
import forge.game.ai.ComputerUtilCost;
|
||||
import forge.game.ai.ComputerUtilMana;
|
||||
import forge.ai.*;
|
||||
import forge.game.GameObject;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.ability.ApiType;
|
||||
import forge.game.card.*;
|
||||
import forge.game.combat.CombatUtil;
|
||||
import forge.game.cost.Cost;
|
||||
import forge.game.phase.PhaseHandler;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.PlayerActionConfirmMode;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
import forge.game.staticability.StaticAbility;
|
||||
import forge.game.trigger.Trigger;
|
||||
import forge.game.trigger.TriggerType;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class AttachAi extends SpellAbilityAi {
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -46,7 +31,7 @@ public class AttachAi extends SpellAbilityAi {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Random r = MyRandom.getRandom();
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
if (abCost != null) {
|
||||
// AI currently disabled for these costs
|
||||
@@ -169,7 +154,7 @@ public class AttachAi extends SpellAbilityAi {
|
||||
String type = "";
|
||||
|
||||
for (final StaticAbility stAb : attachSource.getStaticAbilities()) {
|
||||
final HashMap<String, String> stab = stAb.getMapParams();
|
||||
final Map<String, String> stab = stAb.getMapParams();
|
||||
if (stab.get("Mode").equals("Continuous") && stab.containsKey("AddType")) {
|
||||
type = stab.get("AddType");
|
||||
}
|
||||
@@ -334,7 +319,7 @@ public class AttachAi extends SpellAbilityAi {
|
||||
final Card attachSource) {
|
||||
// AI For choosing a Card to Animate.
|
||||
List<Card> betterList = CardLists.getNotType(list, "Creature");
|
||||
if (sa.getSourceCard().getName().equals("Animate Artifact")) {
|
||||
if (sa.getHostCard().getName().equals("Animate Artifact")) {
|
||||
betterList = CardLists.filter(betterList, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
@@ -400,7 +385,7 @@ public class AttachAi extends SpellAbilityAi {
|
||||
// I know this isn't much better than Hardcoding, but some cards need it for now
|
||||
final Player ai = sa.getActivatingPlayer();
|
||||
Card chosen = null;
|
||||
if ("Guilty Conscience".equals(sa.getSourceCard().getName())) {
|
||||
if ("Guilty Conscience".equals(sa.getHostCard().getName())) {
|
||||
List<Card> aiStuffies = CardLists.filter(list, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
@@ -626,12 +611,12 @@ public class AttachAi extends SpellAbilityAi {
|
||||
*/
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(final Player ai, final SpellAbility sa, final boolean mandatory) {
|
||||
final Card card = sa.getSourceCard();
|
||||
final Card card = sa.getHostCard();
|
||||
// Check if there are any valid targets
|
||||
List<ITargetable> targets = new ArrayList<ITargetable>();
|
||||
List<GameObject> targets = new ArrayList<GameObject>();
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
if (tgt == null) {
|
||||
targets = AbilityUtils.getDefinedObjects(sa.getSourceCard(), sa.getParam("Defined"), sa);
|
||||
targets = AbilityUtils.getDefinedObjects(sa.getHostCard(), sa.getParam("Defined"), sa);
|
||||
} else {
|
||||
AttachAi.attachPreference(sa, tgt, mandatory);
|
||||
targets = sa.getTargets().getTargets();
|
||||
@@ -703,7 +688,7 @@ public class AttachAi extends SpellAbilityAi {
|
||||
* @return true, if successful
|
||||
*/
|
||||
private static boolean attachPreference(final SpellAbility sa, final TargetRestrictions tgt, final boolean mandatory) {
|
||||
ITargetable o;
|
||||
GameObject o;
|
||||
if (tgt.canTgtPlayer()) {
|
||||
o = attachToPlayerAIPreferences(sa.getActivatingPlayer(), sa, mandatory);
|
||||
} else {
|
||||
@@ -778,7 +763,7 @@ public class AttachAi extends SpellAbilityAi {
|
||||
for (Card target : list) {
|
||||
for (Trigger t : target.getTriggers()) {
|
||||
if (t.getMode() == TriggerType.SpellCast) {
|
||||
final HashMap<String, String> params = t.getMapParams();
|
||||
final Map<String, String> params = t.getMapParams();
|
||||
if ("Card.Self".equals(params.get("TargetsValid")) && "You".equals(params.get("ValidActivatingPlayer"))) {
|
||||
magnetList.add(target);
|
||||
break;
|
||||
@@ -945,7 +930,7 @@ public class AttachAi extends SpellAbilityAi {
|
||||
*/
|
||||
private static Card attachToCardAIPreferences(final Player aiPlayer, final SpellAbility sa, final boolean mandatory) {
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
final Card attachSource = sa.getSourceCard();
|
||||
final Card attachSource = sa.getHostCard();
|
||||
// TODO AttachSource is currently set for the Source of the Spell, but
|
||||
// at some point can support attaching a different card
|
||||
|
||||
@@ -1171,6 +1156,8 @@ public class AttachAi extends SpellAbilityAi {
|
||||
if (card.hasKeyword("Shroud") || card.hasKeyword("Hexproof")) {
|
||||
return false;
|
||||
}
|
||||
} else if (keyword.equals("Defender")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -1234,12 +1221,12 @@ public class AttachAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Card chooseSingleCard(Player ai, SpellAbility sa, Collection<Card> options, boolean isOptional) {
|
||||
protected Card chooseSingleCard(Player ai, SpellAbility sa, Collection<Card> options, boolean isOptional, Player targetedPlayer) {
|
||||
return attachToCardAIPreferences(ai, sa, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player chooseSinglePlayer(Player ai, SpellAbility sa, List<Player> options) {
|
||||
protected Player chooseSinglePlayer(Player ai, SpellAbility sa, Collection<Player> options) {
|
||||
return attachToPlayerAIPreferences(ai, sa, true);
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,16 @@
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.card.CardPredicates;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.math.RandomUtils;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CardPredicates;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
public class BalanceAi extends SpellAbilityAi {
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -48,6 +47,6 @@ public class BalanceAi extends SpellAbilityAi {
|
||||
diff += 0.5 * (humHand.size() - compHand.size());
|
||||
|
||||
// Larger differential == more chance to actually cast this spell
|
||||
return diff > 2 && RandomUtils.nextInt(100) < diff*10;
|
||||
return diff > 2 && MyRandom.getRandom().nextInt(100) < diff*10;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package forge.ai.ability;
|
||||
|
||||
|
||||
import forge.ai.ComputerUtilCard;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.Game;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BecomesBlockedAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
final Card source = sa.getHostCard();
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
final Game game = aiPlayer.getGame();
|
||||
|
||||
if (!game.getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS)
|
||||
|| !game.getPhaseHandler().getPlayerTurn().isOpponentOf(aiPlayer)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (tgt != null) {
|
||||
sa.resetTargets();
|
||||
List<Card> list = game.getCardsIn(ZoneType.Battlefield);
|
||||
list = CardLists.filterControlledBy(list, aiPlayer.getOpponents());
|
||||
list = CardLists.getValidCards(list, tgt.getValidTgts(), source.getController(), source);
|
||||
list = CardLists.getTargetableCards(list, sa);
|
||||
list = CardLists.getNotKeyword(list, "Trample");
|
||||
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(source, sa)) {
|
||||
Card choice = null;
|
||||
|
||||
if (list.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
choice = ComputerUtilCard.getBestCreatureAI(list);
|
||||
|
||||
if (choice == null) { // can't find anything left
|
||||
return false;
|
||||
}
|
||||
|
||||
list.remove(choice);
|
||||
sa.getTargets().add(choice);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
|
||||
// TODO - implement AI
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#doTriggerAINoCost(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility, boolean)
|
||||
*/
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, SpellAbility sa, boolean mandatory) {
|
||||
boolean chance;
|
||||
|
||||
// TODO - implement AI
|
||||
chance = false;
|
||||
|
||||
return chance;
|
||||
}
|
||||
}
|
||||
58
forge-ai/src/main/java/forge/ai/ability/BondAi.java
Normal file
58
forge-ai/src/main/java/forge/ai/ability/BondAi.java
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Forge: Play Magic: the Gathering.
|
||||
* Copyright (C) 2011 Forge Team
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package forge.ai.ability;
|
||||
|
||||
import forge.ai.ComputerUtilCard;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* AbilityFactoryBond class.
|
||||
* </p>
|
||||
*
|
||||
* @author Forge
|
||||
* @version $Id: AbilityFactoryBond.java 15090 2012-04-07 12:50:31Z Max mtg $
|
||||
*/
|
||||
public final class BondAi extends SpellAbilityAi {
|
||||
/**
|
||||
* <p>
|
||||
* bondCanPlayAI.
|
||||
* </p>
|
||||
* @param sa
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
* @param af
|
||||
* a {@link forge.game.ability.AbilityFactory} object.
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
return true;
|
||||
} // end bondCanPlayAI()
|
||||
|
||||
|
||||
@Override
|
||||
protected Card chooseSingleCard(Player ai, SpellAbility sa, Collection<Card> options, boolean isOptional, Player targetedPlayer) {
|
||||
return ComputerUtilCard.getBestCreatureAI(options);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.player.Player;
|
||||
|
||||
public class CanPlayAsDrawbackAi extends SpellAbilityAi {
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -22,11 +22,11 @@ public class CanPlayAsDrawbackAi extends SpellAbilityAi {
|
||||
* copySpellTriggerAI.
|
||||
* </p>
|
||||
* @param sa
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
* @param mandatory
|
||||
* a boolean.
|
||||
* @param af
|
||||
* a {@link forge.card.ability.AbilityFactory} object.
|
||||
* a {@link forge.game.ability.AbilityFactory} object.
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
@@ -1,9 +1,9 @@
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
|
||||
public class CannotPlayAi extends SpellAbilityAi {
|
||||
/* (non-Javadoc)
|
||||
@@ -1,8 +1,8 @@
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
|
||||
public class ChangeTargetsAi extends SpellAbilityAi {
|
||||
|
||||
1212
forge-ai/src/main/java/forge/ai/ability/ChangeZoneAi.java
Normal file
1212
forge-ai/src/main/java/forge/ai/ability/ChangeZoneAi.java
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,22 +1,22 @@
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
import forge.ai.ComputerUtilCard;
|
||||
import forge.ai.ComputerUtilCost;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.cost.Cost;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.TargetRestrictions;
|
||||
import forge.game.ai.ComputerUtilCard;
|
||||
import forge.game.ai.ComputerUtilCost;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
public class ChangeZoneAllAi extends SpellAbilityAi {
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -26,7 +26,7 @@ public class ChangeZoneAllAi extends SpellAbilityAi {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
// Change Zone All, can be any type moving from one zone to another
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final ZoneType destination = ZoneType.smartValueOf(sa.getParam("Destination"));
|
||||
final ZoneType origin = ZoneType.listValueOf(sa.getParam("Origin")).get(0);
|
||||
|
||||
@@ -159,9 +159,9 @@ public class ChangeZoneAllAi extends SpellAbilityAi {
|
||||
* changeZoneAllPlayDrawbackAI.
|
||||
* </p>
|
||||
* @param sa
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
* @param af
|
||||
* a {@link forge.card.ability.AbilityFactory} object.
|
||||
* a {@link forge.game.ability.AbilityFactory} object.
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
@@ -1,17 +1,21 @@
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.ability.effects.CharmEffect;
|
||||
import forge.card.spellability.AbilitySub;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.ai.AiController;
|
||||
import forge.ai.AiPlayDecision;
|
||||
import forge.ai.PlayerControllerAi;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.ability.effects.CharmEffect;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.AbilitySub;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.util.Aggregates;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class CharmAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
@@ -44,18 +48,18 @@ public class CharmAi extends SpellAbilityAi {
|
||||
return choices.subList(1, choices.size());
|
||||
}
|
||||
|
||||
|
||||
AiController aic = ((PlayerControllerAi)ai.getController()).getAi();
|
||||
for (int i = 0; i < num; i++) {
|
||||
AbilitySub thisPick = null;
|
||||
for (SpellAbility sub : choices) {
|
||||
sub.setActivatingPlayer(ai);
|
||||
if (!playNow && sub.canPlayAI()) {
|
||||
if (!playNow && AiPlayDecision.WillPlay == aic.canPlaySa(sub)) {
|
||||
thisPick = (AbilitySub) sub;
|
||||
choices.remove(sub);
|
||||
playNow = true;
|
||||
break;
|
||||
}
|
||||
if ((playNow || i < num - 1) && sub.doTrigger(false, ai)) {
|
||||
if ((playNow || i < num - 1) && aic.doTrigger(sub, false)) {
|
||||
thisPick = (AbilitySub) sub;
|
||||
choices.remove(sub);
|
||||
break;
|
||||
@@ -70,7 +74,7 @@ public class CharmAi extends SpellAbilityAi {
|
||||
AbilitySub thisPick = null;
|
||||
for (SpellAbility sub : choices) {
|
||||
sub.setActivatingPlayer(ai);
|
||||
if (sub.doTrigger(true, ai)) {
|
||||
if (aic.doTrigger(sub, true)) {
|
||||
thisPick = (AbilitySub) sub;
|
||||
choices.remove(sub);
|
||||
break;
|
||||
@@ -88,7 +92,7 @@ public class CharmAi extends SpellAbilityAi {
|
||||
* @see forge.card.ability.SpellAbilityAi#chooseSinglePlayer(forge.game.player.Player, forge.card.spellability.SpellAbility, java.util.List)
|
||||
*/
|
||||
@Override
|
||||
public Player chooseSinglePlayer(Player ai, SpellAbility sa, List<Player> opponents) {
|
||||
public Player chooseSinglePlayer(Player ai, SpellAbility sa, Collection<Player> opponents) {
|
||||
return Aggregates.random(opponents);
|
||||
}
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import forge.ai.ComputerUtilCard;
|
||||
import forge.ai.ComputerUtilCombat;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.Game;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.card.CardPredicates.Presets;
|
||||
import forge.game.combat.Combat;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CardPredicates.Presets;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.TargetRestrictions;
|
||||
import forge.game.Game;
|
||||
import forge.game.ai.ComputerUtilCard;
|
||||
import forge.game.ai.ComputerUtilCombat;
|
||||
import forge.game.combat.Combat;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
public class ChooseCardAi extends SpellAbilityAi {
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -26,7 +26,7 @@ public class ChooseCardAi extends SpellAbilityAi {
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(final Player ai, SpellAbility sa) {
|
||||
final Card host = sa.getSourceCard();
|
||||
final Card host = sa.getHostCard();
|
||||
final Game game = ai.getGame();
|
||||
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
@@ -99,8 +99,8 @@ public class ChooseCardAi extends SpellAbilityAi {
|
||||
* @see forge.card.ability.SpellAbilityAi#chooseSingleCard(forge.card.spellability.SpellAbility, java.util.List, boolean)
|
||||
*/
|
||||
@Override
|
||||
public Card chooseSingleCard(final Player ai, SpellAbility sa, Collection<Card> options, boolean isOptional) {
|
||||
final Card host = sa.getSourceCard();
|
||||
public Card chooseSingleCard(final Player ai, SpellAbility sa, Collection<Card> options, boolean isOptional, Player targetedPlayer) {
|
||||
final Card host = sa.getHostCard();
|
||||
final String logic = sa.getParam("AILogic");
|
||||
Card choice = null;
|
||||
if (logic == null) {
|
||||
@@ -159,6 +159,27 @@ public class ChooseCardAi extends SpellAbilityAi {
|
||||
Collections.reverse(creats);
|
||||
choice = creats.get(0);
|
||||
}
|
||||
} else if ("TangleWire".equals(logic)) {
|
||||
List<Card> betterList = CardLists.filter(options, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
if (c.isCreature()) {
|
||||
return false;
|
||||
}
|
||||
for (SpellAbility sa : c.getAllSpellAbilities()) {
|
||||
if (sa.getPayCosts() != null && sa.getPayCosts().hasTapCost()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
System.out.println("Tangle Wire" + options + " - " + betterList);
|
||||
if (!betterList.isEmpty()) {
|
||||
choice = betterList.get(0);
|
||||
} else {
|
||||
choice = ComputerUtilCard.getWorstPermanentAI(options, false, false, false, false);
|
||||
}
|
||||
} else {
|
||||
choice = ComputerUtilCard.getBestAI(options);
|
||||
}
|
||||
@@ -1,19 +1,19 @@
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
import forge.Card;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.TargetRestrictions;
|
||||
import forge.game.ai.ComputerUtil;
|
||||
import forge.game.ai.ComputerUtilMana;
|
||||
import forge.ai.ComputerUtil;
|
||||
import forge.ai.ComputerUtilMana;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
|
||||
public class ChooseCardNameAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
Card source = sa.getSourceCard();
|
||||
Card source = sa.getHostCard();
|
||||
if (sa.hasParam("AILogic")) {
|
||||
// Don't tap creatures that may be able to block
|
||||
if (ComputerUtil.waitForBlocking(sa)) {
|
||||
@@ -1,8 +1,8 @@
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
public class ChooseColorAi extends SpellAbilityAi {
|
||||
@@ -0,0 +1,36 @@
|
||||
package forge.ai.ability;
|
||||
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.util.Aggregates;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this type.
|
||||
*
|
||||
*/
|
||||
public class ChooseGenericEffectAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#chkAIDrawback(java.util.Map, forge.card.spellability.SpellAbility, forge.game.player.Player)
|
||||
*/
|
||||
@Override
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
return canPlayAI(aiPlayer, sa);
|
||||
}
|
||||
|
||||
public SpellAbility chooseSingleSpellAbility(Player player, SpellAbility sa, List<SpellAbility> spells) {
|
||||
if ("Random".equals(sa.getParam("AILogic"))) {
|
||||
return Aggregates.random(spells);
|
||||
} else {
|
||||
return spells.get(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
87
forge-ai/src/main/java/forge/ai/ability/ChoosePlayerAi.java
Normal file
87
forge-ai/src/main/java/forge/ai/ability/ChoosePlayerAi.java
Normal file
@@ -0,0 +1,87 @@
|
||||
package forge.ai.ability;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import forge.ai.ComputerUtil;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class ChoosePlayerAi extends SpellAbilityAi {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player ai) {
|
||||
return canPlayAI(ai, sa);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
return canPlayAI(ai, sa);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.card.ability.SpellAbilityAi#chooseSinglePlayer(forge.game.player.Player, forge.card.spellability.SpellAbility, java.util.List)
|
||||
*/
|
||||
@Override
|
||||
public Player chooseSinglePlayer(Player ai, SpellAbility sa, Collection<Player> choices) {
|
||||
Player chosen = null;
|
||||
if ("Curse".equals(sa.getParam("AILogic"))) {
|
||||
for (Player pc : choices) {
|
||||
if (pc.isOpponentOf(ai)) {
|
||||
chosen = pc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (chosen == null) {
|
||||
chosen = Iterables.getFirst(choices, null);
|
||||
System.out.println("No good curse choices. Picking first available: " + chosen);
|
||||
}
|
||||
} else if ("Pump".equals(sa.getParam("AILogic"))) {
|
||||
chosen = choices.contains(ai) ? ai : Iterables.getFirst(choices, null);
|
||||
} else if ("BestAllyBoardPosition".equals(sa.getParam("AILogic"))) {
|
||||
List<Player> prefChoices = Lists.newArrayList(choices);
|
||||
prefChoices.removeAll(ai.getOpponents());
|
||||
if (!prefChoices.isEmpty()) {
|
||||
chosen = ComputerUtil.evaluateBoardPosition(prefChoices);
|
||||
}
|
||||
if (chosen == null) {
|
||||
chosen = Iterables.getFirst(choices, null);
|
||||
System.out.println("No good curse choices. Picking first available: " + chosen);
|
||||
}
|
||||
} else if ("MostCardsInHand".equals(sa.getParam("AILogic"))) {
|
||||
int cardsInHand = 0;
|
||||
for (final Player p : choices) {
|
||||
int hand = p.getCardsIn(ZoneType.Hand).size();
|
||||
if (hand >= cardsInHand) {
|
||||
chosen = p;
|
||||
cardsInHand = hand;
|
||||
}
|
||||
}
|
||||
} else if ("LeastCreatures".equals(sa.getParam("AILogic"))) {
|
||||
int creats = 50;
|
||||
for (final Player p : choices) {
|
||||
int curr = p.getCreaturesInPlay().size();
|
||||
if (curr <= creats) {
|
||||
chosen = p;
|
||||
creats = curr;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
System.out.println("Default player choice logic.");
|
||||
chosen = choices.contains(ai) ? ai : Iterables.getFirst(choices, null);
|
||||
}
|
||||
return chosen;
|
||||
}
|
||||
}
|
||||
186
forge-ai/src/main/java/forge/ai/ability/ChooseSourceAi.java
Normal file
186
forge-ai/src/main/java/forge/ai/ability/ChooseSourceAi.java
Normal file
@@ -0,0 +1,186 @@
|
||||
package forge.ai.ability;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import forge.ai.ComputerUtilCard;
|
||||
import forge.ai.ComputerUtilCombat;
|
||||
import forge.ai.ComputerUtilCost;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.Game;
|
||||
import forge.game.GameObject;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.ability.ApiType;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.combat.Combat;
|
||||
import forge.game.cost.Cost;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.SpellAbilityStackInstance;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class ChooseSourceAi extends SpellAbilityAi {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(final Player ai, SpellAbility sa) {
|
||||
// TODO: AI Support! Currently this is copied from AF ChooseCard.
|
||||
// When implementing AI, I believe AI also needs to be made aware of the damage sources chosen
|
||||
// to be prevented (e.g. so the AI doesn't attack with a creature that will not deal any damage
|
||||
// to the player because a CoP was pre-activated on it - unless, of course, there's another
|
||||
// possible reason to attack with that creature).
|
||||
final Card host = sa.getHostCard();
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
if (abCost != null) {
|
||||
// AI currently disabled for these costs
|
||||
if (!ComputerUtilCost.checkLifeCost(ai, abCost, source, 4, null)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ComputerUtilCost.checkDiscardCost(ai, abCost, source)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ComputerUtilCost.checkSacrificeCost(ai, abCost, source)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ComputerUtilCost.checkRemoveCounterCost(abCost, source)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
if (tgt != null) {
|
||||
sa.resetTargets();
|
||||
if (sa.canTarget(ai.getOpponent())) {
|
||||
sa.getTargets().add(ai.getOpponent());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (sa.hasParam("AILogic")) {
|
||||
final Game game = ai.getGame();
|
||||
if (sa.getParam("AILogic").equals("NeedsPrevention")) {
|
||||
if (!game.getStack().isEmpty()) {
|
||||
final SpellAbility topStack = game.getStack().peekAbility();
|
||||
if (sa.hasParam("Choices") && !topStack.getHostCard().isValid(sa.getParam("Choices"), ai, source)) {
|
||||
return false;
|
||||
}
|
||||
final ApiType threatApi = topStack.getApi();
|
||||
if (threatApi != ApiType.DealDamage && threatApi != ApiType.DamageAll) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Card threatSource = topStack.getHostCard();
|
||||
List<? extends GameObject> objects = getTargets(topStack);
|
||||
if (!topStack.usesTargeting() && topStack.hasParam("ValidPlayers") && !topStack.hasParam("Defined")) {
|
||||
objects = AbilityUtils.getDefinedPlayers(threatSource, topStack.getParam("ValidPlayers"), topStack);
|
||||
}
|
||||
|
||||
if (!objects.contains(ai) || topStack.hasParam("NoPrevention")) {
|
||||
return false;
|
||||
}
|
||||
int dmg = AbilityUtils.calculateAmount(threatSource, topStack.getParam("NumDmg"), topStack);
|
||||
if (ComputerUtilCombat.predictDamageTo(ai, dmg, threatSource, false) <= 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (game.getPhaseHandler().getPhase() != PhaseType.COMBAT_DECLARE_BLOCKERS) {
|
||||
return false;
|
||||
}
|
||||
List<Card> choices = game.getCardsIn(ZoneType.Battlefield);
|
||||
if (sa.hasParam("Choices")) {
|
||||
choices = CardLists.getValidCards(choices, sa.getParam("Choices"), host.getController(), host);
|
||||
}
|
||||
final Combat combat = game.getCombat();
|
||||
choices = CardLists.filter(choices, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
if (combat == null || !combat.isAttacking(c, ai) || !combat.isUnblocked(c)) {
|
||||
return false;
|
||||
}
|
||||
return ComputerUtilCombat.damageIfUnblocked(c, ai, combat) > 0;
|
||||
}
|
||||
});
|
||||
if (choices.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Card chooseSingleCard(final Player aiChoser, SpellAbility sa, Collection<Card> options, boolean isOptional, Player targetedPlayer) {
|
||||
if ("NeedsPrevention".equals(sa.getParam("AILogic"))) {
|
||||
final Player ai = sa.getActivatingPlayer();
|
||||
final Game game = ai.getGame();
|
||||
if (!game.getStack().isEmpty()) {
|
||||
Card choseCard = chooseCardOnStack(sa, ai, game);
|
||||
if (choseCard != null) {
|
||||
return choseCard;
|
||||
}
|
||||
}
|
||||
|
||||
final Combat combat = game.getCombat();
|
||||
|
||||
List<Card> permanentSources = CardLists.filter(options, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
if (c == null || c.getZone() == null || c.getZone().getZoneType() != ZoneType.Battlefield
|
||||
|| combat == null || !combat.isAttacking(c, ai) || !combat.isUnblocked(c)) {
|
||||
return false;
|
||||
}
|
||||
return ComputerUtilCombat.damageIfUnblocked(c, ai, combat) > 0;
|
||||
}
|
||||
});
|
||||
return ComputerUtilCard.getBestCreatureAI(permanentSources);
|
||||
|
||||
} else {
|
||||
return ComputerUtilCard.getBestAI(options);
|
||||
}
|
||||
}
|
||||
|
||||
private Card chooseCardOnStack(SpellAbility sa, Player ai, Game game) {
|
||||
for (SpellAbilityStackInstance si : game.getStack()) {
|
||||
final Card source = si.getSourceCard();
|
||||
final SpellAbility abilityOnStack = si.getSpellAbility();
|
||||
|
||||
if (sa.hasParam("Choices") && !abilityOnStack.getHostCard().isValid(sa.getParam("Choices"), ai, sa.getHostCard())) {
|
||||
continue;
|
||||
}
|
||||
final ApiType threatApi = abilityOnStack.getApi();
|
||||
if (threatApi != ApiType.DealDamage && threatApi != ApiType.DamageAll) {
|
||||
continue;
|
||||
}
|
||||
|
||||
List<? extends GameObject> objects = getTargets(abilityOnStack);
|
||||
|
||||
if (!abilityOnStack.usesTargeting() && !abilityOnStack.hasParam("Defined") && abilityOnStack.hasParam("ValidPlayers"))
|
||||
objects = AbilityUtils.getDefinedPlayers(source, abilityOnStack.getParam("ValidPlayers"), abilityOnStack);
|
||||
|
||||
if (!objects.contains(ai) || abilityOnStack.hasParam("NoPrevention")) {
|
||||
continue;
|
||||
}
|
||||
int dmg = AbilityUtils.calculateAmount(source, abilityOnStack.getParam("NumDmg"), abilityOnStack);
|
||||
if (ComputerUtilCombat.predictDamageTo(ai, dmg, source, false) <= 0) {
|
||||
continue;
|
||||
}
|
||||
return source;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
|
||||
public class ChooseTypeAi extends SpellAbilityAi {
|
||||
@Override
|
||||
@@ -21,7 +21,7 @@ public class ChooseTypeAi extends SpellAbilityAi {
|
||||
sa.resetTargets();
|
||||
sa.getTargets().add(ai);
|
||||
} else {
|
||||
for (final Player p : AbilityUtils.getDefinedPlayers(sa.getSourceCard(), sa.getParam("Defined"), sa)) {
|
||||
for (final Player p : AbilityUtils.getDefinedPlayers(sa.getHostCard(), sa.getParam("Defined"), sa)) {
|
||||
if (p.isOpponentOf(ai) && !mandatory) {
|
||||
return false;
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.TargetRestrictions;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
|
||||
public class ClashAi extends SpellAbilityAi {
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import forge.Card;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.TargetRestrictions;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.Game;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.phase.PhaseHandler;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.PlayerActionConfirmMode;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CloneAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final Game game = source.getGame();
|
||||
|
||||
boolean useAbility = true;
|
||||
@@ -129,9 +129,9 @@ public class CloneAi extends SpellAbilityAi {
|
||||
* </p>
|
||||
*
|
||||
* @param af
|
||||
* a {@link forge.card.ability.AbilityFactory} object.
|
||||
* a {@link forge.game.ability.AbilityFactory} object.
|
||||
* @param sa
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
* @return a boolean.
|
||||
*/
|
||||
private boolean cloneTgtAI(final SpellAbility sa) {
|
||||
@@ -1,21 +1,20 @@
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import forge.ai.ComputerUtilCard;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.TargetRestrictions;
|
||||
import forge.game.ai.ComputerUtilCard;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
public class ControlExchangeAi extends SpellAbilityAi {
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -29,7 +28,7 @@ public class ControlExchangeAi extends SpellAbilityAi {
|
||||
sa.resetTargets();
|
||||
|
||||
List<Card> list =
|
||||
CardLists.getValidCards(ai.getOpponent().getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), ai, sa.getSourceCard());
|
||||
CardLists.getValidCards(ai.getOpponent().getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), ai, sa.getHostCard());
|
||||
// AI won't try to grab cards that are filtered out of AI decks on
|
||||
// purpose
|
||||
list = CardLists.filter(list, new Predicate<Card>() {
|
||||
@@ -41,10 +40,10 @@ public class ControlExchangeAi extends SpellAbilityAi {
|
||||
});
|
||||
object1 = ComputerUtilCard.getBestAI(list);
|
||||
if (sa.hasParam("Defined")) {
|
||||
object2 = AbilityUtils.getDefinedCards(sa.getSourceCard(), sa.getParam("Defined"), sa).get(0);
|
||||
} else if (tgt.getMinTargets(sa.getSourceCard(), sa) > 1) {
|
||||
object2 = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("Defined"), sa).get(0);
|
||||
} else if (tgt.getMinTargets(sa.getHostCard(), sa) > 1) {
|
||||
List<Card> list2 = ai.getCardsIn(ZoneType.Battlefield);
|
||||
list2 = CardLists.getValidCards(list2, tgt.getValidTgts(), ai, sa.getSourceCard());
|
||||
list2 = CardLists.getValidCards(list2, tgt.getValidTgts(), ai, sa.getHostCard());
|
||||
object2 = ComputerUtilCard.getWorstAI(list2);
|
||||
sa.getTargets().add(object2);
|
||||
}
|
||||
@@ -15,27 +15,27 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import forge.ai.ComputerUtilCard;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.Game;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.combat.CombatUtil;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.Aggregates;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.TargetRestrictions;
|
||||
import forge.game.Game;
|
||||
import forge.game.ai.ComputerUtilCard;
|
||||
import forge.game.combat.CombatUtil;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
|
||||
//AB:GainControl|ValidTgts$Creature|TgtPrompt$Select target legendary creature|LoseControl$Untap,LoseControl|SpellDescription$Gain control of target xxxxxxx
|
||||
|
||||
@@ -89,7 +89,11 @@ public class ControlGainAi extends SpellAbilityAi {
|
||||
if (!opp.canBeTargetedBy(sa)) {
|
||||
return false;
|
||||
}
|
||||
sa.getTargets().add(opp);
|
||||
if (tgt.isRandomTarget()) {
|
||||
sa.getTargets().add(Aggregates.random(tgt.getAllCandidates(sa, false)));
|
||||
} else {
|
||||
sa.getTargets().add(opp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +106,7 @@ public class ControlGainAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
List<Card> list =
|
||||
CardLists.getValidCards(opp.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard());
|
||||
CardLists.getValidCards(opp.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getHostCard());
|
||||
|
||||
// AI won't try to grab cards that are filtered out of AI decks on purpose
|
||||
list = CardLists.filter(list, new Predicate<Card>() {
|
||||
@@ -126,7 +130,7 @@ public class ControlGainAi extends SpellAbilityAi {
|
||||
return false;
|
||||
}
|
||||
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(sa.getSourceCard(), sa)) {
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(sa.getHostCard(), sa)) {
|
||||
Card t = null;
|
||||
for (final Card c : list) {
|
||||
if (c.isCreature()) {
|
||||
@@ -144,7 +148,7 @@ public class ControlGainAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
if (list.isEmpty()) {
|
||||
if ((sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getSourceCard(), sa)) || (sa.getTargets().getNumTargeted() == 0)) {
|
||||
if ((sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa)) || (sa.getTargets().getNumTargeted() == 0)) {
|
||||
sa.resetTargets();
|
||||
return false;
|
||||
} else {
|
||||
@@ -1,24 +1,22 @@
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import forge.ai.ComputerUtil;
|
||||
import forge.ai.ComputerUtilCard;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.card.CardPredicates.Presets;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.PlayerActionConfirmMode;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CardPredicates.Presets;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.TargetRestrictions;
|
||||
import forge.game.ai.ComputerUtilCard;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.PlayerActionConfirmMode;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
public class CopyPermanentAi extends SpellAbilityAi {
|
||||
|
||||
@@ -27,29 +25,23 @@ public class CopyPermanentAi extends SpellAbilityAi {
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
// Card source = sa.getSourceCard();
|
||||
// Card source = sa.getHostCard();
|
||||
// TODO - I'm sure someone can do this AI better
|
||||
|
||||
if (ComputerUtil.preventRunAwayActivations(sa)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sa.hasParam("AtEOT") && !aiPlayer.getGame().getPhaseHandler().is(PhaseType.MAIN1)) {
|
||||
return false;
|
||||
} else {
|
||||
double chance = .4; // 40 percent chance with instant speed stuff
|
||||
if (SpellAbilityAi.isSorcerySpeed(sa)) {
|
||||
chance = .667; // 66.7% chance for sorcery speed (since it will
|
||||
// never activate EOT)
|
||||
}
|
||||
final Random r = MyRandom.getRandom();
|
||||
if (r.nextFloat() <= Math.pow(chance, sa.getActivationsThisTurn() + 1)) {
|
||||
return this.doTriggerAINoCost(aiPlayer, sa, false);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return this.doTriggerAINoCost(aiPlayer, sa, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(final Player aiPlayer, SpellAbility sa, boolean mandatory) {
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
// ////
|
||||
// Targeting
|
||||
@@ -69,9 +61,9 @@ public class CopyPermanentAi extends SpellAbilityAi {
|
||||
});
|
||||
sa.resetTargets();
|
||||
// target loop
|
||||
while (sa.getTargets().getNumTargeted() < abTgt.getMaxTargets(sa.getSourceCard(), sa)) {
|
||||
while (sa.getTargets().getNumTargeted() < abTgt.getMaxTargets(sa.getHostCard(), sa)) {
|
||||
if (list.isEmpty()) {
|
||||
if ((sa.getTargets().getNumTargeted() < abTgt.getMinTargets(sa.getSourceCard(), sa))
|
||||
if ((sa.getTargets().getNumTargeted() < abTgt.getMinTargets(sa.getHostCard(), sa))
|
||||
|| (sa.getTargets().getNumTargeted() == 0)) {
|
||||
sa.resetTargets();
|
||||
return false;
|
||||
@@ -95,7 +87,7 @@ public class CopyPermanentAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
if (choice == null) { // can't find anything left
|
||||
if ((sa.getTargets().getNumTargeted() < abTgt.getMinTargets(sa.getSourceCard(), sa))
|
||||
if ((sa.getTargets().getNumTargeted() < abTgt.getMinTargets(sa.getHostCard(), sa))
|
||||
|| (sa.getTargets().getNumTargeted() == 0)) {
|
||||
sa.resetTargets();
|
||||
return false;
|
||||
@@ -127,7 +119,7 @@ public class CopyPermanentAi extends SpellAbilityAi {
|
||||
* @see forge.card.ability.SpellAbilityAi#chooseSingleCard(forge.game.player.Player, forge.card.spellability.SpellAbility, java.util.List, boolean)
|
||||
*/
|
||||
@Override
|
||||
public Card chooseSingleCard(Player ai, SpellAbility sa, Collection<Card> options, boolean isOptional) {
|
||||
public Card chooseSingleCard(Player ai, SpellAbility sa, Collection<Card> options, boolean isOptional, Player targetedPlayer) {
|
||||
// Select a card to attach to
|
||||
return ComputerUtilCard.getBestAI(options);
|
||||
}
|
||||
@@ -1,16 +1,16 @@
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
import forge.Card;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.TargetRestrictions;
|
||||
import forge.ai.ComputerUtilCost;
|
||||
import forge.ai.ComputerUtilMana;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.Game;
|
||||
import forge.game.ai.ComputerUtilCost;
|
||||
import forge.game.ai.ComputerUtilMana;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardFactoryUtil;
|
||||
import forge.game.cost.Cost;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
public class CounterAi extends SpellAbilityAi {
|
||||
@@ -19,7 +19,7 @@ public class CounterAi extends SpellAbilityAi {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
boolean toReturn = true;
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final Game game = ai.getGame();
|
||||
if (game.getStack().isEmpty()) {
|
||||
return false;
|
||||
@@ -39,12 +39,12 @@ public class CounterAi extends SpellAbilityAi {
|
||||
if (tgt != null) {
|
||||
|
||||
final SpellAbility topSA = game.getStack().peekAbility();
|
||||
if (!CardFactoryUtil.isCounterableBy(topSA.getSourceCard(), sa) || topSA.getActivatingPlayer() == ai) {
|
||||
if (!CardFactoryUtil.isCounterableBy(topSA.getHostCard(), sa) || topSA.getActivatingPlayer() == ai) {
|
||||
// might as well check for player's friendliness
|
||||
return false;
|
||||
}
|
||||
if (sa.hasParam("AITgts") && (topSA.getSourceCard() == null
|
||||
|| !topSA.getSourceCard().isValid(sa.getParam("AITgts"), sa.getActivatingPlayer(), source))) {
|
||||
if (sa.hasParam("AITgts") && (topSA.getHostCard() == null
|
||||
|| !topSA.getHostCard().isValid(sa.getParam("AITgts"), sa.getActivatingPlayer(), source))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ public class CounterAi extends SpellAbilityAi {
|
||||
return false;
|
||||
}
|
||||
final SpellAbility topSA = game.getStack().peekAbility();
|
||||
if (!CardFactoryUtil.isCounterableBy(topSA.getSourceCard(), sa) || topSA.getActivatingPlayer() == ai) {
|
||||
if (!CardFactoryUtil.isCounterableBy(topSA.getHostCard(), sa) || topSA.getActivatingPlayer() == ai) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ public class CounterAi extends SpellAbilityAi {
|
||||
|
||||
String unlessCost = sa.hasParam("UnlessCost") ? sa.getParam("UnlessCost").trim() : null;
|
||||
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
if (unlessCost != null) {
|
||||
// Is this Usable Mana Sources? Or Total Available Mana?
|
||||
final int usableManaSources = ComputerUtilMana.getAvailableMana(ai.getOpponent(), true).size();
|
||||
@@ -15,18 +15,17 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package forge.card.ability.ai;
|
||||
|
||||
import java.util.List;
|
||||
package forge.ai.ability;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CounterType;
|
||||
import forge.game.ai.ComputerUtilCard;
|
||||
import forge.ai.ComputerUtilCard;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.card.CounterType;
|
||||
import forge.util.Aggregates;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -50,7 +49,7 @@ public abstract class CountersAi {
|
||||
* a {@link java.lang.String} object.
|
||||
* @param amount
|
||||
* a int.
|
||||
* @return a {@link forge.Card} object.
|
||||
* @return a {@link forge.game.card.Card} object.
|
||||
*/
|
||||
public static Card chooseCursedTarget(final List<Card> list, final String type, final int amount) {
|
||||
Card choice;
|
||||
@@ -83,18 +82,17 @@ public abstract class CountersAi {
|
||||
* a {@link forge.CardList} object.
|
||||
* @param type
|
||||
* a {@link java.lang.String} object.
|
||||
* @return a {@link forge.Card} object.
|
||||
* @return a {@link forge.game.card.Card} object.
|
||||
*/
|
||||
public static Card chooseBoonTarget(final List<Card> list, final String type) {
|
||||
Card choice;
|
||||
if (type.equals("P1P1")) {
|
||||
choice = ComputerUtilCard.getBestCreatureAI(list);
|
||||
} else if (type.equals("DIVINITY") || type.equals("FATE")) {
|
||||
} else if (type.equals("DIVINITY")) {
|
||||
final List<Card> boon = CardLists.filter(list, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return c.getCounters(CounterType.DIVINITY) == 0
|
||||
&& c.getCounters(CounterType.FATE) == 0;
|
||||
return c.getCounters(CounterType.DIVINITY) == 0;
|
||||
}
|
||||
});
|
||||
choice = ComputerUtilCard.getMostExpensivePermanentAI(boon, null, false);
|
||||
@@ -1,21 +1,21 @@
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CounterType;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.TargetRestrictions;
|
||||
import forge.game.ai.ComputerUtilCard;
|
||||
import forge.ai.ComputerUtilCard;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.card.CounterType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.Aggregates;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class CountersMoveAi extends SpellAbilityAi {
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
@@ -28,7 +28,7 @@ public class CountersMoveAi extends SpellAbilityAi {
|
||||
// TODO handle proper calculation of X values based on Cost
|
||||
int amount = 0;
|
||||
if (!sa.getParam("CounterNum").equals("All")) {
|
||||
amount = AbilityUtils.calculateAmount(sa.getSourceCard(), amountStr, sa);
|
||||
amount = AbilityUtils.calculateAmount(sa.getHostCard(), amountStr, sa);
|
||||
}
|
||||
// don't use it if no counters to add
|
||||
if (amount <= 0) {
|
||||
@@ -47,13 +47,13 @@ public class CountersMoveAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
final Card host = sa.getSourceCard();
|
||||
final Card host = sa.getHostCard();
|
||||
final TargetRestrictions abTgt = sa.getTargetRestrictions();
|
||||
final String type = sa.getParam("CounterType");
|
||||
final String amountStr = sa.getParam("CounterNum");
|
||||
int amount = 0;
|
||||
if (!sa.getParam("CounterNum").equals("All")) {
|
||||
amount = AbilityUtils.calculateAmount(sa.getSourceCard(), amountStr, sa);
|
||||
amount = AbilityUtils.calculateAmount(sa.getHostCard(), amountStr, sa);
|
||||
}
|
||||
boolean chance = false;
|
||||
boolean preferred = true;
|
||||
@@ -1,18 +1,17 @@
|
||||
package forge.card.ability.ai;
|
||||
|
||||
import java.util.List;
|
||||
package forge.ai.ability;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CounterType;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.ai.ComputerUtil;
|
||||
import forge.ai.ComputerUtil;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.card.CounterType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CountersProliferateAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
@@ -43,7 +42,7 @@ public class CountersProliferateAi extends SpellAbilityAi {
|
||||
}
|
||||
});
|
||||
|
||||
if ((cperms.size() == 0) && (hperms.size() == 0) && (ai.getOpponent().getPoisonCounters() == 0)) {
|
||||
if (cperms.isEmpty() && hperms.isEmpty() && ai.getOpponent().getPoisonCounters() == 0) {
|
||||
return false;
|
||||
}
|
||||
return chance;
|
||||
401
forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java
Normal file
401
forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java
Normal file
@@ -0,0 +1,401 @@
|
||||
package forge.ai.ability;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Iterables;
|
||||
import forge.ai.*;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.card.CounterType;
|
||||
import forge.game.combat.CombatUtil;
|
||||
import forge.game.cost.Cost;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.PlayerActionConfirmMode;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.Aggregates;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class CountersPutAi extends SpellAbilityAi {
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, final SpellAbility sa) {
|
||||
// AI needs to be expanded, since this function can be pretty complex
|
||||
// based on
|
||||
// what the expected targets could be
|
||||
final Random r = MyRandom.getRandom();
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final TargetRestrictions abTgt = sa.getTargetRestrictions();
|
||||
final Card source = sa.getHostCard();
|
||||
List<Card> list;
|
||||
Card choice = null;
|
||||
final String type = sa.getParam("CounterType");
|
||||
final String amountStr = sa.getParam("CounterNum");
|
||||
final boolean divided = sa.hasParam("DividedAsYouChoose");
|
||||
|
||||
final Player player = sa.isCurse() ? ai.getOpponent() : ai;
|
||||
|
||||
if (ComputerUtil.preventRunAwayActivations(sa)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ("Never".equals(sa.getParam("AILogic"))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (abCost != null) {
|
||||
// AI currently disabled for these costs
|
||||
if (!ComputerUtilCost.checkLifeCost(ai, abCost, source, 4, null)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ComputerUtilCost.checkDiscardCost(ai, abCost, source)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ComputerUtilCost.checkSacrificeCost(ai, abCost, source)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ComputerUtilCost.checkCreatureSacrificeCost(ai, abCost, source)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ComputerUtilCost.checkRemoveCounterCost(abCost, source)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (sa.hasParam("Monstrosity") && source.isMonstrous()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sa.hasParam("LevelUp")) {
|
||||
// creatures enchanted by curse auras have low priority
|
||||
if (source.getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)) {
|
||||
for (Card aura : source.getEnchantedBy()) {
|
||||
if (aura.getController().isOpponentOf(ai)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
int maxLevel = Integer.parseInt(sa.getParam("MaxLevel"));
|
||||
return source.getCounters(CounterType.LEVEL) < maxLevel;
|
||||
}
|
||||
|
||||
// TODO handle proper calculation of X values based on Cost
|
||||
int amount = AbilityUtils.calculateAmount(source, amountStr, sa);
|
||||
|
||||
if (amountStr.equals("X") && source.getSVar(amountStr).equals("Count$xPaid")) {
|
||||
// Set PayX here to maximum value.
|
||||
amount = ComputerUtilMana.determineLeftoverMana(sa, ai);
|
||||
source.setSVar("PayX", Integer.toString(amount));
|
||||
}
|
||||
|
||||
// don't use it if no counters to add
|
||||
if (amount <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Targeting
|
||||
if (abTgt != null) {
|
||||
sa.resetTargets();
|
||||
// target loop
|
||||
|
||||
list = CardLists.filter(player.getCardsIn(ZoneType.Battlefield), new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return c.canBeTargetedBy(sa) && c.canReceiveCounters(CounterType.valueOf(type));
|
||||
}
|
||||
});
|
||||
|
||||
list = CardLists.getValidCards(list, abTgt.getValidTgts(), source.getController(), source);
|
||||
|
||||
if (list.size() < abTgt.getMinTargets(source, sa)) {
|
||||
return false;
|
||||
}
|
||||
while (sa.getTargets().getNumTargeted() < abTgt.getMaxTargets(sa.getHostCard(), sa)) {
|
||||
if (list.isEmpty()) {
|
||||
if ((sa.getTargets().getNumTargeted() < abTgt.getMinTargets(sa.getHostCard(), sa))
|
||||
|| (sa.getTargets().getNumTargeted() == 0)) {
|
||||
sa.resetTargets();
|
||||
return false;
|
||||
} else {
|
||||
// TODO is this good enough? for up to amounts?
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (sa.isCurse()) {
|
||||
choice = CountersAi.chooseCursedTarget(list, type, amount);
|
||||
} else {
|
||||
choice = CountersAi.chooseBoonTarget(list, type);
|
||||
}
|
||||
|
||||
if (choice == null) { // can't find anything left
|
||||
if ((sa.getTargets().getNumTargeted() < abTgt.getMinTargets(sa.getHostCard(), sa))
|
||||
|| (sa.getTargets().getNumTargeted() == 0)) {
|
||||
sa.resetTargets();
|
||||
return false;
|
||||
} else {
|
||||
// TODO is this good enough? for up to amounts?
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
list.remove(choice);
|
||||
sa.getTargets().add(choice);
|
||||
|
||||
if (divided) {
|
||||
abTgt.addDividedAllocation(choice, amount);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
final List<Card> cards = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("Defined"), sa);
|
||||
// Don't activate Curse abilities on my cards and non-curse abilites
|
||||
// on my opponents
|
||||
if (cards.isEmpty() || !cards.get(0).getController().equals(player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final int currCounters = cards.get(0).getCounters(CounterType.valueOf(type));
|
||||
// each non +1/+1 counter on the card is a 10% chance of not
|
||||
// activating this ability.
|
||||
|
||||
if (!(type.equals("P1P1") || type.equals("M1M1") || type.equals("ICE")) && (r.nextFloat() < (.1 * currCounters))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (ComputerUtil.playImmediately(ai, sa)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Don't use non P1P1/M1M1 counters before main 2 if possible
|
||||
if (ai.getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)
|
||||
&& !sa.hasParam("ActivationPhases")
|
||||
&& !(type.equals("P1P1") || type.equals("M1M1"))
|
||||
&& !ComputerUtil.castSpellInMain1(ai, sa)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ComputerUtil.waitForBlocking(sa)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
} // putCanPlayAI
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(final SpellAbility sa, Player ai) {
|
||||
boolean chance = true;
|
||||
final TargetRestrictions abTgt = sa.getTargetRestrictions();
|
||||
final Card source = sa.getHostCard();
|
||||
Card choice = null;
|
||||
final String type = sa.getParam("CounterType");
|
||||
final String amountStr = sa.getParam("CounterNum");
|
||||
final boolean divided = sa.hasParam("DividedAsYouChoose");
|
||||
final int amount = AbilityUtils.calculateAmount(sa.getHostCard(), amountStr, sa);
|
||||
|
||||
final Player player = sa.isCurse() ? ai.getOpponent() : ai;
|
||||
|
||||
if (abTgt != null) {
|
||||
List<Card> list =
|
||||
CardLists.getValidCards(player.getCardsIn(ZoneType.Battlefield), abTgt.getValidTgts(), source.getController(), source);
|
||||
|
||||
if (list.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
sa.resetTargets();
|
||||
// target loop
|
||||
while (sa.getTargets().getNumTargeted() < abTgt.getMaxTargets(sa.getHostCard(), sa)) {
|
||||
list = CardLists.filter(list, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return sa.canTarget(c);
|
||||
}
|
||||
});
|
||||
if (list.size() == 0) {
|
||||
if ((sa.getTargets().getNumTargeted() < abTgt.getMinTargets(sa.getHostCard(), sa))
|
||||
|| (sa.getTargets().getNumTargeted() == 0)) {
|
||||
sa.resetTargets();
|
||||
return false;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (sa.isCurse()) {
|
||||
choice = CountersAi.chooseCursedTarget(list, type, amount);
|
||||
} else {
|
||||
choice = CountersAi.chooseBoonTarget(list, type);
|
||||
}
|
||||
|
||||
if (choice == null) { // can't find anything left
|
||||
if ((sa.getTargets().getNumTargeted() < abTgt.getMinTargets(sa.getHostCard(), sa))
|
||||
|| (sa.getTargets().getNumTargeted() == 0)) {
|
||||
sa.resetTargets();
|
||||
return false;
|
||||
} else {
|
||||
// TODO is this good enough? for up to amounts?
|
||||
break;
|
||||
}
|
||||
}
|
||||
list.remove(choice);
|
||||
sa.getTargets().add(choice);
|
||||
if (divided) {
|
||||
abTgt.addDividedAllocation(choice, amount);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return chance;
|
||||
} // putPlayDrawbackAI
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
final TargetRestrictions abTgt = sa.getTargetRestrictions();
|
||||
final Card source = sa.getHostCard();
|
||||
// boolean chance = true;
|
||||
boolean preferred = true;
|
||||
List<Card> list;
|
||||
boolean isCurse = sa.isCurse();
|
||||
final Player player = isCurse ? ai.getOpponent() : ai;
|
||||
final String type = sa.getParam("CounterType");
|
||||
final String amountStr = sa.getParam("CounterNum");
|
||||
final boolean divided = sa.hasParam("DividedAsYouChoose");
|
||||
final int amount = AbilityUtils.calculateAmount(sa.getHostCard(), amountStr, sa);
|
||||
|
||||
if (abTgt == null) {
|
||||
// No target. So must be defined
|
||||
list = new ArrayList<Card>(AbilityUtils.getDefinedCards(source, sa.getParam("Defined"), sa));
|
||||
|
||||
if (!mandatory) {
|
||||
// TODO - If Trigger isn't mandatory, when wouldn't we want to
|
||||
// put a counter?
|
||||
// things like Powder Keg, which are way too complex for the AI
|
||||
}
|
||||
} else {
|
||||
list = CardLists.getTargetableCards(player.getCardsIn(ZoneType.Battlefield), sa);
|
||||
list = CardLists.getValidCards(list, abTgt.getValidTgts(), source.getController(), source);
|
||||
|
||||
if (list.isEmpty() && mandatory) {
|
||||
// If there isn't any prefered cards to target, gotta choose
|
||||
// non-preferred ones
|
||||
list = player.getOpponent().getCardsIn(ZoneType.Battlefield);
|
||||
list = CardLists.getTargetableCards(list, sa);
|
||||
list = CardLists.getValidCards(list, abTgt.getValidTgts(), source.getController(), source);
|
||||
preferred = false;
|
||||
}
|
||||
// Not mandatory, or the the list was regenerated and is still
|
||||
// empty,
|
||||
// so return false since there are no targets
|
||||
if (list.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Card choice = null;
|
||||
|
||||
// Choose targets here:
|
||||
if (isCurse) {
|
||||
if (preferred) {
|
||||
choice = CountersAi.chooseCursedTarget(list, type, amount);
|
||||
}
|
||||
|
||||
else {
|
||||
if (type.equals("M1M1")) {
|
||||
choice = ComputerUtilCard.getWorstCreatureAI(list);
|
||||
} else {
|
||||
choice = Aggregates.random(list);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (preferred) {
|
||||
choice = CountersAi.chooseBoonTarget(list, type);
|
||||
}
|
||||
|
||||
else {
|
||||
if (type.equals("P1P1")) {
|
||||
choice = ComputerUtilCard.getWorstCreatureAI(list);
|
||||
} else {
|
||||
choice = Aggregates.random(list);
|
||||
}
|
||||
}
|
||||
if (choice != null && divided) {
|
||||
abTgt.addDividedAllocation(choice, amount);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO - I think choice can be null here. Is that ok for
|
||||
// addTarget()?
|
||||
sa.getTargets().add(choice);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.card.ability.SpellAbilityAi#confirmAction(forge.game.player.Player, forge.card.spellability.SpellAbility, forge.game.player.PlayerActionConfirmMode, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) {
|
||||
final Card source = sa.getHostCard();
|
||||
if (mode == PlayerActionConfirmMode.Tribute) {
|
||||
// add counter if that opponent has a giant creature
|
||||
final List<Card> creats = player.getCreaturesInPlay();
|
||||
final int tributeAmount = source.getKeywordMagnitude("Tribute");
|
||||
final boolean isHaste = source.hasKeyword("Haste");
|
||||
List<Card> threatening = CardLists.filter(creats, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card c) {
|
||||
return CombatUtil.canBlock(source, c, !isHaste)
|
||||
&& (c.getNetDefense() > source.getNetAttack() + tributeAmount || c.hasKeyword("DeathTouch"));
|
||||
}
|
||||
});
|
||||
if (!threatening.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
if (source.hasSVar("TributeAILogic")) {
|
||||
final String logic = source.getSVar("TributeAILogic");
|
||||
if (logic.equals("Always")) {
|
||||
return true;
|
||||
} else if (logic.equals("Never")) {
|
||||
return false;
|
||||
} else if (logic.equals("CanBlockThisTurn")) {
|
||||
// pump haste
|
||||
List<Card> canBlock = CardLists.filter(creats, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card c) {
|
||||
return CombatUtil.canBlock(source, c) && (c.getNetDefense() > source.getNetAttack() || c.hasKeyword("DeathTouch"));
|
||||
}
|
||||
});
|
||||
if (!canBlock.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
} else if (logic.equals("DontControlCreatures")) {
|
||||
return !creats.isEmpty();
|
||||
}
|
||||
}
|
||||
}
|
||||
return MyRandom.getRandom().nextBoolean();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.card.ability.SpellAbilityAi#chooseSinglePlayer(Player, SpellAbility, Collection<Player>)
|
||||
*/
|
||||
@Override
|
||||
public Player chooseSinglePlayer(Player ai, SpellAbility sa, Collection<Player> options) {
|
||||
// logic?
|
||||
return Iterables.getFirst(options, null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,26 +1,26 @@
|
||||
package forge.card.ability.ai;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
package forge.ai.ability;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.spellability.AbilitySub;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.TargetRestrictions;
|
||||
import forge.game.ai.ComputerUtilCost;
|
||||
import forge.game.ai.ComputerUtilMana;
|
||||
import forge.ai.ComputerUtilCost;
|
||||
import forge.ai.ComputerUtilMana;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.cost.Cost;
|
||||
import forge.game.phase.PhaseHandler;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.PlayerActionConfirmMode;
|
||||
import forge.game.spellability.AbilitySub;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class CountersPutAllAi extends SpellAbilityAi {
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
@@ -29,7 +29,7 @@ public class CountersPutAllAi extends SpellAbilityAi {
|
||||
// the expected targets could be
|
||||
final Random r = MyRandom.getRandom();
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
List<Card> hList;
|
||||
List<Card> cList;
|
||||
final String type = sa.getParam("CounterType");
|
||||
@@ -72,7 +72,7 @@ public class CountersPutAllAi extends SpellAbilityAi {
|
||||
amount = ComputerUtilMana.determineLeftoverMana(sa, ai);
|
||||
source.setSVar("PayX", Integer.toString(amount));
|
||||
} else {
|
||||
amount = AbilityUtils.calculateAmount(sa.getSourceCard(), amountStr, sa);
|
||||
amount = AbilityUtils.calculateAmount(sa.getHostCard(), amountStr, sa);
|
||||
}
|
||||
|
||||
// prevent run-away activations - first time will always return true
|
||||
@@ -133,4 +133,11 @@ public class CountersPutAllAi extends SpellAbilityAi {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player ai) {
|
||||
return canPlayAI(ai, sa);
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see forge.card.ability.SpellAbilityAi#confirmAction(forge.game.player.Player, forge.card.spellability.SpellAbility, forge.game.player.PlayerActionConfirmMode, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) {
|
||||
return player.getCreaturesInPlay().size() >= player.getOpponent().getCreaturesInPlay().size();
|
||||
}
|
||||
}
|
||||
@@ -15,21 +15,20 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package forge.card.ability.ai;
|
||||
|
||||
import java.util.List;
|
||||
package forge.ai.ability;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.TargetRestrictions;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* AbilityFactory_PutOrRemoveCountersAi class.
|
||||
@@ -52,7 +51,7 @@ public class CountersPutOrRemoveAi extends SpellAbilityAi {
|
||||
|
||||
List<ZoneType> zones = ZoneType.listValueOf(sa.getParamOrDefault("TgtZones", "Battlefield"));
|
||||
List<Card> validCards = CardLists.getValidCards(ai.getGame().getCardsIn(zones),
|
||||
tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard());
|
||||
tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getHostCard());
|
||||
|
||||
if (validCards.isEmpty()) {
|
||||
return false;
|
||||
@@ -73,9 +72,9 @@ public class CountersPutOrRemoveAi extends SpellAbilityAi {
|
||||
}
|
||||
}
|
||||
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(sa.getSourceCard(), sa)) {
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(sa.getHostCard(), sa)) {
|
||||
Card targetCard = null;
|
||||
if (cWithCounters.isEmpty() && ((sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getSourceCard(), sa))
|
||||
if (cWithCounters.isEmpty() && ((sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa))
|
||||
|| (sa.getTargets().getNumTargeted() == 0))) {
|
||||
sa.resetTargets();
|
||||
return false;
|
||||
@@ -1,15 +1,15 @@
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CounterType;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.TargetRestrictions;
|
||||
import forge.game.ai.ComputerUtil;
|
||||
import forge.game.ai.ComputerUtilCost;
|
||||
import forge.ai.ComputerUtil;
|
||||
import forge.ai.ComputerUtilCost;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CounterType;
|
||||
import forge.game.cost.Cost;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
|
||||
public class CountersRemoveAi extends SpellAbilityAi {
|
||||
|
||||
@@ -20,7 +20,7 @@ public class CountersRemoveAi extends SpellAbilityAi {
|
||||
// the expected targets could be
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
TargetRestrictions abTgt = sa.getTargetRestrictions();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
// List<Card> list;
|
||||
// Card choice = null;
|
||||
|
||||
@@ -59,7 +59,7 @@ public class CountersRemoveAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
// TODO handle proper calculation of X values based on Cost
|
||||
// final int amount = calculateAmount(sa.getSourceCard(), amountStr, sa);
|
||||
// final int amount = calculateAmount(sa.getHostCard(), amountStr, sa);
|
||||
|
||||
if (ComputerUtil.preventRunAwayActivations(sa)) {
|
||||
return false;
|
||||
@@ -77,7 +77,7 @@ public class CountersRemoveAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
if (!type.matches("Any")) {
|
||||
final int currCounters = sa.getSourceCard().getCounters(CounterType.valueOf(type));
|
||||
final int currCounters = sa.getHostCard().getCounters(CounterType.valueOf(type));
|
||||
if (currCounters < 1) {
|
||||
return false;
|
||||
}
|
||||
@@ -1,19 +1,18 @@
|
||||
package forge.card.ability.ai;
|
||||
|
||||
import java.util.List;
|
||||
package forge.ai.ability;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardPredicates;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.ai.ComputerUtilCombat;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.Game;
|
||||
import forge.game.ai.ComputerUtilCombat;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardPredicates;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class DamageAiBase extends SpellAbilityAi {
|
||||
protected boolean shouldTgtP(final Player comp, final SpellAbility sa, final int d, final boolean noPrevention) {
|
||||
int restDamage = d;
|
||||
@@ -22,15 +21,19 @@ public abstract class DamageAiBase extends SpellAbilityAi {
|
||||
if (!sa.canTarget(enemy)) {
|
||||
return false;
|
||||
}
|
||||
if (sa.getTargets() != null && sa.getTargets().getTargets().contains(enemy)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// burn Planeswalkers
|
||||
if (Iterables.any(enemy.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.PLANEWALKERS)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!noPrevention) {
|
||||
restDamage = ComputerUtilCombat.predictDamageTo(enemy, restDamage, sa.getSourceCard(), false);
|
||||
restDamage = ComputerUtilCombat.predictDamageTo(enemy, restDamage, sa.getHostCard(), false);
|
||||
} else {
|
||||
restDamage = enemy.staticReplaceDamage(restDamage, sa.getSourceCard(), false);
|
||||
restDamage = enemy.staticReplaceDamage(restDamage, sa.getHostCard(), false);
|
||||
}
|
||||
|
||||
if (restDamage == 0) {
|
||||
@@ -1,26 +1,21 @@
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import forge.ai.*;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.cost.Cost;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.TargetRestrictions;
|
||||
import forge.game.ai.ComputerUtilCard;
|
||||
import forge.game.ai.ComputerUtilCombat;
|
||||
import forge.game.ai.ComputerUtilCost;
|
||||
import forge.game.ai.ComputerUtilMana;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
public class DamageAllAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
@@ -29,12 +24,12 @@ public class DamageAllAi extends SpellAbilityAi {
|
||||
// based on what the expected targets could be
|
||||
final Random r = MyRandom.getRandom();
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
String validP = "";
|
||||
|
||||
final String damage = sa.getParam("NumDmg");
|
||||
int dmg = AbilityUtils.calculateAmount(sa.getSourceCard(), damage, sa);
|
||||
int dmg = AbilityUtils.calculateAmount(sa.getHostCard(), damage, sa);
|
||||
|
||||
|
||||
if (damage.equals("X") && sa.getSVar(damage).equals("Count$xPaid")) {
|
||||
@@ -104,11 +99,11 @@ public class DamageAllAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player ai) {
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
String validP = "";
|
||||
|
||||
final String damage = sa.getParam("NumDmg");
|
||||
int dmg = AbilityUtils.calculateAmount(sa.getSourceCard(), damage, sa);
|
||||
int dmg = AbilityUtils.calculateAmount(sa.getHostCard(), damage, sa);
|
||||
|
||||
if (damage.equals("X") && sa.getSVar(damage).equals("Count$xPaid")) {
|
||||
// Set PayX here to maximum value.
|
||||
@@ -156,9 +151,9 @@ public class DamageAllAi extends SpellAbilityAi {
|
||||
* </p>
|
||||
*
|
||||
* @param af
|
||||
* a {@link forge.card.ability.AbilityFactory} object.
|
||||
* a {@link forge.game.ability.AbilityFactory} object.
|
||||
* @param sa
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
* @param player
|
||||
* a {@link forge.game.player.Player} object.
|
||||
* @param dmg
|
||||
@@ -166,7 +161,7 @@ public class DamageAllAi extends SpellAbilityAi {
|
||||
* @return a {@link forge.CardList} object.
|
||||
*/
|
||||
private List<Card> getKillableCreatures(final SpellAbility sa, final Player player, final int dmg) {
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
String validC = sa.hasParam("ValidCards") ? sa.getParam("ValidCards") : "";
|
||||
|
||||
// TODO: X may be something different than X paid
|
||||
@@ -188,11 +183,11 @@ public class DamageAllAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
String validP = "";
|
||||
|
||||
final String damage = sa.getParam("NumDmg");
|
||||
int dmg = AbilityUtils.calculateAmount(sa.getSourceCard(), damage, sa);
|
||||
int dmg = AbilityUtils.calculateAmount(sa.getHostCard(), damage, sa);
|
||||
|
||||
if (damage.equals("X") && sa.getSVar(damage).equals("Count$xPaid")) {
|
||||
// Set PayX here to maximum value.
|
||||
@@ -1,42 +1,36 @@
|
||||
package forge.card.ability.ai;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
package forge.ai.ability;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CardPredicates;
|
||||
import forge.ITargetable;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.spellability.AbilitySub;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.TargetChoices;
|
||||
import forge.card.spellability.TargetRestrictions;
|
||||
import forge.ai.*;
|
||||
import forge.game.Game;
|
||||
import forge.game.ai.ComputerUtil;
|
||||
import forge.game.ai.ComputerUtilCard;
|
||||
import forge.game.ai.ComputerUtilCombat;
|
||||
import forge.game.ai.ComputerUtilCost;
|
||||
import forge.game.ai.ComputerUtilMana;
|
||||
import forge.game.GameObject;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.card.CardPredicates;
|
||||
import forge.game.cost.Cost;
|
||||
import forge.game.phase.PhaseHandler;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.AbilitySub;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetChoices;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.Aggregates;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class DamageDealAi extends DamageAiBase {
|
||||
@Override
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player ai) {
|
||||
final String damage = sa.getParam("NumDmg");
|
||||
int dmg = AbilityUtils.calculateAmount(sa.getSourceCard(), damage, sa);
|
||||
int dmg = AbilityUtils.calculateAmount(sa.getHostCard(), damage, sa);
|
||||
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
if (damage.equals("X") && sa.getSVar(damage).equals("Count$xPaid")) {
|
||||
// Set PayX here to maximum value.
|
||||
@@ -53,10 +47,10 @@ public class DamageDealAi extends DamageAiBase {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
final String damage = sa.getParam("NumDmg");
|
||||
int dmg = AbilityUtils.calculateAmount(sa.getSourceCard(), damage, sa);
|
||||
int dmg = AbilityUtils.calculateAmount(sa.getHostCard(), damage, sa);
|
||||
|
||||
if (damage.equals("X") && sa.getSVar(damage).equals("Count$xPaid")) {
|
||||
// Set PayX here to maximum value.
|
||||
@@ -136,7 +130,7 @@ public class DamageDealAi extends DamageAiBase {
|
||||
* a {@link forge.game.player.Player} object.
|
||||
* @param mandatory
|
||||
* a boolean.
|
||||
* @return a {@link forge.Card} object.
|
||||
* @return a {@link forge.game.card.Card} object.
|
||||
*/
|
||||
private Card dealDamageChooseTgtC(final Player ai, final SpellAbility sa, final int d, final boolean noPrevention,
|
||||
final Player pl, final boolean mandatory) {
|
||||
@@ -146,10 +140,10 @@ public class DamageDealAi extends DamageAiBase {
|
||||
return null;
|
||||
}
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
List<Card> hPlay = CardLists.getValidCards(pl.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), ai, source);
|
||||
|
||||
final List<ITargetable> objects = Lists.newArrayList(sa.getTargets().getTargets());
|
||||
final List<GameObject> objects = Lists.newArrayList(sa.getTargets().getTargets());
|
||||
if (sa.hasParam("TargetUnique")) {
|
||||
objects.addAll(sa.getUniqueTargets());
|
||||
}
|
||||
@@ -201,7 +195,7 @@ public class DamageDealAi extends DamageAiBase {
|
||||
* </p>
|
||||
*
|
||||
* @param saMe
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
* @param dmg
|
||||
* a int.
|
||||
* @return a boolean.
|
||||
@@ -226,9 +220,9 @@ public class DamageDealAi extends DamageAiBase {
|
||||
* </p>
|
||||
*
|
||||
* @param sa
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
* @param tgt
|
||||
* a {@link forge.card.spellability.TargetRestrictions} object.
|
||||
* a {@link forge.game.spellability.TargetRestrictions} object.
|
||||
* @param dmg
|
||||
* a int.
|
||||
* @param mandatory
|
||||
@@ -237,7 +231,7 @@ public class DamageDealAi extends DamageAiBase {
|
||||
*/
|
||||
private boolean damageChoosingTargets(final Player ai, final SpellAbility sa, final TargetRestrictions tgt, int dmg,
|
||||
final boolean isTrigger, final boolean mandatory) {
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final boolean noPrevention = sa.hasParam("NoPrevention");
|
||||
final Game game = source.getGame();
|
||||
final PhaseHandler phase = game.getPhaseHandler();
|
||||
@@ -344,7 +338,7 @@ public class DamageDealAi extends DamageAiBase {
|
||||
}
|
||||
}
|
||||
// fell through all the choices, no targets left?
|
||||
if (((sa.getTargets().getNumTargeted() < tgt.getMinTargets(source, sa)) || (sa.getTargets().getNumTargeted() == 0))) {
|
||||
if (sa.getTargets().getNumTargeted() < tgt.getMinTargets(source, sa) || sa.getTargets().getNumTargeted() == 0) {
|
||||
if (!mandatory) {
|
||||
sa.resetTargets();
|
||||
return false;
|
||||
@@ -367,21 +361,21 @@ public class DamageDealAi extends DamageAiBase {
|
||||
* @param ai
|
||||
*
|
||||
* @param saMe
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
* @param dmg
|
||||
* a int.
|
||||
* @return a boolean.
|
||||
*/
|
||||
private boolean damageChooseNontargeted(Player ai, final SpellAbility saMe, final int dmg) {
|
||||
// TODO: Improve circumstances where the Defined Damage is unwanted
|
||||
final List<ITargetable> objects = AbilityUtils.getDefinedObjects(saMe.getSourceCard(), saMe.getParam("Defined"), saMe);
|
||||
final List<GameObject> objects = AbilityUtils.getDefinedObjects(saMe.getHostCard(), saMe.getParam("Defined"), saMe);
|
||||
boolean urgent = false; // can it wait?
|
||||
boolean positive = false;
|
||||
|
||||
for (final Object o : objects) {
|
||||
if (o instanceof Card) {
|
||||
Card c = (Card) o;
|
||||
final int restDamage = ComputerUtilCombat.predictDamageTo(c, dmg, saMe.getSourceCard(), false);
|
||||
final int restDamage = ComputerUtilCombat.predictDamageTo(c, dmg, saMe.getHostCard(), false);
|
||||
if (!c.hasKeyword("Indestructible") && ComputerUtilCombat.getDamageToKill(c) <= restDamage) {
|
||||
if (c.getController().equals(ai)) {
|
||||
return false;
|
||||
@@ -394,7 +388,7 @@ public class DamageDealAi extends DamageAiBase {
|
||||
}
|
||||
} else if (o instanceof Player) {
|
||||
final Player p = (Player) o;
|
||||
final int restDamage = ComputerUtilCombat.predictDamageTo(p, dmg, saMe.getSourceCard(), false);
|
||||
final int restDamage = ComputerUtilCombat.predictDamageTo(p, dmg, saMe.getHostCard(), false);
|
||||
if (!p.isOpponentOf(ai) && p.canLoseLife() && restDamage + 3 >= p.getLife() && restDamage > 0) {
|
||||
// from this spell will kill me
|
||||
return false;
|
||||
@@ -422,9 +416,9 @@ public class DamageDealAi extends DamageAiBase {
|
||||
* </p>
|
||||
*
|
||||
* @param sa
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
* @param tgt
|
||||
* a {@link forge.card.spellability.TargetRestrictions} object.
|
||||
* a {@link forge.game.spellability.TargetRestrictions} object.
|
||||
* @param dmg
|
||||
* a int.
|
||||
* @param mandatory
|
||||
@@ -437,7 +431,7 @@ public class DamageDealAi extends DamageAiBase {
|
||||
final boolean noPrevention = sa.hasParam("NoPrevention");
|
||||
final boolean divided = sa.hasParam("DividedAsYouChoose");
|
||||
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getSourceCard(), sa)) {
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa)) {
|
||||
// TODO: Consider targeting the planeswalker
|
||||
if (tgt.canTgtCreature()) {
|
||||
final Card c = this.dealDamageChooseTgtC(ai, sa, dmg, noPrevention, ai, mandatory);
|
||||
@@ -471,7 +465,7 @@ public class DamageDealAi extends DamageAiBase {
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final String damage = sa.getParam("NumDmg");
|
||||
int dmg = AbilityUtils.calculateAmount(source, damage, sa);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.TargetRestrictions;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
|
||||
public class DamageEachAi extends DamageAiBase {
|
||||
|
||||
@@ -21,7 +21,7 @@ public class DamageEachAi extends DamageAiBase {
|
||||
}
|
||||
|
||||
final String damage = sa.getParam("NumDmg");
|
||||
final int iDmg = AbilityUtils.calculateAmount(sa.getSourceCard(), damage, sa);
|
||||
final int iDmg = AbilityUtils.calculateAmount(sa.getHostCard(), damage, sa);
|
||||
return this.shouldTgtP(ai, sa, iDmg, false);
|
||||
}
|
||||
|
||||
@@ -1,33 +1,30 @@
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CardPredicates;
|
||||
import forge.ITargetable;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.TargetRestrictions;
|
||||
import forge.ai.*;
|
||||
import forge.game.Game;
|
||||
import forge.game.ai.ComputerUtil;
|
||||
import forge.game.ai.ComputerUtilCard;
|
||||
import forge.game.ai.ComputerUtilCombat;
|
||||
import forge.game.ai.ComputerUtilCost;
|
||||
import forge.game.GameObject;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.card.CardPredicates;
|
||||
import forge.game.combat.Combat;
|
||||
import forge.game.cost.Cost;
|
||||
import forge.game.phase.PhaseHandler;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetChoices;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DamagePreventAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Card hostCard = sa.getSourceCard();
|
||||
final Card hostCard = sa.getHostCard();
|
||||
final Game game = ai.getGame();
|
||||
final Combat combat = game.getCombat();
|
||||
boolean chance = false;
|
||||
@@ -55,11 +52,11 @@ public class DamagePreventAi extends SpellAbilityAi {
|
||||
if (tgt == null) {
|
||||
// As far as I can tell these Defined Cards will only have one of
|
||||
// them
|
||||
final List<ITargetable> objects = AbilityUtils.getDefinedObjects(sa.getSourceCard(), sa.getParam("Defined"), sa);
|
||||
final List<GameObject> objects = AbilityUtils.getDefinedObjects(sa.getHostCard(), sa.getParam("Defined"), sa);
|
||||
|
||||
// react to threats on the stack
|
||||
if (!game.getStack().isEmpty()) {
|
||||
final List<ITargetable> threatenedObjects = ComputerUtil.predictThreatenedObjects(sa.getActivatingPlayer(), sa);
|
||||
final List<GameObject> threatenedObjects = ComputerUtil.predictThreatenedObjects(sa.getActivatingPlayer(), sa);
|
||||
for (final Object o : objects) {
|
||||
if (threatenedObjects.contains(o)) {
|
||||
chance = true;
|
||||
@@ -93,11 +90,12 @@ public class DamagePreventAi extends SpellAbilityAi {
|
||||
// react to threats on the stack
|
||||
else if (!game.getStack().isEmpty()) {
|
||||
sa.resetTargets();
|
||||
final TargetChoices tcs = sa.getTargets();
|
||||
// check stack for something on the stack will kill anything i control
|
||||
final List<ITargetable> objects = ComputerUtil.predictThreatenedObjects(sa.getActivatingPlayer(), sa);
|
||||
final List<GameObject> objects = ComputerUtil.predictThreatenedObjects(sa.getActivatingPlayer(), sa);
|
||||
|
||||
if (objects.contains(ai)) {
|
||||
sa.getTargets().add(ai);
|
||||
tcs.add(ai);
|
||||
chance = true;
|
||||
}
|
||||
final List<Card> threatenedTargets = new ArrayList<Card>();
|
||||
@@ -113,17 +111,18 @@ public class DamagePreventAi extends SpellAbilityAi {
|
||||
|
||||
if (!threatenedTargets.isEmpty()) {
|
||||
// Choose "best" of the remaining to save
|
||||
sa.getTargets().add(ComputerUtilCard.getBestCreatureAI(threatenedTargets));
|
||||
tcs.add(ComputerUtilCard.getBestCreatureAI(threatenedTargets));
|
||||
chance = true;
|
||||
}
|
||||
|
||||
} // Protect combatants
|
||||
else if (game.getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS)) {
|
||||
sa.resetTargets();
|
||||
final TargetChoices tcs = sa.getTargets();
|
||||
if (sa.canTarget(ai) && ComputerUtilCombat.wouldLoseLife(ai, combat)
|
||||
&& (ComputerUtilCombat.lifeInDanger(ai, combat) || sa.isAbility() || sa.isTrigger())
|
||||
&& game.getPhaseHandler().getPlayerTurn().isOpponentOf(ai)) {
|
||||
sa.getTargets().add(ai);
|
||||
tcs.add(ai);
|
||||
chance = true;
|
||||
} else {
|
||||
// filter AIs battlefield by what I can target
|
||||
@@ -135,18 +134,18 @@ public class DamagePreventAi extends SpellAbilityAi {
|
||||
return false;
|
||||
}
|
||||
final List<Card> combatants = CardLists.filter(targetables, CardPredicates.Presets.CREATURES);
|
||||
CardLists.sortByEvaluateCreature(combatants);
|
||||
ComputerUtilCard.sortByEvaluateCreature(combatants);
|
||||
|
||||
for (final Card c : combatants) {
|
||||
if (ComputerUtilCombat.combatantWouldBeDestroyed(ai, c, combat)) {
|
||||
sa.getTargets().add(c);
|
||||
if (ComputerUtilCombat.combatantWouldBeDestroyed(ai, c, combat) && tcs.getNumTargeted() < tgt.getMaxTargets(hostCard, sa)) {
|
||||
tcs.add(c);
|
||||
chance = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sa.hasParam("DividedAsYouChoose") && sa.getTargets() != null && !sa.getTargets().getTargets().isEmpty()) {
|
||||
tgt.addDividedAllocation(sa.getTargets().getTargets().get(0), AbilityUtils.calculateAmount(sa.getSourceCard(), sa.getParam("Amount"), sa));
|
||||
tgt.addDividedAllocation(sa.getTargets().getTargets().get(0), AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("Amount"), sa));
|
||||
}
|
||||
|
||||
return chance;
|
||||
@@ -172,9 +171,9 @@ public class DamagePreventAi extends SpellAbilityAi {
|
||||
* </p>
|
||||
*
|
||||
* @param af
|
||||
* a {@link forge.card.ability.AbilityFactory} object.
|
||||
* a {@link forge.game.ability.AbilityFactory} object.
|
||||
* @param sa
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
* @param mandatory
|
||||
* a boolean.
|
||||
* @return a boolean.
|
||||
@@ -185,7 +184,7 @@ public class DamagePreventAi extends SpellAbilityAi {
|
||||
// filter AIs battlefield by what I can target
|
||||
final Game game = ai.getGame();
|
||||
List<Card> targetables = game.getCardsIn(ZoneType.Battlefield);
|
||||
targetables = CardLists.getValidCards(targetables, tgt.getValidTgts(), ai, sa.getSourceCard());
|
||||
targetables = CardLists.getValidCards(targetables, tgt.getValidTgts(), ai, sa.getHostCard());
|
||||
final List<Card> compTargetables = CardLists.filterControlledBy(targetables, ai);
|
||||
Card target = null;
|
||||
|
||||
@@ -199,7 +198,7 @@ public class DamagePreventAi extends SpellAbilityAi {
|
||||
|
||||
if (!compTargetables.isEmpty()) {
|
||||
final List<Card> combatants = CardLists.filter(compTargetables, CardPredicates.Presets.CREATURES);
|
||||
CardLists.sortByEvaluateCreature(combatants);
|
||||
ComputerUtilCard.sortByEvaluateCreature(combatants);
|
||||
if (game.getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS)) {
|
||||
Combat combat = game.getCombat();
|
||||
for (final Card c : combatants) {
|
||||
@@ -217,7 +216,7 @@ public class DamagePreventAi extends SpellAbilityAi {
|
||||
}
|
||||
sa.getTargets().add(target);
|
||||
if (sa.hasParam("DividedAsYouChoose")) {
|
||||
tgt.addDividedAllocation(target, AbilityUtils.calculateAmount(sa.getSourceCard(), sa.getParam("Amount"), sa));
|
||||
tgt.addDividedAllocation(target, AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("Amount"), sa));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
|
||||
import forge.Card;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.ai.ComputerUtilCost;
|
||||
import forge.ai.ComputerUtilCost;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.cost.Cost;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
|
||||
public class DamagePreventAllAi extends SpellAbilityAi {
|
||||
|
||||
@@ -16,7 +16,7 @@ public class DamagePreventAllAi extends SpellAbilityAi {
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Card hostCard = sa.getSourceCard();
|
||||
final Card hostCard = sa.getHostCard();
|
||||
boolean chance = false;
|
||||
|
||||
final Cost cost = sa.getPayCosts();
|
||||
@@ -1,30 +1,29 @@
|
||||
package forge.card.ability.ai;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
package forge.ai.ability;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.SpellAbilityRestriction;
|
||||
import forge.card.spellability.TargetRestrictions;
|
||||
import forge.ai.ComputerUtilCard;
|
||||
import forge.ai.ComputerUtilCost;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.Game;
|
||||
import forge.game.ai.ComputerUtilCard;
|
||||
import forge.game.ai.ComputerUtilCost;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.combat.Combat;
|
||||
import forge.game.cost.Cost;
|
||||
import forge.game.phase.PhaseHandler;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.SpellAbilityRestriction;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class DebuffAi extends SpellAbilityAi {
|
||||
// *************************************************************************
|
||||
// ***************************** Debuff ************************************
|
||||
@@ -33,7 +32,7 @@ public class DebuffAi extends SpellAbilityAi {
|
||||
@Override
|
||||
protected boolean canPlayAI(final Player ai, final SpellAbility sa) {
|
||||
// if there is no target and host card isn't in play, don't activate
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final Game game = ai.getGame();
|
||||
if ((sa.getTargetRestrictions() == null) && !source.isInPlay()) {
|
||||
return false;
|
||||
@@ -76,7 +75,7 @@ public class DebuffAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
if (!sa.usesTargeting() || !sa.getTargetRestrictions().doesTarget()) {
|
||||
List<Card> cards = AbilityUtils.getDefinedCards(sa.getSourceCard(), sa.getParam("Defined"), sa);
|
||||
List<Card> cards = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("Defined"), sa);
|
||||
|
||||
|
||||
final Combat combat = game.getCombat();
|
||||
@@ -117,9 +116,9 @@ public class DebuffAi extends SpellAbilityAi {
|
||||
* </p>
|
||||
*
|
||||
* @param af
|
||||
* a {@link forge.card.ability.AbilityFactory} object.
|
||||
* a {@link forge.game.ability.AbilityFactory} object.
|
||||
* @param sa
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
* @param kws
|
||||
* a {@link java.util.ArrayList} object.
|
||||
* @param mandatory
|
||||
@@ -135,7 +134,7 @@ public class DebuffAi extends SpellAbilityAi {
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
sa.resetTargets();
|
||||
List<Card> list = getCurseCreatures(ai, sa, kws == null ? Lists.<String>newArrayList() : kws);
|
||||
list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard());
|
||||
list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getHostCard());
|
||||
|
||||
// several uses here:
|
||||
// 1. make human creatures lose evasion when they are attacking
|
||||
@@ -148,12 +147,12 @@ public class DebuffAi extends SpellAbilityAi {
|
||||
return mandatory && debuffMandatoryTarget(ai, sa, mandatory);
|
||||
}
|
||||
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(sa.getSourceCard(), sa)) {
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(sa.getHostCard(), sa)) {
|
||||
Card t = null;
|
||||
// boolean goodt = false;
|
||||
|
||||
if (list.isEmpty()) {
|
||||
if ((sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getSourceCard(), sa)) || (sa.getTargets().getNumTargeted() == 0)) {
|
||||
if ((sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa)) || (sa.getTargets().getNumTargeted() == 0)) {
|
||||
if (mandatory) {
|
||||
return debuffMandatoryTarget(ai, sa, mandatory);
|
||||
}
|
||||
@@ -180,9 +179,9 @@ public class DebuffAi extends SpellAbilityAi {
|
||||
* </p>
|
||||
*
|
||||
* @param af
|
||||
* a {@link forge.card.ability.AbilityFactory} object.
|
||||
* a {@link forge.game.ability.AbilityFactory} object.
|
||||
* @param sa
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
* @param kws
|
||||
* a {@link java.util.ArrayList} object.
|
||||
* @return a {@link forge.CardList} object.
|
||||
@@ -211,9 +210,9 @@ public class DebuffAi extends SpellAbilityAi {
|
||||
* </p>
|
||||
*
|
||||
* @param af
|
||||
* a {@link forge.card.ability.AbilityFactory} object.
|
||||
* a {@link forge.game.ability.AbilityFactory} object.
|
||||
* @param sa
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
* @param mandatory
|
||||
* a boolean.
|
||||
* @return a boolean.
|
||||
@@ -221,9 +220,9 @@ public class DebuffAi extends SpellAbilityAi {
|
||||
private boolean debuffMandatoryTarget(final Player ai, final SpellAbility sa, final boolean mandatory) {
|
||||
List<Card> list = ai.getGame().getCardsIn(ZoneType.Battlefield);
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard());
|
||||
list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getHostCard());
|
||||
|
||||
if (list.size() < tgt.getMinTargets(sa.getSourceCard(), sa)) {
|
||||
if (list.size() < tgt.getMinTargets(sa.getHostCard(), sa)) {
|
||||
sa.resetTargets();
|
||||
return false;
|
||||
}
|
||||
@@ -235,7 +234,7 @@ public class DebuffAi extends SpellAbilityAi {
|
||||
|
||||
final List<Card> pref = CardLists.filterControlledBy(list, ai.getOpponent());
|
||||
final List<Card> forced = CardLists.filterControlledBy(list, ai);
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(source, sa)) {
|
||||
if (pref.isEmpty()) {
|
||||
@@ -254,7 +253,7 @@ public class DebuffAi extends SpellAbilityAi {
|
||||
sa.getTargets().add(c);
|
||||
}
|
||||
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getSourceCard(), sa)) {
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa)) {
|
||||
if (forced.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
@@ -273,7 +272,7 @@ public class DebuffAi extends SpellAbilityAi {
|
||||
sa.getTargets().add(c);
|
||||
}
|
||||
|
||||
if (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getSourceCard(), sa)) {
|
||||
if (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa)) {
|
||||
sa.resetTargets();
|
||||
return false;
|
||||
}
|
||||
@@ -1,27 +1,26 @@
|
||||
package forge.card.ability.ai;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
package forge.ai.ability;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.combat.CombatUtil;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class DebuffAllAi extends SpellAbilityAi {
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
String valid = "";
|
||||
final Random r = MyRandom.getRandom();
|
||||
// final Card source = sa.getSourceCard();
|
||||
final Card hostCard = sa.getSourceCard();
|
||||
// final Card source = sa.getHostCard();
|
||||
final Card hostCard = sa.getHostCard();
|
||||
final Player opp = ai.getOpponent();
|
||||
|
||||
final boolean chance = r.nextFloat() <= Math.pow(.6667, sa.getActivationsThisTurn()); // to
|
||||
@@ -0,0 +1,50 @@
|
||||
package forge.ai.ability;
|
||||
|
||||
import forge.ai.AiController;
|
||||
import forge.ai.AiPlayDecision;
|
||||
import forge.ai.PlayerControllerAi;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.ai.SpellApiToAi;
|
||||
import forge.game.ability.AbilityFactory;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.AbilitySub;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
|
||||
public class DelayedTriggerAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player ai) {
|
||||
final String svarName = sa.getParam("Execute");
|
||||
final SpellAbility trigsa = AbilityFactory.getAbility(sa.getHostCard().getSVar(svarName), sa.getHostCard());
|
||||
trigsa.setActivatingPlayer(ai);
|
||||
|
||||
if (trigsa instanceof AbilitySub) {
|
||||
return SpellApiToAi.Converter.get(((AbilitySub) trigsa).getApi()).chkDrawbackWithSubs(ai, (AbilitySub)trigsa);
|
||||
} else {
|
||||
return AiPlayDecision.WillPlay == ((PlayerControllerAi)ai.getController()).getAi().canPlaySa(trigsa);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
final String svarName = sa.getParam("Execute");
|
||||
final SpellAbility trigsa = AbilityFactory.getAbility(sa.getHostCard().getSVar(svarName), sa.getHostCard());
|
||||
AiController aic = ((PlayerControllerAi)ai.getController()).getAi();
|
||||
trigsa.setActivatingPlayer(ai);
|
||||
|
||||
if (!sa.hasParam("OptionalDecider")) {
|
||||
return aic.doTrigger(trigsa, true);
|
||||
} else {
|
||||
return aic.doTrigger(trigsa, !sa.getParam("OptionalDecider").equals("You"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final String svarName = sa.getParam("Execute");
|
||||
final SpellAbility trigsa = AbilityFactory.getAbility(sa.getHostCard().getSVar(svarName), sa.getHostCard());
|
||||
trigsa.setActivatingPlayer(ai);
|
||||
return AiPlayDecision.WillPlay == ((PlayerControllerAi)ai.getController()).getAi().canPlaySa(trigsa);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,28 +1,27 @@
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import forge.ai.ComputerUtil;
|
||||
import forge.ai.ComputerUtilCard;
|
||||
import forge.ai.ComputerUtilCost;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.card.CounterType;
|
||||
import forge.game.cost.Cost;
|
||||
import forge.game.cost.CostPart;
|
||||
import forge.game.cost.CostSacrifice;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CounterType;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.cost.CostPart;
|
||||
import forge.card.cost.CostSacrifice;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.TargetRestrictions;
|
||||
import forge.game.ai.ComputerUtil;
|
||||
import forge.game.ai.ComputerUtilCard;
|
||||
import forge.game.ai.ComputerUtilCost;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
public class DestroyAi extends SpellAbilityAi {
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -42,7 +41,7 @@ public class DestroyAi extends SpellAbilityAi {
|
||||
final Random r = MyRandom.getRandom();
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final TargetRestrictions abTgt = sa.getTargetRestrictions();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final boolean noRegen = sa.hasParam("NoRegen");
|
||||
List<Card> list;
|
||||
|
||||
@@ -104,7 +103,7 @@ public class DestroyAi extends SpellAbilityAi {
|
||||
list = CardLists.filter(list, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return ((c.getShield() == 0) && !ComputerUtil.canRegenerate(ai, c));
|
||||
return (c.getShield().isEmpty() && !ComputerUtil.canRegenerate(ai, c));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -113,9 +112,9 @@ public class DestroyAi extends SpellAbilityAi {
|
||||
return false;
|
||||
}
|
||||
// target loop
|
||||
while (sa.getTargets().getNumTargeted() < abTgt.getMaxTargets(sa.getSourceCard(), sa)) {
|
||||
while (sa.getTargets().getNumTargeted() < abTgt.getMaxTargets(sa.getHostCard(), sa)) {
|
||||
if (list.size() == 0) {
|
||||
if ((sa.getTargets().getNumTargeted() < abTgt.getMinTargets(sa.getSourceCard(), sa))
|
||||
if ((sa.getTargets().getNumTargeted() < abTgt.getMinTargets(sa.getHostCard(), sa))
|
||||
|| (sa.getTargets().getNumTargeted() == 0)) {
|
||||
sa.resetTargets();
|
||||
return false;
|
||||
@@ -136,7 +135,7 @@ public class DestroyAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
if (choice == null) { // can't find anything left
|
||||
if ((sa.getTargets().getNumTargeted() < abTgt.getMinTargets(sa.getSourceCard(), sa))
|
||||
if ((sa.getTargets().getNumTargeted() < abTgt.getMinTargets(sa.getHostCard(), sa))
|
||||
|| (sa.getTargets().getNumTargeted() == 0)) {
|
||||
sa.resetTargets();
|
||||
return false;
|
||||
@@ -176,7 +175,7 @@ public class DestroyAi extends SpellAbilityAi {
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final boolean noRegen = sa.hasParam("NoRegen");
|
||||
if (tgt != null) {
|
||||
List<Card> list;
|
||||
@@ -184,7 +183,7 @@ public class DestroyAi extends SpellAbilityAi {
|
||||
list = CardLists.getTargetableCards(list, sa);
|
||||
list = CardLists.getValidCards(list, tgt.getValidTgts(), source.getController(), source);
|
||||
|
||||
if (list.isEmpty() || list.size() < tgt.getMinTargets(sa.getSourceCard(), sa)) {
|
||||
if (list.isEmpty() || list.size() < tgt.getMinTargets(sa.getHostCard(), sa)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -201,7 +200,7 @@ public class DestroyAi extends SpellAbilityAi {
|
||||
preferred = CardLists.filter(preferred, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return c.getShield() == 0;
|
||||
return c.getShield().isEmpty();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -210,10 +209,10 @@ public class DestroyAi extends SpellAbilityAi {
|
||||
list.remove(c);
|
||||
}
|
||||
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(sa.getSourceCard(), sa)) {
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(sa.getHostCard(), sa)) {
|
||||
if (preferred.isEmpty()) {
|
||||
if ((sa.getTargets().getNumTargeted() == 0)
|
||||
|| (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getSourceCard(), sa))) {
|
||||
|| (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa))) {
|
||||
if (!mandatory) {
|
||||
sa.resetTargets();
|
||||
return false;
|
||||
@@ -237,7 +236,7 @@ public class DestroyAi extends SpellAbilityAi {
|
||||
}
|
||||
}
|
||||
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getSourceCard(), sa)) {
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa)) {
|
||||
if (list.isEmpty()) {
|
||||
break;
|
||||
} else {
|
||||
@@ -252,7 +251,7 @@ public class DestroyAi extends SpellAbilityAi {
|
||||
}
|
||||
}
|
||||
|
||||
if (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getSourceCard(), sa)) {
|
||||
if (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
@@ -1,21 +1,20 @@
|
||||
package forge.card.ability.ai;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
package forge.ai.ability;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.ai.ComputerUtilCard;
|
||||
import forge.game.ai.ComputerUtilCost;
|
||||
import forge.game.ai.ComputerUtilMana;
|
||||
import forge.ai.ComputerUtil;
|
||||
import forge.ai.ComputerUtilCard;
|
||||
import forge.ai.ComputerUtilCost;
|
||||
import forge.ai.ComputerUtilMana;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.cost.Cost;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DestroyAllAi extends SpellAbilityAi {
|
||||
|
||||
@@ -31,7 +30,7 @@ public class DestroyAllAi extends SpellAbilityAi {
|
||||
*/
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
String valid = "";
|
||||
if (mandatory) {
|
||||
return true;
|
||||
@@ -79,9 +78,8 @@ public class DestroyAllAi extends SpellAbilityAi {
|
||||
protected boolean canPlayAI(final Player ai, SpellAbility sa) {
|
||||
// AI needs to be expanded, since this function can be pretty complex
|
||||
// based on what the expected targets could be
|
||||
final Random r = MyRandom.getRandom();
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
String valid = "";
|
||||
|
||||
if (sa.hasParam("ValidCards")) {
|
||||
@@ -115,29 +113,31 @@ public class DestroyAllAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
// prevent run-away activations - first time will always return true
|
||||
boolean chance = r.nextFloat() <= Math.pow(.6667, sa.getActivationsThisTurn());
|
||||
if (ComputerUtil.preventRunAwayActivations(sa)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// if only creatures are affected evaluate both lists and pass only if
|
||||
// human creatures are more valuable
|
||||
if ((CardLists.getNotType(humanlist, "Creature").size() == 0) && (CardLists.getNotType(computerlist, "Creature").size() == 0)) {
|
||||
if ((ComputerUtilCard.evaluateCreatureList(computerlist) + 200) >= ComputerUtilCard
|
||||
.evaluateCreatureList(humanlist)) {
|
||||
if (CardLists.getNotType(humanlist, "Creature").isEmpty() && CardLists.getNotType(computerlist, "Creature").isEmpty()) {
|
||||
if (ComputerUtilCard.evaluateCreatureList(computerlist) + 200 >= ComputerUtilCard.evaluateCreatureList(humanlist)) {
|
||||
return false;
|
||||
}
|
||||
} // only lands involved
|
||||
else if ((CardLists.getNotType(humanlist, "Land").size() == 0) && (CardLists.getNotType(computerlist, "Land").size() == 0)) {
|
||||
if ((ComputerUtilCard.evaluatePermanentList(computerlist) + 1) >= ComputerUtilCard
|
||||
.evaluatePermanentList(humanlist)) {
|
||||
else if (CardLists.getNotType(humanlist, "Land").isEmpty() && CardLists.getNotType(computerlist, "Land").isEmpty()) {
|
||||
if (ai.isCardInPlay("Crucible of Worlds") && !ai.getOpponent().isCardInPlay("Crucible of Worlds") && !humanlist.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
if (ComputerUtilCard.evaluatePermanentList(computerlist) + 1 >= ComputerUtilCard.evaluatePermanentList(humanlist)) {
|
||||
return false;
|
||||
}
|
||||
} // otherwise evaluate both lists by CMC and pass only if human
|
||||
// permanents are more valuable
|
||||
} // otherwise evaluate both lists by CMC and pass only if human permanents are more valuable
|
||||
else if ((ComputerUtilCard.evaluatePermanentList(computerlist) + 3) >= ComputerUtilCard
|
||||
.evaluatePermanentList(humanlist)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return chance;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,18 +1,20 @@
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import forge.Card;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.ai.ComputerUtil;
|
||||
import forge.ai.ComputerUtil;
|
||||
import forge.ai.ComputerUtilCard;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.PlayerActionConfirmMode;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Random;
|
||||
|
||||
|
||||
public class DigAi extends SpellAbilityAi {
|
||||
/* (non-Javadoc)
|
||||
@@ -22,7 +24,7 @@ public class DigAi extends SpellAbilityAi {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
|
||||
Player opp = ai.getOpponent();
|
||||
final Card host = sa.getSourceCard();
|
||||
final Card host = sa.getHostCard();
|
||||
Player libraryOwner = ai;
|
||||
|
||||
if (sa.usesTargeting()) {
|
||||
@@ -78,6 +80,15 @@ public class DigAi extends SpellAbilityAi {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Card chooseSingleCard(Player ai, SpellAbility sa, Collection<Card> valid, boolean isOptional, Player relatedPlayer) {
|
||||
Card chosen = ComputerUtilCard.getBestAI(valid);
|
||||
if (sa.getActivatingPlayer().isOpponentOf(ai) && relatedPlayer.isOpponentOf(ai)) {
|
||||
return ComputerUtilCard.getWorstAI(valid);
|
||||
}
|
||||
return chosen;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.card.ability.SpellAbilityAi#confirmAction(forge.card.spellability.SpellAbility, forge.game.player.PlayerActionConfirmMode, java.lang.String)
|
||||
@@ -1,25 +1,25 @@
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
import forge.ai.ComputerUtilMana;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.card.CardPredicates;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.PlayerActionConfirmMode;
|
||||
import forge.game.spellability.AbilitySub;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CardPredicates;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.AbilitySub;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.ai.ComputerUtilMana;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.PlayerActionConfirmMode;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
public class DigUntilAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
Card source = sa.getSourceCard();
|
||||
Card source = sa.getHostCard();
|
||||
double chance = .4; // 40 percent chance with instant speed stuff
|
||||
if (SpellAbilityAi.isSorcerySpeed(sa)) {
|
||||
chance = .667; // 66.7% chance for sorcery speed (since it will
|
||||
@@ -1,29 +1,29 @@
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import forge.Card;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.TargetRestrictions;
|
||||
import forge.game.ai.ComputerUtil;
|
||||
import forge.game.ai.ComputerUtilCost;
|
||||
import forge.game.ai.ComputerUtilMana;
|
||||
import forge.ai.ComputerUtil;
|
||||
import forge.ai.ComputerUtilCost;
|
||||
import forge.ai.ComputerUtilMana;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.cost.Cost;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.PlayerActionConfirmMode;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class DiscardAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
|
||||
if (abCost != null) {
|
||||
@@ -54,7 +54,7 @@ public class DiscardAi extends SpellAbilityAi {
|
||||
}
|
||||
} else {
|
||||
// TODO: Add appropriate restrictions
|
||||
final List<Player> players = AbilityUtils.getDefinedPlayers(sa.getSourceCard(),
|
||||
final List<Player> players = AbilityUtils.getDefinedPlayers(sa.getHostCard(),
|
||||
sa.getParam("Defined"), sa);
|
||||
|
||||
if (players.size() == 1) {
|
||||
@@ -85,7 +85,7 @@ public class DiscardAi extends SpellAbilityAi {
|
||||
}
|
||||
source.setSVar("PayX", Integer.toString(cardsToDiscard));
|
||||
} else {
|
||||
if (AbilityUtils.calculateAmount(sa.getSourceCard(), sa.getParam("NumCards"), sa) < 1) {
|
||||
if (AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("NumCards"), sa) < 1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -115,7 +115,7 @@ public class DiscardAi extends SpellAbilityAi {
|
||||
private boolean discardTargetAI(final Player ai, final SpellAbility sa) {
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
Player opp = ai.getOpponent();
|
||||
if (opp.getCardsIn(ZoneType.Hand).isEmpty()) {
|
||||
if (opp.getCardsIn(ZoneType.Hand).isEmpty() && !ComputerUtil.activateForCost(sa, ai)) {
|
||||
return false;
|
||||
}
|
||||
if (tgt != null) {
|
||||
@@ -144,11 +144,11 @@ public class DiscardAi extends SpellAbilityAi {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ("X".equals(sa.getParam("RevealNumber")) && sa.getSourceCard().getSVar("X").equals("Count$xPaid")) {
|
||||
if ("X".equals(sa.getParam("RevealNumber")) && sa.getHostCard().getSVar("X").equals("Count$xPaid")) {
|
||||
// Set PayX here to maximum value.
|
||||
final int cardsToDiscard = Math.min(ComputerUtilMana.determineLeftoverMana(sa, ai), ai.getOpponent()
|
||||
.getCardsIn(ZoneType.Hand).size());
|
||||
sa.getSourceCard().setSVar("PayX", Integer.toString(cardsToDiscard));
|
||||
sa.getHostCard().setSVar("PayX", Integer.toString(cardsToDiscard));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import forge.Card;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.TargetRestrictions;
|
||||
import forge.game.player.Player;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
public class DrainManaAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
@@ -18,7 +18,7 @@ public class DrainManaAi extends SpellAbilityAi {
|
||||
// AI cannot use this properly until he can use SAs during Humans turn
|
||||
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final Player opp = ai.getOpponent();
|
||||
final Random r = MyRandom.getRandom();
|
||||
boolean randomReturn = r.nextFloat() <= Math.pow(.6667, sa.getActivationsThisTurn());
|
||||
@@ -45,7 +45,7 @@ public class DrainManaAi extends SpellAbilityAi {
|
||||
final Player opp = ai.getOpponent();
|
||||
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
if (null == tgt) {
|
||||
if (mandatory) {
|
||||
@@ -71,7 +71,7 @@ public class DrainManaAi extends SpellAbilityAi {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player ai) {
|
||||
// AI cannot use this properly until he can use SAs during Humans turn
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
boolean randomReturn = true;
|
||||
|
||||
@@ -16,25 +16,22 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
import forge.Card;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.cost.CostDiscard;
|
||||
import forge.card.cost.CostPart;
|
||||
import forge.card.cost.PaymentDecision;
|
||||
import forge.card.spellability.AbilitySub;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.TargetRestrictions;
|
||||
import forge.ai.*;
|
||||
import forge.game.Game;
|
||||
import forge.game.ai.ComputerUtil;
|
||||
import forge.game.ai.ComputerUtilCost;
|
||||
import forge.game.ai.ComputerUtilMana;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.cost.Cost;
|
||||
import forge.game.cost.CostDiscard;
|
||||
import forge.game.cost.CostPart;
|
||||
import forge.game.cost.PaymentDecision;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.PlayerActionConfirmMode;
|
||||
import forge.game.spellability.AbilitySub;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
public class DrawAi extends SpellAbilityAi {
|
||||
@@ -50,7 +47,7 @@ public class DrawAi extends SpellAbilityAi {
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Game game = ai.getGame();
|
||||
|
||||
@@ -65,10 +62,10 @@ public class DrawAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
if (!ComputerUtilCost.checkDiscardCost(ai, abCost, source)) {
|
||||
AiCostDecision aiDecisions = new AiCostDecision(ai, sa);
|
||||
for (final CostPart part : abCost.getCostParts()) {
|
||||
if (part instanceof CostDiscard) {
|
||||
CostDiscard cd = (CostDiscard) part;
|
||||
PaymentDecision decision = cd.decideAIPayment(ai, sa, sa.getSourceCard());
|
||||
PaymentDecision decision = part.accept(aiDecisions);
|
||||
if ( null == decision )
|
||||
return false;
|
||||
for (Card discard : decision.cards) {
|
||||
@@ -106,6 +103,10 @@ public class DrawAi extends SpellAbilityAi {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sa.getConditions() != null && !sa.getConditions().areMet(sa) && sa.getSubAbility() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Don't use draw abilities before main 2 if possible
|
||||
if (game.getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)
|
||||
&& !sa.hasParam("ActivationPhases") && !ComputerUtil.castSpellInMain1(ai, sa)) {
|
||||
@@ -129,7 +130,7 @@ public class DrawAi extends SpellAbilityAi {
|
||||
|
||||
private boolean targetAI(final Player ai, final SpellAbility sa, final boolean mandatory) {
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final boolean drawback = (sa instanceof AbilitySub);
|
||||
final Game game = ai.getGame();
|
||||
Player opp = ai.getOpponent();
|
||||
@@ -146,7 +147,7 @@ public class DrawAi extends SpellAbilityAi {
|
||||
|
||||
int numCards = 1;
|
||||
if (sa.hasParam("NumCards")) {
|
||||
numCards = AbilityUtils.calculateAmount(sa.getSourceCard(), sa.getParam("NumCards"), sa);
|
||||
numCards = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("NumCards"), sa);
|
||||
}
|
||||
|
||||
boolean xPaid = false;
|
||||
@@ -164,8 +165,7 @@ public class DrawAi extends SpellAbilityAi {
|
||||
//if (n)
|
||||
|
||||
// TODO: if xPaid and one of the below reasons would fail, instead of
|
||||
// bailing
|
||||
// reduce toPay amount to acceptable level
|
||||
// bailing reduce toPay amount to acceptable level
|
||||
|
||||
if (tgt != null) {
|
||||
// ability is targeted
|
||||
@@ -264,7 +264,7 @@ public class DrawAi extends SpellAbilityAi {
|
||||
*/
|
||||
@Override
|
||||
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) {
|
||||
int numCards = sa.hasParam("NumCards") ? AbilityUtils.calculateAmount(sa.getSourceCard(), sa.getParam("NumCards"), sa) : 1;
|
||||
int numCards = sa.hasParam("NumCards") ? AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("NumCards"), sa) : 1;
|
||||
// AI shouldn't mill itself
|
||||
return numCards < player.getZone(ZoneType.Library).size();
|
||||
}
|
||||
@@ -1,28 +1,27 @@
|
||||
package forge.card.ability.ai;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
package forge.ai.ability;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.card.ability.ApiType;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.SpellAbilityStackInstance;
|
||||
import forge.card.spellability.TargetRestrictions;
|
||||
import forge.ai.ComputerUtilCard;
|
||||
import forge.ai.ComputerUtilCombat;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.Game;
|
||||
import forge.game.ai.ComputerUtilCard;
|
||||
import forge.game.ai.ComputerUtilCombat;
|
||||
import forge.game.ability.ApiType;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.combat.CombatUtil;
|
||||
import forge.game.phase.PhaseHandler;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.SpellAbilityStackInstance;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class EffectAi extends SpellAbilityAi {
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
@@ -65,7 +64,7 @@ public class EffectAi extends SpellAbilityAi {
|
||||
if (tgt != null) {
|
||||
sa.resetTargets();
|
||||
List<Card> list = game.getCombat().getAttackers();
|
||||
list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard());
|
||||
list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getHostCard());
|
||||
list = CardLists.getTargetableCards(list, sa);
|
||||
Card target = ComputerUtilCard.getBestCreatureAI(list);
|
||||
if (target == null) {
|
||||
@@ -124,7 +123,7 @@ public class EffectAi extends SpellAbilityAi {
|
||||
if ("False".equals(sa.getParam("Stackable"))) {
|
||||
String name = sa.getParam("Name");
|
||||
if (name == null) {
|
||||
name = sa.getSourceCard().getName() + "'s Effect";
|
||||
name = sa.getHostCard().getName() + "'s Effect";
|
||||
}
|
||||
final List<Card> list = sa.getActivatingPlayer().getCardsIn(ZoneType.Command, name);
|
||||
if (!list.isEmpty()) {
|
||||
@@ -15,21 +15,20 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package forge.card.ability.ai;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
package forge.ai.ability;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.ai.ComputerUtilCard;
|
||||
import forge.ai.ComputerUtilCard;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.combat.CombatUtil;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.PlayerActionConfirmMode;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -45,9 +44,9 @@ public final class EncodeAi extends SpellAbilityAi {
|
||||
* bondCanPlayAI.
|
||||
* </p>
|
||||
* @param sa
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
* @param af
|
||||
* a {@link forge.card.ability.AbilityFactory} object.
|
||||
* a {@link forge.game.ability.AbilityFactory} object.
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
@@ -72,7 +71,7 @@ public final class EncodeAi extends SpellAbilityAi {
|
||||
* @see forge.card.ability.SpellAbilityAi#chooseSingleCard(forge.game.player.Player, forge.card.spellability.SpellAbility, java.util.List, boolean)
|
||||
*/
|
||||
@Override
|
||||
public Card chooseSingleCard(final Player ai, SpellAbility sa, Collection<Card> options, boolean isOptional) {
|
||||
public Card chooseSingleCard(final Player ai, SpellAbility sa, Collection<Card> options, boolean isOptional, Player targetedPlayer) {
|
||||
Card choice = null;
|
||||
// final String logic = sa.getParam("AILogic");
|
||||
// if (logic == null) {
|
||||
@@ -1,9 +1,9 @@
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this type.
|
||||
@@ -1,19 +1,19 @@
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
import forge.ai.ComputerUtil;
|
||||
import forge.ai.ComputerUtilCard;
|
||||
import forge.ai.ComputerUtilCombat;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.ai.ComputerUtil;
|
||||
import forge.game.ai.ComputerUtilCard;
|
||||
import forge.game.ai.ComputerUtilCombat;
|
||||
import forge.game.player.Player;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
public class FightAi extends SpellAbilityAi {
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -22,7 +22,7 @@ public class FightAi extends SpellAbilityAi {
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
sa.resetTargets();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
List<Card> aiCreatures = ai.getCreaturesInPlay();
|
||||
aiCreatures = CardLists.getTargetableCards(aiCreatures, sa);
|
||||
@@ -107,7 +107,7 @@ public class FightAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
//try to make a good trade or no trade
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
List<Card> humCreatures = ai.getOpponent().getCreaturesInPlay();
|
||||
humCreatures = CardLists.getTargetableCards(humCreatures, sa);
|
||||
if (humCreatures.isEmpty()) {
|
||||
@@ -1,8 +1,8 @@
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
|
||||
public class FlipACoinAi extends SpellAbilityAi {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.ai.ComputerUtilCombat;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.Game;
|
||||
import forge.game.ai.ComputerUtilCombat;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
|
||||
public class FogAi extends SpellAbilityAi {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.TargetRestrictions;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
|
||||
public class GameLossAi extends SpellAbilityAi {
|
||||
@Override
|
||||
@@ -1,9 +1,9 @@
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
|
||||
public class GameWinAi extends SpellAbilityAi {
|
||||
/* (non-Javadoc)
|
||||
30
forge-ai/src/main/java/forge/ai/ability/HauntAi.java
Normal file
30
forge-ai/src/main/java/forge/ai/ability/HauntAi.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package forge.ai.ability;
|
||||
|
||||
import forge.ai.ComputerUtilCard;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class HauntAi extends SpellAbilityAi {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.card.ability.SpellAbilityAi#canPlayAI(forge.game.player.Player, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
return false; // should not get here
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Card chooseSingleCard(Player ai, SpellAbility sa, Collection<Card> creats, boolean isOptional, Player targetedPlayer) {
|
||||
final List<Card> oppCreats = CardLists.filterControlledBy(creats, ai.getOpponents());
|
||||
return ComputerUtilCard.getWorstCreatureAI(oppCreats.isEmpty() ? creats : oppCreats);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,13 +1,12 @@
|
||||
package forge.card.ability.ai;
|
||||
|
||||
import java.util.Collection;
|
||||
package forge.ai.ability;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import forge.Card;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this type.
|
||||
@@ -25,7 +24,7 @@ public class LegendaryRuleAi extends SpellAbilityAi {
|
||||
|
||||
|
||||
@Override
|
||||
public Card chooseSingleCard(Player ai, SpellAbility sa, Collection<Card> options, boolean isOptional) {
|
||||
public Card chooseSingleCard(Player ai, SpellAbility sa, Collection<Card> options, boolean isOptional, Player targetedPlayer) {
|
||||
// Choose a single legendary/planeswalker card to keep
|
||||
Card firstOption = Iterables.getFirst(options, null);
|
||||
boolean choosingFromPlanewalkers = firstOption.isPlaneswalker();
|
||||
@@ -1,13 +1,13 @@
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.TargetRestrictions;
|
||||
import forge.game.player.Player;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
public class LifeExchangeAi extends SpellAbilityAi {
|
||||
|
||||
/*
|
||||
@@ -1,24 +1,15 @@
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
import forge.Card;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.spellability.AbilitySub;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.TargetRestrictions;
|
||||
import forge.ai.*;
|
||||
import forge.game.Game;
|
||||
import forge.game.ai.ComputerUtil;
|
||||
import forge.game.ai.ComputerUtilCombat;
|
||||
import forge.game.ai.ComputerUtilCost;
|
||||
import forge.game.ai.ComputerUtilMana;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.cost.Cost;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this type.
|
||||
*
|
||||
*/
|
||||
import forge.game.spellability.AbilitySub;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
|
||||
public class LifeGainAi extends SpellAbilityAi {
|
||||
|
||||
@@ -28,27 +19,28 @@ public class LifeGainAi extends SpellAbilityAi {
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final Game game = source.getGame();
|
||||
final int life = ai.getLife();
|
||||
final String amountStr = sa.getParam("LifeAmount");
|
||||
int lifeAmount = 0;
|
||||
boolean activateForCost = ComputerUtil.activateForCost(sa, ai);
|
||||
if (amountStr.equals("X") && source.getSVar(amountStr).equals("Count$xPaid")) {
|
||||
// Set PayX here to maximum value.
|
||||
final int xPay = ComputerUtilMana.determineLeftoverMana(sa, ai);
|
||||
source.setSVar("PayX", Integer.toString(xPay));
|
||||
lifeAmount = xPay;
|
||||
} else {
|
||||
lifeAmount = AbilityUtils.calculateAmount(sa.getSourceCard(), amountStr, sa);
|
||||
lifeAmount = AbilityUtils.calculateAmount(sa.getHostCard(), amountStr, sa);
|
||||
}
|
||||
|
||||
// don't use it if no life to gain
|
||||
if (lifeAmount <= 0) {
|
||||
if (!activateForCost && lifeAmount <= 0) {
|
||||
return false;
|
||||
}
|
||||
// don't play if the conditions aren't met, unless it would trigger a
|
||||
// beneficial sub-condition
|
||||
if (!sa.getConditions().areMet(sa)) {
|
||||
if (!activateForCost && !sa.getConditions().areMet(sa)) {
|
||||
final AbilitySub abSub = sa.getSubAbility();
|
||||
if (abSub != null && !sa.isWrapper() && "True".equals(source.getSVar("AIPlayForSub"))) {
|
||||
if (!abSub.getConditions().areMet(abSub)) {
|
||||
@@ -80,7 +72,7 @@ public class LifeGainAi extends SpellAbilityAi {
|
||||
}
|
||||
}
|
||||
|
||||
if (!ai.canGainLife()) {
|
||||
if (!activateForCost && !ai.canGainLife()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -99,10 +91,9 @@ public class LifeGainAi extends SpellAbilityAi {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!lifeCritical && (!game.getPhaseHandler().getNextTurn().equals(ai)
|
||||
if (!lifeCritical && !activateForCost && (!game.getPhaseHandler().getNextTurn().equals(ai)
|
||||
|| game.getPhaseHandler().getPhase().isBefore(PhaseType.END_OF_TURN))
|
||||
&& !sa.hasParam("PlayerTurn") && !SpellAbilityAi.isSorcerySpeed(sa)
|
||||
&& !ComputerUtil.activateForCost(sa, ai)) {
|
||||
&& !sa.hasParam("PlayerTurn") && !SpellAbilityAi.isSorcerySpeed(sa)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -130,11 +121,11 @@ public class LifeGainAi extends SpellAbilityAi {
|
||||
* gainLifeDoTriggerAINoCost.
|
||||
* </p>
|
||||
* @param sa
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
* @param mandatory
|
||||
* a boolean.
|
||||
* @param af
|
||||
* a {@link forge.card.ability.AbilityFactory} object.
|
||||
* a {@link forge.game.ability.AbilityFactory} object.
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
@@ -157,7 +148,7 @@ public class LifeGainAi extends SpellAbilityAi {
|
||||
}
|
||||
}
|
||||
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final String amountStr = sa.getParam("LifeAmount");
|
||||
if (amountStr.equals("X") && source.getSVar(amountStr).equals("Count$xPaid")) {
|
||||
// Set PayX here to maximum value.
|
||||
@@ -1,17 +1,18 @@
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
import java.util.List;
|
||||
import forge.Card;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.TargetRestrictions;
|
||||
import forge.game.ai.ComputerUtil;
|
||||
import forge.game.ai.ComputerUtilCost;
|
||||
import forge.game.ai.ComputerUtilMana;
|
||||
import forge.ai.ComputerUtil;
|
||||
import forge.ai.ComputerUtilCost;
|
||||
import forge.ai.ComputerUtilMana;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.cost.Cost;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LifeLoseAi extends SpellAbilityAi {
|
||||
|
||||
@@ -20,7 +21,7 @@ public class LifeLoseAi extends SpellAbilityAi {
|
||||
|
||||
List<Player> tgtPlayers = getTargetPlayers(sa);
|
||||
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final String amountStr = sa.getParam("LifeAmount");
|
||||
int amount = 0;
|
||||
if (amountStr.equals("X") && source.getSVar(amountStr).equals("Count$xPaid")) {
|
||||
@@ -45,13 +46,13 @@ public class LifeLoseAi extends SpellAbilityAi {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
final String amountStr = sa.getParam("LifeAmount");
|
||||
|
||||
// TODO handle proper calculation of X values based on Cost and what
|
||||
// would be paid
|
||||
int amount = AbilityUtils.calculateAmount(sa.getSourceCard(), amountStr, sa);
|
||||
int amount = AbilityUtils.calculateAmount(sa.getHostCard(), amountStr, sa);
|
||||
|
||||
if (amountStr.equals("X") && source.getSVar(amountStr).equals("Count$xPaid")) {
|
||||
// Set PayX here to maximum value.
|
||||
@@ -145,7 +146,7 @@ public class LifeLoseAi extends SpellAbilityAi {
|
||||
}
|
||||
}
|
||||
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final String amountStr = sa.getParam("LifeAmount");
|
||||
int amount = 0;
|
||||
if (amountStr.equals("X") && source.getSVar(amountStr).equals("Count$xPaid")) {
|
||||
@@ -1,25 +1,25 @@
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CounterType;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.TargetRestrictions;
|
||||
import forge.game.ai.ComputerUtilMana;
|
||||
import forge.ai.ComputerUtilMana;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CounterType;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class LifeSetAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Random r = MyRandom.getRandom();
|
||||
// Ability_Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final int myLife = ai.getLife();
|
||||
final Player opponent = ai.getOpponent();
|
||||
final int hlife = opponent.getLife();
|
||||
@@ -45,7 +45,7 @@ public class LifeSetAi extends SpellAbilityAi {
|
||||
source.setSVar("PayX", Integer.toString(xPay));
|
||||
amount = xPay;
|
||||
} else {
|
||||
amount = AbilityUtils.calculateAmount(sa.getSourceCard(), amountStr, sa);
|
||||
amount = AbilityUtils.calculateAmount(sa.getHostCard(), amountStr, sa);
|
||||
}
|
||||
|
||||
// prevent run-away activations - first time will always return true
|
||||
@@ -105,7 +105,7 @@ public class LifeSetAi extends SpellAbilityAi {
|
||||
final int myLife = ai.getLife();
|
||||
final Player opponent = ai.getOpponent();
|
||||
final int hlife = opponent.getLife();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
final String amountStr = sa.getParam("LifeAmount");
|
||||
|
||||
@@ -116,7 +116,7 @@ public class LifeSetAi extends SpellAbilityAi {
|
||||
source.setSVar("PayX", Integer.toString(xPay));
|
||||
amount = xPay;
|
||||
} else {
|
||||
amount = AbilityUtils.calculateAmount(sa.getSourceCard(), amountStr, sa);
|
||||
amount = AbilityUtils.calculateAmount(sa.getHostCard(), amountStr, sa);
|
||||
}
|
||||
|
||||
if (source.getName().equals("Eternity Vessel")
|
||||
35
forge-ai/src/main/java/forge/ai/ability/ManaEffectAi.java
Normal file
35
forge-ai/src/main/java/forge/ai/ability/ManaEffectAi.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package forge.ai.ability;
|
||||
|
||||
|
||||
import forge.ai.ComputerUtil;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
|
||||
public class ManaEffectAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
if (ai.getGame().getPhaseHandler().is(PhaseType.MAIN2) && ComputerUtil.activateForCost(sa, ai)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sa
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
* @param mandatory
|
||||
* a boolean.
|
||||
* @param af
|
||||
* a {@link forge.game.ability.AbilityFactory} object.
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, SpellAbility sa, boolean mandatory) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,26 +1,26 @@
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import forge.Card;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.TargetRestrictions;
|
||||
import forge.game.ai.ComputerUtil;
|
||||
import forge.game.ai.ComputerUtilCost;
|
||||
import forge.game.ai.ComputerUtilMana;
|
||||
import forge.ai.ComputerUtil;
|
||||
import forge.ai.ComputerUtilCost;
|
||||
import forge.ai.ComputerUtilMana;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.cost.Cost;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.PlayerActionConfirmMode;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MillAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
|
||||
if (abCost != null) {
|
||||
@@ -94,7 +94,7 @@ public class MillAi extends SpellAbilityAi {
|
||||
return false;
|
||||
}
|
||||
|
||||
final int numCards = AbilityUtils.calculateAmount(sa.getSourceCard(), sa.getParam("NumCards"), sa);
|
||||
final int numCards = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("NumCards"), sa);
|
||||
|
||||
final List<Card> pLibrary = opp.getCardsIn(ZoneType.Library);
|
||||
|
||||
@@ -135,7 +135,7 @@ public class MillAi extends SpellAbilityAi {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
if (sa.getParam("NumCards").equals("X") && source.getSVar("X").equals("Count$xPaid")) {
|
||||
// Set PayX here to maximum value.
|
||||
final int cardsToDiscard = Math.min(ComputerUtilMana.determineLeftoverMana(sa, aiPlayer), aiPlayer.getOpponent()
|
||||
@@ -1,9 +1,9 @@
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
|
||||
public class MustAttackAi extends SpellAbilityAi {
|
||||
|
||||
@@ -1,23 +1,22 @@
|
||||
package forge.card.ability.ai;
|
||||
|
||||
import java.util.List;
|
||||
package forge.ai.ability;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CardPredicates;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.TargetRestrictions;
|
||||
import forge.game.ai.ComputerUtilCard;
|
||||
import forge.game.ai.ComputerUtilCombat;
|
||||
import forge.ai.ComputerUtilCard;
|
||||
import forge.ai.ComputerUtilCombat;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.card.CardPredicates;
|
||||
import forge.game.combat.CombatUtil;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MustBlockAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
@@ -34,7 +33,7 @@ public class MustBlockAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(final Player ai, SpellAbility sa, boolean mandatory) {
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final TargetRestrictions abTgt = sa.getTargetRestrictions();
|
||||
|
||||
// only use on creatures that can attack
|
||||
@@ -44,7 +43,7 @@ public class MustBlockAi extends SpellAbilityAi {
|
||||
|
||||
Card attacker = null;
|
||||
if (sa.hasParam("DefinedAttacker")) {
|
||||
final List<Card> cards = AbilityUtils.getDefinedCards(sa.getSourceCard(), sa.getParam("DefinedAttacker"), sa);
|
||||
final List<Card> cards = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("DefinedAttacker"), sa);
|
||||
if (cards.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
39
forge-ai/src/main/java/forge/ai/ability/PeekAndRevealAi.java
Normal file
39
forge-ai/src/main/java/forge/ai/ability/PeekAndRevealAi.java
Normal file
@@ -0,0 +1,39 @@
|
||||
package forge.ai.ability;
|
||||
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.ai.SpellApiToAi;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.PlayerActionConfirmMode;
|
||||
import forge.game.spellability.AbilityStatic;
|
||||
import forge.game.spellability.AbilitySub;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this type.
|
||||
*
|
||||
*/
|
||||
public class PeekAndRevealAi extends SpellAbilityAi {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
if (sa instanceof AbilityStatic) {
|
||||
return false;
|
||||
}
|
||||
// So far this only appears on Triggers, but will expand
|
||||
// once things get converted from Dig + NoMove
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.card.ability.SpellAbilityAi#confirmAction(forge.game.player.Player, forge.card.spellability.SpellAbility, forge.game.player.PlayerActionConfirmMode, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) {
|
||||
AbilitySub subAb = sa.getSubAbility();
|
||||
return subAb != null && SpellApiToAi.Converter.get(subAb.getApi()).chkDrawbackWithSubs(player, subAb);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,20 +1,19 @@
|
||||
package forge.card.ability.ai;
|
||||
|
||||
import java.util.List;
|
||||
package forge.ai.ability;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardPredicates;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.ai.ComputerUtil;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.Game;
|
||||
import forge.game.ai.ComputerUtil;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardPredicates;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* AbilityFactory for Creature Spells.
|
||||
*
|
||||
@@ -46,7 +45,7 @@ public class PermanentCreatureAi extends SpellAbilityAi {
|
||||
for(Card c : cards) {
|
||||
ArrayList<StaticAbility> statics = c.getStaticAbilities();
|
||||
for(StaticAbility s : statics) {
|
||||
final Map<String, String> stabMap = s.getMapParams();
|
||||
final Map<String, String> stabMap = s.parseParams();
|
||||
|
||||
if (!stabMap.get("Mode").equals("Continuous")) {
|
||||
continue;
|
||||
@@ -1,10 +1,10 @@
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.ai.ComputerUtil;
|
||||
import forge.ai.ComputerUtil;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
|
||||
/**
|
||||
* AbilityFactory for Creature Spells.
|
||||
@@ -1,19 +1,19 @@
|
||||
package forge.card.ability.ai;
|
||||
package forge.ai.ability;
|
||||
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.Game;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.TargetRestrictions;
|
||||
import forge.game.Game;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
public class PhasesAi extends SpellAbilityAi {
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -23,7 +23,7 @@ public class PhasesAi extends SpellAbilityAi {
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
// This still needs to be fleshed out
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
final Random r = MyRandom.getRandom();
|
||||
boolean randomReturn = r.nextFloat() <= Math.pow(.6667, sa.getActivationsThisTurn());
|
||||
@@ -89,18 +89,18 @@ public class PhasesAi extends SpellAbilityAi {
|
||||
* </p>
|
||||
*
|
||||
* @param tgt
|
||||
* a {@link forge.card.spellability.TargetRestrictions} object.
|
||||
* a {@link forge.game.spellability.TargetRestrictions} object.
|
||||
* @param af
|
||||
* a {@link forge.card.ability.AbilityFactory} object.
|
||||
* a {@link forge.game.ability.AbilityFactory} object.
|
||||
* @param sa
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
* @param mandatory
|
||||
* a boolean.
|
||||
* @return a boolean.
|
||||
*/
|
||||
private boolean phasesPrefTargeting(final TargetRestrictions tgt, final SpellAbility sa,
|
||||
final boolean mandatory) {
|
||||
// Card source = sa.getSourceCard();
|
||||
// Card source = sa.getHostCard();
|
||||
|
||||
// List<Card> phaseList =
|
||||
// AllZoneUtil.getCardsIn(Zone.Battlefield).getTargetableCards(source)
|
||||
@@ -126,15 +126,15 @@ public class PhasesAi extends SpellAbilityAi {
|
||||
* </p>
|
||||
*
|
||||
* @param af
|
||||
* a {@link forge.card.ability.AbilityFactory} object.
|
||||
* a {@link forge.game.ability.AbilityFactory} object.
|
||||
* @param sa
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
* @param mandatory
|
||||
* a boolean.
|
||||
* @return a boolean.
|
||||
*/
|
||||
private boolean phasesUnpreferredTargeting(final Game game, final SpellAbility sa, final boolean mandatory) {
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card source = sa.getHostCard();
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
|
||||
List<Card> list = game.getCardsIn(ZoneType.Battlefield);
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user