@Override public Mode chooseMode(Modes modes, Ability source, Game game) { Iterator<Mode> it = modes.values().iterator(); Mode mode = it.next(); if (modes.size() == 1) return mode; int modeNum = rnd.nextInt(modes.values().size()); for (int i = 0; i < modeNum; i++) { mode = it.next(); } return mode; }
protected String getMessageText(Game game) { StringBuilder sb = threadLocalBuilder.get(); MageObject object = game.getObject(this.sourceId); if (object != null) { if (object instanceof StackAbility) { Card card = game.getCard(((StackAbility) object).getSourceId()); if (card != null) { sb.append(GameLog.getColoredObjectIdName(card)); } else { sb.append(GameLog.getColoredObjectIdName(object)); } } else if (object instanceof Spell) { Spell spell = (Spell) object; String castText = spell.getSpellCastText(game); sb.append((castText.startsWith("Cast ") ? castText.substring(5) : castText)); if (spell.getFromZone() == Zone.GRAVEYARD) { sb.append(" from graveyard"); } sb.append(getOptionalTextSuffix(game, spell)); } else { sb.append(GameLog.getColoredObjectIdName(object)); } } else { sb.append("unknown"); } if (object instanceof Spell && ((Spell) object).getSpellAbilities().size() > 1) { if (((Spell) object) .getSpellAbility() .getSpellAbilityType() .equals(SpellAbilityType.SPLIT_FUSED)) { Spell spell = (Spell) object; int i = 0; for (SpellAbility spellAbility : spell.getSpellAbilities()) { i++; String half; if (i == 1) { half = " left"; } else { half = " right"; } if (spellAbility.getTargets().size() > 0) { sb.append(half).append(" half targeting "); for (Target target : spellAbility.getTargets()) { sb.append(target.getTargetedName(game)); } } } } else { Spell spell = (Spell) object; int i = 0; for (SpellAbility spellAbility : spell.getSpellAbilities()) { i++; if (i > 1) { sb.append(" splicing "); if (spellAbility.name.length() > 5 && spellAbility.name.startsWith("Cast ")) { sb.append(spellAbility.name.substring(5)); } else { sb.append(spellAbility.name); } } sb.append(getTargetDescriptionForLog(spellAbility.getTargets(), game)); } } } else if (object instanceof Spell && ((Spell) object).getSpellAbility().getModes().size() > 1) { Modes spellModes = ((Spell) object).getSpellAbility().getModes(); for (Mode selectedMode : spellModes.getSelectedModes()) { int item = 0; for (Mode mode : spellModes.values()) { item++; if (mode.getId().equals(selectedMode.getId())) { sb.append(" (mode ").append(item).append(")"); sb.append(getTargetDescriptionForLog(selectedMode.getTargets(), game)); break; } } } } else { sb.append(getTargetDescriptionForLog(getTargets(), game)); } return sb.toString(); }