mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Attempt to combat game memory leaks after game finishes.
- Make PLAY_LAND_SURROGATE a game field rather than static - Remove games from cache more aggressively - Remove targeting overlay from global view after game ends
This commit is contained in:
@@ -1097,9 +1097,9 @@ public class AiController {
|
||||
if (landsWannaPlay != null && !landsWannaPlay.isEmpty() && player.canPlayLand(null)) {
|
||||
Card land = chooseBestLandToPlay(landsWannaPlay);
|
||||
if (ComputerUtil.damageFromETB(player, land) < player.getLife() || !player.canLoseLife()) {
|
||||
Ability.PLAY_LAND_SURROGATE.setHostCard(land);
|
||||
game.PLAY_LAND_SURROGATE.setHostCard(land);
|
||||
final List<SpellAbility> abilities = new ArrayList<SpellAbility>();
|
||||
abilities.add(Ability.PLAY_LAND_SURROGATE);
|
||||
abilities.add(game.PLAY_LAND_SURROGATE);
|
||||
return abilities;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -397,10 +397,9 @@ public class PlayerControllerAi extends PlayerController {
|
||||
@Override
|
||||
public void playChosenSpellAbility(SpellAbility sa) {
|
||||
// System.out.println("Playing sa: " + sa);
|
||||
if (sa == Ability.PLAY_LAND_SURROGATE) {
|
||||
if (sa == sa.getHostCard().getGame().PLAY_LAND_SURROGATE) {
|
||||
player.playLand(sa.getHostCard(), false);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ComputerUtil.handlePlayingSpellAbility(player, sa, game);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ import forge.game.GameObject;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardCollection;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.Ability;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetChoices;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
@@ -152,7 +151,7 @@ public class GameSimulator {
|
||||
}
|
||||
}
|
||||
|
||||
if (sa == Ability.PLAY_LAND_SURROGATE) {
|
||||
if (sa == origSa.getHostCard().getGame().PLAY_LAND_SURROGATE) {
|
||||
aiPlayer.playLand(sa.getHostCard(), false);
|
||||
} else {
|
||||
if (debugPrint && !sa.getAllTargetChoices().isEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user