@Override public int getNumberOfSpecialCommons() { // Then about an eighth of the packs will have a second double-faced card, which will be a rare or mythic rare. return RandomUtil.nextInt(8) == 0 ? 1 : 0; }
public String nextString() { for (int idx = 0; idx < buf.length; ++idx) { buf[idx] = symbols[RandomUtil.nextInt(symbols.length)]; } return new String(buf); } }
@Override public int getAmount(int min, int max, String message, Game game) { log.debug("getAmount"); if (message.startsWith("Assign damage to ")) { return min; } //TODO: improve this if (min < max && min == 0) { return RandomUtil.nextInt(max + 1); } return min; }
/** * @param name * @return random card with the provided name or null if none is found */ public CardInfo findCard(String name) { List<CardInfo> cards = findCards(name); if (!cards.isEmpty()) { return cards.get(RandomUtil.nextInt(cards.size())); } return null; }
@Override public TriggeredAbility chooseTriggeredAbility(List<TriggeredAbility> abilities, Game game) { if (this.isHuman()) { return abilities.get(RandomUtil.nextInt(abilities.size())); } return super.chooseTriggeredAbility(abilities, game); }
@Override public int chooseReplacementEffect(Map<String, String> rEffects, Game game) { if (this.isHuman()) { return RandomUtil.nextInt(rEffects.size()); } return super.chooseReplacementEffect(rEffects, game); }
@Override public void setExpansionSetCodeForImage(String code) { super.setExpansionSetCodeForImage(code); if (getOriginalExpansionSetCode().equals("BFZ")) { this.setTokenType(RandomUtil.nextInt(3) + 1); // 3 different images } if (getOriginalExpansionSetCode().equals("OGW")) { this.setTokenType(RandomUtil.nextInt(6) + 1); // 6 different images } }
@Override public UUID chooseAttackerOrder(List<Permanent> attackers, Game game) { if (this.isHuman()) { return attackers.get(RandomUtil.nextInt(attackers.size())).getId(); } return super.chooseAttackerOrder(attackers, game); }
@Override public UUID chooseBlockerOrder(List<Permanent> blockers, CombatGroup combatGroup, List<UUID> blockerOrder, Game game) { if (this.isHuman()) { return blockers.get(RandomUtil.nextInt(blockers.size())).getId(); } return super.chooseBlockerOrder(blockers, combatGroup, blockerOrder, game); }
@Override public void setExpansionSetCodeForImage(String code) { super.setExpansionSetCodeForImage(code); if (getOriginalExpansionSetCode().equals("KTK")) { this.setTokenType(RandomUtil.nextInt(2) + 1); } } }
@Override public void setExpansionSetCodeForImage(String code) { super.setExpansionSetCodeForImage(code); if (getOriginalExpansionSetCode() != null && getOriginalExpansionSetCode().equals("ORI")) { this.setTokenType(RandomUtil.nextInt(2) + 1); } if (getOriginalExpansionSetCode() != null && getOriginalExpansionSetCode().equals("KLD")) { this.setTokenType(RandomUtil.nextInt(3) + 1); } }
public MetallurgicSummoningsConstructToken(int xValue) { super("Construct", "X/X colorless Construct artifact creature token"); setOriginalExpansionSetCode("KLD"); setTokenType(RandomUtil.nextInt(2) + 1); cardType.add(CardType.ARTIFACT); cardType.add(CardType.CREATURE); subtype.add(SubType.CONSTRUCT); power = new MageInt(xValue); toughness = new MageInt(xValue); } public MetallurgicSummoningsConstructToken(final MetallurgicSummoningsConstructToken token) {
@Override public void setExpansionSetCodeForImage(String code) { super.setExpansionSetCodeForImage(code); if (getOriginalExpansionSetCode() != null && getOriginalExpansionSetCode().equals("KLD")) { this.setTokenType(RandomUtil.nextInt(3) + 1); } }
@Override public void setExpansionSetCodeForImage(String code) { super.setExpansionSetCodeForImage(code); if (getOriginalExpansionSetCode() != null && getOriginalExpansionSetCode().equals("THS")) { this.setTokenType(RandomUtil.nextInt(2) + 1); } if (getOriginalExpansionSetCode() != null && getOriginalExpansionSetCode().equals("CN2") || getOriginalExpansionSetCode().equals("MM3")) { setTokenType(1); } }
@Override public Card getRandom(Game game) { if (this.isEmpty()) { return null; } UUID[] cards = this.toArray(new UUID[this.size()]); MageObject object = game.getObject(cards[RandomUtil.nextInt(cards.length)]); // neccessary if permanent tokens are in the collection if (object instanceof Card) { return (Card) object; } return null; }
public CentaurToken() { super("Centaur", "3/3 green Centaur creature token"); cardType.add(CardType.CREATURE); availableImageSetCodes = tokenImageSets; if (getOriginalExpansionSetCode() != null && getOriginalExpansionSetCode().equals("RNA")) { setTokenType(RandomUtil.nextInt(2) + 1); // randomly take image 1 or 2 } color.setGreen(true); subtype.add(SubType.CENTAUR); power = new MageInt(3); toughness = new MageInt(3); }
public MoltenBirthElementalToken() { super("Elemental", "1/1 red Elemental creature"); this.setOriginalExpansionSetCode("M14"); this.setTokenType(RandomUtil.nextInt(2) + 1); cardType.add(CardType.CREATURE); color.setRed(true); subtype.add(SubType.ELEMENTAL); power = new MageInt(1); toughness = new MageInt(1); }
@Override public boolean apply(Game game, Ability source) { List<Permanent> creatureList = game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), game); if (creatureList.size() < 2) { return true; } int toSave = RandomUtil.nextInt(creatureList.size()); FilterCreaturePermanent filter = new FilterCreaturePermanent(); filter.add(Predicates.not(new PermanentIdPredicate(creatureList.get(toSave).getId()))); return new DestroyAllEffect(filter).apply(game, source); } }
public EldraziSpawnToken() { super("Eldrazi Spawn", "0/1 colorless Eldrazi Spawn creature with \"Sacrifice this creature: Add {C}.\""); cardType.add(CardType.CREATURE); subtype.add(SubType.ELDRAZI); subtype.add(SubType.SPAWN); power = new MageInt(0); toughness = new MageInt(1); addAbility(new SimpleManaAbility(Zone.BATTLEFIELD, Mana.ColorlessMana(1), new SacrificeSourceCost())); availableImageSetCodes = tokenImageSets; // Get one of the four possible token images this.setTokenType(RandomUtil.nextInt(4) + 1); }
@Override public boolean apply(Game game, Ability source) { PlayerList players = game.getState().getPlayersInRange(source.getControllerId(), game); int count = players.size(); for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterNonlandPermanent(), source.getControllerId(), source.getSourceId(), game)) { ContinuousEffect effect = new GainControlTargetEffect(Duration.Custom, true, players.get(RandomUtil.nextInt(count))); effect.setTargetPointer(new FixedTarget(permanent.getId())); game.addEffect(effect, source); permanent.untap(game); } return true; }