public boolean activate() { // if true continue to execute if (Inventory.getCount(Essence) >= 11 && (InAltar.contains(Players.getMyPlayer().getLocation()))) { return true; } return false; }
public TimeReversal(GameState state) { super(state); // Each player shuffles his or her hand and graveyard into his or her // library, SetGenerator handsAndGraveyards = InZone.instance( Union.instance( HandOf.instance(Players.instance()), GraveyardOf.instance(Players.instance()))); EventFactory shuffle = new EventFactory( EventType.SHUFFLE_INTO_LIBRARY, "Each player shuffles his or her hand and graveyard into his or her library,"); shuffle.parameters.put(EventType.Parameter.CAUSE, This.instance()); shuffle.parameters.put( EventType.Parameter.OBJECT, Union.instance(handsAndGraveyards, Players.instance())); this.addEffect(shuffle); // then draws seven cards. this.addEffect(drawCards(Players.instance(), 7, "then draws seven cards.")); // Exile Time Reversal. this.addEffect(exile(This.instance(), "Exile Time Reversal.")); }
public List<Players> getAllPlayers() { if (_local) { SQLiteDatabase db = this.getReadableDatabase(); List<Players> players = new ArrayList<Players>(); String selectPlayerQuery = "SELECT * FROM " + TABLE_PLAYERS; Log.i(LOG, selectPlayerQuery); Cursor c = db.rawQuery(selectPlayerQuery, null); if (c != null && c.moveToFirst()) { do { // create the instance of Players using cursor information Players player = new Players(); player.setpid(c.getLong(c.getColumnIndex(KEY_P_ID))); player.settid(c.getLong(c.getColumnIndex(KEY_T_ID))); player.setpname((c.getString(c.getColumnIndex(KEY_P_NAME)))); player.setpnum((c.getInt(c.getColumnIndex(KEY_P_NUM)))); // adding to players list players.add(player); } while (c.moveToNext()); } return players; } else { return _net.getAllPlayers(); } }
public int updatePlayer(Players player) { SQLiteDatabase db = this.getWritableDatabase(); ContentValues values = new ContentValues(); values.put(KEY_T_ID, player.gettid()); values.put(KEY_P_NAME, player.getpname()); values.put(KEY_P_NUM, player.getpnum()); if (!_local) { _net.updatePlayer(player); } return db.update( TABLE_PLAYERS, values, KEY_P_ID + " = ?", new String[] {String.valueOf(player.getpid())}); }
private void handleDoubleJeopardy() { Player player = askForPlayer(); Integer wager = askForWager(player); Players.setDoubleJeopardyPlayer(player); getFrame().setDoubleJeopardyWager(wager); }
public IncreasingSavagery(GameState state) { super(state); // Put five +1/+1 counters on target creature. If Increasing Savagery // was cast from a graveyard, put ten +1/+1 counters on that creature // instead. SetGenerator target = targetedBy(this.addTarget(CreaturePermanents.instance(), "target creature")); SetGenerator number = IfThenElse.instance( Intersect.instance( ZoneCastFrom.instance(This.instance()), GraveyardOf.instance(Players.instance())), numberGenerator(10), numberGenerator(5)); this.addEffect( putCounters( number, Counter.CounterType.PLUS_ONE_PLUS_ONE, target, "Put five +1/+1 counters on target creature. If Increasing Savagery was cast from a graveyard, put ten +1/+1 counters on that creature instead.")); // Flashback (5)(G)(G) (You may cast this card from your graveyard for // its flashback cost. Then exile it.) this.addAbility(new Flashback(state, "(5)(G)(G)")); }
public CellarDoorAbility0(GameState state) { super( state, "(3), (T): Target player puts the bottom card of his or her library into his or her graveyard. If it's a creature card, you put a 2/2 black Zombie creature token onto the battlefield."); this.setManaCost(new ManaPool("(3)")); this.costsTap = true; SetGenerator target = targetedBy(this.addTarget(Players.instance(), "target player")); SetGenerator library = LibraryOf.instance(target); EventFactory putIntoGraveyard = new EventFactory( EventType.MOVE_OBJECTS, "Target player puts the bottom card of his or her library into his or her graveyard."); putIntoGraveyard.parameters.put(EventType.Parameter.CAUSE, This.instance()); putIntoGraveyard.parameters.put(EventType.Parameter.TO, GraveyardOf.instance(target)); putIntoGraveyard.parameters.put(EventType.Parameter.OBJECT, BottomCards.instance(1, library)); this.addEffect(putIntoGraveyard); SetGenerator object = NewObjectOf.instance(EffectResult.instance(putIntoGraveyard)); SetGenerator isCreature = Intersect.instance(object, HasType.instance(Type.CREATURE)); CreateTokensFactory token = new CreateTokensFactory( 1, 2, 2, "you put a 2/2 black Zombie creature token onto the battlefield."); token.setColors(Color.BLACK); token.setSubTypes(SubType.ZOMBIE); this.addEffect( ifThen( isCreature, token.getEventFactory(), "If it's a creature card, you put a 2/2 black Zombie creature token onto the battlefield.")); }
public SurgicalExtraction(GameState state) { super(state); // Choose target card in a graveyard other than a basic land card. SetGenerator inGraveyards = InZone.instance(GraveyardOf.instance(Players.instance())); SetGenerator basicLands = Intersect.instance(HasSuperType.instance(SuperType.BASIC), HasType.instance(Type.LAND)); SetGenerator legalTargets = RelativeComplement.instance(inGraveyards, basicLands); Target t = this.addTarget(legalTargets, "target card in a graveyard other than a basic land card"); // Search its owner's graveyard, hand, and library for all cards with // the same name as that card and exile them. SetGenerator itsOwner = OwnerOf.instance(targetedBy(t)); SetGenerator graveyard = GraveyardOf.instance(itsOwner); SetGenerator hand = HandOf.instance(itsOwner); SetGenerator library = LibraryOf.instance(itsOwner); SetGenerator zones = Union.instance(graveyard, hand, library); EventFactory effect = new EventFactory( EventType.SEARCH_FOR_ALL_AND_PUT_INTO, "Choose target card in a graveyard other than a basic land card. Search its owner's graveyard, hand, and library for all cards with the same name as that card and exile them."); effect.parameters.put(EventType.Parameter.CAUSE, This.instance()); effect.parameters.put(EventType.Parameter.PLAYER, You.instance()); effect.parameters.put(EventType.Parameter.ZONE, zones); effect.parameters.put( EventType.Parameter.TYPE, Identity.instance(HasName.instance(NameOf.instance(targetedBy(t))))); effect.parameters.put(EventType.Parameter.TO, ExileZone.instance()); this.addEffect(effect); // Then that player shuffles his or her library. this.addEffect(shuffleLibrary(targetedBy(t), "Then that player shuffles his or her library.")); }
public RuneflareTrap(GameState state) { super(state); // If an opponent drew three or more cards this turn, you may pay (R) // rather than pay Runeflare Trap's mana cost. state.ensureTracker(new CardsDrawn()); SetGenerator opponents = OpponentsOf.instance(You.instance()); SetGenerator cardsDrawn = MaximumPerPlayer.instance(CardsDrawn.class, opponents); SetGenerator trapCondition = Intersect.instance(cardsDrawn, Between.instance(3, null)); this.addAbility( new Trap( state, this.getName(), trapCondition, "If an opponent drew three or more cards this turn", "(R)")); // Runeflare Trap deals damage to target player equal to the number of // cards in that player's hand. Target target = this.addTarget(Players.instance(), "target player"); SetGenerator amount = Count.instance(InZone.instance(HandOf.instance(targetedBy(target)))); this.addEffect( spellDealDamage( amount, targetedBy(target), "Runeflare Trap deals damage to target player equal to the number of cards in that player's hand.")); }
private void onEnablePost() { loaded = true; PluginManager pm = getServer().getPluginManager(); scanPlugins(); // scan for other plugins and store them in case any use our API FlagFactory.getInstance().init(); FlagFactory.getInstance().initPermissions(); RecipeBooks.getInstance().init(); RecipeBooks.getInstance().reload(null); Files.init(); Players.init(); Workbenches.init(); reload(null, false, true); // load data pm.callEvent( new RecipeManagerEnabledEvent()); // Call the enabled event to notify other plugins that use // this plugin's API // Register commands getCommand("rm").setExecutor(new HelpCommand()); getCommand("rmrecipes").setExecutor(new RecipeCommand()); getCommand("rmfinditem").setExecutor(new FindItemCommand()); getCommand("rmcheck").setExecutor(new CheckCommand()); getCommand("rmreload").setExecutor(new ReloadCommand()); getCommand("rmreloadbooks").setExecutor(new ReloadBooksCommand()); getCommand("rmextract").setExecutor(new ExtractCommand()); getCommand("rmgetbook").setExecutor(new GetBookCommand()); getCommand("rmbooks").setExecutor(new BooksCommand()); getCommand("rmupdate").setExecutor(new UpdateCommand()); getCommand("rmcreaterecipe").setExecutor(new CreateRecipeCommand()); }
@Override protected EventFactory getKinshipEffect() { EventFactory factory = new EventFactory( DISCARD_AND_DRAW, "Each player discards his or her hand, then draws four cards."); factory.parameters.put(EventType.Parameter.CAUSE, This.instance()); factory.parameters.put(EventType.Parameter.PLAYER, Players.instance()); return factory; }
@Test public void playerIdsAreSameAsPlayingOrder() { Players players = new Players(); Player player1Team1 = new Player(null); players.playerJoined(player1Team1); Player player2Team1 = new Player(null); players.playerJoined(player2Team1); Player player1Team2 = new Player(null); players.playerJoined(player1Team2); Player player2Team2 = new Player(null); players.playerJoined(player2Team2); assertEquals(0, player1Team1.getId()); assertEquals(1, player1Team2.getId()); assertEquals(2, player2Team1.getId()); assertEquals(3, player2Team2.getId()); }
public Worldfire(GameState state) { super(state); // Exile all permanents. Exile all cards from all hands and graveyards. // Each player's life total becomes 1. this.addEffect(exile(Permanents.instance(), "Exile all permanents.")); this.addEffect( exile( InZone.instance( Union.instance( HandOf.instance(Players.instance()), GraveyardOf.instance(Players.instance()))), "Exile all cards from all hands and graveyards.")); EventFactory life = new EventFactory(EventType.SET_LIFE, "Each player's life total becomes 1."); life.parameters.put(EventType.Parameter.CAUSE, This.instance()); life.parameters.put(EventType.Parameter.NUMBER, numberGenerator(1)); life.parameters.put(EventType.Parameter.PLAYER, Players.instance()); this.addEffect(life); }
public GroundSealAbility1(GameState state) { super(state, "Cards in graveyards can't be the targets of spells or abilities."); SetGenerator inYards = InZone.instance(GraveyardOf.instance(Players.instance())); ContinuousEffect.Part part = new ContinuousEffect.Part(ContinuousEffectType.CANT_BE_THE_TARGET_OF); part.parameters.put(ContinuousEffectType.Parameter.OBJECT, inYards); part.parameters.put( ContinuousEffectType.Parameter.RESTRICTION, Identity.instance(SetPattern.EVERYTHING)); this.addEffectPart(part); }
private void playersTest(TestResult result) { Players players = new Players(); players.Add(new Player("P1", Color.GREEN)); players.Add(new Player("P2", Color.RED)); players.Add(new Player("P3", Color.BLUE)); players.Add(new Player("P4", Color.YELLOW)); if (players.setup(126)) { for (int i = 0; i < players.players.length; i++) { if (players.players[i].getShips().length != 9) { result.addComment(players.players[i].getName() + ": " + players.players[i].getShips()); result.setResult(false); } } int indexsum = 0; int indexprevsum = 0; for (int i = 0; i < players.players.length; i++) { indexsum = 0; for (int j = 0; j < players.players[i].getShips().length; j++) { indexsum += players.players[i].getShips()[j].getIndex(); } } } else result.setResult(false); }
public DrawThreeDiscardThree(GameState state) { super( state, "Threshold \u2014 (U), (T), Sacrifice Cephalid Coliseum: Target player draws three cards, then discards three cards. Activate this ability only if seven or more cards are in your graveyard."); this.setManaCost(new ManaPool("U")); this.costsTap = true; this.addCost(sacrificeThis("Cephalid Coliseum")); Target target = this.addTarget(Players.instance(), "target player"); this.addEffect(drawCards(targetedBy(target), 3, "Target player draws three cards,")); this.addEffect(discardCards(targetedBy(target), 3, "then discards three cards.")); this.addActivateRestriction(Not.instance(Threshold.instance())); }
public ManaDenial(GameState state) { super( state, "When a Faerie is championed with Mistbind Clique, tap all lands target player controls."); this.addPattern( whenSomethingIsChampioned(ABILITY_SOURCE_OF_THIS, HasSubType.instance(SubType.FAERIE))); Target target = this.addTarget(Players.instance(), "target player"); this.addEffect( tap( Intersect.instance( LandPermanents.instance(), ControlledBy.instance(targetedBy(target))), "Tap all lands target player controls.")); }
public SelhoffOccultistAbility0(GameState state) { super( state, "Whenever Selhoff Occultist or another creature dies, target player puts the top card of his or her library into his or her graveyard."); this.addPattern( whenXDies(Union.instance(ABILITY_SOURCE_OF_THIS, CreaturePermanents.instance()))); SetGenerator target = targetedBy(this.addTarget(Players.instance(), "target player")); this.addEffect( millCards( target, 1, "Target player puts the top card of his or her library into his or her graveyard.")); }
private Player askForPlayer() { Optional<Player> player; do { player = Dialogs.create() .owner(null) .title("Double Jeopardy!") .masthead(null) .message("You have encountered a Double Jeopardy!\nWhich player are you?") .showChoices(Players.getPlayerList()); } while (player == null); return player.get(); }
public ScrapyardSalvo(GameState state) { super(state); // Scrapyard Salvo deals damage to target player equal to the number of // artifact cards in your graveyard. SetGenerator artifacts = HasType.instance(Type.ARTIFACT); SetGenerator inYourYard = InZone.instance(GraveyardOf.instance(You.instance())); SetGenerator amount = Count.instance(Intersect.instance(artifacts, inYourYard)); SetGenerator target = targetedBy(this.addTarget(Players.instance(), "target player")); this.addEffect( spellDealDamage( amount, target, "Scrapyard Salvo deals damage to target player equal to the number of artifact cards in your graveyard.")); }
public DeathriteShamanAbility2(GameState state) { super(state, "(G), (T): Exile target creature card from a graveyard. You gain 2 life."); this.setManaCost(new ManaPool("(G)")); this.costsTap = true; SetGenerator target = targetedBy( this.addTarget( Intersect.instance( HasType.instance(Type.CREATURE), InZone.instance(GraveyardOf.instance(Players.instance()))), "target creature card in a graveyard")); this.addEffect(exile(target, "Exile target creature card from a graveyard.")); this.addEffect(gainLife(You.instance(), 2, "You gain 2 life.")); }
public ZombiePT(GameState state) { super( state, "Soulless One's power and toughness are each equal to the number of Zombies on the battlefield plus the number of Zombie cards in all graveyards.", Characteristics.Characteristic.POWER, Characteristics.Characteristic.TOUGHNESS); SetGenerator aliveAndDead = InZone.instance( Union.instance(Battlefield.instance(), GraveyardOf.instance(Players.instance()))); SetGenerator zombiesAndDeadZombies = Intersect.instance(HasSubType.instance(SubType.ZOMBIE), aliveAndDead); SetGenerator number = Count.instance(zombiesAndDeadZombies); this.addEffectPart(setPowerAndToughness(This.instance(), number, number)); }
public Ten(GameState state) { super( state, "When Magister Sphinx enters the battlefield, target player's life total becomes 10."); this.addPattern(whenThisEntersTheBattlefield()); Target target = this.addTarget(Players.instance(), "target player"); EventFactory factory = new EventFactory(EventType.SET_LIFE, "Target player's life total becomes 10"); factory.parameters.put(EventType.Parameter.CAUSE, This.instance()); factory.parameters.put(EventType.Parameter.NUMBER, numberGenerator(10)); factory.parameters.put(EventType.Parameter.PLAYER, targetedBy(target)); this.addEffect(factory); }
public Lavalanche(GameState state) { super(state); Target target = this.addTarget(Players.instance(), "target player"); SetGenerator victims = Union.instance( targetedBy(target), Intersect.instance( CreaturePermanents.instance(), ControlledBy.instance(targetedBy(target)))); this.addEffect( spellDealDamage( ValueOfX.instance(This.instance()), victims, "Lavalanche deals X damage to target player and each creature he or she controls.")); }
@Override public void onDisable() { try { Bukkit.getScheduler().cancelTasks(this); if (plugin == null) { return; } Vanilla.removeCustomRecipes(); Furnaces.save(); Furnaces.clean(); BrewingStands.save(); BrewingStands.clean(); Workbenches.clean(); Players.clean(); Vanilla.clean(); recipes.clean(); recipes = null; recipeBooks.clean(); recipeBooks = null; events.clean(); events = null; Settings.clean(); Econ.getInstance().clean(); Perms.getInstance().clean(); if (metrics != null) { metrics.stop(); metrics = null; } plugin = null; } catch (Throwable e) { MessageSender.getInstance().error(null, e, null); } }
public DeathriteShamanAbility1(GameState state) { super( state, "(B), (T): Exile target instant or sorcery card from a graveyard. Each opponent loses 2 life."); this.setManaCost(new ManaPool("(B)")); this.costsTap = true; SetGenerator target = targetedBy( this.addTarget( Intersect.instance( HasType.instance(Type.INSTANT, Type.SORCERY), InZone.instance(GraveyardOf.instance(Players.instance()))), "target instant or sorcery card in a graveyard")); this.addEffect(exile(target, "Exile target instant or sorcery card from a graveyard.")); this.addEffect( loseLife(OpponentsOf.instance(You.instance()), 2, "Each opponent loses 2 life.")); }
public AllyLife(GameState state) { super( state, "Whenever Hagra Diabolist or another Ally enters the battlefield under your control, you may have target player lose life equal to the number of Allies you control."); this.addPattern(allyTrigger()); Target target = this.addTarget(Players.instance(), "target player"); EventFactory lifeFactory = loseLife( targetedBy(target), Count.instance(ALLIES_YOU_CONTROL), "Target player loses life equal to the number of Allies you control"); this.addEffect( youMay( lifeFactory, "You may have target player lose life equal to the number of Allies you control.")); }
public TapForThreeDamage(GameState state) { super(state, "(T): Lightning Crafter deals 3 damage to target creature or player."); this.costsTap = true; Target target = this.addTarget( Union.instance( Players.instance(), Intersect.instance( HasType.instance(Type.CREATURE), InZone.instance(Battlefield.instance()))), "target creature or player"); this.addEffect( permanentDealDamage( 3, targetedBy(target), "Lightning Crafter deals 3 damage to target creature or player.")); }
public BlueSunsZenith(GameState state) { super(state); // Target player draws X cards. SetGenerator target = targetedBy(this.addTarget(Players.instance(), "target player")); this.addEffect( drawCards(target, ValueOfX.instance(This.instance()), "Target player draws X cards.")); // Shuffle Blue Sun's Zenith into its owner's library. EventFactory shuffle = new EventFactory( EventType.SHUFFLE_INTO_LIBRARY, "Shuffle Blue Sun's Zenith into its owner's library."); shuffle.parameters.put(EventType.Parameter.CAUSE, This.instance()); shuffle.parameters.put( EventType.Parameter.OBJECT, Union.instance(This.instance(), You.instance())); this.addEffect(shuffle); }
public VentSentinelAbility1(GameState state) { super( state, "(1)(R), (T): Vent Sentinel deals damage to target player equal to the number of creatures with defender you control."); this.setManaCost(new ManaPool("(1)(R)")); this.costsTap = true; SetGenerator amount = Count.instance( Intersect.instance( CREATURES_YOU_CONTROL, HasKeywordAbility.instance(Defender.class))); SetGenerator target = targetedBy(this.addTarget(Players.instance(), "target player")); this.addEffect( permanentDealDamage( amount, target, "Vent Sentinel deals damage to target player equal to the number of creatures with defender you control.")); }