mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
commit
4cee603515
15 changed files with 268 additions and 81 deletions
|
@ -1321,7 +1321,6 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
break;
|
||||
case CLIENT_DISCONNECT:
|
||||
if (SessionHandler.isConnected()) {
|
||||
endTables();
|
||||
SessionHandler.disconnect(false);
|
||||
}
|
||||
tablesPane.clearChat();
|
||||
|
@ -1351,7 +1350,6 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
break;
|
||||
case CLIENT_EXIT:
|
||||
if (SessionHandler.isConnected()) {
|
||||
endTables();
|
||||
SessionHandler.disconnect(false);
|
||||
}
|
||||
CardRepository.instance.closeDB();
|
||||
|
|
|
@ -418,7 +418,12 @@ class UpdateSeatsTask extends SwingWorker<Void, TableView> {
|
|||
@Override
|
||||
protected Void doInBackground() throws Exception {
|
||||
while (!isCancelled()) {
|
||||
SessionHandler.getTable(roomId, tableId).ifPresent(this::publish);
|
||||
Optional<TableView> tableView = SessionHandler.getTable(roomId, tableId);
|
||||
if (tableView.isPresent()) {
|
||||
tableView.ifPresent(this::publish);
|
||||
} else {
|
||||
dialog.closeDialog();
|
||||
}
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -41,7 +41,7 @@ public class MageVersion implements Serializable, Comparable<MageVersion> {
|
|||
public final static int MAGE_VERSION_MAJOR = 1;
|
||||
public final static int MAGE_VERSION_MINOR = 4;
|
||||
public final static int MAGE_VERSION_PATCH = 26;
|
||||
public final static String MAGE_VERSION_MINOR_PATCH = "V0";
|
||||
public final static String MAGE_VERSION_MINOR_PATCH = "V1";
|
||||
public final static String MAGE_VERSION_INFO = "";
|
||||
|
||||
private final int major;
|
||||
|
|
|
@ -27,6 +27,9 @@
|
|||
*/
|
||||
package mage.server;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import mage.interfaces.callback.ClientCallback;
|
||||
import mage.interfaces.callback.ClientCallbackMethod;
|
||||
import mage.view.ChatMessage;
|
||||
|
@ -35,10 +38,6 @@ import mage.view.ChatMessage.MessageType;
|
|||
import mage.view.ChatMessage.SoundToPlay;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
|
@ -78,7 +77,7 @@ public class ChatSession {
|
|||
}
|
||||
if (userId != null && clients.containsKey(userId)) {
|
||||
String userName = clients.get(userId);
|
||||
if (reason != DisconnectReason.LostConnection) { // for lost connection the user will be reconnected or session expire so no remove of chat yet
|
||||
if (reason != DisconnectReason.LostConnection) { // for lost connection the user will be reconnected or session expire so no removeUserFromAllTables of chat yet
|
||||
clients.remove(userId);
|
||||
logger.debug(userName + '(' + reason.toString() + ')' + " removed from chatId " + chatId);
|
||||
}
|
||||
|
|
|
@ -796,13 +796,21 @@ public class MageServerImpl implements MageServer {
|
|||
@Override
|
||||
public void quitMatch(final UUID gameId, final String sessionId) throws MageException {
|
||||
execute("quitMatch", sessionId, () -> {
|
||||
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||
if (!session.isPresent()) {
|
||||
logger.error("Session not found : " + sessionId);
|
||||
} else {
|
||||
UUID userId = session.get().getUserId();
|
||||
try {
|
||||
callExecutor.execute(
|
||||
() -> {
|
||||
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||
if (!session.isPresent()) {
|
||||
logger.error("Session not found : " + sessionId);
|
||||
} else {
|
||||
UUID userId = session.get().getUserId();
|
||||
GameManager.instance.quitMatch(gameId, userId);
|
||||
}
|
||||
|
||||
GameManager.instance.quitMatch(gameId, userId);
|
||||
}
|
||||
);
|
||||
} catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -810,33 +818,51 @@ public class MageServerImpl implements MageServer {
|
|||
@Override
|
||||
public void quitTournament(final UUID tournamentId, final String sessionId) throws MageException {
|
||||
execute("quitTournament", sessionId, () -> {
|
||||
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||
if (!session.isPresent()) {
|
||||
logger.error("Session not found : " + sessionId);
|
||||
} else {
|
||||
UUID userId = session.get().getUserId();
|
||||
try {
|
||||
callExecutor.execute(
|
||||
() -> {
|
||||
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||
if (!session.isPresent()) {
|
||||
logger.error("Session not found : " + sessionId);
|
||||
} else {
|
||||
UUID userId = session.get().getUserId();
|
||||
|
||||
TournamentManager.instance.quit(tournamentId, userId);
|
||||
TournamentManager.instance.quit(tournamentId, userId);
|
||||
}
|
||||
}
|
||||
);
|
||||
} catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public void quitDraft(final UUID draftId, final String sessionId) throws MageException {
|
||||
execute("quitDraft", sessionId, () -> {
|
||||
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||
if (!session.isPresent()) {
|
||||
logger.error("Session not found : " + sessionId);
|
||||
} else {
|
||||
UUID userId = session.get().getUserId();
|
||||
UUID tableId = DraftManager.instance.getControllerByDraftId(draftId).getTableId();
|
||||
Table table = TableManager.instance.getTable(tableId);
|
||||
if (table.isTournament()) {
|
||||
UUID tournamentId = table.getTournament().getId();
|
||||
TournamentManager.instance.quit(tournamentId, userId);
|
||||
}
|
||||
try {
|
||||
callExecutor.execute(
|
||||
() -> {
|
||||
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||
if (!session.isPresent()) {
|
||||
logger.error("Session not found : " + sessionId);
|
||||
} else {
|
||||
UUID userId = session.get().getUserId();
|
||||
UUID tableId = DraftManager.instance.getControllerByDraftId(draftId).getTableId();
|
||||
Table table = TableManager.instance.getTable(tableId);
|
||||
if (table.isTournament()) {
|
||||
UUID tournamentId = table.getTournament().getId();
|
||||
TournamentManager.instance.quit(tournamentId, userId);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
} catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1257,6 +1283,7 @@ public class MageServerImpl implements MageServer {
|
|||
@Override
|
||||
public List<CardInfo> getMissingCardsData(List<String> classNames) {
|
||||
return CardRepository.instance.getMissingCards(classNames);
|
||||
|
||||
}
|
||||
|
||||
private static class MyActionWithNullNegativeResult extends ActionWithNullNegativeResult<Object> {
|
||||
|
|
|
@ -356,7 +356,7 @@ public class Session {
|
|||
} else {
|
||||
logger.error("SESSION LOCK - kill: userId " + userId);
|
||||
}
|
||||
UserManager.instance.removeUser(userId, reason);
|
||||
UserManager.instance.removeUserFromAllTables(userId, reason);
|
||||
} catch (InterruptedException ex) {
|
||||
logger.error("SESSION LOCK - kill: userId " + userId, ex);
|
||||
} finally {
|
||||
|
|
|
@ -511,7 +511,7 @@ public class TableController {
|
|||
if (this.userId != null && this.userId.equals(userId) // tourn. sub tables have no creator user
|
||||
&& (table.getState() == TableState.WAITING
|
||||
|| table.getState() == TableState.READY_TO_START)) {
|
||||
// table not started yet and user is the owner, remove the table
|
||||
// table not started yet and user is the owner, removeUserFromAllTables the table
|
||||
TableManager.instance.removeTable(table.getId());
|
||||
} else {
|
||||
UUID playerId = userPlayerMap.get(userId);
|
||||
|
@ -826,7 +826,7 @@ public class TableController {
|
|||
}
|
||||
user.showUserMessage("Match info", sb.toString());
|
||||
}
|
||||
// remove table from user - table manager holds table for display of finished matches
|
||||
// removeUserFromAllTables table from user - table manager holds table for display of finished matches
|
||||
if (!table.isTournamentSubTable()) {
|
||||
user.removeTable(entry.getValue());
|
||||
}
|
||||
|
@ -913,7 +913,7 @@ public class TableController {
|
|||
return false;
|
||||
}
|
||||
} else {
|
||||
// check if table creator is still a valid user, if not remove table
|
||||
// check if table creator is still a valid user, if not removeUserFromAllTables table
|
||||
return UserManager.instance.getUser(userId).isPresent();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -161,7 +161,7 @@ public enum TableManager {
|
|||
}
|
||||
}
|
||||
|
||||
// remove user from all tournament sub tables
|
||||
// removeUserFromAllTables user from all tournament sub tables
|
||||
public void userQuitTournamentSubTables(UUID userId) {
|
||||
for (TableController controller : controllers.values()) {
|
||||
if (controller.getTable() != null) {
|
||||
|
@ -174,7 +174,7 @@ public enum TableManager {
|
|||
}
|
||||
}
|
||||
|
||||
// remove user from all sub tables of a tournament
|
||||
// removeUserFromAllTables user from all sub tables of a tournament
|
||||
public void userQuitTournamentSubTables(UUID tournamentId, UUID userId) {
|
||||
for (TableController controller : controllers.values()) {
|
||||
if (controller.getTable().isTournamentSubTable() && controller.getTable().getTournament().getId().equals(tournamentId)) {
|
||||
|
@ -386,8 +386,8 @@ public enum TableManager {
|
|||
for (Table table : tableCopy) {
|
||||
try {
|
||||
if (table.getState() != TableState.FINISHED
|
||||
&& ((System.currentTimeMillis() - table.getStartTime().getTime()) / 1000) > 30) { // remove only if table started longer than 30 seconds ago
|
||||
// remove tables and games not valid anymore
|
||||
&& ((System.currentTimeMillis() - table.getStartTime().getTime()) / 1000) > 30) { // removeUserFromAllTables only if table started longer than 30 seconds ago
|
||||
// removeUserFromAllTables tables and games not valid anymore
|
||||
logger.debug(table.getId() + " [" + table.getName() + "] " + formatter.format(table.getStartTime() == null ? table.getCreateTime() : table.getCreateTime()) + " (" + table.getState().toString() + ") " + (table.isTournament() ? "- Tournament" : ""));
|
||||
getController(table.getId()).ifPresent(tableController -> {
|
||||
if ((table.isTournament() && !tableController.isTournamentStillValid())
|
||||
|
|
|
@ -437,7 +437,7 @@ public class User {
|
|||
sideboarding.remove(tableId);
|
||||
}
|
||||
|
||||
public void remove(DisconnectReason reason) {
|
||||
public void removeUserFromAllTables(DisconnectReason reason) {
|
||||
logger.trace("REMOVE " + userName + " Draft sessions " + draftSessions.size());
|
||||
for (DraftSession draftSession : draftSessions.values()) {
|
||||
draftSession.setKilled();
|
||||
|
|
|
@ -112,6 +112,7 @@ public enum UserManager {
|
|||
if (user.isPresent()) {
|
||||
user.get().setSessionId("");
|
||||
if (reason == DisconnectReason.Disconnected) {
|
||||
removeUserFromAllTables(userId, reason);
|
||||
user.get().setUserState(UserState.Offline);
|
||||
}
|
||||
}
|
||||
|
@ -130,19 +131,17 @@ public enum UserManager {
|
|||
return false;
|
||||
}
|
||||
|
||||
public void removeUser(final UUID userId, final DisconnectReason reason) {
|
||||
public void removeUserFromAllTables(final UUID userId, final DisconnectReason reason) {
|
||||
if (userId != null) {
|
||||
getUser(userId).ifPresent(user
|
||||
-> USER_EXECUTOR.execute(
|
||||
() -> {
|
||||
try {
|
||||
LOGGER.info("USER REMOVE - " + user.getName() + " (" + reason.toString() + ") userId: " + userId + " [" + user.getGameInfo() + ']');
|
||||
user.remove(reason);
|
||||
user.removeUserFromAllTables(reason);
|
||||
LOGGER.debug("USER REMOVE END - " + user.getName());
|
||||
} catch (Exception ex) {
|
||||
handleException(ex);
|
||||
} finally {
|
||||
users.remove(userId);
|
||||
}
|
||||
}
|
||||
));
|
||||
|
@ -168,26 +167,39 @@ public enum UserManager {
|
|||
*
|
||||
*/
|
||||
private void checkExpired() {
|
||||
Calendar calendarExp = Calendar.getInstance();
|
||||
calendarExp.add(Calendar.MINUTE, -3);
|
||||
Calendar calendarRemove = Calendar.getInstance();
|
||||
calendarRemove.add(Calendar.MINUTE, -8);
|
||||
List<User> toRemove = new ArrayList<>();
|
||||
for (User user : users.values()) {
|
||||
if (user.getUserState() != UserState.Offline
|
||||
&& user.isExpired(calendarExp.getTime())) {
|
||||
if (user.getUserState() == UserState.Connected) {
|
||||
user.lostConnection();
|
||||
disconnect(user.getId(), DisconnectReason.BecameInactive);
|
||||
try {
|
||||
Calendar calendarExp = Calendar.getInstance();
|
||||
calendarExp.add(Calendar.MINUTE, -3);
|
||||
Calendar calendarRemove = Calendar.getInstance();
|
||||
calendarRemove.add(Calendar.MINUTE, -8);
|
||||
List<User> toRemove = new ArrayList<>();
|
||||
for (User user : users.values()) {
|
||||
try {
|
||||
if (user.getUserState() == UserState.Offline) {
|
||||
if (user.isExpired(calendarRemove.getTime())) {
|
||||
toRemove.add(user);
|
||||
}
|
||||
} else {
|
||||
if (user.isExpired(calendarExp.getTime())) {
|
||||
if (user.getUserState() == UserState.Connected) {
|
||||
user.lostConnection();
|
||||
disconnect(user.getId(), DisconnectReason.BecameInactive);
|
||||
}
|
||||
removeUserFromAllTables(user.getId(), DisconnectReason.SessionExpired);
|
||||
user.setUserState(UserState.Offline);
|
||||
// Remove the user from all tournaments
|
||||
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
user.setUserState(UserState.Offline);
|
||||
}
|
||||
if (user.getUserState() == UserState.Offline && user.isExpired(calendarRemove.getTime())) {
|
||||
toRemove.add(user);
|
||||
for (User user : toRemove) {
|
||||
users.remove(user.getId());
|
||||
}
|
||||
}
|
||||
for (User user : toRemove) {
|
||||
removeUser(user.getId(), DisconnectReason.SessionExpired);
|
||||
} catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -196,23 +208,27 @@ public enum UserManager {
|
|||
*
|
||||
*/
|
||||
private void updateUserInfoList() {
|
||||
List<UserView> newUserInfoList = new ArrayList<>();
|
||||
for (User user : UserManager.instance.getUsers()) {
|
||||
newUserInfoList.add(new UserView(
|
||||
user.getName(),
|
||||
user.getHost(),
|
||||
user.getSessionId(),
|
||||
user.getConnectionTime(),
|
||||
user.getLastActivity(),
|
||||
user.getGameInfo(),
|
||||
user.getUserState().toString(),
|
||||
user.getChatLockedUntil(),
|
||||
user.getClientVersion(),
|
||||
user.getEmail(),
|
||||
user.getUserIdStr()
|
||||
));
|
||||
try {
|
||||
List<UserView> newUserInfoList = new ArrayList<>();
|
||||
for (User user : UserManager.instance.getUsers()) {
|
||||
newUserInfoList.add(new UserView(
|
||||
user.getName(),
|
||||
user.getHost(),
|
||||
user.getSessionId(),
|
||||
user.getConnectionTime(),
|
||||
user.getLastActivity(),
|
||||
user.getGameInfo(),
|
||||
user.getUserState().toString(),
|
||||
user.getChatLockedUntil(),
|
||||
user.getClientVersion(),
|
||||
user.getEmail(),
|
||||
user.getUserIdStr()
|
||||
));
|
||||
}
|
||||
userInfoList = newUserInfoList;
|
||||
} catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
userInfoList = newUserInfoList;
|
||||
}
|
||||
|
||||
public List<UserView> getUserInfoList() {
|
||||
|
|
|
@ -95,7 +95,7 @@ public class GamesRoomImpl extends RoomImpl implements GamesRoom, Serializable {
|
|||
} else if (matchList.size() < 50) {
|
||||
matchList.add(new MatchView(table));
|
||||
} else {
|
||||
// more since 50 matches finished since this match so remove it
|
||||
// more since 50 matches finished since this match so removeUserFromAllTables it
|
||||
if (table.isTournament()) {
|
||||
TournamentManager.instance.removeTournament(table.getTournament().getId());
|
||||
}
|
||||
|
|
140
Mage.Sets/src/mage/cards/m/MinionOfLeshrac.java
Normal file
140
Mage.Sets/src/mage/cards/m/MinionOfLeshrac.java
Normal file
|
@ -0,0 +1,140 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.cards.m;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.common.SacrificeTargetCost;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.DestroyTargetEffect;
|
||||
import mage.abilities.keyword.ProtectionAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.TargetController;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.common.FilterControlledPermanent;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.mageobject.CardTypePredicate;
|
||||
import mage.filter.predicate.permanent.AnotherPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.target.common.TargetControlledPermanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jeffwadsworth
|
||||
*/
|
||||
public class MinionOfLeshrac extends CardImpl {
|
||||
|
||||
private static final FilterPermanent filterCreatureOrLand = new FilterPermanent("creature or land");
|
||||
|
||||
static {
|
||||
filterCreatureOrLand.add(Predicates.or(new CardTypePredicate(CardType.CREATURE), new CardTypePredicate(CardType.LAND)));
|
||||
}
|
||||
|
||||
public MinionOfLeshrac(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{B}{B}{B}");
|
||||
|
||||
this.subtype.add("Demon");
|
||||
this.subtype.add("Minion");
|
||||
this.power = new MageInt(5);
|
||||
this.toughness = new MageInt(5);
|
||||
|
||||
// Protection from black
|
||||
this.addAbility(ProtectionAbility.from(ObjectColor.BLACK));
|
||||
|
||||
// At the beginning of your upkeep, Minion of Leshrac deals 5 damage to you unless you sacrifice a creature other than Minion of Leshrac. If Minion of Leshrac deals damage to you this way, tap it.
|
||||
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new MinionLeshracEffect(), TargetController.YOU, false));
|
||||
|
||||
// {tap}: Destroy target creature or land.
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DestroyTargetEffect(), new TapSourceCost());
|
||||
ability.addTarget(new TargetPermanent(filterCreatureOrLand));
|
||||
this.addAbility(ability);
|
||||
|
||||
}
|
||||
|
||||
public MinionOfLeshrac(final MinionOfLeshrac card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MinionOfLeshrac copy() {
|
||||
return new MinionOfLeshrac(this);
|
||||
}
|
||||
}
|
||||
|
||||
class MinionLeshracEffect extends OneShotEffect {
|
||||
|
||||
public MinionLeshracEffect() {
|
||||
super(Outcome.Sacrifice);
|
||||
staticText = "{this} deals 5 damage to you unless you sacrifice a creature other than {this}. If {this} deals damage to you this way, tap it";
|
||||
}
|
||||
|
||||
public MinionLeshracEffect(final MinionLeshracEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Permanent minionLeshrac = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||
if (controller != null
|
||||
&& minionLeshrac != null) {
|
||||
FilterControlledPermanent filterCreature = new FilterControlledPermanent();
|
||||
filterCreature.add(new CardTypePredicate(CardType.CREATURE));
|
||||
filterCreature.add(new AnotherPredicate());
|
||||
TargetControlledPermanent target = new TargetControlledPermanent(filterCreature);
|
||||
SacrificeTargetCost cost = new SacrificeTargetCost(target);
|
||||
if (controller.chooseUse(Outcome.AIDontUseIt, "Do you wish to sacrifice another creature to prevent the 5 damage to you?", source, game)
|
||||
&& cost.canPay(source, source.getSourceId(), source.getControllerId(), game)
|
||||
&& cost.pay(source, game, source.getSourceId(), source.getControllerId(), true)) {
|
||||
return true;
|
||||
}
|
||||
if (controller.damage(5, minionLeshrac.getId(), game, false, true) > 0) {
|
||||
minionLeshrac.tap(game);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MinionLeshracEffect copy() {
|
||||
return new MinionLeshracEffect(this);
|
||||
}
|
||||
}
|
|
@ -196,6 +196,7 @@ public class IceAge extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Mesmeric Trance", 83, Rarity.RARE, mage.cards.m.MesmericTrance.class));
|
||||
cards.add(new SetCardInfo("Mind Ravel", 35, Rarity.COMMON, mage.cards.m.MindRavel.class));
|
||||
cards.add(new SetCardInfo("Mind Warp", 36, Rarity.UNCOMMON, mage.cards.m.MindWarp.class));
|
||||
cards.add(new SetCardInfo("Minion of Leshrac", 38, Rarity.RARE, mage.cards.m.MinionOfLeshrac.class));
|
||||
cards.add(new SetCardInfo("Mole Worms", 40, Rarity.UNCOMMON, mage.cards.m.MoleWorms.class));
|
||||
cards.add(new SetCardInfo("Moor Fiend", 41, Rarity.COMMON, mage.cards.m.MoorFiend.class));
|
||||
cards.add(new SetCardInfo("Mountain", 340, Rarity.LAND, mage.cards.basiclands.Mountain.class, NON_FULL_USE_VARIOUS));
|
||||
|
|
|
@ -164,6 +164,7 @@ public class MastersEditionII extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Mana Crypt", 214, Rarity.RARE, mage.cards.m.ManaCrypt.class));
|
||||
cards.add(new SetCardInfo("Marjhan", 54, Rarity.RARE, mage.cards.m.Marjhan.class));
|
||||
cards.add(new SetCardInfo("Mesmeric Trance", 55, Rarity.RARE, mage.cards.m.MesmericTrance.class));
|
||||
cards.add(new SetCardInfo("Minion of Leshrac", 104, Rarity.RARE, mage.cards.m.MinionOfLeshrac.class));
|
||||
cards.add(new SetCardInfo("Mudslide", 136, Rarity.RARE, mage.cards.m.Mudslide.class));
|
||||
cards.add(new SetCardInfo("Narwhal", 57, Rarity.UNCOMMON, mage.cards.n.Narwhal.class));
|
||||
cards.add(new SetCardInfo("Necrite", 106, Rarity.COMMON, Necrite.class));
|
||||
|
|
|
@ -58,7 +58,7 @@ public enum CardRepository {
|
|||
// raise this if db structure was changed
|
||||
private static final long CARD_DB_VERSION = 51;
|
||||
// raise this if new cards were added to the server
|
||||
private static final long CARD_CONTENT_VERSION = 86;
|
||||
private static final long CARD_CONTENT_VERSION = 87;
|
||||
private final TreeSet<String> landTypes = new TreeSet<>();
|
||||
private Dao<CardInfo, Object> cardDao;
|
||||
private Set<String> classNames;
|
||||
|
|
Loading…
Reference in a new issue