mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
refactor the code assigning profiles to AI players.
This commit is contained in:
@@ -15,6 +15,7 @@ import forge.deck.Deck;
|
|||||||
import forge.error.BugReporter;
|
import forge.error.BugReporter;
|
||||||
import forge.game.ai.AiProfileUtil;
|
import forge.game.ai.AiProfileUtil;
|
||||||
import forge.game.event.DuelOutcomeEvent;
|
import forge.game.event.DuelOutcomeEvent;
|
||||||
|
import forge.game.player.AIPlayer;
|
||||||
import forge.game.player.LobbyPlayer;
|
import forge.game.player.LobbyPlayer;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.player.PlayerStatistics;
|
import forge.game.player.PlayerStatistics;
|
||||||
@@ -140,24 +141,22 @@ public class MatchController {
|
|||||||
|
|
||||||
// Set the current AI profile.
|
// Set the current AI profile.
|
||||||
for (Player p : currentGame.getPlayers()) {
|
for (Player p : currentGame.getPlayers()) {
|
||||||
if (p.getType() == PlayerType.COMPUTER) {
|
if ( !(p instanceof AIPlayer))
|
||||||
if (Singletons.getModel().getPreferences().getPref(FPref.UI_CURRENT_AI_PROFILE).equals(AiProfileUtil.AI_PROFILE_RANDOM_DUEL)) {
|
continue;
|
||||||
String randomProfile = AiProfileUtil.getRandomProfile();
|
|
||||||
p.getLobbyPlayer().setAiProfile(randomProfile);
|
String currentAiProfile = Singletons.getModel().getPreferences().getPref(FPref.UI_CURRENT_AI_PROFILE);
|
||||||
} else if (Singletons.getModel().getPreferences().getPref(FPref.UI_CURRENT_AI_PROFILE).equals(AiProfileUtil.AI_PROFILE_RANDOM_MATCH)) {
|
|
||||||
if (this.getPlayedGames().isEmpty()) {
|
// TODO: implement specific AI profiles for quest mode.
|
||||||
String randomProfile = AiProfileUtil.getRandomProfile();
|
boolean wantRandomProfile = currentAiProfile.equals(AiProfileUtil.AI_PROFILE_RANDOM_DUEL)
|
||||||
p.getLobbyPlayer().setAiProfile(randomProfile);
|
|| (this.getPlayedGames().isEmpty() && currentAiProfile.equals(AiProfileUtil.AI_PROFILE_RANDOM_MATCH));
|
||||||
}
|
|
||||||
} else {
|
String profileToSet = wantRandomProfile ? AiProfileUtil.getRandomProfile() : currentAiProfile;
|
||||||
// TODO: implement specific AI profiles for quest mode.
|
|
||||||
String profile = Singletons.getModel().getPreferences().getPref(FPref.UI_CURRENT_AI_PROFILE);
|
p.getLobbyPlayer().setAiProfile(profileToSet);
|
||||||
p.getLobbyPlayer().setAiProfile(profile);
|
System.out.println(String.format("AI profile %s was chosen for the lobby player %s.", p.getLobbyPlayer().getAiProfile(), p.getLobbyPlayer().getName()));
|
||||||
}
|
|
||||||
System.out.println(String.format("AI profile %s was chosen for the lobby player %s.", p.getLobbyPlayer().getAiProfile(), p.getLobbyPlayer().getName()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Player localHuman = Aggregates.firstFieldEquals(currentGame.getPlayers(), Player.Accessors.FN_GET_TYPE, PlayerType.HUMAN);
|
Player localHuman = Aggregates.firstFieldEquals(currentGame.getPlayers(), Player.Accessors.FN_GET_TYPE, PlayerType.HUMAN);
|
||||||
FControl.SINGLETON_INSTANCE.setPlayer(localHuman);
|
FControl.SINGLETON_INSTANCE.setPlayer(localHuman);
|
||||||
|
|||||||
Reference in New Issue
Block a user