New league prizes (fixed), and check for player corruption at the start of the game.
This commit is contained in:
@@ -46,6 +46,6 @@ public class BiddingGameProcess implements GameProcess {
|
||||
|
||||
@Override
|
||||
public GameProcess getNextProcess() {
|
||||
return new CheckForCorruptionGameProcess(_bids, _playerOrderFeedback);
|
||||
return new ChooseSeatingOrderGameProcess(_bids, _playerOrderFeedback);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,37 +1,39 @@
|
||||
package com.gempukku.lotro.logic.timing.processes.pregame;
|
||||
|
||||
import com.gempukku.lotro.game.state.LotroGame;
|
||||
import com.gempukku.lotro.logic.timing.PlayerOrderFeedback;
|
||||
import com.gempukku.lotro.logic.PlayOrder;
|
||||
import com.gempukku.lotro.logic.timing.processes.GameProcess;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class CheckForCorruptionGameProcess implements GameProcess {
|
||||
private Map<String, Integer> _bids;
|
||||
private PlayerOrderFeedback _playerOrderFeedback;
|
||||
private GameProcess _nextProcess;
|
||||
private String _firstPlayer;
|
||||
|
||||
public CheckForCorruptionGameProcess(Map<String, Integer> bids, PlayerOrderFeedback playerOrderFeedback) {
|
||||
_bids = bids;
|
||||
_playerOrderFeedback = playerOrderFeedback;
|
||||
public CheckForCorruptionGameProcess(String firstPlayer) {
|
||||
_firstPlayer = firstPlayer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(LotroGame game) {
|
||||
for (Map.Entry<String, Integer> playerBid : _bids.entrySet()) {
|
||||
String player = playerBid.getKey();
|
||||
int bid = playerBid.getValue();
|
||||
PlayOrder playOrder = game.getGameState().getPlayerOrder().getClockwisePlayOrder(_firstPlayer, false);
|
||||
|
||||
game.getGameState().startPlayerTurn(player);
|
||||
int ringBearerResistance = game.getModifiersQuerying().getResistance(game.getGameState(), game.getGameState().getRingBearer(player));
|
||||
if (ringBearerResistance<=bid) {
|
||||
game.playerLost(player, "Corrupted before game started");
|
||||
while (true) {
|
||||
String nextPlayer = playOrder.getNextPlayer();
|
||||
if (nextPlayer == null)
|
||||
break;
|
||||
|
||||
game.getGameState().startPlayerTurn(nextPlayer);
|
||||
int ringBearerResistance = game.getModifiersQuerying().getResistance(game.getGameState(), game.getGameState().getRingBearer(nextPlayer));
|
||||
if (ringBearerResistance<=0) {
|
||||
game.playerLost(nextPlayer, "Corrupted before game started");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_nextProcess = new PlayStartingFellowshipGameProcess(game.getGameState().getPlayerOrder().getClockwisePlayOrder(_firstPlayer, false), _firstPlayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameProcess getNextProcess() {
|
||||
return new ChooseSeatingOrderGameProcess(_bids, _playerOrderFeedback);
|
||||
return _nextProcess;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,12 +33,10 @@ public class PlayRingBearerRingAndAddBurdersGameProcess implements GameProcess {
|
||||
gameState.addBurdens(_bids.get(playerId));
|
||||
}
|
||||
gameState.setCurrentPhase(Phase.PLAY_STARTING_FELLOWSHIP);
|
||||
|
||||
_nextProcess = new PlayStartingFellowshipGameProcess(game.getGameState().getPlayerOrder().getClockwisePlayOrder(_firstPlayer, false), _firstPlayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameProcess getNextProcess() {
|
||||
return _nextProcess;
|
||||
return new CheckForCorruptionGameProcess(_firstPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,15 +28,12 @@ public final class CollectionType {
|
||||
CollectionType that = (CollectionType) o;
|
||||
|
||||
if (_code != null ? !_code.equals(that._code) : that._code != null) return false;
|
||||
if (_fullName != null ? !_fullName.equals(that._fullName) : that._fullName != null) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = _code != null ? _code.hashCode() : 0;
|
||||
result = 31 * result + (_fullName != null ? _fullName.hashCode() : 0);
|
||||
return result;
|
||||
return _code != null ? _code.hashCode() : 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,22 +37,26 @@ public class DefaultCardCollection implements MutableCardCollection {
|
||||
|
||||
@Override
|
||||
public synchronized void addItem(String itemId, int toAdd) {
|
||||
Item oldCount = _counts.get(itemId);
|
||||
if (oldCount == null)
|
||||
_counts.put(itemId, Item.createItem(itemId, toAdd));
|
||||
else
|
||||
_counts.put(itemId, Item.createItem(itemId, toAdd + oldCount.getCount()));
|
||||
if (toAdd > 0) {
|
||||
Item oldCount = _counts.get(itemId);
|
||||
if (oldCount == null)
|
||||
_counts.put(itemId, Item.createItem(itemId, toAdd));
|
||||
else
|
||||
_counts.put(itemId, Item.createItem(itemId, toAdd + oldCount.getCount()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean removeItem(String itemId, int toRemove) {
|
||||
Item oldCount = _counts.get(itemId);
|
||||
if (oldCount == null || oldCount.getCount() < toRemove)
|
||||
return false;
|
||||
if (oldCount.getCount() == toRemove)
|
||||
_counts.remove(itemId);
|
||||
else
|
||||
_counts.put(itemId, Item.createItem(itemId, oldCount.getCount() - toRemove));
|
||||
if (toRemove > 0) {
|
||||
Item oldCount = _counts.get(itemId);
|
||||
if (oldCount == null || oldCount.getCount() < toRemove)
|
||||
return false;
|
||||
if (oldCount.getCount() == toRemove)
|
||||
_counts.remove(itemId);
|
||||
else
|
||||
_counts.put(itemId, Item.createItem(itemId, oldCount.getCount() - toRemove));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,10 +11,10 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ConstructedLeagueData implements LeagueData {
|
||||
private LeaguePrizes _leaguePrizes = new FixedLeaguePrizes();
|
||||
private List<LeagueSerieData> _series = new ArrayList<LeagueSerieData>();
|
||||
private CollectionType _prizeCollectionType = CollectionType.MY_CARDS;
|
||||
private float _prizeMultiplier;
|
||||
private LeaguePrizes _leaguePrizes = new NewLeaguePrizes();
|
||||
private CollectionType _collectionType;
|
||||
|
||||
// Example params - 20120312,fotr_block,0.7,default,All cards,7,10,3,fotr1_block,fotr_block,fotr2_block,fotr_block,fotr_block,fotr_block
|
||||
// Which means - start date,league prize pool,prizes multiplier,collection type,collection name,serie length,serie match count,series count,
|
||||
@@ -24,18 +24,16 @@ public class ConstructedLeagueData implements LeagueData {
|
||||
public ConstructedLeagueData(String parameters) {
|
||||
String[] params = parameters.split(",");
|
||||
final int start = Integer.parseInt(params[0]);
|
||||
_prizeMultiplier = Float.parseFloat(params[2]);
|
||||
CollectionType collectionType = new CollectionType(params[3], params[4]);
|
||||
_collectionType = new CollectionType(params[3], params[4]);
|
||||
int days = Integer.parseInt(params[5]);
|
||||
int matchCount = Integer.parseInt(params[6]);
|
||||
int series = Integer.parseInt(params[7]);
|
||||
for (int i = 0; i < series; i++) {
|
||||
String format = params[8 + i * 2];
|
||||
String seriePrizePool = params[9 + i * 2];
|
||||
|
||||
DefaultLeagueSerieData data = new DefaultLeagueSerieData(_leaguePrizes, false, "Week " + (i + 1),
|
||||
DateUtils.offsetDate(start, i * days), DateUtils.offsetDate(start, ((i + 1) * days) - 1),
|
||||
matchCount, format, collectionType);
|
||||
matchCount, format, _collectionType);
|
||||
_series.add(data);
|
||||
}
|
||||
}
|
||||
@@ -62,7 +60,7 @@ public class ConstructedLeagueData implements LeagueData {
|
||||
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(), leagueStanding.getGamesPlayed(), maxGamesCount, _prizeMultiplier);
|
||||
CardCollection leaguePrize = _leaguePrizes.getPrizeForLeague(leagueStanding.getStanding(), leagueStandings.size(), leagueStanding.getGamesPlayed(), maxGamesCount, _collectionType);
|
||||
if (leaguePrize != null)
|
||||
collectionsManager.addItemsToPlayerCollection(true, "End of league prizes", leagueStanding.getPlayerName(), _prizeCollectionType, leaguePrize.getAll().values());
|
||||
}
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
package com.gempukku.lotro.league;
|
||||
|
||||
public class ConstructedLeaguePrizes {
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
package com.gempukku.lotro.league;
|
||||
|
||||
import com.gempukku.lotro.cards.packs.RarityReader;
|
||||
import com.gempukku.lotro.cards.packs.SetRarity;
|
||||
import com.gempukku.lotro.db.vo.CollectionType;
|
||||
import com.gempukku.lotro.game.CardCollection;
|
||||
import com.gempukku.lotro.game.DefaultCardCollection;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class FixedLeaguePrizes implements LeaguePrizes {
|
||||
private List<String> _commons = new ArrayList<String>();
|
||||
private List<String> _uncommons = new ArrayList<String>();
|
||||
private List<String> _rares = new ArrayList<String>();
|
||||
|
||||
public FixedLeaguePrizes() {
|
||||
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"));
|
||||
_rares.addAll(setRarity.getCardsOfRarity("R"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CardCollection getPrizeForLeagueMatchWinner(int winCountThisSerie, int totalGamesPlayedThisSerie) {
|
||||
DefaultCardCollection winnerPrize = new DefaultCardCollection();
|
||||
if (winCountThisSerie % 2 == 1) {
|
||||
winnerPrize.addItem("(S)Booster Choice", 1);
|
||||
} else {
|
||||
if (winCountThisSerie <= 4) {
|
||||
winnerPrize.addItem(getRandom(_commons) + "*", 1);
|
||||
} else if (winCountThisSerie <= 8) {
|
||||
winnerPrize.addItem(getRandom(_uncommons) + "*", 1);
|
||||
} else {
|
||||
winnerPrize.addItem(getRandom(_rares) + "*", 1);
|
||||
}
|
||||
}
|
||||
return winnerPrize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CardCollection getPrizeForLeagueMatchLoser(int winCountThisSerie, int totalGamesPlayedThisSerie) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CardCollection getPrizeForLeague(int position, int playersCount, int gamesPlayed, int maxGamesPlayed, CollectionType collectionType) {
|
||||
if (collectionType.equals(CollectionType.ALL_CARDS)) {
|
||||
return getPrizeForConstructedLeague(position, playersCount, gamesPlayed, maxGamesPlayed);
|
||||
} else if (collectionType.equals(CollectionType.MY_CARDS)) {
|
||||
return getPrizeForCollectorsLeague(position, playersCount, gamesPlayed, maxGamesPlayed);
|
||||
} else {
|
||||
return getPrizeForSealedLeague(position, playersCount, gamesPlayed, maxGamesPlayed);
|
||||
}
|
||||
}
|
||||
|
||||
//1st - 60 boosters, 4 tengwar, 3 foil rares
|
||||
//2nd - 55 boosters, 3 tengwar, 2 foil rares
|
||||
//3rd - 50 boosters, 2 tengwar, 1 foil rare
|
||||
//4th - 45 boosters, 1 tengwar
|
||||
//5th-8th - 40 boosters
|
||||
//9th-16th - 35 boosters
|
||||
//17th-32nd - 20 boosters
|
||||
//33rd-64th - 10 boosters
|
||||
//65th-128th - 5 boosters
|
||||
private CardCollection getPrizeForSealedLeague(int position, int playersCount, int gamesPlayed, int maxGamesPlayed) {
|
||||
DefaultCardCollection prize = new DefaultCardCollection();
|
||||
prize.addItem("(S)Booster Choice", getSealedBoosterCount(position));
|
||||
prize.addItem("(S)Tengwar", getTengwarCount(position));
|
||||
addPrizes(prize, getRandomFoil(_rares, getRandomRareFoilCount(position)));
|
||||
if (prize.getAll().size() > 0)
|
||||
return prize;
|
||||
return null;
|
||||
}
|
||||
|
||||
private int getSealedBoosterCount(int position) {
|
||||
if (position < 5)
|
||||
return 65 - position * 5;
|
||||
else if (position < 9)
|
||||
return 40;
|
||||
else if (position < 17)
|
||||
return 35;
|
||||
else if (position < 33)
|
||||
return 20;
|
||||
else if (position < 65)
|
||||
return 10;
|
||||
else if (position < 129)
|
||||
return 5;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//1st - 30 boosters, 4 tengwar, 3 foil rares
|
||||
//2nd - 25 boosters, 3 tengwar, 2 foil rares
|
||||
//3rd - 20 boosters, 2 tengwar, 1 foil rares
|
||||
//4th - 15 boosters, 1 tengwar
|
||||
//5th-8th - 10 boosters, 2 promos
|
||||
//9th-16th - 5 boosters, 1 promo
|
||||
//17th-32nd - 2 boosters
|
||||
private CardCollection getPrizeForCollectorsLeague(int position, int playersCount, int gamesPlayed, int maxGamesPlayed) {
|
||||
DefaultCardCollection prize = new DefaultCardCollection();
|
||||
prize.addItem("(S)Booster Choice", getCollectorsBoosterCount(position));
|
||||
prize.addItem("(S)Tengwar", getTengwarCount(position));
|
||||
addPrizes(prize, getRandomFoil(_rares, getRandomRareFoilCount(position)));
|
||||
if (prize.getAll().size() > 0)
|
||||
return prize;
|
||||
return null;
|
||||
}
|
||||
|
||||
private int getCollectorsBoosterCount(int position) {
|
||||
if (position < 5)
|
||||
return 35 - position * 5;
|
||||
else if (position < 9)
|
||||
return 10;
|
||||
else if (position < 17)
|
||||
return 5;
|
||||
else if (position < 33)
|
||||
return 2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//1st - 10 boosters, 4 tengwar, 3 foil rares
|
||||
//2nd - 8 boosters, 3 tengwar, 2 foil rares
|
||||
//3rd - 6 boosters, 2 tengwar, 1 foil rare
|
||||
//4th - 4 boosters, 1 tengwar
|
||||
//5th-8th - 3 boosters
|
||||
//9th-16th - 2 boosters
|
||||
//17th-32nd - 1 boosters
|
||||
private CardCollection getPrizeForConstructedLeague(int position, int playersCount, int gamesPlayed, int maxGamesPlayed) {
|
||||
DefaultCardCollection prize = new DefaultCardCollection();
|
||||
prize.addItem("(S)Booster Choice", getConstructedBoosterCount(position));
|
||||
prize.addItem("(S)Tengwar", getTengwarCount(position));
|
||||
addPrizes(prize, getRandomFoil(_rares, getRandomRareFoilCount(position)));
|
||||
if (prize.getAll().size() > 0)
|
||||
return prize;
|
||||
return null;
|
||||
}
|
||||
|
||||
private int getConstructedBoosterCount(int position) {
|
||||
if (position < 5)
|
||||
return 12 - position * 2;
|
||||
else if (position < 9)
|
||||
return 3;
|
||||
else if (position < 17)
|
||||
return 2;
|
||||
else if (position < 33)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
private int getRandomRareFoilCount(int position) {
|
||||
if (position < 4)
|
||||
return 4 - position;
|
||||
return 0;
|
||||
}
|
||||
|
||||
private void addPrizes(DefaultCardCollection leaguePrize, List<String> cards) {
|
||||
for (String card : cards)
|
||||
leaguePrize.addItem(card, 1);
|
||||
}
|
||||
|
||||
private int getTengwarCount(int position) {
|
||||
if (position < 5)
|
||||
return 5 - position;
|
||||
return 0;
|
||||
}
|
||||
|
||||
private String getRandom(List<String> list) {
|
||||
return list.get(new Random().nextInt(list.size()));
|
||||
}
|
||||
|
||||
private List<String> getRandomFoil(List<String> list, int count) {
|
||||
List<String> result = new LinkedList<String>();
|
||||
for (String element : list)
|
||||
result.add(element + "*");
|
||||
Collections.shuffle(result);
|
||||
return result.subList(0, count);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.gempukku.lotro.league;
|
||||
|
||||
import com.gempukku.lotro.db.vo.CollectionType;
|
||||
import com.gempukku.lotro.game.CardCollection;
|
||||
|
||||
public interface LeaguePrizes {
|
||||
@@ -7,5 +8,5 @@ public interface LeaguePrizes {
|
||||
|
||||
public CardCollection getPrizeForLeagueMatchLoser(int winCountThisSerie, int totalGamesPlayedThisSerie);
|
||||
|
||||
public CardCollection getPrizeForLeague(int position, int playersCount, int gamesPlayed, int maxGamesPlayed, float multiplier);
|
||||
public CardCollection getPrizeForLeague(int position, int playersCount, int gamesPlayed, int maxGamesPlayed, CollectionType collectionType);
|
||||
}
|
||||
|
||||
@@ -12,23 +12,21 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class NewConstructedLeagueData implements LeagueData {
|
||||
private LeaguePrizes _leaguePrizes = new FixedLeaguePrizes();
|
||||
private List<LeagueSerieData> _series = new ArrayList<LeagueSerieData>();
|
||||
|
||||
private CollectionType _prizeCollectionType = CollectionType.MY_CARDS;
|
||||
private LeaguePrizes _leaguePrizes = new NewLeaguePrizes();
|
||||
private float _prizeMultiplier;
|
||||
private CollectionType _collectionType;
|
||||
|
||||
public NewConstructedLeagueData(String parameters) {
|
||||
String[] params = parameters.split(",");
|
||||
int start = Integer.parseInt(params[0]);
|
||||
CollectionType collectionType;
|
||||
if (params[1].equals("default"))
|
||||
collectionType = CollectionType.ALL_CARDS;
|
||||
_collectionType = CollectionType.ALL_CARDS;
|
||||
else if (params[1].equals("permanent"))
|
||||
collectionType = CollectionType.MY_CARDS;
|
||||
_collectionType = CollectionType.MY_CARDS;
|
||||
else
|
||||
throw new IllegalArgumentException("Unkown collection type");
|
||||
_prizeMultiplier = Float.parseFloat(params[2]);
|
||||
int series = Integer.parseInt(params[3]);
|
||||
|
||||
int serieStart = start;
|
||||
@@ -38,7 +36,7 @@ public class NewConstructedLeagueData implements LeagueData {
|
||||
int maxMatches = Integer.parseInt(params[6 + i * 3]);
|
||||
_series.add(new DefaultLeagueSerieData(_leaguePrizes, false, "Serie " + (i + 1),
|
||||
serieStart, DateUtils.offsetDate(serieStart, duration - 1),
|
||||
maxMatches, format, collectionType));
|
||||
maxMatches, format, _collectionType));
|
||||
|
||||
serieStart = DateUtils.offsetDate(serieStart, duration);
|
||||
}
|
||||
@@ -66,7 +64,7 @@ public class NewConstructedLeagueData implements LeagueData {
|
||||
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(), leagueStanding.getGamesPlayed(), maxGamesPlayed, _prizeMultiplier);
|
||||
CardCollection leaguePrize = _leaguePrizes.getPrizeForLeague(leagueStanding.getStanding(), leagueStandings.size(), leagueStanding.getGamesPlayed(), maxGamesPlayed, _collectionType);
|
||||
if (leaguePrize != null)
|
||||
collectionsManager.addItemsToPlayerCollection(true, "End of league prizes", leagueStanding.getPlayerName(), _prizeCollectionType, leaguePrize.getAll().values());
|
||||
}
|
||||
|
||||
@@ -1,124 +0,0 @@
|
||||
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 NewLeaguePrizes implements LeaguePrizes {
|
||||
private List<String> _commons = new ArrayList<String>();
|
||||
private List<String> _uncommons = new ArrayList<String>();
|
||||
private List<String> _promos = new ArrayList<String>();
|
||||
private List<String> _rares = new ArrayList<String>();
|
||||
|
||||
public NewLeaguePrizes() {
|
||||
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) {
|
||||
DefaultCardCollection leaguePrize = new DefaultCardCollection();
|
||||
int count = (int) Math.floor((2 * playersCount + 24) / (position + 9) - 2.4);
|
||||
if (count > 0) {
|
||||
count = 1 + (int) Math.floor((count - 1) * multiplier);
|
||||
leaguePrize.addItem("(S)Booster Choice", count);
|
||||
}
|
||||
int tengwar = getTengwarCount(position);
|
||||
if (tengwar > 0)
|
||||
leaguePrize.addItem("(S)Tengwar", tengwar);
|
||||
|
||||
if (position == 1) {
|
||||
addPrizes(leaguePrize, getRandomFoil(_promos, 3));
|
||||
} else if (position == 2) {
|
||||
addPrizes(leaguePrize, getRandomFoil(_promos, 2));
|
||||
addPrizes(leaguePrize, getRandom(_promos, 1));
|
||||
} else if (position == 3) {
|
||||
addPrizes(leaguePrize, getRandomFoil(_promos, 1));
|
||||
addPrizes(leaguePrize, getRandom(_promos, 2));
|
||||
} else if (position >= 4 && position <= 6) {
|
||||
addPrizes(leaguePrize, getRandom(_promos, 7 - position));
|
||||
} else if (position >= 9 && position <= 12) {
|
||||
addPrizes(leaguePrize, getRandom(_promos, 1));
|
||||
}
|
||||
|
||||
if (leaguePrize.getAll().size() == 0)
|
||||
return null;
|
||||
return leaguePrize;
|
||||
}
|
||||
|
||||
private void addPrizes(DefaultCardCollection leaguePrize, List<String> cards) {
|
||||
for (String card : cards)
|
||||
leaguePrize.addItem(card, 1);
|
||||
}
|
||||
|
||||
private int getTengwarCount(int position) {
|
||||
if (position == 1)
|
||||
return 4;
|
||||
else if (position == 2)
|
||||
return 3;
|
||||
else if (position == 3)
|
||||
return 2;
|
||||
else if (position <= 8)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
private String getRandom(List<String> list) {
|
||||
return list.get(new Random().nextInt(list.size()));
|
||||
}
|
||||
|
||||
private List<String> getRandom(List<String> list, int count) {
|
||||
List<String> result = new LinkedList<String>(list);
|
||||
Collections.shuffle(result);
|
||||
return result.subList(0, count);
|
||||
}
|
||||
|
||||
private List<String> getRandomFoil(List<String> list, int count) {
|
||||
List<String> result = new LinkedList<String>();
|
||||
for (String element : list)
|
||||
result.add(element + "*");
|
||||
Collections.shuffle(result);
|
||||
return result.subList(0, count);
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ public class NewSealedLeagueData implements LeagueData {
|
||||
private List<LeagueSerieData> _series;
|
||||
private CollectionType _collectionType;
|
||||
private CollectionType _prizeCollectionType = CollectionType.MY_CARDS;
|
||||
private LeaguePrizes _leaguePrizes;
|
||||
private LeaguePrizes _leaguePrizes = new FixedLeaguePrizes();
|
||||
private SealedLeagueProduct _leagueProduct;
|
||||
|
||||
public NewSealedLeagueData(String parameters) {
|
||||
@@ -31,7 +31,6 @@ public class NewSealedLeagueData implements LeagueData {
|
||||
|
||||
_collectionType = new CollectionType(params[4], params[5]);
|
||||
|
||||
_leaguePrizes = new NewLeaguePrizes();
|
||||
_leagueProduct = new SealedLeagueProduct();
|
||||
|
||||
_series = new LinkedList<LeagueSerieData>();
|
||||
@@ -88,7 +87,7 @@ public class NewSealedLeagueData implements LeagueData {
|
||||
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(), leagueStanding.getGamesPlayed(), maxGamesTotal, 1f);
|
||||
CardCollection leaguePrize = _leaguePrizes.getPrizeForLeague(leagueStanding.getStanding(), leagueStandings.size(), leagueStanding.getGamesPlayed(), maxGamesTotal, _collectionType);
|
||||
if (leaguePrize != null)
|
||||
collectionsManager.addItemsToPlayerCollection(true, "End of league prizes", leagueStanding.getPlayerName(), _prizeCollectionType, leaguePrize.getAll().values());
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public class SealedLeagueData implements LeagueData {
|
||||
private List<LeagueSerieData> _series;
|
||||
private CollectionType _collectionType;
|
||||
private CollectionType _prizeCollectionType = CollectionType.MY_CARDS;
|
||||
private LeaguePrizes _leaguePrizes;
|
||||
private LeaguePrizes _leaguePrizes = new FixedLeaguePrizes();
|
||||
private SealedLeagueProduct _leagueProduct;
|
||||
|
||||
public SealedLeagueData(String parameters) {
|
||||
@@ -31,7 +31,6 @@ public class SealedLeagueData implements LeagueData {
|
||||
int serieDuration = 7;
|
||||
int maxMatches = 10;
|
||||
|
||||
_leaguePrizes = new NewLeaguePrizes();
|
||||
_leagueProduct = new SealedLeagueProduct();
|
||||
|
||||
_series = new LinkedList<LeagueSerieData>();
|
||||
@@ -89,7 +88,7 @@ public class SealedLeagueData implements LeagueData {
|
||||
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(), leagueStanding.getGamesPlayed(), maxGamesPlayed, 1f);
|
||||
CardCollection leaguePrize = _leaguePrizes.getPrizeForLeague(leagueStanding.getStanding(), leagueStandings.size(), leagueStanding.getGamesPlayed(), maxGamesPlayed, _collectionType);
|
||||
if (leaguePrize != null)
|
||||
collectionsManager.addItemsToPlayerCollection(true, "End of league prizes", leagueStanding.getPlayerName(), _prizeCollectionType, leaguePrize.getAll().values());
|
||||
}
|
||||
|
||||
@@ -1,146 +0,0 @@
|
||||
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<String> _commons = new ArrayList<String>();
|
||||
private List<String> _uncommons = new ArrayList<String>();
|
||||
private List<String> _promos = new ArrayList<String>();
|
||||
private List<String> _rares = new ArrayList<String>();
|
||||
|
||||
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<String> cards) {
|
||||
for (String card : cards)
|
||||
leaguePrize.addItem(card, 1);
|
||||
}
|
||||
|
||||
private String getRandom(List<String> list) {
|
||||
return list.get(new Random().nextInt(list.size()));
|
||||
}
|
||||
|
||||
private List<String> getRandom(List<String> list, int count) {
|
||||
List<String> result = new LinkedList<String>(list);
|
||||
Collections.shuffle(result);
|
||||
return result.subList(0, count);
|
||||
}
|
||||
|
||||
private List<String> getRandomFoil(List<String> list, int count) {
|
||||
List<String> result = new LinkedList<String>();
|
||||
for (String element : list)
|
||||
result.add(element + "*");
|
||||
Collections.shuffle(result);
|
||||
return result.subList(0, count);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.gempukku.lotro.league;
|
||||
|
||||
import com.gempukku.lotro.db.vo.CollectionType;
|
||||
import com.gempukku.lotro.game.CardCollection;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -8,7 +9,7 @@ import java.util.Map;
|
||||
public class LeaguePrizesTest {
|
||||
@Test
|
||||
public void test() {
|
||||
LeaguePrizes leaguePrizes = new NewLeaguePrizes();
|
||||
LeaguePrizes leaguePrizes = new FixedLeaguePrizes();
|
||||
CardCollection prize = leaguePrizes.getPrizeForLeagueMatchWinner(2, 2);
|
||||
for (Map.Entry<String, CardCollection.Item> stringIntegerEntry : prize.getAll().entrySet()) {
|
||||
System.out.println(stringIntegerEntry.getKey() + ": " + stringIntegerEntry.getValue().getCount());
|
||||
@@ -17,10 +18,10 @@ public class LeaguePrizesTest {
|
||||
|
||||
@Test
|
||||
public void testLeaguePrize() {
|
||||
LeaguePrizes leaguePrizes = new NewLeaguePrizes();
|
||||
LeaguePrizes leaguePrizes = new FixedLeaguePrizes();
|
||||
for (int i = 1; i <= 32; i++) {
|
||||
System.out.println("Place "+i);
|
||||
CardCollection prize = leaguePrizes.getPrizeForLeague(i, 60, 1, 2, 2f);
|
||||
CardCollection prize = leaguePrizes.getPrizeForLeague(i, 60, 1, 2, CollectionType.ALL_CARDS);
|
||||
if (prize != null)
|
||||
for (Map.Entry<String, CardCollection.Item> stringIntegerEntry : prize.getAll().entrySet()) {
|
||||
System.out.println(stringIntegerEntry.getKey() + ": " + stringIntegerEntry.getValue().getCount());
|
||||
|
||||
Reference in New Issue
Block a user