Search in sources :

Example 46 with Game

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;
}
Also used : StaticFilters(mage.filter.StaticFilters) Zone(mage.constants.Zone) Cards(mage.cards.Cards) Outcome(mage.constants.Outcome) OneShotEffect(mage.abilities.effects.OneShotEffect) UUID(java.util.UUID) CardsImpl(mage.cards.CardsImpl) Player(mage.players.Player) CardSetInfo(mage.cards.CardSetInfo) Game(mage.game.Game) CardImpl(mage.cards.CardImpl) CardType(mage.constants.CardType) Ability(mage.abilities.Ability) Player(mage.players.Player) UUID(java.util.UUID) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 47 with Game

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;
}
Also used : Game(mage.game.Game) FreeForAll(mage.game.FreeForAll)

Example 48 with 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");
}
Also used : Game(mage.game.Game)

Example 49 with Game

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"));
}
Also used : Player(mage.players.Player) HumanPlayer(mage.player.human.HumanPlayer) Game(mage.game.Game) PlanarDieRollResult(mage.constants.PlanarDieRollResult) HumanPlayer(mage.player.human.HumanPlayer) TwoPlayerDuel(mage.game.TwoPlayerDuel) File(java.io.File) BufferedImage(java.awt.image.BufferedImage) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 50 with Game

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"));
}
Also used : Player(mage.players.Player) HumanPlayer(mage.player.human.HumanPlayer) Game(mage.game.Game) HumanPlayer(mage.player.human.HumanPlayer) TwoPlayerDuel(mage.game.TwoPlayerDuel) File(java.io.File) BufferedImage(java.awt.image.BufferedImage) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

Game (mage.game.Game)212 Ability (mage.abilities.Ability)139 Player (mage.players.Player)126 UUID (java.util.UUID)117 OneShotEffect (mage.abilities.effects.OneShotEffect)104 CardSetInfo (mage.cards.CardSetInfo)102 CardImpl (mage.cards.CardImpl)100 CardType (mage.constants.CardType)82 Outcome (mage.constants.Outcome)78 Permanent (mage.game.permanent.Permanent)66 MageInt (mage.MageInt)60 mage.constants (mage.constants)47 Zone (mage.constants.Zone)46 GameEvent (mage.game.events.GameEvent)44 Objects (java.util.Objects)41 StaticFilters (mage.filter.StaticFilters)40 Collectors (java.util.stream.Collectors)35 SubType (mage.constants.SubType)34 Card (mage.cards.Card)32 MageObjectReference (mage.MageObjectReference)30