mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
cut Dependencies on log entry type and AI profiles
This commit is contained in:
@@ -4,10 +4,7 @@ public class Dependencies {
|
||||
|
||||
public static PreferencesMethods preferences;
|
||||
public interface PreferencesMethods {
|
||||
@Deprecated public abstract boolean getEnableAiCheats();
|
||||
@Deprecated public abstract boolean getCloneModeSource();
|
||||
@Deprecated public abstract String getLogEntryType();
|
||||
@Deprecated public abstract String getCurrentAiProfile();
|
||||
@Deprecated public abstract boolean isManaBurnEnabled();
|
||||
@Deprecated public abstract boolean areBlocksFree();
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.Dependencies;
|
||||
import forge.card.CardType;
|
||||
import forge.card.MagicColor;
|
||||
import forge.deck.CardPool;
|
||||
@@ -78,7 +77,16 @@ public class AiController {
|
||||
|
||||
private final Player player;
|
||||
private final Game game;
|
||||
public boolean canCheatShuffle;
|
||||
public boolean bCheatShuffle;
|
||||
|
||||
public boolean canCheatShuffle() {
|
||||
return bCheatShuffle;
|
||||
}
|
||||
|
||||
public void allowCheatShuffle(boolean canCheatShuffle) {
|
||||
this.bCheatShuffle = canCheatShuffle;
|
||||
}
|
||||
|
||||
public Game getGame()
|
||||
{
|
||||
return game;
|
||||
@@ -97,8 +105,6 @@ public class AiController {
|
||||
public AiController(final Player computerPlayer, final Game game0) {
|
||||
player = computerPlayer;
|
||||
game = game0;
|
||||
|
||||
canCheatShuffle = Dependencies.preferences.getEnableAiCheats();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1023,7 +1029,7 @@ public class AiController {
|
||||
* @return an array of {@link forge.game.card.Card} objects.
|
||||
*/
|
||||
public List<Card> cheatShuffle(List<Card> in) {
|
||||
if( in.size() < 20 || !canCheatShuffle )
|
||||
if( in.size() < 20 || !canCheatShuffle() )
|
||||
return in;
|
||||
|
||||
final List<Card> library = Lists.newArrayList(in);
|
||||
|
||||
@@ -24,7 +24,6 @@ import java.util.Observable;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import forge.Dependencies;
|
||||
import forge.game.event.IGameEventVisitor;
|
||||
|
||||
|
||||
@@ -106,11 +105,6 @@ public class GameLog extends Observable {
|
||||
return result;
|
||||
}
|
||||
|
||||
public GameLogEntryType getGameLogEntryTypeSetting() {
|
||||
String logEntryType = Dependencies.preferences.getLogEntryType();
|
||||
return GameLogEntryType.valueOf(logEntryType);
|
||||
}
|
||||
|
||||
public IGameEventVisitor<?> getEventVisitor() {
|
||||
return formatter;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package forge.game.player;
|
||||
|
||||
import forge.Dependencies;
|
||||
import forge.ai.AiProfileUtil;
|
||||
import forge.game.Game;
|
||||
|
||||
@@ -10,7 +9,18 @@ public class LobbyPlayerAi extends LobbyPlayer {
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -19,14 +29,20 @@ public class LobbyPlayerAi extends LobbyPlayer {
|
||||
return aiProfile;
|
||||
}
|
||||
|
||||
public void setRotateProfileEachGame(boolean rotateProfileEachGame) {
|
||||
this.rotateProfileEachGame = rotateProfileEachGame;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PlayerType getType() {
|
||||
return PlayerType.COMPUTER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerController createControllerFor(Player ai) {
|
||||
return new PlayerControllerAi(ai.getGame(), ai, this);
|
||||
public PlayerControllerAi createControllerFor(Player ai) {
|
||||
PlayerControllerAi result = new PlayerControllerAi(ai.getGame(), ai, this);
|
||||
result.allowCheatShuffle(allowCheatShuffle);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -34,15 +50,10 @@ public class LobbyPlayerAi extends LobbyPlayer {
|
||||
Player ai = new Player(getName(), game);
|
||||
ai.setFirstController(createControllerFor(ai));
|
||||
|
||||
String currentAiProfile = Dependencies.preferences.getCurrentAiProfile();
|
||||
String lastProfileChosen = game.getMatch().getPlayedGames().isEmpty() ? currentAiProfile : getAiProfile();
|
||||
|
||||
// TODO: implement specific AI profiles for quest mode.
|
||||
boolean wantRandomProfile = currentAiProfile.equals(AiProfileUtil.AI_PROFILE_RANDOM_DUEL)
|
||||
|| game.getMatch().getPlayedGames().isEmpty() && currentAiProfile.equals(AiProfileUtil.AI_PROFILE_RANDOM_MATCH);
|
||||
|
||||
setAiProfile(wantRandomProfile ? AiProfileUtil.getRandomProfile() : lastProfileChosen);
|
||||
System.out.println(String.format("AI profile %s was chosen for the lobby player %s.", getAiProfile(), getName()));
|
||||
if( rotateProfileEachGame ) {
|
||||
setAiProfile(AiProfileUtil.getRandomProfile());
|
||||
System.out.println(String.format("AI profile %s was chosen for the lobby player %s.", getAiProfile(), getName()));
|
||||
}
|
||||
return ai;
|
||||
}
|
||||
|
||||
|
||||
@@ -79,6 +79,11 @@ public class PlayerControllerAi extends PlayerController {
|
||||
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user