Merge pull request #6036 from kevlahnota/master2

update adventure defeat penalty
This commit is contained in:
kevlahnota
2024-09-02 21:41:47 +08:00
committed by GitHub
17 changed files with 88 additions and 21 deletions

View File

@@ -23,6 +23,7 @@ public class ItemData {
public boolean usableOnWorldMap;
public boolean usableInPoi;
public boolean isCracked;
public String commandOnUse;
public int shardsNeeded;
public DialogData dialogOnUse;

View File

@@ -842,6 +842,20 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
return false;
}
public ItemData getRandomEquippedArmor() {
Array<ItemData> armor = new Array<>();
for (String name : equippedItems.values()) {
ItemData data = ItemData.getItem(name);
if (data != null
&& ("Boots".equalsIgnoreCase(data.equipmentSlot)
|| "Body".equalsIgnoreCase(data.equipmentSlot)
|| "Neck".equalsIgnoreCase(data.equipmentSlot))) {
armor.add(data);
}
}
return armor.random();
}
public ItemData getEquippedAbility1() {
for (String name : equippedItems.values()) {
ItemData data = ItemData.getItem(name);
@@ -879,6 +893,10 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
return difficultyData;
}
public boolean isHardorInsaneDifficulty() {
return "Hard".equalsIgnoreCase(difficultyData.name) || "Insane".equalsIgnoreCase(difficultyData.name);
}
public void renameDeck(String text) {
deck = (Deck) deck.copyTo(text);
decks[selectedDeckIndex] = deck;

View File

@@ -302,7 +302,7 @@ public class DuelScene extends ForgeScene {
} else if (this.eventData != null) {
deck = eventData.nextOpponent.getDeck();
} else {
deck = currentEnemy.copyPlayerDeck ? this.playerDeck : currentEnemy.generateDeck(Current.player().isFantasyMode(), Current.player().isUsingCustomDeck() || Current.player().getDifficulty().name.equalsIgnoreCase("Insane") || Current.player().getDifficulty().name.equalsIgnoreCase("Hard"));
deck = currentEnemy.copyPlayerDeck ? this.playerDeck : currentEnemy.generateDeck(Current.player().isFantasyMode(), Current.player().isUsingCustomDeck() || Current.player().isHardorInsaneDifficulty());
}
RegisteredPlayer aiPlayer = RegisteredPlayer.forVariants(playerCount, appliedVariants, deck, null, false, null, null);
@@ -410,9 +410,7 @@ public class DuelScene extends ForgeScene {
this.eventData = eventData;
if (eventData != null && eventData.eventRules == null)
eventData.eventRules = new AdventureEventData.AdventureEventRules(AdventureEventController.EventFormat.Constructed, 1.0f);
this.arenaBattleChallenge = isArena
&& (Current.player().getDifficulty().name.equalsIgnoreCase("Hard")
|| Current.player().getDifficulty().name.equalsIgnoreCase("Insane"));
this.arenaBattleChallenge = isArena && Current.player().isHardorInsaneDifficulty();
if (eventData != null && eventData.registeredDeck != null)
this.playerDeck = eventData.registeredDeck;
else

View File

@@ -218,10 +218,13 @@ public class InventoryScene extends UIScene {
}
}
public void clearItemDescription() {
itemDescription.setText("");
}
private void setSelected(Button actor) {
selected = actor;
if (actor == null) {
itemDescription.setText("");
clearItemDescription();
deleteButton.setDisabled(true);
equipButton.setDisabled(true);
useButton.setDisabled(true);
@@ -246,7 +249,7 @@ public class InventoryScene extends UIScene {
if (Current.player().getShards() < data.shardsNeeded)
useButton.setDisabled(true);
if (data.equipmentSlot == null || data.equipmentSlot.isEmpty()) {
if (data.equipmentSlot == null || data.equipmentSlot.isEmpty() || data.isCracked) {
equipButton.setDisabled(true);
} else {
equipButton.setDisabled(false);
@@ -261,7 +264,8 @@ public class InventoryScene extends UIScene {
button.layout();
}
}
itemDescription.setText(data.name + "\n[%98]" + data.getDescription());
String status = data.isCracked ? " (" + Forge.getLocalizer().getMessage("lblCracked") + ")" : "";
itemDescription.setText(data.name + status + "\n[%98]" + data.getDescription());
}
else if (deckLocation.containsKey(actor)){
Deck data = (deckLocation.get(actor));

View File

@@ -379,6 +379,28 @@ public class SaveLoadScene extends UIScene {
}
public String getSaveFileSuffix() {
return ASCII_179 + GameScene.instance().getAdventurePlayerLocation(true, true);
String difficulty;
switch (AdventurePlayer.current().getDifficulty().name) {
case "easy":
case "Easy":
difficulty = "[%99][CYAN]\uFF0A[WHITE]";
break;
case "normal":
case "Normal":
difficulty = "[%99][GREEN]\uFF0A[WHITE]";
break;
case "hard":
case "Hard":
difficulty = "[%99][GOLD]\uFF0A[WHITE]";
break;
case "insane":
case "Insane":
difficulty = "[%99][RED]\uFF0A[WHITE]";
break;
default:
difficulty = "[%99][WHITE]";
break;
}
return ASCII_179 + difficulty + GameScene.instance().getAdventurePlayerLocation(true, true);
}
}

View File

@@ -254,7 +254,7 @@ public class ConsoleCommandInterpreter {
});
registerCommand(new String[]{"dumpEnemyDeckColors"}, s -> {
for (EnemyData E : new Array.ArrayIterator<>(WorldData.getAllEnemies())) {
Deck D = E.generateDeck(Current.player().isFantasyMode(), Current.player().isUsingCustomDeck() || Current.player().getDifficulty().name.equalsIgnoreCase("Hard"));
Deck D = E.generateDeck(Current.player().isFantasyMode(), Current.player().isUsingCustomDeck() || Current.player().isHardorInsaneDifficulty());
DeckProxy DP = new DeckProxy(D, "Constructed", GameType.Constructed, null);
ColorSet colorSet = DP.getColor();
System.out.printf("%s: Colors: %s (%s%s%s%s%s%s)\n", D.getName(), DP.getColor(),
@@ -270,7 +270,7 @@ public class ConsoleCommandInterpreter {
});
registerCommand(new String[]{"dumpEnemyDeckList"}, s -> {
for (EnemyData E : new Array.ArrayIterator<>(WorldData.getAllEnemies())) {
Deck D = E.generateDeck(Current.player().isFantasyMode(), Current.player().isUsingCustomDeck() || Current.player().getDifficulty().name.equalsIgnoreCase("Hard"));
Deck D = E.generateDeck(Current.player().isFantasyMode(), Current.player().isUsingCustomDeck() || Current.player().isHardorInsaneDifficulty());
DeckProxy DP = new DeckProxy(D, "Constructed", GameType.Constructed, null);
System.out.printf("Deck: %s\n%s\n\n", D.getName(), DP.getDeck().getMain().toCardList("\n")
);
@@ -279,7 +279,7 @@ public class ConsoleCommandInterpreter {
});
registerCommand(new String[]{"dumpEnemyColorIdentity"}, s -> {
for (EnemyData E : new Array.ArrayIterator<>(WorldData.getAllEnemies())) {
Deck D = E.generateDeck(Current.player().isFantasyMode(), Current.player().isUsingCustomDeck() || Current.player().getDifficulty().name.equalsIgnoreCase("Hard"));
Deck D = E.generateDeck(Current.player().isFantasyMode(), Current.player().isUsingCustomDeck() || Current.player().isHardorInsaneDifficulty());
DeckProxy DP = new DeckProxy(D, "Constructed", GameType.Constructed, null);
System.out.printf("%s Colors: %s | Deck Colors: %s (%s)%s\n", E.name, E.colors, DP.getColorIdentity().toEnumSet().toString(), DP.getName()
, E.boss ? " - BOSS" : "");

View File

@@ -658,11 +658,12 @@ public abstract class GameStage extends Stage {
Timer.schedule(new Timer.Task() {
@Override
public void run() {
showImageDialog(Forge.getLocalizer().getMessage("lblYouDied", Current.player().getName()), null,
showImageDialog(Current.generateDefeatMessage(), null,
() -> FThreads.invokeInEdtNowOrLater(() -> Forge.setTransitionScreen(new TransitionScreen(() -> {
Forge.advFreezePlayerControls = false;
WorldStage.getInstance().setPosition(new Vector2(poi.getPosition().x - 16f, poi.getPosition().y + 16f));
WorldStage.getInstance().loadPOI(poi);
WorldSave.getCurrentSave().autoSave();
Forge.clearTransitionScreen();
}, Forge.takeScreenshot(), ""))));
}

View File

@@ -750,7 +750,6 @@ public class MapStage extends GameStage {
}
public boolean exitDungeon(boolean defeated) {
WorldSave.getCurrentSave().autoSave();
AdventureQuestController.instance().updateQuestsLeave();
clearIsInMap();
AdventureQuestController.instance().showQuestDialogs(this);

View File

@@ -1,6 +1,9 @@
package forge.adventure.util;
import forge.Forge;
import forge.adventure.data.ItemData;
import forge.adventure.player.AdventurePlayer;
import forge.adventure.scene.InventoryScene;
import forge.adventure.world.World;
import forge.adventure.world.WorldSave;
import forge.deck.Deck;
@@ -24,5 +27,18 @@ public class Current {
public static void setLatestDeck(Deck generateDeck) {
deck=generateDeck;
}
public static String generateDefeatMessage() {;
String message = Forge.getLocalizer().getMessage("lblYouDied", player().getName());
if (player().isHardorInsaneDifficulty()) {
ItemData itemData = player().getRandomEquippedArmor();
if (itemData != null) {
itemData.isCracked = true;
player().equip(itemData); //unequip...
InventoryScene.instance().clearItemDescription();
message += "\n{GRADIENT=RED;GRAY;1;1}" + itemData.name + " {ENDGRADIENT}" + Forge.getLocalizer().getMessage("lblCracked");
}
}
return message;
}
}

View File

@@ -3433,4 +3433,5 @@ lblHideNoSell=No-Sell Ausblenden
lblShowNoSell=No-Sell Anzeigen
lblShowAll=Alle Anzeigen
lblHideCollection=Sammlung Ausblenden
lblShowCollection=Sammlung Anzeigen
lblShowCollection=Sammlung Anzeigen
lblCracked=Geknackt!

View File

@@ -3166,4 +3166,5 @@ lblHideNoSell=Hide No-Sell
lblShowNoSell=Show No-Sell
lblShowAll=Show All
lblHideCollection=Hide Collection
lblShowCollection=Show Collection
lblShowCollection=Show Collection
lblCracked=Cracked!

View File

@@ -3447,4 +3447,5 @@ lblHideNoSell=Ocultar No Vender
lblShowNoSell=Mostrar No Vender
lblShowAll=Mostrar Todo
lblHideCollection=Ocultar Colección
lblShowCollection=Mostrar Colección
lblShowCollection=Mostrar Colección
lblCracked=¡Agrietado!

View File

@@ -3441,4 +3441,5 @@ lblHideNoSell=Masquer Non-Vente
lblShowNoSell=Afficher Non-Vente
lblShowAll=Afficher Tout
lblHideCollection=Masquer la Collection
lblShowCollection=Afficher la Collection
lblShowCollection=Afficher la Collection
lblCracked=Fissuré!

View File

@@ -3439,4 +3439,5 @@ lblHideNoSell=Nascondi Non Vendita
lblShowNoSell=Mostra Non Vendita
lblShowAll=Mostra Tutto
lblHideCollection=Nascondi Collezione
lblShowCollection=Mostra Collezione
lblShowCollection=Mostra Collezione
lblCracked=Incrinato!

View File

@@ -3435,4 +3435,5 @@ lblHideNoSell=ノーセールを隠す
lblShowNoSell=ノーセールを表示
lblShowAll=すべて表示
lblHideCollection=コレクションを非表示にする
lblShowCollection=ショーコレクション
lblShowCollection=ショーコレクション
lblCracked=ひび割れた!

View File

@@ -3525,4 +3525,5 @@ lblHideNoSell=Ocultar Não Vender
lblShowNoSell=Mostrar Não-Venda
lblShowAll=Mostrar Tudo
lblHideCollection=Ocultar Coleção
lblShowCollection=Mostrar Coleção
lblShowCollection=Mostrar Coleção
lblCracked=Rachado!

View File

@@ -3426,4 +3426,5 @@ lblHideNoSell=隐藏不卖
lblShowNoSell=显示不卖
lblShowAll=显示全部
lblHideCollection=隐藏收藏
lblShowCollection=展会系列
lblShowCollection=展会系列
lblCracked=破裂了!