Browse Source

Translated all the outputs to German

remotes/origin/fight-engine
fdai7430 2 years ago
parent
commit
6539908e62
  1. 36
      src/main/java/org/bitbiome/commands/UseCommand.java
  2. 24
      src/test/java/org/bitbiome/commands/UseCommandTest.java

36
src/main/java/org/bitbiome/commands/UseCommand.java

@ -27,16 +27,16 @@ private boolean combat = false;
Mob mob = enemies.get(i); Mob mob = enemies.get(i);
float hp = player.getHp(); float hp = player.getHp();
hp -= mob.getDamage(); hp -= mob.getDamage();
System.out.println(mob.getName() + " attacked you for " + mob.getDamage() + " damage.");
System.out.println(mob.getName() + " hat dich angegriffen und " + mob.getDamage() + " Schaden zugefügt.");
if(hp <= 0) { if(hp <= 0) {
player.setHp(0); player.setHp(0);
System.out.println("You died.");
System.out.println("Du bist gestorben.");
System.exit(0); System.exit(0);
} }
player.setHp(hp); player.setHp(hp);
} }
COMBAT_LOOP:do { COMBAT_LOOP:do {
System.out.println("What do you want to do?");
System.out.println("Was willst du tun?");
String input = scanner.nextLine(); String input = scanner.nextLine();
switch(input) { switch(input) {
case "use": case "use":
@ -44,27 +44,27 @@ private boolean combat = false;
break COMBAT_LOOP; break COMBAT_LOOP;
case "runaway": case "runaway":
if(runawaySucceeds(getRunawayChance())) { if(runawaySucceeds(getRunawayChance())) {
System.out.println("You successfully ran away.");
System.out.println("Du bist erfolgreich geflüchtet.");
combat = false; combat = false;
break COMBAT_LOOP; break COMBAT_LOOP;
} }
System.out.println("You failed to run away.");
System.out.println("Dein Fluchtversuch ist fehlgeschlagen.");
break; break;
case "help": case "help":
new HelpCommand().performCommand(scanner, true, "", engine); new HelpCommand().performCommand(scanner, true, "", engine);
break; break;
case "exit": case "exit":
case "quit": case "quit":
System.out.println("You cannot quit while in combat.");
System.out.println("Du kannst nicht während eines Kampfes das Spiel verlassen.");
break; break;
case "location": case "location":
new LocationCommand().performCommand(scanner, true, "", engine); new LocationCommand().performCommand(scanner, true, "", engine);
break; break;
case "travel": case "travel":
System.out.println("You cannot travel while in combat.");
System.out.println("Du kannst nicht während eines Kampfes reisen.");
break; break;
default: default:
System.out.println("That is not a valid command.");
System.out.println("Unbekannter Befehl - Siehe " + Colors.ANSI_PURPLE + "help" + Colors.ANSI_RESET);
break; break;
} }
} while(true); } while(true);
@ -89,9 +89,9 @@ private boolean combat = false;
} }
public String use(Scanner scanner, TravelEngine engine) { public String use(Scanner scanner, TravelEngine engine) {
System.out.println("Which item would you like to use?");
System.out.println("Welches Item willst du benutzen?");
String item = scanner.nextLine(); String item = scanner.nextLine();
System.out.println("On who? (leave blank for self)");
System.out.println("Auf welchen Gegner willst du es benutzen? (Leer lassen, um es auf dich selbst anzuwenden)");
String target = scanner.nextLine(); String target = scanner.nextLine();
if(target.equals("")) if(target.equals(""))
return getUseMessage(item, engine); return getUseMessage(item, engine);
@ -109,7 +109,7 @@ private boolean combat = false;
Item item = inv.get(i); Item item = inv.get(i);
if(item.getName().toLowerCase().equals(itemName.toLowerCase())) { if(item.getName().toLowerCase().equals(itemName.toLowerCase())) {
if(!item.doesDamage()) if(!item.doesDamage())
return "You can't attack with this.";
return "Damit kannst du nicht angreifen.";
if(message.length == 1) if(message.length == 1)
return useItem(item, player); return useItem(item, player);
String targetName = message[1]; String targetName = message[1];
@ -120,22 +120,22 @@ private boolean combat = false;
if(mob.getName().toLowerCase().equals(targetName.toLowerCase())) if(mob.getName().toLowerCase().equals(targetName.toLowerCase()))
return useItem(item, mob, loc); return useItem(item, mob, loc);
} }
return "That target is not available.";
return "Dieses Ziel ist nicht verfügbar.";
} }
} }
return "That item is not in your inventory.";
return "Du bist nicht im Besitz dieses Items.";
} }
public String useItem(Item item, Player target) { public String useItem(Item item, Player target) {
float hp = target.getHp(); float hp = target.getHp();
hp -= item.getDamage(); hp -= item.getDamage();
String retString = "You used " + item.getName() + " on yourself";
String retString = "Du hast " + item.getName() + " auf dich selbst angewandt";
if(hp <= 0) { if(hp <= 0) {
target.setHp(0); target.setHp(0);
return retString + " and died.";
return retString + " und bist gestorben.";
} }
target.setHp(hp); target.setHp(hp);
return retString;
return retString + ".";
} }
public String useItem(Item item, Mob target, Location location) { public String useItem(Item item, Mob target, Location location) {
@ -147,11 +147,11 @@ private boolean combat = false;
if(dmg>=hp) { if(dmg>=hp) {
location.getMobList().remove(target); location.getMobList().remove(target);
enemies.remove(target); enemies.remove(target);
return "You killed " + target.getName() + " with " + item.getName();
return "Du hast " + target.getName() + " mit " + item.getName() + " getötet.";
} }
target.setHp(hp-dmg); target.setHp(hp-dmg);
target.setFriendly(false); target.setFriendly(false);
return "You used " + item.getName() + " on " + target.getName();
return "Du hast " + item.getName() + " auf " + target.getName() + " angewandt.";
} }
public void getEnemies(ArrayList<Mob> allMobs) { public void getEnemies(ArrayList<Mob> allMobs) {

24
src/test/java/org/bitbiome/commands/UseCommandTest.java

@ -49,9 +49,9 @@ public class UseCommandTest {
Mob mob = new Mob("Wolf", false, 11, 10); Mob mob = new Mob("Wolf", false, 11, 10);
player.getLocation().getMobList().add(mob); player.getLocation().getMobList().add(mob);
Item sword = new Item("Sword", true, 10); Item sword = new Item("Sword", true, 10);
assertEquals("You used Sword on Wolf", com.useItem(sword, mob, player.getLocation()));
assertEquals("Du hast Sword auf Wolf angewandt.", com.useItem(sword, mob, player.getLocation()));
assertEquals(1, player.getLocation().getMobList().size()); assertEquals(1, player.getLocation().getMobList().size());
assertEquals("You killed Wolf with Sword", com.useItem(sword, mob, player.getLocation()));
assertEquals("Du hast Wolf mit Sword getötet.", com.useItem(sword, mob, player.getLocation()));
assertEquals(0, player.getLocation().getMobList().size()); assertEquals(0, player.getLocation().getMobList().size());
} }
@ -60,27 +60,27 @@ public class UseCommandTest {
UseCommand com = new UseCommand(); UseCommand com = new UseCommand();
Player player = new Player("test"); Player player = new Player("test");
Item sword = new Item("Sword", true, 10); Item sword = new Item("Sword", true, 10);
assertEquals("You used Sword on yourself", com.useItem(sword, player));
assertEquals("Du hast Sword auf dich selbst angewandt.", com.useItem(sword, player));
assertEquals(90, player.getHp()); assertEquals(90, player.getHp());
Item sword2 = new Item("Heiliges Schwert der Engel", true, 1000); Item sword2 = new Item("Heiliges Schwert der Engel", true, 1000);
assertEquals("You used Heiliges Schwert der Engel on yourself and died.", com.useItem(sword2, player));
assertEquals("Du hast Heiliges Schwert der Engel auf dich selbst angewandt und bist gestorben.", com.useItem(sword2, player));
} }
@Test @Test
public void testGetUseMessage() { public void testGetUseMessage() {
UseCommand com = new UseCommand(); UseCommand com = new UseCommand();
TravelEngine engine = new TravelEngine(new Player("test")); TravelEngine engine = new TravelEngine(new Player("test"));
assertEquals("That item is not in your inventory.", com.getUseMessage("", engine));
assertEquals("That item is not in your inventory.", com.getUseMessage("Fell", engine));
assertEquals("Du bist nicht im Besitz dieses Items.", com.getUseMessage("", engine));
assertEquals("Du bist nicht im Besitz dieses Items.", com.getUseMessage("Fell", engine));
engine.getPlayer().addToInventory(new Item("Fell", false, 0)); engine.getPlayer().addToInventory(new Item("Fell", false, 0));
assertEquals("You can't attack with this.", com.getUseMessage("Fell", engine));
assertEquals("Damit kannst du nicht angreifen.", com.getUseMessage("Fell", engine));
engine.getPlayer().addToInventory(new Item("Heiliges Schwert der Erzengel", true, 3000)); engine.getPlayer().addToInventory(new Item("Heiliges Schwert der Erzengel", true, 3000));
assertEquals("That target is not available.", com.getUseMessage("Heiliges Schwert der Erzengel on Wolf", engine));
assertEquals("That target is not available.", com.getUseMessage("hEiLiGeS sChWeRt DeR eRzEnGeL on WoLf", engine));
assertEquals("Dieses Ziel ist nicht verfügbar.", com.getUseMessage("Heiliges Schwert der Erzengel on Wolf", engine));
assertEquals("Dieses Ziel ist nicht verfügbar.", com.getUseMessage("hEiLiGeS sChWeRt DeR eRzEnGeL on WoLf", engine));
engine.getPlayer().getLocation().getMobList().add(new Mob("Wolf", false, 11, 10)); engine.getPlayer().getLocation().getMobList().add(new Mob("Wolf", false, 11, 10));
assertEquals("You killed Wolf with Heiliges Schwert der Erzengel", com.getUseMessage("Heiliges Schwert der Erzengel on Wolf", engine));
assertEquals("That target is not available.", com.getUseMessage("Heiliges Schwert der Erzengel on Wolf", engine));
assertEquals("Du hast Wolf mit Heiliges Schwert der Erzengel getötet.", com.getUseMessage("Heiliges Schwert der Erzengel on Wolf", engine));
assertEquals("Dieses Ziel ist nicht verfügbar.", com.getUseMessage("Heiliges Schwert der Erzengel on Wolf", engine));
engine.getPlayer().getLocation().getMobList().add(new Mob("Wolf", false, 11, 10)); engine.getPlayer().getLocation().getMobList().add(new Mob("Wolf", false, 11, 10));
assertEquals("You killed Wolf with Heiliges Schwert der Erzengel", com.getUseMessage("hEiLiGeS sChWeRt DeR eRzEnGeL on WoLf", engine));
assertEquals("Du hast Wolf mit Heiliges Schwert der Erzengel getötet.", com.getUseMessage("hEiLiGeS sChWeRt DeR eRzEnGeL on WoLf", engine));
} }
} }
Loading…
Cancel
Save