diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/actions/PlayEventAction.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/actions/PlayEventAction.java index 3735ebd61..5b8bcdc2d 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/actions/PlayEventAction.java +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/actions/PlayEventAction.java @@ -151,8 +151,7 @@ public class PlayEventAction extends AbstractCostToEffectAction implements Disco if (!_cardDiscarded && !_skipDiscardCard) { _cardDiscarded = true; - if (_eventPlayed.getZone() != null) - game.getGameState().removeCardsFromZone(_eventPlayed.getOwner(), Collections.singleton(_eventPlayed)); + game.getGameState().removeCardsFromZone(_eventPlayed.getOwner(), Collections.singleton(_eventPlayed)); game.getGameState().addCardToZone(game, _eventPlayed, Zone.DISCARD); } diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/PlayEventEffect.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/PlayEventEffect.java index 310b0021f..e3d45a829 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/PlayEventEffect.java +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/PlayEventEffect.java @@ -7,8 +7,6 @@ import com.gempukku.lotro.game.PhysicalCard; import com.gempukku.lotro.game.state.LotroGame; import com.gempukku.lotro.logic.effects.PlayCardEffect; -import java.util.Collections; - public class PlayEventEffect extends PlayCardEffect { private PhysicalCard _cardPlayed; private PlayEventResult _playEventResult; @@ -25,8 +23,6 @@ public class PlayEventEffect extends PlayCardEffect { @Override protected FullEffectResult playEffectReturningResult(LotroGame game) { - if (_cardPlayed.getZone() != null) - game.getGameState().removeCardsFromZone(_cardPlayed.getOwner(), Collections.singleton(_cardPlayed)); game.getActionsEnvironment().emitEffectResult(_playEventResult); return new FullEffectResult(true); } diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/PutPlayedEventIntoHandEffect.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/PutPlayedEventIntoHandEffect.java index bc8c57968..16f05c0fa 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/PutPlayedEventIntoHandEffect.java +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/PutPlayedEventIntoHandEffect.java @@ -2,10 +2,13 @@ package com.gempukku.lotro.cards.effects; import com.gempukku.lotro.cards.actions.PlayEventAction; import com.gempukku.lotro.common.Zone; +import com.gempukku.lotro.game.PhysicalCard; import com.gempukku.lotro.game.state.LotroGame; import com.gempukku.lotro.logic.GameUtils; import com.gempukku.lotro.logic.timing.AbstractEffect; +import java.util.Collections; + public class PutPlayedEventIntoHandEffect extends AbstractEffect { private PlayEventAction _action; @@ -31,9 +34,11 @@ public class PutPlayedEventIntoHandEffect extends AbstractEffect { @Override protected FullEffectResult playEffectReturningResult(LotroGame game) { if (isPlayableInFull(game)) { - game.getGameState().sendMessage(_action.getPerformingPlayer() + " puts " + GameUtils.getCardLink(_action.getEventPlayed()) + " into hand"); + PhysicalCard eventPlayed = _action.getEventPlayed(); + game.getGameState().sendMessage(_action.getPerformingPlayer() + " puts " + GameUtils.getCardLink(eventPlayed) + " into hand"); _action.skipDiscardPart(); - game.getGameState().addCardToZone(game, _action.getEventPlayed(), Zone.HAND); + game.getGameState().removeCardsFromZone(eventPlayed.getOwner(), Collections.singletonList(eventPlayed)); + game.getGameState().addCardToZone(game, eventPlayed, Zone.HAND); return new FullEffectResult(true); } return new FullEffectResult(false); diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/PutPlayedEventOnBottomOfDeckEffect.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/PutPlayedEventOnBottomOfDeckEffect.java index dd94e34ed..185c768af 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/PutPlayedEventOnBottomOfDeckEffect.java +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/PutPlayedEventOnBottomOfDeckEffect.java @@ -2,10 +2,13 @@ package com.gempukku.lotro.cards.effects; import com.gempukku.lotro.cards.actions.PlayEventAction; import com.gempukku.lotro.common.Zone; +import com.gempukku.lotro.game.PhysicalCard; import com.gempukku.lotro.game.state.LotroGame; import com.gempukku.lotro.logic.GameUtils; import com.gempukku.lotro.logic.timing.AbstractEffect; +import java.util.Collections; + public class PutPlayedEventOnBottomOfDeckEffect extends AbstractEffect { private PlayEventAction _action; @@ -31,9 +34,11 @@ public class PutPlayedEventOnBottomOfDeckEffect extends AbstractEffect { @Override protected FullEffectResult playEffectReturningResult(LotroGame game) { if (isPlayableInFull(game)) { - game.getGameState().sendMessage(_action.getPerformingPlayer() + " puts " + GameUtils.getCardLink(_action.getEventPlayed()) + " on bottom of his/her deck"); + PhysicalCard eventPlayed = _action.getEventPlayed(); + game.getGameState().sendMessage(_action.getPerformingPlayer() + " puts " + GameUtils.getCardLink(eventPlayed) + " on bottom of his/her deck"); _action.skipDiscardPart(); - game.getGameState().putCardOnBottomOfDeck(_action.getEventPlayed()); + game.getGameState().removeCardsFromZone(eventPlayed.getOwner(), Collections.singletonList(eventPlayed)); + game.getGameState().putCardOnBottomOfDeck(eventPlayed); return new FullEffectResult(true); } return new FullEffectResult(false); diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/PutPlayedEventOnTopOfDeckEffect.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/PutPlayedEventOnTopOfDeckEffect.java index c18cff130..8996bc820 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/PutPlayedEventOnTopOfDeckEffect.java +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/PutPlayedEventOnTopOfDeckEffect.java @@ -2,10 +2,13 @@ package com.gempukku.lotro.cards.effects; import com.gempukku.lotro.cards.actions.PlayEventAction; import com.gempukku.lotro.common.Zone; +import com.gempukku.lotro.game.PhysicalCard; import com.gempukku.lotro.game.state.LotroGame; import com.gempukku.lotro.logic.GameUtils; import com.gempukku.lotro.logic.timing.AbstractEffect; +import java.util.Collections; + public class PutPlayedEventOnTopOfDeckEffect extends AbstractEffect { private PlayEventAction _action; @@ -31,9 +34,11 @@ public class PutPlayedEventOnTopOfDeckEffect extends AbstractEffect { @Override protected FullEffectResult playEffectReturningResult(LotroGame game) { if (isPlayableInFull(game)) { - game.getGameState().sendMessage(_action.getPerformingPlayer() + " puts " + GameUtils.getCardLink(_action.getEventPlayed()) + " on top of his/her deck"); + PhysicalCard eventPlayed = _action.getEventPlayed(); + game.getGameState().sendMessage(_action.getPerformingPlayer() + " puts " + GameUtils.getCardLink(eventPlayed) + " on top of his/her deck"); _action.skipDiscardPart(); - game.getGameState().putCardOnTopOfDeck(_action.getEventPlayed()); + game.getGameState().removeCardsFromZone(eventPlayed.getOwner(), Collections.singletonList(eventPlayed)); + game.getGameState().putCardOnTopOfDeck(eventPlayed); return new FullEffectResult(true); } return new FullEffectResult(false); diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/RemovePlayedEventFromGameEffect.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/RemovePlayedEventFromGameEffect.java index ca2162de7..2cd2b0d40 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/RemovePlayedEventFromGameEffect.java +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/RemovePlayedEventFromGameEffect.java @@ -2,10 +2,13 @@ package com.gempukku.lotro.cards.effects; import com.gempukku.lotro.cards.actions.PlayEventAction; import com.gempukku.lotro.common.Zone; +import com.gempukku.lotro.game.PhysicalCard; import com.gempukku.lotro.game.state.LotroGame; import com.gempukku.lotro.logic.GameUtils; import com.gempukku.lotro.logic.timing.AbstractEffect; +import java.util.Collections; + public class RemovePlayedEventFromGameEffect extends AbstractEffect { private PlayEventAction _action; @@ -31,9 +34,11 @@ public class RemovePlayedEventFromGameEffect extends AbstractEffect { @Override protected FullEffectResult playEffectReturningResult(LotroGame game) { if (isPlayableInFull(game)) { - game.getGameState().sendMessage(_action.getPerformingPlayer() + " removes " + GameUtils.getCardLink(_action.getEventPlayed()) + " from the game"); + PhysicalCard eventPlayed = _action.getEventPlayed(); + game.getGameState().sendMessage(_action.getPerformingPlayer() + " removes " + GameUtils.getCardLink(eventPlayed) + " from the game"); _action.skipDiscardPart(); - game.getGameState().addCardToZone(game, _action.getEventPlayed(), Zone.REMOVED); + game.getGameState().removeCardsFromZone(eventPlayed.getOwner(), Collections.singletonList(eventPlayed)); + game.getGameState().addCardToZone(game, eventPlayed, Zone.REMOVED); return new FullEffectResult(true); } return new FullEffectResult(false); diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/StackPlayedEventOnACardEffect.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/StackPlayedEventOnACardEffect.java index 6565d56fd..7628f0e19 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/StackPlayedEventOnACardEffect.java +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/StackPlayedEventOnACardEffect.java @@ -7,6 +7,8 @@ import com.gempukku.lotro.game.state.LotroGame; import com.gempukku.lotro.logic.GameUtils; import com.gempukku.lotro.logic.timing.AbstractEffect; +import java.util.Collections; + public class StackPlayedEventOnACardEffect extends AbstractEffect { private PlayEventAction _action; private PhysicalCard _stackOn; @@ -34,9 +36,11 @@ public class StackPlayedEventOnACardEffect extends AbstractEffect { @Override protected FullEffectResult playEffectReturningResult(LotroGame game) { if (isPlayableInFull(game)) { - game.getGameState().sendMessage(_action.getPerformingPlayer() + " stacks " + GameUtils.getCardLink(_action.getEventPlayed()) + " on "+GameUtils.getCardLink(_stackOn)); + PhysicalCard eventPlayed = _action.getEventPlayed(); + game.getGameState().sendMessage(_action.getPerformingPlayer() + " stacks " + GameUtils.getCardLink(eventPlayed) + " on " + GameUtils.getCardLink(_stackOn)); _action.skipDiscardPart(); - game.getGameState().stackCard(game, _action.getEventPlayed(), _stackOn); + game.getGameState().removeCardsFromZone(eventPlayed.getOwner(), Collections.singletonList(eventPlayed)); + game.getGameState().stackCard(game, eventPlayed, _stackOn); return new FullEffectResult(true); } return new FullEffectResult(false); diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/ConstructedLeagueData.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/ConstructedLeagueData.java index bfd113af8..19ed380f1 100644 --- a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/ConstructedLeagueData.java +++ b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/ConstructedLeagueData.java @@ -54,10 +54,15 @@ public class ConstructedLeagueData implements LeagueData { public int process(CollectionsManager collectionsManager, List leagueStandings, int oldStatus, int currentTime) { int status = oldStatus; if (status == 0) { + int maxGamesCount = 0; + for (LeagueSerieData sery : _series) { + maxGamesCount+=sery.getMaxMatches(); + } + LeagueSerieData lastSerie = _series.get(_series.size() - 1); if (currentTime > DateUtils.offsetDate(lastSerie.getEnd(), 1)) { for (PlayerStanding leagueStanding : leagueStandings) { - CardCollection leaguePrize = _leaguePrizes.getPrizeForLeague(leagueStanding.getStanding(), leagueStandings.size(), _prizeMultiplier); + CardCollection leaguePrize = _leaguePrizes.getPrizeForLeague(leagueStanding.getStanding(), leagueStandings.size(), leagueStanding.getGamesPlayed(), maxGamesCount, _prizeMultiplier); if (leaguePrize != null) collectionsManager.addItemsToPlayerCollection(true, "End of league prizes", leagueStanding.getPlayerName(), _prizeCollectionType, leaguePrize.getAll().values()); } diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/ConstructedLeaguePrizes.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/ConstructedLeaguePrizes.java new file mode 100644 index 000000000..a534fa8e4 --- /dev/null +++ b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/ConstructedLeaguePrizes.java @@ -0,0 +1,4 @@ +package com.gempukku.lotro.league; + +public class ConstructedLeaguePrizes { +} diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/LeaguePrizes.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/LeaguePrizes.java index d44bdd246..7c0193140 100644 --- a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/LeaguePrizes.java +++ b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/LeaguePrizes.java @@ -7,5 +7,5 @@ public interface LeaguePrizes { public CardCollection getPrizeForLeagueMatchLoser(int winCountThisSerie, int totalGamesPlayedThisSerie); - public CardCollection getPrizeForLeague(int position, int playersCount, float multiplier); + public CardCollection getPrizeForLeague(int position, int playersCount, int gamesPlayed, int maxGamesPlayed, float multiplier); } diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/NewConstructedLeagueData.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/NewConstructedLeagueData.java index e097c9daa..35709e812 100644 --- a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/NewConstructedLeagueData.java +++ b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/NewConstructedLeagueData.java @@ -58,10 +58,15 @@ public class NewConstructedLeagueData implements LeagueData { public int process(CollectionsManager collectionsManager, List leagueStandings, int oldStatus, int currentTime) { int status = oldStatus; if (status == 0) { + int maxGamesPlayed = 0; + for (LeagueSerieData sery : _series) { + maxGamesPlayed+=sery.getMaxMatches(); + } + LeagueSerieData lastSerie = _series.get(_series.size() - 1); if (currentTime > DateUtils.offsetDate(lastSerie.getEnd(), 1)) { for (PlayerStanding leagueStanding : leagueStandings) { - CardCollection leaguePrize = _leaguePrizes.getPrizeForLeague(leagueStanding.getStanding(), leagueStandings.size(), _prizeMultiplier); + CardCollection leaguePrize = _leaguePrizes.getPrizeForLeague(leagueStanding.getStanding(), leagueStandings.size(), leagueStanding.getGamesPlayed(), maxGamesPlayed, _prizeMultiplier); if (leaguePrize != null) collectionsManager.addItemsToPlayerCollection(true, "End of league prizes", leagueStanding.getPlayerName(), _prizeCollectionType, leaguePrize.getAll().values()); } diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/NewLeaguePrizes.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/NewLeaguePrizes.java index b6a0951c2..a7fab3425 100644 --- a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/NewLeaguePrizes.java +++ b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/NewLeaguePrizes.java @@ -57,7 +57,7 @@ public class NewLeaguePrizes implements LeaguePrizes { return null; } - public CardCollection getPrizeForLeague(int position, int playersCount, float multiplier) { + public CardCollection getPrizeForLeague(int position, int playersCount, int gamesPlayed, int maxGamesPlayed, float multiplier) { DefaultCardCollection leaguePrize = new DefaultCardCollection(); int count = (int) Math.floor((2 * playersCount + 24) / (position + 9) - 2.4); if (count > 0) { diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/NewSealedLeagueData.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/NewSealedLeagueData.java index 9507a0591..265d4526b 100644 --- a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/NewSealedLeagueData.java +++ b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/NewSealedLeagueData.java @@ -19,7 +19,7 @@ public class NewSealedLeagueData implements LeagueData { private List _series; private CollectionType _collectionType; private CollectionType _prizeCollectionType = CollectionType.MY_CARDS; - private NewLeaguePrizes _leaguePrizes; + private LeaguePrizes _leaguePrizes; private SealedLeagueProduct _leagueProduct; public NewSealedLeagueData(String parameters) { @@ -80,11 +80,15 @@ public class NewSealedLeagueData implements LeagueData { } } + int maxGamesTotal = 0; + for (LeagueSerieData sery : _series) + maxGamesTotal+=sery.getMaxMatches(); + if (status == _series.size()) { LeagueSerieData lastSerie = _series.get(_series.size() - 1); if (currentTime > DateUtils.offsetDate(lastSerie.getEnd(), 1)) { for (PlayerStanding leagueStanding : leagueStandings) { - CardCollection leaguePrize = _leaguePrizes.getPrizeForLeague(leagueStanding.getStanding(), leagueStandings.size(), 1f); + CardCollection leaguePrize = _leaguePrizes.getPrizeForLeague(leagueStanding.getStanding(), leagueStandings.size(), leagueStanding.getGamesPlayed(), maxGamesTotal, 1f); if (leaguePrize != null) collectionsManager.addItemsToPlayerCollection(true, "End of league prizes", leagueStanding.getPlayerName(), _prizeCollectionType, leaguePrize.getAll().values()); } diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/SealedLeagueData.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/SealedLeagueData.java index 74daefc4e..45b6aaf98 100644 --- a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/SealedLeagueData.java +++ b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/SealedLeagueData.java @@ -81,10 +81,15 @@ public class SealedLeagueData implements LeagueData { } if (status == _series.size()) { + int maxGamesPlayed = 0; + for (LeagueSerieData sery : _series) { + maxGamesPlayed+=sery.getMaxMatches(); + } + LeagueSerieData lastSerie = _series.get(_series.size() - 1); if (currentTime > DateUtils.offsetDate(lastSerie.getEnd(), 1)) { for (PlayerStanding leagueStanding : leagueStandings) { - CardCollection leaguePrize = _leaguePrizes.getPrizeForLeague(leagueStanding.getStanding(), leagueStandings.size(), 1f); + CardCollection leaguePrize = _leaguePrizes.getPrizeForLeague(leagueStanding.getStanding(), leagueStandings.size(), leagueStanding.getGamesPlayed(), maxGamesPlayed, 1f); if (leaguePrize != null) collectionsManager.addItemsToPlayerCollection(true, "End of league prizes", leagueStanding.getPlayerName(), _prizeCollectionType, leaguePrize.getAll().values()); } diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/SealedLeaguePrizes.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/SealedLeaguePrizes.java new file mode 100644 index 000000000..d79626f3e --- /dev/null +++ b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/SealedLeaguePrizes.java @@ -0,0 +1,146 @@ +package com.gempukku.lotro.league; + +import com.gempukku.lotro.cards.packs.RarityReader; +import com.gempukku.lotro.cards.packs.SetRarity; +import com.gempukku.lotro.game.CardCollection; +import com.gempukku.lotro.game.DefaultCardCollection; + +import java.util.*; + +public class SealedLeaguePrizes implements LeaguePrizes { + private List _commons = new ArrayList(); + private List _uncommons = new ArrayList(); + private List _promos = new ArrayList(); + private List _rares = new ArrayList(); + + public SealedLeaguePrizes() { + RarityReader rarityReader = new RarityReader(); + + for (int i = 0; i <= 19; i++) { + SetRarity setRarity = rarityReader.getSetRarity(String.valueOf(i)); + _commons.addAll(setRarity.getCardsOfRarity("C")); + _uncommons.addAll(setRarity.getCardsOfRarity("U")); + _promos.addAll(setRarity.getCardsOfRarity("P")); + _rares.addAll(setRarity.getCardsOfRarity("R")); + } + } + + public CardCollection getPrizeForLeagueMatchWinner(int winCountThisSerie, int totalGamesPlayedThisSerie) { + DefaultCardCollection winnerPrize = new DefaultCardCollection(); + if (winCountThisSerie == 1 || winCountThisSerie == 3 || winCountThisSerie == 5 || winCountThisSerie == 8 + || winCountThisSerie == 10 || winCountThisSerie == 12) + winnerPrize.addItem("(S)Booster Choice", 1); + else { + if (winCountThisSerie == 2) + winnerPrize.addItem(getRandom(_commons) + "*", 1); + else if (winCountThisSerie == 4) + winnerPrize.addItem(getRandom(_promos), 1); + else if (winCountThisSerie == 6) + winnerPrize.addItem(getRandom(_promos) + "*", 1); + else if (winCountThisSerie == 7) + winnerPrize.addItem(getRandom(_uncommons) + "*", 1); + else if (winCountThisSerie == 9) { + winnerPrize.addItem(getRandom(_promos), 1); + winnerPrize.addItem(getRandom(_commons) + "*", 1); + } else if (winCountThisSerie == 11) + winnerPrize.addItem(getRandom(_promos), 1); + else if (winCountThisSerie == 13) { + winnerPrize.addItem(getRandom(_promos)+"*", 1); + winnerPrize.addItem(getRandom(_rares)+"*", 1); + } + + } + return winnerPrize; + } + + public CardCollection getPrizeForLeagueMatchLoser(int winCountThisSerie, int totalGamesPlayedThisSerie) { + return null; + } + + public CardCollection getPrizeForLeague(int position, int playersCount, int gamesPlayed, int maxGamesPlayed, float multiplier) { + if (gamesPlayed*4>=maxGamesPlayed) { + DefaultCardCollection leaguePrize = new DefaultCardCollection(); + leaguePrize.addItem("(S)Booster Choice", getBoosterCount(position)); + leaguePrize.addItem("(S)Tengwar", getTengwarCount(position)); + addPrizes(leaguePrize, getRandomFoil(_promos, getFoilCount(position))); + addPrizes(leaguePrize, getRandom(_promos, getPromoCount(position))); + + if (leaguePrize.getAll().size() == 0) + return null; + return leaguePrize; + } else { + return null; + } + } + + private int getFoilCount(int position) { + if (position<=3) + return 4-position; + else + return 0; + } + + private int getPromoCount(int position) { + if (position<=4) + return position-1; + else if (position<=8) + return 2; + else if (position<=16) + return 1; + else + return 0; + } + + private int getTengwarCount(int position) { + if (position<=4) + return 5-position; + else + return 0; + } + + private int getBoosterCount(int position) { + if (position == 1) + return 60; + else if (position == 2) + return 55; + else if (position == 3) + return 50; + else if (position == 4) + return 45; + else if (position<=8) + return 40; + else if (position<=16) + return 35; + else if (position<=32) + return 20; + else if (position<=64) + return 10; + else if (position<=128) + return 5; + else + return 0; + } + + private void addPrizes(DefaultCardCollection leaguePrize, List cards) { + for (String card : cards) + leaguePrize.addItem(card, 1); + } + + private String getRandom(List list) { + return list.get(new Random().nextInt(list.size())); + } + + private List getRandom(List list, int count) { + List result = new LinkedList(list); + Collections.shuffle(result); + return result.subList(0, count); + } + + private List getRandomFoil(List list, int count) { + List result = new LinkedList(); + for (String element : list) + result.add(element + "*"); + Collections.shuffle(result); + return result.subList(0, count); + } +} diff --git a/gemp-lotr/gemp-lotr-server/src/test/java/com/gempukku/lotro/league/LeaguePrizesTest.java b/gemp-lotr/gemp-lotr-server/src/test/java/com/gempukku/lotro/league/LeaguePrizesTest.java index 683e6be83..ba85bca83 100644 --- a/gemp-lotr/gemp-lotr-server/src/test/java/com/gempukku/lotro/league/LeaguePrizesTest.java +++ b/gemp-lotr/gemp-lotr-server/src/test/java/com/gempukku/lotro/league/LeaguePrizesTest.java @@ -18,9 +18,13 @@ public class LeaguePrizesTest { @Test public void testLeaguePrize() { LeaguePrizes leaguePrizes = new NewLeaguePrizes(); - CardCollection prize = leaguePrizes.getPrizeForLeague(1, 100, 2f); - for (Map.Entry stringIntegerEntry : prize.getAll().entrySet()) { - System.out.println(stringIntegerEntry.getKey() + ": " + stringIntegerEntry.getValue().getCount()); + for (int i = 1; i <= 32; i++) { + System.out.println("Place "+i); + CardCollection prize = leaguePrizes.getPrizeForLeague(i, 60, 1, 2, 2f); + if (prize != null) + for (Map.Entry stringIntegerEntry : prize.getAll().entrySet()) { + System.out.println(stringIntegerEntry.getKey() + ": " + stringIntegerEntry.getValue().getCount()); + } } } }