mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Merge pull request #6539 from kevlahnota/master2
prevent townPriceModifier NPE
This commit is contained in:
@@ -3,6 +3,7 @@ package forge.adventure.character;
|
|||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
import forge.Forge;
|
import forge.Forge;
|
||||||
import forge.adventure.data.ShopData;
|
import forge.adventure.data.ShopData;
|
||||||
|
import forge.adventure.pointofintrest.PointOfInterestChanges;
|
||||||
import forge.adventure.scene.RewardScene;
|
import forge.adventure.scene.RewardScene;
|
||||||
import forge.adventure.stage.MapStage;
|
import forge.adventure.stage.MapStage;
|
||||||
import forge.adventure.util.Reward;
|
import forge.adventure.util.Reward;
|
||||||
@@ -11,31 +12,33 @@ import forge.adventure.util.Reward;
|
|||||||
/**
|
/**
|
||||||
* Map actor that will open the Shop on collision
|
* Map actor that will open the Shop on collision
|
||||||
*/
|
*/
|
||||||
public class ShopActor extends MapActor{
|
public class ShopActor extends MapActor {
|
||||||
private final MapStage stage;
|
private final MapStage stage;
|
||||||
private ShopData shopData;
|
private ShopData shopData;
|
||||||
Array<Reward> rewardData;
|
Array<Reward> rewardData;
|
||||||
|
|
||||||
public ShopActor(MapStage stage, int id, Array<Reward> rewardData, ShopData data)
|
public ShopActor(MapStage stage, int id, Array<Reward> rewardData, ShopData data) {
|
||||||
{
|
|
||||||
super(id);
|
super(id);
|
||||||
this.stage = stage;
|
this.stage = stage;
|
||||||
this.shopData = data;
|
this.shopData = data;
|
||||||
this.rewardData = rewardData;
|
this.rewardData = rewardData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getPriceModifier() { return ( stage.getChanges().getShopPriceModifier(objectId) * stage.getChanges().getTownPriceModifier() ); }
|
public float getPriceModifier() {
|
||||||
public MapStage getMapStage()
|
PointOfInterestChanges changes = stage.getChanges();
|
||||||
{
|
float townPricemodifier = changes == null ? 1f : changes.getTownPriceModifier();
|
||||||
|
float shopPriceModifier = changes == null ? 1f : changes.getShopPriceModifier(objectId);
|
||||||
|
return shopPriceModifier * townPricemodifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MapStage getMapStage() {
|
||||||
return stage;
|
return stage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerCollide()
|
public void onPlayerCollide() {
|
||||||
{
|
|
||||||
|
|
||||||
stage.getPlayerSprite().stop();
|
stage.getPlayerSprite().stop();
|
||||||
RewardScene.instance().loadRewards(rewardData, RewardScene.Type.Shop,this);
|
RewardScene.instance().loadRewards(rewardData, RewardScene.Type.Shop, this);
|
||||||
Forge.switchScene(RewardScene.instance());
|
Forge.switchScene(RewardScene.instance());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,8 +64,15 @@ public class ShopActor extends MapActor{
|
|||||||
return getRestockPrice() > 0;
|
return getRestockPrice() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ShopData getShopData() { return shopData; }
|
public ShopData getShopData() {
|
||||||
|
return shopData;
|
||||||
|
}
|
||||||
|
|
||||||
public void setRewardData(Array<Reward> data) { rewardData = data; }
|
public void setRewardData(Array<Reward> data) {
|
||||||
public Array<Reward> getRewardData() { return rewardData;}
|
rewardData = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Array<Reward> getRewardData() {
|
||||||
|
return rewardData;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ public class AdventureEventData implements Serializable {
|
|||||||
random = (eventSeed > 0 ? new Random(eventSeed) : new Random());
|
random = (eventSeed > 0 ? new Random(eventSeed) : new Random());
|
||||||
return random;
|
return random;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AdventureEventData(Long seed, AdventureEventController.EventFormat selectedFormat) {
|
public AdventureEventData(Long seed, AdventureEventController.EventFormat selectedFormat) {
|
||||||
setEventSeed(seed);
|
setEventSeed(seed);
|
||||||
eventStatus = AdventureEventController.EventStatus.Available;
|
eventStatus = AdventureEventController.EventStatus.Available;
|
||||||
@@ -106,7 +107,7 @@ public class AdventureEventData implements Serializable {
|
|||||||
//Below all to be fully generated in later release
|
//Below all to be fully generated in later release
|
||||||
rewardPacks = getRewardPacks(3);
|
rewardPacks = getRewardPacks(3);
|
||||||
generateParticipants(7);
|
generateParticipants(7);
|
||||||
if (cardBlock != null){
|
if (cardBlock != null) {
|
||||||
packConfiguration = getBoosterConfiguration(cardBlock);
|
packConfiguration = getBoosterConfiguration(cardBlock);
|
||||||
|
|
||||||
rewards = new AdventureEventData.AdventureEventReward[4];
|
rewards = new AdventureEventData.AdventureEventReward[4];
|
||||||
@@ -127,8 +128,7 @@ public class AdventureEventData implements Serializable {
|
|||||||
r2.itemRewards = new String[]{"Challenge Coin"};
|
r2.itemRewards = new String[]{"Challenge Coin"};
|
||||||
rewards[2] = r2;
|
rewards[2] = r2;
|
||||||
}
|
}
|
||||||
}
|
} else if (format.equals(AdventureEventController.EventFormat.Jumpstart)) {
|
||||||
else if (format.equals(AdventureEventController.EventFormat.Jumpstart)) {
|
|
||||||
int numPacksToPickFrom = 6;
|
int numPacksToPickFrom = 6;
|
||||||
generateParticipants(7);
|
generateParticipants(7);
|
||||||
|
|
||||||
@@ -139,7 +139,7 @@ public class AdventureEventData implements Serializable {
|
|||||||
|
|
||||||
jumpstartBoosters = AdventureEventController.instance().getJumpstartBoosters(cardBlock, numPacksToPickFrom);
|
jumpstartBoosters = AdventureEventController.instance().getJumpstartBoosters(cardBlock, numPacksToPickFrom);
|
||||||
|
|
||||||
packConfiguration = new String[] {cardBlock.getLandSet().getCode(), cardBlock.getLandSet().getCode(), cardBlock.getLandSet().getCode()};
|
packConfiguration = new String[]{cardBlock.getLandSet().getCode(), cardBlock.getLandSet().getCode(), cardBlock.getLandSet().getCode()};
|
||||||
|
|
||||||
for (AdventureEventParticipant participant : participants) {
|
for (AdventureEventParticipant participant : participants) {
|
||||||
List<Deck> availableOptions = AdventureEventController.instance().getJumpstartBoosters(cardBlock, numPacksToPickFrom);
|
List<Deck> availableOptions = AdventureEventController.instance().getJumpstartBoosters(cardBlock, numPacksToPickFrom);
|
||||||
@@ -172,9 +172,8 @@ public class AdventureEventData implements Serializable {
|
|||||||
}
|
}
|
||||||
if (themeAdded.isEmpty()) {
|
if (themeAdded.isEmpty()) {
|
||||||
done = true;
|
done = true;
|
||||||
}
|
} else {
|
||||||
else {
|
chosenPacks.addAll(themeMap.get(themeAdded).subList(0, Math.min(themeMap.get(themeAdded).size(), packConfiguration.length - chosenPacks.size())));
|
||||||
chosenPacks.addAll(themeMap.get(themeAdded).subList(0, Math.min(themeMap.get(themeAdded).size(),packConfiguration.length - chosenPacks.size())));
|
|
||||||
availableOptions.removeAll(themeMap.get(themeAdded));
|
availableOptions.removeAll(themeMap.get(themeAdded));
|
||||||
themeMap.remove(themeAdded);
|
themeMap.remove(themeAdded);
|
||||||
themeAdded = "";
|
themeAdded = "";
|
||||||
@@ -184,13 +183,20 @@ public class AdventureEventData implements Serializable {
|
|||||||
//2. Fill remaining slots with colors already picked whenever possible
|
//2. Fill remaining slots with colors already picked whenever possible
|
||||||
Map<String, List<Deck>> colorMap = new HashMap<>();
|
Map<String, List<Deck>> colorMap = new HashMap<>();
|
||||||
for (Deck option : availableOptions) {
|
for (Deck option : availableOptions) {
|
||||||
if (option.getTags().contains("black")) colorMap.getOrDefault("black", new ArrayList<Deck>()).add(option);
|
if (option.getTags().contains("black"))
|
||||||
if (option.getTags().contains("blue")) colorMap.getOrDefault("blue", new ArrayList<Deck>()).add(option);
|
colorMap.getOrDefault("black", new ArrayList<Deck>()).add(option);
|
||||||
if (option.getTags().contains("green")) colorMap.getOrDefault("green", new ArrayList<Deck>()).add(option);
|
if (option.getTags().contains("blue"))
|
||||||
if (option.getTags().contains("red")) colorMap.getOrDefault("red", new ArrayList<Deck>()).add(option);
|
colorMap.getOrDefault("blue", new ArrayList<Deck>()).add(option);
|
||||||
if (option.getTags().contains("white")) colorMap.getOrDefault("white", new ArrayList<Deck>()).add(option);
|
if (option.getTags().contains("green"))
|
||||||
if (option.getTags().contains("multicolor")) colorMap.getOrDefault("multicolor", new ArrayList<Deck>()).add(option);
|
colorMap.getOrDefault("green", new ArrayList<Deck>()).add(option);
|
||||||
if (option.getTags().contains("colorless")) colorMap.getOrDefault("colorless", new ArrayList<Deck>()).add(option);
|
if (option.getTags().contains("red"))
|
||||||
|
colorMap.getOrDefault("red", new ArrayList<Deck>()).add(option);
|
||||||
|
if (option.getTags().contains("white"))
|
||||||
|
colorMap.getOrDefault("white", new ArrayList<Deck>()).add(option);
|
||||||
|
if (option.getTags().contains("multicolor"))
|
||||||
|
colorMap.getOrDefault("multicolor", new ArrayList<Deck>()).add(option);
|
||||||
|
if (option.getTags().contains("colorless"))
|
||||||
|
colorMap.getOrDefault("colorless", new ArrayList<Deck>()).add(option);
|
||||||
}
|
}
|
||||||
|
|
||||||
done = false;
|
done = false;
|
||||||
@@ -218,19 +224,18 @@ public class AdventureEventData implements Serializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//3. If no matching color found and need more packs, add any available at random.
|
//3. If no matching color found and need more packs, add any available at random.
|
||||||
if (packConfiguration.length > chosenPacks.size() && colorAdded.isEmpty() && !availableOptions.isEmpty()){
|
if (packConfiguration.length > chosenPacks.size() && colorAdded.isEmpty() && !availableOptions.isEmpty()) {
|
||||||
chosenPacks.add(Aggregates.removeRandom(availableOptions));
|
chosenPacks.add(Aggregates.removeRandom(availableOptions));
|
||||||
colorAdded = "";
|
colorAdded = "";
|
||||||
}
|
} else {
|
||||||
else {
|
done = colorAdded.isEmpty() || packConfiguration.length <= chosenPacks.size();
|
||||||
done = colorAdded.isEmpty() || packConfiguration.length <= chosenPacks.size();
|
colorAdded = "";
|
||||||
colorAdded = "";
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
participant.registeredDeck = new Deck();
|
participant.registeredDeck = new Deck();
|
||||||
for (Deck chosen : chosenPacks){
|
for (Deck chosen : chosenPacks) {
|
||||||
participant.registeredDeck.getMain().addAllFlat(chosen.getMain().toFlatList());
|
participant.registeredDeck.getMain().addAllFlat(chosen.getMain().toFlatList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -404,7 +409,7 @@ public class AdventureEventData implements Serializable {
|
|||||||
legalBlocks.removeIf(q -> q.getName().equals(restricted));
|
legalBlocks.removeIf(q -> q.getName().equals(restricted));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return legalBlocks.isEmpty()?null:Aggregates.random(legalBlocks);
|
return legalBlocks.isEmpty() ? null : Aggregates.random(legalBlocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -505,9 +510,7 @@ public class AdventureEventData implements Serializable {
|
|||||||
draftedDeck.setComment("Prize for placing 1st overall in draft event");
|
draftedDeck.setComment("Prize for placing 1st overall in draft event");
|
||||||
rewards[3].cardRewards = new Deck[]{draftedDeck};
|
rewards[3].cardRewards = new Deck[]{draftedDeck};
|
||||||
|
|
||||||
}
|
} else if (format == AdventureEventController.EventFormat.Jumpstart) {
|
||||||
|
|
||||||
else if (format == AdventureEventController.EventFormat.Jumpstart) {
|
|
||||||
|
|
||||||
rewards[3] = new AdventureEventReward();
|
rewards[3] = new AdventureEventReward();
|
||||||
rewards[3].minWins = 0;
|
rewards[3].minWins = 0;
|
||||||
@@ -538,7 +541,7 @@ public class AdventureEventData implements Serializable {
|
|||||||
data.itemName = item;
|
data.itemName = item;
|
||||||
ret.addAll(data.generate(false, true));
|
ret.addAll(data.generate(false, true));
|
||||||
}
|
}
|
||||||
for (RewardData data : r.rewards) {
|
for (RewardData data : r.rewards) {
|
||||||
ret.addAll(data.generate(false, true));
|
ret.addAll(data.generate(false, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -570,12 +573,13 @@ public class AdventureEventData implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription(PointOfInterestChanges changes) {
|
public String getDescription(PointOfInterestChanges changes) {
|
||||||
|
float townPriceModifier = changes == null ? 1f : changes.getTownPriceModifier();
|
||||||
if (format.equals(AdventureEventController.EventFormat.Draft)) {
|
if (format.equals(AdventureEventController.EventFormat.Draft)) {
|
||||||
description = "Event Type: Booster Draft\n";
|
description = "Event Type: Booster Draft\n";
|
||||||
description += "Block: " + getCardBlock() + "\n";
|
description += "Block: " + getCardBlock() + "\n";
|
||||||
description += "Boosters: " + String.join(", ", packConfiguration) + "\n";
|
description += "Boosters: " + String.join(", ", packConfiguration) + "\n";
|
||||||
description += "Competition Style: " + participants.length + " players, matches played as best of " + eventRules.gamesPerMatch + ", " + (getPairingDescription()) + "\n\n";
|
description += "Competition Style: " + participants.length + " players, matches played as best of " + eventRules.gamesPerMatch + ", " + (getPairingDescription()) + "\n\n";
|
||||||
description += String.format("Entry Fee (incl. reputation)\nGold %d[][+Gold][BLACK]\nMana Shards %d[][+Shards][BLACK]\n", Math.round(eventRules.goldToEnter * changes.getTownPriceModifier()), Math.round(eventRules.shardsToEnter * changes.getTownPriceModifier()));
|
description += String.format("Entry Fee (incl. reputation)\nGold %d[][+Gold][BLACK]\nMana Shards %d[][+Shards][BLACK]\n", Math.round(eventRules.goldToEnter * townPriceModifier), Math.round(eventRules.shardsToEnter * townPriceModifier));
|
||||||
if (eventRules.acceptsBronzeChallengeCoin) {
|
if (eventRules.acceptsBronzeChallengeCoin) {
|
||||||
description += "Bronze Challenge Coin [][+BronzeChallengeCoin][BLACK]\n\n";
|
description += "Bronze Challenge Coin [][+BronzeChallengeCoin][BLACK]\n\n";
|
||||||
} else if (eventRules.acceptsSilverChallengeCoin) {
|
} else if (eventRules.acceptsSilverChallengeCoin) {
|
||||||
@@ -586,12 +590,11 @@ public class AdventureEventData implements Serializable {
|
|||||||
description += "\n";
|
description += "\n";
|
||||||
}
|
}
|
||||||
description += String.format("Prizes\nChampion: Keep drafted deck\n2+ round wins: Challenge Coin \n1+ round wins: %s Booster, %s Booster\n0 round wins: %s Booster", rewardPacks[0].getComment(), rewardPacks[1].getComment(), rewardPacks[2].getComment());
|
description += String.format("Prizes\nChampion: Keep drafted deck\n2+ round wins: Challenge Coin \n1+ round wins: %s Booster, %s Booster\n0 round wins: %s Booster", rewardPacks[0].getComment(), rewardPacks[1].getComment(), rewardPacks[2].getComment());
|
||||||
}
|
} else if (format.equals(AdventureEventController.EventFormat.Jumpstart)) {
|
||||||
else if (format.equals(AdventureEventController.EventFormat.Jumpstart)) {
|
|
||||||
description = "Event Type: Jumpstart\n";
|
description = "Event Type: Jumpstart\n";
|
||||||
description += "Block: " + getCardBlock() + "\n";
|
description += "Block: " + getCardBlock() + "\n";
|
||||||
description += "Competition Style: " + participants.length + " players, matches played as best of " + eventRules.gamesPerMatch + ", " + (getPairingDescription()) + "\n\n";
|
description += "Competition Style: " + participants.length + " players, matches played as best of " + eventRules.gamesPerMatch + ", " + (getPairingDescription()) + "\n\n";
|
||||||
description += String.format("Entry Fee (incl. reputation)\nGold %d[][+Gold][BLACK]\nMana Shards %d[][+Shards][BLACK]\n", Math.round(eventRules.goldToEnter * changes.getTownPriceModifier()), Math.round(eventRules.shardsToEnter * changes.getTownPriceModifier()));
|
description += String.format("Entry Fee (incl. reputation)\nGold %d[][+Gold][BLACK]\nMana Shards %d[][+Shards][BLACK]\n", Math.round(eventRules.goldToEnter * townPriceModifier), Math.round(eventRules.shardsToEnter * townPriceModifier));
|
||||||
if (eventRules.acceptsBronzeChallengeCoin) {
|
if (eventRules.acceptsBronzeChallengeCoin) {
|
||||||
description += "Bronze Challenge Coin [][+BronzeChallengeCoin][BLACK]\n\n";
|
description += "Bronze Challenge Coin [][+BronzeChallengeCoin][BLACK]\n\n";
|
||||||
} else if (eventRules.acceptsSilverChallengeCoin) {
|
} else if (eventRules.acceptsSilverChallengeCoin) {
|
||||||
@@ -645,7 +648,7 @@ public class AdventureEventData implements Serializable {
|
|||||||
public Image getAvatar() {
|
public Image getAvatar() {
|
||||||
if (sprite == null) {
|
if (sprite == null) {
|
||||||
EnemyData data = WorldData.getEnemy(enemyDataName);
|
EnemyData data = WorldData.getEnemy(enemyDataName);
|
||||||
if (data == null){
|
if (data == null) {
|
||||||
//enemyDataName was not found, replace with something valid.
|
//enemyDataName was not found, replace with something valid.
|
||||||
enemyDataName = Aggregates.random(WorldData.getAllEnemies()).getName();
|
enemyDataName = Aggregates.random(WorldData.getAllEnemies()).getName();
|
||||||
}
|
}
|
||||||
@@ -683,10 +686,12 @@ public class AdventureEventData implements Serializable {
|
|||||||
public Deck getDeck() {
|
public Deck getDeck() {
|
||||||
return registeredDeck == null ? Current.player().getSelectedDeck() : registeredDeck;
|
return registeredDeck == null ? Current.player().getSelectedDeck() : registeredDeck;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return Current.player().getName();
|
return Current.player().getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Image getAvatar() {
|
public Image getAvatar() {
|
||||||
return new Image(Current.player().avatar());
|
return new Image(Current.player().avatar());
|
||||||
@@ -717,12 +722,12 @@ public class AdventureEventData implements Serializable {
|
|||||||
this(format, PairingStyle.SingleElimination, localPriceModifier);
|
this(format, PairingStyle.SingleElimination, localPriceModifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AdventureEventRules(AdventureEventController.EventFormat format, PairingStyle pairingStyle, float localPriceModifier){
|
public AdventureEventRules(AdventureEventController.EventFormat format, PairingStyle pairingStyle, float localPriceModifier) {
|
||||||
int baseGoldEntry = 99999;
|
int baseGoldEntry = 99999;
|
||||||
int baseShardEntry = 9999;
|
int baseShardEntry = 9999;
|
||||||
this.pairingStyle = pairingStyle;
|
this.pairingStyle = pairingStyle;
|
||||||
|
|
||||||
switch (format){
|
switch (format) {
|
||||||
case Constructed:
|
case Constructed:
|
||||||
acceptsSilverChallengeCoin = true;
|
acceptsSilverChallengeCoin = true;
|
||||||
acceptsChallengeCoin = false;
|
acceptsChallengeCoin = false;
|
||||||
|
|||||||
@@ -350,8 +350,7 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
|||||||
setColorIdentity(temp);
|
setColorIdentity(temp);
|
||||||
else
|
else
|
||||||
colorIdentity = ColorSet.ALL_COLORS;
|
colorIdentity = ColorSet.ALL_COLORS;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
colorIdentity = ColorSet.ALL_COLORS;
|
colorIdentity = ColorSet.ALL_COLORS;
|
||||||
|
|
||||||
gold = data.readInt("gold");
|
gold = data.readInt("gold");
|
||||||
@@ -467,19 +466,19 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
|||||||
|
|
||||||
if (data.containsKey("newCards")) {
|
if (data.containsKey("newCards")) {
|
||||||
InventoryItem[] items = (InventoryItem[]) data.readObject("newCards");
|
InventoryItem[] items = (InventoryItem[]) data.readObject("newCards");
|
||||||
for (InventoryItem item : items){
|
for (InventoryItem item : items) {
|
||||||
newCards.add((PaperCard)item);
|
newCards.add((PaperCard) item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (data.containsKey("noSellCards")) {
|
if (data.containsKey("noSellCards")) {
|
||||||
PaperCard[] items = (PaperCard[]) data.readObject("noSellCards");
|
PaperCard[] items = (PaperCard[]) data.readObject("noSellCards");
|
||||||
for (PaperCard item : items){
|
for (PaperCard item : items) {
|
||||||
noSellCards.add(item);
|
noSellCards.add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (data.containsKey("autoSellCards")) {
|
if (data.containsKey("autoSellCards")) {
|
||||||
PaperCard[] items = (PaperCard[]) data.readObject("autoSellCards");
|
PaperCard[] items = (PaperCard[]) data.readObject("autoSellCards");
|
||||||
for (PaperCard item : items){
|
for (PaperCard item : items) {
|
||||||
autoSellCards.add(item);
|
autoSellCards.add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -598,6 +597,7 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
|||||||
public TextureRegion avatar() {
|
public TextureRegion avatar() {
|
||||||
return HeroListData.instance().getAvatar(heroRace, isFemale, avatarIndex);
|
return HeroListData.instance().getAvatar(heroRace, isFemale, avatarIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String raceName() {
|
public String raceName() {
|
||||||
return HeroListData.instance().getRaces().get(Current.player().heroRace);
|
return HeroListData.instance().getRaces().get(Current.player().heroRace);
|
||||||
}
|
}
|
||||||
@@ -607,6 +607,7 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
|||||||
return MapStage.getInstance();
|
return MapStage.getInstance();
|
||||||
return WorldStage.getInstance();
|
return WorldStage.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addStatusMessage(String iconName, String message, Integer itemCount, float x, float y) {
|
public void addStatusMessage(String iconName, String message, Integer itemCount, float x, float y) {
|
||||||
String symbol = itemCount == null || itemCount < 0 ? "" : " +";
|
String symbol = itemCount == null || itemCount < 0 ? "" : " +";
|
||||||
String icon = iconName == null ? "" : "[+" + iconName + "]";
|
String icon = iconName == null ? "" : "[+" + iconName + "]";
|
||||||
@@ -614,12 +615,13 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
|||||||
TextraLabel actor = Controls.newTextraLabel("[%95]" + icon + "[WHITE]" + symbol + count + " " + message);
|
TextraLabel actor = Controls.newTextraLabel("[%95]" + icon + "[WHITE]" + symbol + count + " " + message);
|
||||||
actor.setPosition(x, y);
|
actor.setPosition(x, y);
|
||||||
actor.addAction(Actions.sequence(
|
actor.addAction(Actions.sequence(
|
||||||
Actions.parallel(Actions.moveBy(0f, 5f, 3f), Actions.fadeIn(2f)),
|
Actions.parallel(Actions.moveBy(0f, 5f, 3f), Actions.fadeIn(2f)),
|
||||||
Actions.hide(),
|
Actions.hide(),
|
||||||
Actions.removeActor())
|
Actions.removeActor())
|
||||||
);
|
);
|
||||||
getCurrentGameStage().addActor(actor);
|
getCurrentGameStage().addActor(actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addCard(PaperCard card) {
|
public void addCard(PaperCard card) {
|
||||||
cards.add(card);
|
cards.add(card);
|
||||||
newCards.add(card);
|
newCards.add(card);
|
||||||
@@ -631,8 +633,8 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
|||||||
cards.add(reward.getCard());
|
cards.add(reward.getCard());
|
||||||
newCards.add(reward.getCard());
|
newCards.add(reward.getCard());
|
||||||
if (reward.isAutoSell()) {
|
if (reward.isAutoSell()) {
|
||||||
autoSellCards.add(reward.getCard());
|
autoSellCards.add(reward.getCard());
|
||||||
refreshEditor();
|
refreshEditor();
|
||||||
} else if (reward.isNoSell()) {
|
} else if (reward.isNoSell()) {
|
||||||
noSellCards.add(reward.getCard());
|
noSellCards.add(reward.getCard());
|
||||||
refreshEditor();
|
refreshEditor();
|
||||||
@@ -847,9 +849,9 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
|||||||
for (String name : equippedItems.values()) {
|
for (String name : equippedItems.values()) {
|
||||||
ItemData data = ItemData.getItem(name);
|
ItemData data = ItemData.getItem(name);
|
||||||
if (data != null
|
if (data != null
|
||||||
&& ("Boots".equalsIgnoreCase(data.equipmentSlot)
|
&& ("Boots".equalsIgnoreCase(data.equipmentSlot)
|
||||||
|| "Body".equalsIgnoreCase(data.equipmentSlot)
|
|| "Body".equalsIgnoreCase(data.equipmentSlot)
|
||||||
|| "Neck".equalsIgnoreCase(data.equipmentSlot))) {
|
|| "Neck".equalsIgnoreCase(data.equipmentSlot))) {
|
||||||
armor.add(data);
|
armor.add(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -903,7 +905,8 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int cardSellPrice(PaperCard card) {
|
public int cardSellPrice(PaperCard card) {
|
||||||
return (int) (CardUtil.getCardPrice(card) * difficultyData.sellFactor * (2.0f - currentLocationChanges.getTownPriceModifier()));
|
float townPriceModifier = currentLocationChanges == null ? 1f : currentLocationChanges.getTownPriceModifier();
|
||||||
|
return (int) (CardUtil.getCardPrice(card) * difficultyData.sellFactor * (2.0f - townPriceModifier));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sellCard(PaperCard card, Integer result) {
|
public void sellCard(PaperCard card, Integer result) {
|
||||||
|
|||||||
@@ -57,29 +57,30 @@ public class EventScene extends MenuScene implements IAfterMatch {
|
|||||||
|
|
||||||
private EventScene() {
|
private EventScene() {
|
||||||
super(Forge.isLandscapeMode() ? "ui/event.json" : "ui/event_portrait.json");
|
super(Forge.isLandscapeMode() ? "ui/event.json" : "ui/event_portrait.json");
|
||||||
//todo: add translation
|
// TODO: Add translation
|
||||||
|
float townPriceModifier = changes == null ? 1f : changes.getTownPriceModifier();
|
||||||
DialogData introDialog = new DialogData();
|
DialogData introDialog = new DialogData();
|
||||||
introDialog.text = "Enter this event?";
|
introDialog.text = "Enter this event?";
|
||||||
DialogData enterWithCoin = new DialogData();
|
DialogData enterWithCoin = new DialogData();
|
||||||
|
|
||||||
DialogData enterWithShards = new DialogData();
|
DialogData enterWithShards = new DialogData();
|
||||||
enterWithShards.name = String.format("Spend %d [+shards]", Math.round(currentEvent.eventRules.shardsToEnter* changes.getTownPriceModifier()));
|
enterWithShards.name = String.format("Spend %d [+shards]", Math.round(currentEvent.eventRules.shardsToEnter * townPriceModifier));
|
||||||
DialogData enterWithGold = new DialogData();
|
DialogData enterWithGold = new DialogData();
|
||||||
enterWithGold.name = String.format("Spend %d [+gold]", Math.round(currentEvent.eventRules.goldToEnter * changes.getTownPriceModifier()));
|
enterWithGold.name = String.format("Spend %d [+gold]", Math.round(currentEvent.eventRules.goldToEnter * townPriceModifier));
|
||||||
|
|
||||||
DialogData.ConditionData hasGold = new DialogData.ConditionData();
|
DialogData.ConditionData hasGold = new DialogData.ConditionData();
|
||||||
hasGold.hasGold = Math.round(currentEvent.eventRules.goldToEnter * changes.getTownPriceModifier());
|
hasGold.hasGold = Math.round(currentEvent.eventRules.goldToEnter * townPriceModifier);
|
||||||
enterWithGold.condition = new DialogData.ConditionData[]{hasGold};
|
enterWithGold.condition = new DialogData.ConditionData[]{hasGold};
|
||||||
|
|
||||||
DialogData.ConditionData hasShards = new DialogData.ConditionData();
|
DialogData.ConditionData hasShards = new DialogData.ConditionData();
|
||||||
hasShards.hasShards = Math.round(currentEvent.eventRules.shardsToEnter * changes.getTownPriceModifier());
|
hasShards.hasShards = Math.round(currentEvent.eventRules.shardsToEnter * townPriceModifier);
|
||||||
enterWithShards.condition = new DialogData.ConditionData[]{hasShards};
|
enterWithShards.condition = new DialogData.ConditionData[]{hasShards};
|
||||||
|
|
||||||
if (currentEvent.eventRules.acceptsChallengeCoin) {
|
if (currentEvent.eventRules.acceptsChallengeCoin) {
|
||||||
enterWithCoin.name = "Redeem a Challenge Coin [+ChallengeCoin]";
|
enterWithCoin.name = "Redeem a Challenge Coin [+ChallengeCoin]";
|
||||||
|
|
||||||
DialogData.ConditionData hasCoin = new DialogData.ConditionData();
|
DialogData.ConditionData hasCoin = new DialogData.ConditionData();
|
||||||
hasCoin.item="Challenge Coin";
|
hasCoin.item = "Challenge Coin";
|
||||||
enterWithCoin.condition = new DialogData.ConditionData[]{hasCoin};
|
enterWithCoin.condition = new DialogData.ConditionData[]{hasCoin};
|
||||||
|
|
||||||
DialogData.ActionData giveCoin = new DialogData.ActionData();
|
DialogData.ActionData giveCoin = new DialogData.ActionData();
|
||||||
@@ -88,7 +89,7 @@ public class EventScene extends MenuScene implements IAfterMatch {
|
|||||||
} else if (currentEvent.eventRules.acceptsSilverChallengeCoin) {
|
} else if (currentEvent.eventRules.acceptsSilverChallengeCoin) {
|
||||||
enterWithCoin.name = "Redeem a Challenge Coin [+SilverChallengeCoin]";
|
enterWithCoin.name = "Redeem a Challenge Coin [+SilverChallengeCoin]";
|
||||||
DialogData.ConditionData hasCoin = new DialogData.ConditionData();
|
DialogData.ConditionData hasCoin = new DialogData.ConditionData();
|
||||||
hasCoin.item="Silver Challenge Coin";
|
hasCoin.item = "Silver Challenge Coin";
|
||||||
enterWithCoin.condition = new DialogData.ConditionData[]{hasCoin};
|
enterWithCoin.condition = new DialogData.ConditionData[]{hasCoin};
|
||||||
|
|
||||||
DialogData.ActionData giveCoin = new DialogData.ActionData();
|
DialogData.ActionData giveCoin = new DialogData.ActionData();
|
||||||
@@ -97,30 +98,28 @@ public class EventScene extends MenuScene implements IAfterMatch {
|
|||||||
} else if (currentEvent.eventRules.acceptsBronzeChallengeCoin) {
|
} else if (currentEvent.eventRules.acceptsBronzeChallengeCoin) {
|
||||||
enterWithCoin.name = "Redeem a Challenge Coin [+BronzeChallengeCoin]";
|
enterWithCoin.name = "Redeem a Challenge Coin [+BronzeChallengeCoin]";
|
||||||
DialogData.ConditionData hasCoin = new DialogData.ConditionData();
|
DialogData.ConditionData hasCoin = new DialogData.ConditionData();
|
||||||
hasCoin.item="Bronze Challenge Coin";
|
hasCoin.item = "Bronze Challenge Coin";
|
||||||
enterWithCoin.condition = new DialogData.ConditionData[]{hasCoin};
|
enterWithCoin.condition = new DialogData.ConditionData[]{hasCoin};
|
||||||
|
|
||||||
DialogData.ActionData giveCoin = new DialogData.ActionData();
|
DialogData.ActionData giveCoin = new DialogData.ActionData();
|
||||||
giveCoin.removeItem = hasCoin.item;
|
giveCoin.removeItem = hasCoin.item;
|
||||||
enterWithCoin.action = new DialogData.ActionData[]{giveCoin};
|
enterWithCoin.action = new DialogData.ActionData[]{giveCoin};
|
||||||
|
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
DialogData.ConditionData alwaysFalse = new DialogData.ConditionData();
|
DialogData.ConditionData alwaysFalse = new DialogData.ConditionData();
|
||||||
alwaysFalse.item = "NonexistentItem";
|
alwaysFalse.item = "NonexistentItem";
|
||||||
enterWithCoin.condition = new DialogData.ConditionData[]{alwaysFalse};
|
enterWithCoin.condition = new DialogData.ConditionData[]{alwaysFalse};
|
||||||
}
|
}
|
||||||
|
|
||||||
DialogData.ActionData spendGold = new DialogData.ActionData();
|
DialogData.ActionData spendGold = new DialogData.ActionData();
|
||||||
spendGold.addGold=-Math.round(currentEvent.eventRules.goldToEnter * changes.getTownPriceModifier());
|
spendGold.addGold = -Math.round(currentEvent.eventRules.goldToEnter * townPriceModifier);
|
||||||
enterWithGold.action = new DialogData.ActionData[]{spendGold};
|
enterWithGold.action = new DialogData.ActionData[]{spendGold};
|
||||||
|
|
||||||
DialogData.ActionData spendShards = new DialogData.ActionData();
|
DialogData.ActionData spendShards = new DialogData.ActionData();
|
||||||
spendShards.addShards =-Math.round(currentEvent.eventRules.shardsToEnter * changes.getTownPriceModifier());
|
spendShards.addShards = -Math.round(currentEvent.eventRules.shardsToEnter * townPriceModifier);
|
||||||
enterWithShards.action = new DialogData.ActionData[]{spendShards};
|
enterWithShards.action = new DialogData.ActionData[]{spendShards};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DialogData decline = new DialogData();
|
DialogData decline = new DialogData();
|
||||||
//todo: add translation
|
//todo: add translation
|
||||||
decline.name = "Do not enter event";
|
decline.name = "Do not enter event";
|
||||||
@@ -194,8 +193,7 @@ public class EventScene extends MenuScene implements IAfterMatch {
|
|||||||
if (currentEvent.format == AdventureEventController.EventFormat.Draft && currentEvent.eventStatus == Ready) {
|
if (currentEvent.format == AdventureEventController.EventFormat.Draft && currentEvent.eventStatus == Ready) {
|
||||||
DraftScene.instance().loadEvent(currentEvent);
|
DraftScene.instance().loadEvent(currentEvent);
|
||||||
Forge.switchScene(DraftScene.instance());
|
Forge.switchScene(DraftScene.instance());
|
||||||
}
|
} else if (currentEvent.format == AdventureEventController.EventFormat.Jumpstart && currentEvent.eventStatus == Ready) {
|
||||||
else if (currentEvent.format == AdventureEventController.EventFormat.Jumpstart && currentEvent.eventStatus == Ready) {
|
|
||||||
DeckEditScene.getInstance().loadEvent(currentEvent);
|
DeckEditScene.getInstance().loadEvent(currentEvent);
|
||||||
Forge.switchScene(DeckEditScene.getInstance());
|
Forge.switchScene(DeckEditScene.getInstance());
|
||||||
}
|
}
|
||||||
@@ -214,7 +212,7 @@ public class EventScene extends MenuScene implements IAfterMatch {
|
|||||||
|
|
||||||
ScrollPane blessing = ui.findActor("blessingInfo");
|
ScrollPane blessing = ui.findActor("blessingInfo");
|
||||||
blessing.setActor(blessingScroll);
|
blessing.setActor(blessingScroll);
|
||||||
blessingScroll.setWidth(blessing.getWidth()-5);
|
blessingScroll.setWidth(blessing.getWidth() - 5);
|
||||||
blessing.layout();
|
blessing.layout();
|
||||||
window.add(root);
|
window.add(root);
|
||||||
|
|
||||||
@@ -225,19 +223,18 @@ public class EventScene extends MenuScene implements IAfterMatch {
|
|||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refresh(){
|
private void refresh() {
|
||||||
if (metaDraftTable.isVisible()){
|
if (metaDraftTable.isVisible()) {
|
||||||
scrollContainer = metaDraftTable;
|
scrollContainer = metaDraftTable;
|
||||||
headerTable.clear();
|
headerTable.clear();
|
||||||
//todo: add translation
|
//todo: add translation
|
||||||
headerTable.add("Pack Selection");
|
headerTable.add("Pack Selection");
|
||||||
|
|
||||||
if (currentEvent.eventStatus == Entered){
|
if (currentEvent.eventStatus == Entered) {
|
||||||
loadMetaDraft();
|
loadMetaDraft();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
scrollContainer = new Table(Controls.getSkin());
|
scrollContainer = new Table(Controls.getSkin());
|
||||||
scrollContainer.row();
|
scrollContainer.row();
|
||||||
|
|
||||||
@@ -340,7 +337,7 @@ public class EventScene extends MenuScene implements IAfterMatch {
|
|||||||
performTouch(scroller);
|
performTouch(scroller);
|
||||||
|
|
||||||
//todo: add translations
|
//todo: add translations
|
||||||
switch (currentEvent.eventStatus){
|
switch (currentEvent.eventStatus) {
|
||||||
case Available:
|
case Available:
|
||||||
nextPage.setDisabled(true);
|
nextPage.setDisabled(true);
|
||||||
previousPage.setDisabled(true);
|
previousPage.setDisabled(true);
|
||||||
@@ -354,10 +351,9 @@ public class EventScene extends MenuScene implements IAfterMatch {
|
|||||||
previousPage.setDisabled(true);
|
previousPage.setDisabled(true);
|
||||||
editDeck.setDisabled(true);
|
editDeck.setDisabled(true);
|
||||||
editDeck.setVisible(false);
|
editDeck.setVisible(false);
|
||||||
if (currentEvent.getDraft() != null){
|
if (currentEvent.getDraft() != null) {
|
||||||
advance.setText("Enter Draft");
|
advance.setText("Enter Draft");
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
advance.setText("Select Deck");
|
advance.setText("Select Deck");
|
||||||
}
|
}
|
||||||
advance.setVisible(true);
|
advance.setVisible(true);
|
||||||
@@ -371,7 +367,7 @@ public class EventScene extends MenuScene implements IAfterMatch {
|
|||||||
previousPage.setDisabled(false);
|
previousPage.setDisabled(false);
|
||||||
break;
|
break;
|
||||||
case Started:
|
case Started:
|
||||||
advance.setText("Play round " +currentEvent.currentRound);
|
advance.setText("Play round " + currentEvent.currentRound);
|
||||||
advance.setVisible(true);
|
advance.setVisible(true);
|
||||||
editDeck.setDisabled(true);
|
editDeck.setDisabled(true);
|
||||||
editDeck.setVisible(false);
|
editDeck.setVisible(false);
|
||||||
@@ -406,23 +402,21 @@ public class EventScene extends MenuScene implements IAfterMatch {
|
|||||||
// if (object == null)
|
// if (object == null)
|
||||||
object = new EventScene();
|
object = new EventScene();
|
||||||
if (lastGameScene != null)
|
if (lastGameScene != null)
|
||||||
object.lastGameScene=lastGameScene;
|
object.lastGameScene = lastGameScene;
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void nextPage(boolean reverse) {
|
private void nextPage(boolean reverse) {
|
||||||
//todo: add translations
|
//todo: add translations
|
||||||
headerTable.clear();
|
headerTable.clear();
|
||||||
if (!reverse && ++pageIndex >= eventPages.length){
|
if (!reverse && ++pageIndex >= eventPages.length) {
|
||||||
pageIndex = 0;
|
pageIndex = 0;
|
||||||
}
|
} else if (reverse && --pageIndex < 0) {
|
||||||
else if (reverse && --pageIndex < 0) {
|
|
||||||
pageIndex = eventPages.length - 1;
|
pageIndex = eventPages.length - 1;
|
||||||
}
|
}
|
||||||
if (pageIndex == 0){
|
if (pageIndex == 0) {
|
||||||
headerTable.add("Event Standings").expand();
|
headerTable.add("Event Standings").expand();
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
headerTable.add("Round " + (pageIndex) + " of " + (eventPages.length - 1));
|
headerTable.add("Round " + (pageIndex) + " of " + (eventPages.length - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -443,29 +437,29 @@ public class EventScene extends MenuScene implements IAfterMatch {
|
|||||||
}
|
}
|
||||||
performTouch(scrollPaneOfActor(scrollContainer)); //can use mouse wheel if available to scroll
|
performTouch(scrollPaneOfActor(scrollContainer)); //can use mouse wheel if available to scroll
|
||||||
|
|
||||||
if (currentEvent.eventStatus == Entered){
|
if (currentEvent.eventStatus == Entered) {
|
||||||
loadMetaDraft();
|
loadMetaDraft();
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void editDeck(){
|
public void editDeck() {
|
||||||
if (currentEvent.eventStatus == Ready){
|
if (currentEvent.eventStatus == Ready) {
|
||||||
DraftScene.instance().loadEvent(currentEvent);
|
DraftScene.instance().loadEvent(currentEvent);
|
||||||
Forge.switchScene(DraftScene.instance());
|
Forge.switchScene(DraftScene.instance());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void advance() {
|
public void advance() {
|
||||||
switch (currentEvent.eventStatus){
|
switch (currentEvent.eventStatus) {
|
||||||
case Available:
|
case Available:
|
||||||
activate(entryDialog); //Entry fee pop-up
|
activate(entryDialog); //Entry fee pop-up
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case Entered: //Start draft or select deck
|
case Entered: //Start draft or select deck
|
||||||
//Show progress / wait indicator? Draft can take a while to generate
|
//Show progress / wait indicator? Draft can take a while to generate
|
||||||
switch (currentEvent.format){
|
switch (currentEvent.format) {
|
||||||
case Draft:
|
case Draft:
|
||||||
DraftScene.instance().loadEvent(currentEvent);
|
DraftScene.instance().loadEvent(currentEvent);
|
||||||
Forge.switchScene(DraftScene.instance());
|
Forge.switchScene(DraftScene.instance());
|
||||||
@@ -495,12 +489,12 @@ public class EventScene extends MenuScene implements IAfterMatch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean back(){
|
public boolean back() {
|
||||||
if (currentEvent.eventStatus.equals(Awarded)){
|
if (currentEvent.eventStatus.equals(Awarded)) {
|
||||||
AdventureEventController.instance().finalizeEvent(currentEvent);
|
AdventureEventController.instance().finalizeEvent(currentEvent);
|
||||||
currentEvent = null;
|
currentEvent = null;
|
||||||
}
|
}
|
||||||
Forge.switchScene(lastGameScene==null?GameScene.instance():lastGameScene);
|
Forge.switchScene(lastGameScene == null ? GameScene.instance() : lastGameScene);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -512,7 +506,7 @@ public class EventScene extends MenuScene implements IAfterMatch {
|
|||||||
if (match.p2 == null) {
|
if (match.p2 == null) {
|
||||||
//shouldn't happen under current setup, but this would be a bye
|
//shouldn't happen under current setup, but this would be a bye
|
||||||
match.winner = match.p1;
|
match.winner = match.p1;
|
||||||
match.p1.wins +=1;
|
match.p1.wins += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match.p1 instanceof AdventureEventData.AdventureEventHuman) {
|
if (match.p1 instanceof AdventureEventData.AdventureEventHuman) {
|
||||||
@@ -526,12 +520,11 @@ public class EventScene extends MenuScene implements IAfterMatch {
|
|||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
//Todo: Actually run match simulation here
|
//Todo: Actually run match simulation here
|
||||||
if(MyRandom.percentTrue(50)){
|
if (MyRandom.percentTrue(50)) {
|
||||||
match.p1.wins++;
|
match.p1.wins++;
|
||||||
match.p2.losses++;
|
match.p2.losses++;
|
||||||
match.winner = match.p1;
|
match.winner = match.p1;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
match.p1.losses++;
|
match.p1.losses++;
|
||||||
match.p2.wins++;
|
match.p2.wins++;
|
||||||
match.winner = match.p2;
|
match.winner = match.p2;
|
||||||
@@ -542,8 +535,7 @@ public class EventScene extends MenuScene implements IAfterMatch {
|
|||||||
|
|
||||||
if (humanMatch != null && humanMatch.round != currentEvent.currentRound)
|
if (humanMatch != null && humanMatch.round != currentEvent.currentRound)
|
||||||
humanMatch = null;
|
humanMatch = null;
|
||||||
if (humanMatch != null)
|
if (humanMatch != null) {
|
||||||
{
|
|
||||||
DuelScene duelScene = DuelScene.instance();
|
DuelScene duelScene = DuelScene.instance();
|
||||||
EnemySprite enemy = humanMatch.p2.getSprite();
|
EnemySprite enemy = humanMatch.p2.getSprite();
|
||||||
currentEvent.nextOpponent = humanMatch.p2;
|
currentEvent.nextOpponent = humanMatch.p2;
|
||||||
@@ -551,9 +543,7 @@ public class EventScene extends MenuScene implements IAfterMatch {
|
|||||||
duelScene.initDuels(WorldStage.getInstance().getPlayerSprite(), enemy, false, currentEvent);
|
duelScene.initDuels(WorldStage.getInstance().getPlayerSprite(), enemy, false, currentEvent);
|
||||||
Forge.switchScene(duelScene);
|
Forge.switchScene(duelScene);
|
||||||
}, Forge.takeScreenshot(), true, false, false, false, "", Current.player().avatar(), enemy.getAtlasPath(), Current.player().getName(), enemy.getName(), humanMatch.p1.getRecord(), humanMatch.p2.getRecord())));
|
}, Forge.takeScreenshot(), true, false, false, false, "", Current.player().avatar(), enemy.getAtlasPath(), Current.player().getName(), enemy.getName(), humanMatch.p1.getRecord(), humanMatch.p2.getRecord())));
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
finishRound();
|
finishRound();
|
||||||
}
|
}
|
||||||
advance.setDisabled(false);
|
advance.setDisabled(false);
|
||||||
@@ -577,8 +567,7 @@ public class EventScene extends MenuScene implements IAfterMatch {
|
|||||||
if (winner) {
|
if (winner) {
|
||||||
//AdventureQuestController.instance().updateQuestsWin(currentMob,enemies);
|
//AdventureQuestController.instance().updateQuestsWin(currentMob,enemies);
|
||||||
//AdventureQuestController.instance().showQuestDialogs(MapStage.this);
|
//AdventureQuestController.instance().showQuestDialogs(MapStage.this);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
// AdventureQuestController.instance().updateQuestsLose(currentMob);
|
// AdventureQuestController.instance().updateQuestsLose(currentMob);
|
||||||
// AdventureQuestController.instance().showQuestDialogs(MapStage.this);
|
// AdventureQuestController.instance().showQuestDialogs(MapStage.this);
|
||||||
}
|
}
|
||||||
@@ -586,23 +575,22 @@ public class EventScene extends MenuScene implements IAfterMatch {
|
|||||||
finishRound();
|
finishRound();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void finishRound(){
|
public void finishRound() {
|
||||||
if (currentEvent.currentRound == currentEvent.rounds){
|
if (currentEvent.currentRound == currentEvent.rounds) {
|
||||||
finishEvent();
|
finishEvent();
|
||||||
}
|
} else currentEvent.currentRound += 1;
|
||||||
else currentEvent.currentRound += 1;
|
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void finishEvent(){
|
public void finishEvent() {
|
||||||
currentEvent.eventStatus = AdventureEventController.EventStatus.Completed;
|
currentEvent.eventStatus = AdventureEventController.EventStatus.Completed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadMetaDraft(){
|
public void loadMetaDraft() {
|
||||||
metaDraftTable.setVisible(true);
|
metaDraftTable.setVisible(true);
|
||||||
|
|
||||||
metaDraftTable.clear();
|
metaDraftTable.clear();
|
||||||
for (Deck deckOption : currentEvent.jumpstartBoosters) {
|
for (Deck deckOption : currentEvent.jumpstartBoosters) {
|
||||||
if (metaDraftTable.hasChildren())
|
if (metaDraftTable.hasChildren())
|
||||||
metaDraftTable.row();
|
metaDraftTable.row();
|
||||||
|
|
||||||
@@ -629,11 +617,9 @@ public class EventScene extends MenuScene implements IAfterMatch {
|
|||||||
public void clicked(InputEvent event, float x, float y) {
|
public void clicked(InputEvent event, float x, float y) {
|
||||||
selectButton.clearListeners();
|
selectButton.clearListeners();
|
||||||
deckOption.getTags().add("Selected");
|
deckOption.getTags().add("Selected");
|
||||||
if (!selectedJumpstartPackIsLast(deckOption))
|
if (!selectedJumpstartPackIsLast(deckOption)) {
|
||||||
{
|
|
||||||
loadMetaDraft();
|
loadMetaDraft();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
metaDraftTable.setVisible(false);
|
metaDraftTable.setVisible(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -646,11 +632,11 @@ public class EventScene extends MenuScene implements IAfterMatch {
|
|||||||
eventPages[0] = metaDraftTable;
|
eventPages[0] = metaDraftTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean selectedJumpstartPackIsLast(Deck selectedPack){
|
private boolean selectedJumpstartPackIsLast(Deck selectedPack) {
|
||||||
int packsToPick = 3;
|
int packsToPick = 3;
|
||||||
int packsPicked = 0;
|
int packsPicked = 0;
|
||||||
Deck currentPicks = new Deck();
|
Deck currentPicks = new Deck();
|
||||||
for (Deck deckOption : currentEvent.jumpstartBoosters) {
|
for (Deck deckOption : currentEvent.jumpstartBoosters) {
|
||||||
if (deckOption.getTags().contains("Selected")) {
|
if (deckOption.getTags().contains("Selected")) {
|
||||||
packsPicked++;
|
packsPicked++;
|
||||||
currentPicks.getMain().addAll(deckOption.getAllCardsInASinglePool());
|
currentPicks.getMain().addAll(deckOption.getAllCardsInASinglePool());
|
||||||
|
|||||||
@@ -101,8 +101,8 @@ public class InnScene extends UIScene {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void refreshStatus(){
|
private void refreshStatus(){
|
||||||
|
float townPriceModifier = changes == null ? 1f : changes.getTownPriceModifier();
|
||||||
tempHealthCost = Math.round(Current.player().falseLifeCost() * changes.getTownPriceModifier());
|
tempHealthCost = Math.round(Current.player().falseLifeCost() * townPriceModifier);
|
||||||
boolean purchaseable = Current.player().getMaxLife() == Current.player().getLife() &&
|
boolean purchaseable = Current.player().getMaxLife() == Current.player().getLife() &&
|
||||||
tempHealthCost <= Current.player().getGold();
|
tempHealthCost <= Current.player().getGold();
|
||||||
|
|
||||||
|
|||||||
@@ -48,15 +48,16 @@ public class ShopScene extends ForgeScene {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void doAutosell() {
|
public void doAutosell() {
|
||||||
boolean promptToConfirmSale = false; //Todo: config option
|
boolean promptToConfirmSale = false; // TODO: config option
|
||||||
if (promptToConfirmSale) {
|
if (promptToConfirmSale) {
|
||||||
|
float townPriceModifier = changes == null ? 1f : changes.getTownPriceModifier();
|
||||||
int profit = 0;
|
int profit = 0;
|
||||||
int cards = 0;
|
int cards = 0;
|
||||||
for (PaperCard cardToSell: Current.player().autoSellCards.toFlatList()) {
|
for (PaperCard cardToSell: Current.player().autoSellCards.toFlatList()) {
|
||||||
cards++;
|
cards++;
|
||||||
profit += getCardPrice(cardToSell);
|
profit += getCardPrice(cardToSell);
|
||||||
}
|
}
|
||||||
if (!confirmAutosell(profit, cards, changes.getTownPriceModifier())) {
|
if (!confirmAutosell(profit, cards, townPriceModifier)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,20 +26,20 @@ public class AdventureEventController implements Serializable {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum EventFormat{
|
public enum EventFormat {
|
||||||
Draft,
|
Draft,
|
||||||
Sealed,
|
Sealed,
|
||||||
Jumpstart,
|
Jumpstart,
|
||||||
Constructed
|
Constructed
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum EventStyle{
|
public enum EventStyle {
|
||||||
Bracket,
|
Bracket,
|
||||||
RoundRobin,
|
RoundRobin,
|
||||||
Swiss
|
Swiss
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum EventStatus{
|
public enum EventStatus {
|
||||||
Available, //New event
|
Available, //New event
|
||||||
Entered, //Entry fee paid, deck not locked in
|
Entered, //Entry fee paid, deck not locked in
|
||||||
Ready, //Deck is registered but can still be edited
|
Ready, //Deck is registered but can still be edited
|
||||||
@@ -58,73 +58,68 @@ public class AdventureEventController implements Serializable {
|
|||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
private AdventureEventController(){
|
private AdventureEventController() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private transient Array<AdventureEventData> allEvents = new Array<>();
|
private transient Array<AdventureEventData> allEvents = new Array<>();
|
||||||
private Map<String, Long> nextEventDate = new HashMap<>();
|
private Map<String, Long> nextEventDate = new HashMap<>();
|
||||||
|
|
||||||
public AdventureEventController(AdventureEventController other){
|
public AdventureEventController(AdventureEventController other) {
|
||||||
if (object == null) {
|
if (object == null) {
|
||||||
object = this;
|
object = this;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
System.out.println("Could not initialize AdventureEventController. An instance already exists and cannot be merged.");
|
System.out.println("Could not initialize AdventureEventController. An instance already exists and cannot be merged.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clear(){
|
public static void clear() {
|
||||||
object = null;
|
object = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AdventureEventData createEvent(EventStyle style, String pointID, int eventOrigin, PointOfInterestChanges changes)
|
public AdventureEventData createEvent(EventStyle style, String pointID, int eventOrigin, PointOfInterestChanges changes) {
|
||||||
{
|
if (nextEventDate.containsKey(pointID) && nextEventDate.get(pointID) >= LocalDate.now().toEpochDay()) {
|
||||||
if (nextEventDate.containsKey(pointID) && nextEventDate.get(pointID) >= LocalDate.now().toEpochDay()){
|
|
||||||
//No event currently available here
|
//No event currently available here
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
long eventSeed;
|
long eventSeed;
|
||||||
long timeSeed = LocalDate.now().toEpochDay();
|
long timeSeed = LocalDate.now().toEpochDay();
|
||||||
long placeSeed = Long.parseLong(pointID.replaceAll("[^0-9]",""));
|
long placeSeed = Long.parseLong(pointID.replaceAll("[^0-9]", ""));
|
||||||
long room = Long.MAX_VALUE - placeSeed;
|
long room = Long.MAX_VALUE - placeSeed;
|
||||||
if (timeSeed > room){
|
if (timeSeed > room) {
|
||||||
//ensuring we don't ever hit an overflow
|
//ensuring we don't ever hit an overflow
|
||||||
eventSeed = Long.MIN_VALUE + timeSeed - room;
|
eventSeed = Long.MIN_VALUE + timeSeed - room;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
eventSeed = timeSeed + placeSeed;
|
eventSeed = timeSeed + placeSeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
Random random = new Random(eventSeed);
|
Random random = new Random(eventSeed);
|
||||||
|
|
||||||
AdventureEventData e ;
|
AdventureEventData e;
|
||||||
|
|
||||||
if (random.nextInt(10) <=2){
|
if (random.nextInt(10) <= 2) {
|
||||||
e = new AdventureEventData(eventSeed, EventFormat.Jumpstart);
|
e = new AdventureEventData(eventSeed, EventFormat.Jumpstart);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
e = new AdventureEventData(eventSeed, EventFormat.Draft);
|
e = new AdventureEventData(eventSeed, EventFormat.Draft);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.cardBlock == null){
|
if (e.cardBlock == null) {
|
||||||
//covers cases where (somehow) editions that do not match the event style have been picked up
|
//covers cases where (somehow) editions that do not match the event style have been picked up
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
e.sourceID = pointID;
|
e.sourceID = pointID;
|
||||||
e.eventOrigin = eventOrigin;
|
e.eventOrigin = eventOrigin;
|
||||||
e.eventRules = new AdventureEventData.AdventureEventRules(e.format, changes.getTownPriceModifier());
|
e.eventRules = new AdventureEventData.AdventureEventRules(e.format, changes == null ? 1f : changes.getTownPriceModifier());
|
||||||
e.style = style;
|
e.style = style;
|
||||||
|
|
||||||
switch (style){
|
switch (style) {
|
||||||
case Swiss:
|
case Swiss:
|
||||||
case Bracket:
|
case Bracket:
|
||||||
e.rounds = (e.participants.length / 2) - 1;
|
e.rounds = (e.participants.length / 2) - 1;
|
||||||
break;
|
break;
|
||||||
case RoundRobin:
|
case RoundRobin:
|
||||||
e.rounds = e.participants.length - 1 ;
|
e.rounds = e.participants.length - 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,12 +138,11 @@ public class AdventureEventController implements Serializable {
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Deck> getJumpstartBoosters(CardBlock block, int count){
|
public List<Deck> getJumpstartBoosters(CardBlock block, int count) {
|
||||||
//Get all candidates then remove at random until no more than count are included
|
//Get all candidates then remove at random until no more than count are included
|
||||||
//This will prevent duplicate choices within a round of a Jumpstart draft
|
//This will prevent duplicate choices within a round of a Jumpstart draft
|
||||||
List<Deck> packsAsDecks = new ArrayList<>();
|
List<Deck> packsAsDecks = new ArrayList<>();
|
||||||
for(SealedTemplate template : StaticData.instance().getSpecialBoosters())
|
for (SealedTemplate template : StaticData.instance().getSpecialBoosters()) {
|
||||||
{
|
|
||||||
if (!template.getEdition().contains(block.getLandSet().getCode()))
|
if (!template.getEdition().contains(block.getLandSet().getCode()))
|
||||||
continue;
|
continue;
|
||||||
UnOpenedProduct toOpen = new UnOpenedProduct(template);
|
UnOpenedProduct toOpen = new UnOpenedProduct(template);
|
||||||
@@ -158,7 +152,7 @@ public class AdventureEventController implements Serializable {
|
|||||||
|
|
||||||
int size = contents.getMain().toFlatList().size();
|
int size = contents.getMain().toFlatList().size();
|
||||||
|
|
||||||
if ( size < 18 || size > 25)
|
if (size < 18 || size > 25)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
contents.setName(template.getEdition());
|
contents.setName(template.getEdition());
|
||||||
@@ -171,7 +165,7 @@ public class AdventureEventController implements Serializable {
|
|||||||
int multi = 0;
|
int multi = 0;
|
||||||
int colorless = 0;
|
int colorless = 0;
|
||||||
|
|
||||||
for (PaperCard card: contents.getMain().toFlatList()) {
|
for (PaperCard card : contents.getMain().toFlatList()) {
|
||||||
int colors = 0;
|
int colors = 0;
|
||||||
if (card.getRules().getColorIdentity().hasBlack()) {
|
if (card.getRules().getColorIdentity().hasBlack()) {
|
||||||
black++;
|
black++;
|
||||||
@@ -195,8 +189,7 @@ public class AdventureEventController implements Serializable {
|
|||||||
}
|
}
|
||||||
if (colors == 0 && !card.getRules().getType().isLand()) {
|
if (colors == 0 && !card.getRules().getType().isLand()) {
|
||||||
colorless++;
|
colorless++;
|
||||||
}
|
} else if (colors > 1) {
|
||||||
else if (colors > 1) {
|
|
||||||
multi++;
|
multi++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -219,7 +212,7 @@ public class AdventureEventController implements Serializable {
|
|||||||
packsAsDecks.add(contents);
|
packsAsDecks.add(contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (packsAsDecks.size() > count){
|
while (packsAsDecks.size() > count) {
|
||||||
Aggregates.removeRandom(packsAsDecks);
|
Aggregates.removeRandom(packsAsDecks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user