mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 02:08:00 +00:00
Merge pull request #8528 from kevlahnota/master3
update ConsoleCommandInterpreter
This commit is contained in:
@@ -6,11 +6,9 @@ import com.badlogic.gdx.utils.Array;
|
||||
import forge.Forge;
|
||||
import forge.StaticData;
|
||||
import forge.adventure.character.PlayerSprite;
|
||||
import forge.adventure.data.BiomeData;
|
||||
import forge.adventure.data.EnemyData;
|
||||
import forge.adventure.data.PointOfInterestData;
|
||||
import forge.adventure.data.WorldData;
|
||||
import forge.adventure.data.*;
|
||||
import forge.adventure.pointofintrest.PointOfInterest;
|
||||
import forge.adventure.scene.InventoryScene;
|
||||
import forge.adventure.util.AdventureEventController;
|
||||
import forge.adventure.util.Current;
|
||||
import forge.adventure.util.Paths;
|
||||
@@ -91,8 +89,9 @@ public class ConsoleCommandInterpreter {
|
||||
return "Command not found. Available commands:\n" + String.join(" ", Arrays.copyOfRange(words, 0, i)) + "\n" + String.join("\n", currentCommand.children.keySet());
|
||||
}
|
||||
String[] parameters = Arrays.copyOfRange(words, i, words.length);
|
||||
for (int j = 0; j < parameters.length; j++)
|
||||
parameters[j] = parameters[j].replaceAll("[\"']", "");
|
||||
// this removes apostrophe...
|
||||
/*for (int j = 0; j < parameters.length; j++)
|
||||
parameters[j] = parameters[j].replaceAll("[\"']", "");*/
|
||||
return currentCommand.function.apply(parameters);
|
||||
}
|
||||
|
||||
@@ -133,7 +132,7 @@ public class ConsoleCommandInterpreter {
|
||||
WorldStage.getInstance().player.playEffect(Paths.EFFECT_TELEPORT, 10);
|
||||
return "teleport to (" + s[0] + "," + s[1] + ")";
|
||||
} catch (Exception e) {
|
||||
return "Exception occured, Invalid input";
|
||||
return "Exception occurred, Invalid input";
|
||||
}
|
||||
});
|
||||
registerCommand(new String[]{"teleport", "to", "poi"}, s -> {
|
||||
@@ -174,8 +173,7 @@ public class ConsoleCommandInterpreter {
|
||||
int ID;
|
||||
try {
|
||||
ID = Integer.parseInt(s[0]);
|
||||
}
|
||||
catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
return "Can not convert " + s[0] + " to number";
|
||||
}
|
||||
Current.player().addQuest(ID, false);
|
||||
@@ -221,8 +219,8 @@ public class ConsoleCommandInterpreter {
|
||||
int amount = Integer.parseInt(s[1]);
|
||||
Current.player().addCard(card, amount);
|
||||
return String.format("Added %d cards: %s", amount, card.getName());
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
catch(NumberFormatException ignored) {}
|
||||
}
|
||||
Current.player().addCard(card);
|
||||
return "Added card: " + card.getName();
|
||||
@@ -236,8 +234,8 @@ public class ConsoleCommandInterpreter {
|
||||
int amount = Integer.parseInt(s[1]);
|
||||
Current.player().addCard(card.getNoSellVersion(), amount);
|
||||
return String.format("Added %d cards: %s", amount, card.getName());
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
catch(NumberFormatException ignored) {}
|
||||
}
|
||||
Current.player().addCard(card.getNoSellVersion());
|
||||
return "Added card: " + card.getName();
|
||||
@@ -247,7 +245,8 @@ public class ConsoleCommandInterpreter {
|
||||
CardEdition edition = StaticData.instance().getCardEdition(s[0]);
|
||||
if (edition == null) return "Cannot find edition: " + s[0];
|
||||
CardEdition.EditionEntry cis = edition.getCardFromCollectorNumber(s[1]);
|
||||
if (cis == null) return String.format("Set '%s' does not have a card with collector number '%s'.", edition.getName(), s[1]);
|
||||
if (cis == null)
|
||||
return String.format("Set '%s' does not have a card with collector number '%s'.", edition.getName(), s[1]);
|
||||
PaperCard card = StaticData.instance().fetchCard(cis.name(), edition.getCode(), cis.collectorNumber());
|
||||
if (card == null) {
|
||||
//Found in the set, not supported.
|
||||
@@ -258,8 +257,8 @@ public class ConsoleCommandInterpreter {
|
||||
int amount = Integer.parseInt(s[2]);
|
||||
Current.player().addCard(card, amount);
|
||||
return String.format("Added %d cards: %s", amount, card.getName());
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
catch(NumberFormatException ignored) {}
|
||||
}
|
||||
Current.player().addCard(card);
|
||||
return "Added card: " + card.getName();
|
||||
@@ -294,7 +293,8 @@ public class ConsoleCommandInterpreter {
|
||||
if (s.length >= 2) {
|
||||
try {
|
||||
amount = Integer.parseInt(s[1]);
|
||||
} catch (NumberFormatException ignored) {}
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < amount; i++) {
|
||||
@@ -385,7 +385,7 @@ public class ConsoleCommandInterpreter {
|
||||
});
|
||||
registerCommand(new String[]{"heal", "amount"}, s -> {
|
||||
if (s.length < 1) return "Command needs 1 parameter: Amount";
|
||||
int N = 0;
|
||||
int N;
|
||||
try {
|
||||
N = Integer.parseInt(s[0]);
|
||||
} catch (Exception e) {
|
||||
@@ -397,7 +397,7 @@ public class ConsoleCommandInterpreter {
|
||||
});
|
||||
registerCommand(new String[]{"heal", "percent"}, s -> {
|
||||
if (s.length < 1) return "Command needs 1 parameter: Amount";
|
||||
float value = 0;
|
||||
float value;
|
||||
try {
|
||||
value = Float.parseFloat(s[0]);
|
||||
} catch (Exception e) {
|
||||
@@ -448,7 +448,7 @@ public class ConsoleCommandInterpreter {
|
||||
|
||||
registerCommand(new String[]{"hide"}, s -> {
|
||||
if (s.length < 1) return "Command needs 1 parameter: Amount";
|
||||
float value = 0;
|
||||
float value;
|
||||
try {
|
||||
value = Float.parseFloat(s[0]);
|
||||
} catch (Exception e) {
|
||||
@@ -460,7 +460,7 @@ public class ConsoleCommandInterpreter {
|
||||
|
||||
registerCommand(new String[]{"fly"}, s -> {
|
||||
if (s.length < 1) return "Command needs 1 parameter: Amount";
|
||||
float value = 0;
|
||||
float value;
|
||||
try {
|
||||
value = Float.parseFloat(s[0]);
|
||||
} catch (Exception e) {
|
||||
@@ -471,7 +471,7 @@ public class ConsoleCommandInterpreter {
|
||||
});
|
||||
registerCommand(new String[]{"sprint"}, s -> {
|
||||
if (s.length < 1) return "Command needs 1 parameter: Amount";
|
||||
float value = 0;
|
||||
float value;
|
||||
try {
|
||||
value = Float.parseFloat(s[0]);
|
||||
} catch (Exception e) {
|
||||
@@ -497,5 +497,18 @@ public class ConsoleCommandInterpreter {
|
||||
MapStage.getInstance().deleteObject(id);
|
||||
return "Removed enemy " + s[0];
|
||||
});
|
||||
// this is for test purposes unless you want to crack your items
|
||||
registerCommand(new String[]{"crack"}, s -> {
|
||||
ItemData itemData = Current.player().getRandomEquippedItem();
|
||||
String value = Current.player().isHardorInsaneDifficulty() ? "items" : "armor";
|
||||
String message = "Ok, no equipped " + value + " to crack... :)";
|
||||
if (itemData != null) {
|
||||
itemData.isCracked = true;
|
||||
Current.player().equip(itemData); //Unequipped the itemData
|
||||
InventoryScene.instance().clearItemDescription();
|
||||
message = itemData.name + " " + Forge.getLocalizer().getMessage("lblCracked");
|
||||
}
|
||||
return message;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user