This commit is contained in:
magenoxx 2014-08-11 17:45:53 +04:00
commit e6750f2f58
13 changed files with 486 additions and 19 deletions

View file

@ -222,7 +222,7 @@ public class MageServerImpl implements MageServer {
if (logger.isDebugEnabled()) {
User user = UserManager.getInstance().getUser(userId);
if (user != null) {
logger.debug("join tourn. tableId: " + tableId + " " + user.getName());
logger.debug("join tourn. tableId: " + tableId + " " + name);
}
}
if (userId == null) {

View file

@ -230,7 +230,7 @@ public class TableManager {
removeTable(tableId);
} else {
logger.debug("TableManager.leaveTable leaveTable");
logger.debug("TABLE leave - userId: " + userId + " tableId: " + tableId);
tableController.leaveTable(userId);
}
}

View file

@ -203,9 +203,9 @@ public class TournamentController {
}
private synchronized void startTournament() {
for (final Entry<UUID, TournamentSession> entry: tournamentSessions.entrySet()) {
if (!entry.getValue().init()) {
logger.fatal("Unable to initialize client");
for (final TournamentSession tournamentSession: tournamentSessions.values()) {
if (!tournamentSession.init()) {
logger.fatal("Unable to initialize client userId: " + tournamentSession.userId + " tournamentId " + tournament.getId());
//TODO: generate client error message
return;
}
@ -220,7 +220,6 @@ public class TournamentController {
}
for (final TournamentSession tournamentSession: tournamentSessions.values()) {
tournamentSession.tournamentOver();
tournamentSession.removeTournamentForUser();
}
this.tournamentSessions.clear();
TableManager.getInstance().endTournament(tableId, tournament);
@ -344,6 +343,9 @@ public class TournamentController {
}
tPlayer.setQuit(info);
tournament.quit(playerId);
if (tournamentSessions.containsKey(playerId)) {
tournamentSessions.get(tPlayer.getPlayer().getId()).quit();
}
}
} else {
tournament.leave(playerId);

View file

@ -157,13 +157,6 @@ public class TournamentSession {
}
}
public void removeTournamentForUser() {
User user = UserManager.getInstance().getUser(userId);
if (user != null) {
user.removeTournament(playerId);
}
}
private TournamentView getTournamentView() {
return new TournamentView(tournament);
}
@ -172,8 +165,27 @@ public class TournamentSession {
return tournament.getId();
}
void tournamentOver() {
public void tournamentOver() {
cleanUp();
removeTournamentForUser();
}
public void quit() {
cleanUp();
removeTournamentForUser();
}
private void cleanUp() {
if (!futureTimeout.isDone()) {
futureTimeout.cancel(true);
}
}
private void removeTournamentForUser() {
User user = UserManager.getInstance().getUser(userId);
if (user != null) {
user.removeTournament(playerId);
}
}
}

View file

@ -0,0 +1,70 @@
/*
* 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.sets.commander;
import java.util.UUID;
import mage.MageInt;
import static mage.Mana.GreenMana;
import mage.abilities.common.BeginningOfPreCombatMainTriggeredAbility;
import mage.abilities.effects.common.AddManaToManaPoolEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.constants.TargetController;
import mage.constants.Zone;
/**
*
* @author LevelX2
*/
public class MagusOfTheVineyard extends CardImpl {
public MagusOfTheVineyard(UUID ownerId) {
super(ownerId, 166, "Magus of the Vineyard", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{G}");
this.expansionSetCode = "CMD";
this.subtype.add("Human");
this.subtype.add("Wizard");
this.color.setGreen(true);
this.power = new MageInt(1);
this.toughness = new MageInt(1);
// At the beginning of each player's precombat main phase, add {G}{G} to that player's mana pool.
this.addAbility(new BeginningOfPreCombatMainTriggeredAbility(
Zone.BATTLEFIELD, new AddManaToManaPoolEffect(GreenMana(2)), TargetController.ANY, false, true));
}
public MagusOfTheVineyard(final MagusOfTheVineyard card) {
super(card);
}
@Override
public MagusOfTheVineyard copy() {
return new MagusOfTheVineyard(this);
}
}

View file

@ -32,10 +32,8 @@ import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfPreCombatMainTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.delayed.AtTheBeginOfPreCombatMainDelayedTriggeredAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ManaInAnyCombinationEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.mana.AnyColorManaAbility;
import mage.cards.CardImpl;

View file

@ -0,0 +1,122 @@
/*
* 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.sets.futuresight;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.continious.BoostSourceEffect;
import mage.abilities.effects.common.continious.GainAbilityAllEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game;
import mage.game.combat.CombatGroup;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
/**
*
* @author LevelX2
*/
public class FrenzySliver extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("All sliver creatures");
private static final FilterCreaturePermanent targetSliverFilter = new FilterCreaturePermanent("Sliver");
static {
filter.add(new SubtypePredicate("Sliver"));
targetSliverFilter.add(new SubtypePredicate("Sliver"));
}
public FrenzySliver(UUID ownerId) {
super(ownerId, 85, "Frenzy Sliver", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{1}{B}");
this.expansionSetCode = "FUT";
this.subtype.add("Sliver");
this.color.setBlack(true);
this.power = new MageInt(1);
this.toughness = new MageInt(1);
// All Sliver creatures have frenzy 1. (Whenever a Sliver attacks and isn't blocked, it gets +1/+0 until end of turn.)
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAllEffect(
new FrenzyAbility(), Duration.WhileOnBattlefield,
filter, "All Sliver creatures have frenzy 1. <i>(Whenever a Sliver attacks and isn't blocked, it gets +1/+0 until end of turn.)</i>\"")));
}
public FrenzySliver(final FrenzySliver card) {
super(card);
}
@Override
public FrenzySliver copy() {
return new FrenzySliver(this);
}
}
class FrenzyAbility extends TriggeredAbilityImpl {
public FrenzyAbility() {
super(Zone.BATTLEFIELD, new BoostSourceEffect(1,0, Duration.EndOfTurn));
}
public FrenzyAbility(final FrenzyAbility ability) {
super(ability);
}
@Override
public FrenzyAbility copy() {
return new FrenzyAbility(this);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.DECLARED_BLOCKERS) {
Permanent sourcePermanent = game.getPermanent(getSourceId());
if (sourcePermanent.isAttacking()) {
for (CombatGroup combatGroup: game.getCombat().getGroups()) {
if (combatGroup.getBlockers().isEmpty() && combatGroup.getAttackers().contains(getSourceId())) {
return true;
}
}
}
}
return false;
}
@Override
public String getRule() {
return "Frenzy 1. <i>(Whenever this creature attacks and isn't blocked, it gets +1/+0 until end of turn.)</i>";
}
}

View file

@ -0,0 +1,52 @@
/*
* 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.sets.futuresight;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public class MagusOfTheVineyard extends mage.sets.commander.MagusOfTheVineyard {
public MagusOfTheVineyard(UUID ownerId) {
super(ownerId);
this.cardNumber = 132;
this.expansionSetCode = "FUT";
}
public MagusOfTheVineyard(final MagusOfTheVineyard card) {
super(card);
}
@Override
public MagusOfTheVineyard copy() {
return new MagusOfTheVineyard(this);
}
}

View file

@ -0,0 +1,65 @@
/*
* 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.sets.tempest;
import java.util.UUID;
import static mage.Mana.GreenMana;
import mage.abilities.common.BeginningOfPreCombatMainTriggeredAbility;
import mage.abilities.effects.common.AddManaToManaPoolEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.constants.TargetController;
import mage.constants.Zone;
/**
*
* @author LevelX2
*/
public class EladamrisVineyard extends CardImpl {
public EladamrisVineyard(UUID ownerId) {
super(ownerId, 118, "Eladamri's Vineyard", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{G}");
this.expansionSetCode = "TMP";
this.color.setGreen(true);
// At the beginning of each player's precombat main phase, add {G}{G} to that player's mana pool.
this.addAbility(new BeginningOfPreCombatMainTriggeredAbility(
Zone.BATTLEFIELD, new AddManaToManaPoolEffect(GreenMana(2)), TargetController.ANY, false, true));
}
public EladamrisVineyard(final EladamrisVineyard card) {
super(card);
}
@Override
public EladamrisVineyard copy() {
return new EladamrisVineyard(this);
}
}

View file

@ -0,0 +1,94 @@
/*
* 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.sets.timespiral;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.common.continious.BoostTargetEffect;
import mage.abilities.effects.common.continious.GainAbilityAllEffect;
import mage.abilities.keyword.HasteAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.target.common.TargetCreaturePermanent;
/**
*
* @author LevelX2
*/
public class FirewakeSliver extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("All sliver creatures");
private static final FilterCreaturePermanent targetSliverFilter = new FilterCreaturePermanent("Sliver");
static {
filter.add(new SubtypePredicate("Sliver"));
targetSliverFilter.add(new SubtypePredicate("Sliver"));
}
public FirewakeSliver(UUID ownerId) {
super(ownerId, 238, "Firewake Sliver", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{1}{R}{G}");
this.expansionSetCode = "TSP";
this.subtype.add("Sliver");
this.color.setRed(true);
this.color.setGreen(true);
this.power = new MageInt(1);
this.toughness = new MageInt(1);
// All Sliver creatures have haste.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAllEffect(HasteAbility.getInstance(), Duration.WhileOnBattlefield, filter, false)));
// All Slivers have "{1}, Sacrifice this permanent: Target Sliver creature gets +2/+2 until end of turn."
Ability gainedAbility = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BoostTargetEffect(2,2,Duration.EndOfTurn), new GenericManaCost(1));
gainedAbility.addCost(new SacrificeSourceCost());
gainedAbility.addTarget(new TargetCreaturePermanent(targetSliverFilter));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAllEffect(
gainedAbility, Duration.WhileOnBattlefield,
filter, "All Slivers have \"{1}, Sacrifice this permanent: Target Sliver creature gets +2/+2 until end of turn.\"")));
}
public FirewakeSliver(final FirewakeSliver card) {
super(card);
}
@Override
public FirewakeSliver copy() {
return new FirewakeSliver(this);
}
}

View file

@ -87,7 +87,7 @@ public class BeginningOfPreCombatMainTriggeredAbility extends TriggeredAbilityIm
case OPPONENT:
return "At the beginning of each opponent's precombat main phase, " + generateZoneString() + getEffects().getText(modes.getMode());
case ANY:
return "At the beginning of each precombat main phase, " + generateZoneString() + getEffects().getText(modes.getMode());
return "At the beginning of each player's precombat main phase, " + generateZoneString() + getEffects().getText(modes.getMode());
}
return "";
}

View file

@ -156,8 +156,10 @@ public class CostsImpl<T extends Cost> extends ArrayList<T> implements Costs<T>
public Targets getTargets() {
Targets targets = new Targets();
for (T cost: this) {
if (cost.getTargets() != null) {
targets.addAll(cost.getTargets());
}
}
return targets;
}

View file

@ -0,0 +1,50 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mage.abilities.effects.common;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
import mage.game.Game;
import mage.players.Player;
/**
*
* @author LevelX2
*/
public class AddManaToManaPoolEffect extends OneShotEffect {
protected Mana mana;
public AddManaToManaPoolEffect(Mana mana) {
super(Outcome.PutManaInPool);
this.mana = mana;
this.staticText = "add " + mana.toString() + " to that player's mana pool";
}
public AddManaToManaPoolEffect(final AddManaToManaPoolEffect effect) {
super(effect);
this.mana = effect.mana;
}
@Override
public AddManaToManaPoolEffect copy() {
return new AddManaToManaPoolEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
if (player != null) {
player.getManaPool().addMana(mana, game, source);
return true;
}
return false;
}
}