forked from External/mage
AI: reworked blockers selections:
* fixed game freezes for no-possible block configurations like Menace (#13290); * fixed computer cheating to ignore block requirements like Menace (now AI will choose all required blockers instead 1); * improved computer logic for blockers selection (try to sacrifice a creature instead game loose, simple use cases only); * added freeze protection for bad or unsupported attacker-block configuration; * refactor: deleted outdated AI code;
This commit is contained in:
parent
a99871988d
commit
92b7ed8efc
12 changed files with 495 additions and 202 deletions
|
|
@ -3174,7 +3174,7 @@ public abstract class GameImpl implements Game {
|
|||
if (simulation) {
|
||||
return;
|
||||
}
|
||||
makeSureCalledOutsideLayersEffects();
|
||||
makeSureCalledOutsideLayerEffects();
|
||||
tableEventSource.fireTableEvent(EventType.INFO, message, this);
|
||||
}
|
||||
|
||||
|
|
@ -3183,7 +3183,7 @@ public abstract class GameImpl implements Game {
|
|||
if (simulation) {
|
||||
return;
|
||||
}
|
||||
makeSureCalledOutsideLayersEffects();
|
||||
makeSureCalledOutsideLayerEffects();
|
||||
tableEventSource.fireTableEvent(EventType.STATUS, message, withTime, withTurnInfo, this);
|
||||
}
|
||||
|
||||
|
|
@ -3192,7 +3192,7 @@ public abstract class GameImpl implements Game {
|
|||
if (simulation) {
|
||||
return;
|
||||
}
|
||||
makeSureCalledOutsideLayersEffects();
|
||||
makeSureCalledOutsideLayerEffects();
|
||||
tableEventSource.fireTableEvent(EventType.UPDATE, null, this);
|
||||
getState().clearLookedAt();
|
||||
getState().clearRevealed();
|
||||
|
|
@ -3203,23 +3203,23 @@ public abstract class GameImpl implements Game {
|
|||
if (simulation) {
|
||||
return;
|
||||
}
|
||||
makeSureCalledOutsideLayersEffects();
|
||||
makeSureCalledOutsideLayerEffects();
|
||||
tableEventSource.fireTableEvent(EventType.END_GAME_INFO, null, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireErrorEvent(String message, Exception ex) {
|
||||
makeSureCalledOutsideLayersEffects();
|
||||
makeSureCalledOutsideLayerEffects();
|
||||
tableEventSource.fireTableEvent(EventType.ERROR, message, ex, this);
|
||||
}
|
||||
|
||||
private void makeSureCalledOutsideLayersEffects() {
|
||||
private void makeSureCalledOutsideLayerEffects() {
|
||||
// very slow, enable/comment it for debug or load/stability tests only
|
||||
// TODO: enable check and remove/rework all wrong usages
|
||||
if (true) return;
|
||||
Arrays.stream(Thread.currentThread().getStackTrace()).forEach(e -> {
|
||||
if (e.toString().contains("GameState.applyEffects")) {
|
||||
throw new IllegalStateException("Wrong code usage: client side events can't be called from layers effects (wrong informPlayers usage?");
|
||||
throw new IllegalStateException("Wrong code usage: client side events can't be called from layers effects (wrong informPlayers usage?)");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -3890,7 +3890,7 @@ public abstract class GameImpl implements Game {
|
|||
@Override
|
||||
public void initTimer(UUID playerId) {
|
||||
if (priorityTime > 0) {
|
||||
makeSureCalledOutsideLayersEffects();
|
||||
makeSureCalledOutsideLayerEffects();
|
||||
tableEventSource.fireTableEvent(EventType.INIT_TIMER, playerId, null, this);
|
||||
}
|
||||
}
|
||||
|
|
@ -3898,7 +3898,7 @@ public abstract class GameImpl implements Game {
|
|||
@Override
|
||||
public void resumeTimer(UUID playerId) {
|
||||
if (priorityTime > 0) {
|
||||
makeSureCalledOutsideLayersEffects();
|
||||
makeSureCalledOutsideLayerEffects();
|
||||
tableEventSource.fireTableEvent(EventType.RESUME_TIMER, playerId, null, this);
|
||||
}
|
||||
}
|
||||
|
|
@ -3906,7 +3906,7 @@ public abstract class GameImpl implements Game {
|
|||
@Override
|
||||
public void pauseTimer(UUID playerId) {
|
||||
if (priorityTime > 0) {
|
||||
makeSureCalledOutsideLayersEffects();
|
||||
makeSureCalledOutsideLayerEffects();
|
||||
tableEventSource.fireTableEvent(EventType.PAUSE_TIMER, playerId, null, this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue