use of mage.game.Game in project mage by magefree.
the class HonorTheFallenEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Cards cards = new CardsImpl();
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player == null) {
continue;
}
cards.addAll(player.getGraveyard().getCards(StaticFilters.FILTER_CARD_CREATURE, game));
}
controller.moveCards(cards, Zone.EXILED, source, game);
int count = cards.stream().map(game.getState()::getZone).map(Zone.EXILED::equals).mapToInt(x -> x ? 1 : 0).sum();
controller.gainLife(count, game, source);
return true;
}
use of mage.game.Game in project mage by magefree.
the class GoadTest method createNewGameAndPlayers.
@Override
protected Game createNewGameAndPlayers() throws GameException, FileNotFoundException {
Game game = new FreeForAll(MultiplayerAttackOption.MULTIPLE, RangeOfInfluence.ALL, MulliganType.GAME_DEFAULT.getMulligan(0), 40);
// Player order: A -> D -> C -> B
playerA = createPlayer(game, playerA, "PlayerA");
playerB = createPlayer(game, playerB, "PlayerB");
playerC = createPlayer(game, playerC, "PlayerC");
playerD = createPlayer(game, playerD, "PlayerD");
return game;
}
use of mage.game.Game in project mage by magefree.
the class CopyGameStatePerformanceTest method run.
public void run() throws Exception {
init();
reset();
System.out.println("Started copying...");
long t1 = System.currentTimeMillis();
for (int i = 0; i < 2000; i++) {
Game game = currentGame.copy();
Game game2 = game.copy();
}
long t2 = System.currentTimeMillis();
System.out.println("Test took: " + (t2 - t1) + " ms");
}
use of mage.game.Game in project mage by magefree.
the class RandomTest method test_GenerateRandomPlanarDicePng.
@Test
@Ignore
public void test_GenerateRandomPlanarDicePng() throws IOException {
String dest = "f:/test/xmage/";
// RandomUtil.setSeed(123);
Player player = new HumanPlayer("random", RangeOfInfluence.ALL, 1);
Game game = new TwoPlayerDuel(MultiplayerAttackOption.MULTIPLE, RangeOfInfluence.ALL, MulliganType.GAME_DEFAULT.getMulligan(0), 50);
int height = 512;
int weight = 512;
BufferedImage image = new BufferedImage(weight, height, BufferedImage.TYPE_INT_RGB);
for (int x = 0; x < weight; x++) {
for (int y = 0; y < height; y++) {
// roll planar dice
PlanarDieRollResult res = player.rollPlanarDie(Outcome.Neutral, null, game);
image.setRGB(x, y, new Color(res.equals(PlanarDieRollResult.CHAOS_ROLL) ? 255 : 0, res.equals(PlanarDieRollResult.PLANAR_ROLL) ? 255 : 0, res.equals(PlanarDieRollResult.BLANK_ROLL) ? 255 : 0).getRGB());
}
}
ImageIO.write(image, "png", new File(dest + "xmage_random_planar_dice.png"));
}
use of mage.game.Game in project mage by magefree.
the class RandomTest method test_GenerateRandomDicePng.
@Test
@Ignore
public void test_GenerateRandomDicePng() throws IOException {
String dest = "f:/test/xmage/";
// RandomUtil.setSeed(123);
Player player = new HumanPlayer("random", RangeOfInfluence.ALL, 1);
Game game = new TwoPlayerDuel(MultiplayerAttackOption.MULTIPLE, RangeOfInfluence.ALL, MulliganType.GAME_DEFAULT.getMulligan(0), 50);
int height = 512;
int weight = 512;
BufferedImage image = new BufferedImage(weight, height, BufferedImage.TYPE_INT_RGB);
for (int x = 0; x < weight; x++) {
for (int y = 0; y < height; y++) {
// roll dice
int diceVal = player.rollDice(Outcome.Neutral, null, game, 12);
int colorMult = Math.floorDiv(255, 12);
image.setRGB(x, y, new Color(colorMult * diceVal, colorMult * diceVal, colorMult * diceVal).getRGB());
}
}
ImageIO.write(image, "png", new File(dest + "xmage_random_dice.png"));
}
Aggregations