diff --git a/src/main/java/com/vamk/tbg/command/CommandManager.java b/src/main/java/com/vamk/tbg/command/CommandManager.java index 9205a6a..193e244 100644 --- a/src/main/java/com/vamk/tbg/command/CommandManager.java +++ b/src/main/java/com/vamk/tbg/command/CommandManager.java @@ -4,6 +4,8 @@ import com.vamk.tbg.command.impl.HealCommand; import com.vamk.tbg.command.impl.KillCommand; import com.vamk.tbg.command.impl.ListCommand; +import com.vamk.tbg.command.impl.ListEffectsCommand; +import com.vamk.tbg.command.impl.ListMovesCommand; import com.vamk.tbg.command.impl.RemoveEffectCommand; import com.vamk.tbg.command.impl.SetEffectCommand; import com.vamk.tbg.command.mapper.ArgumentMapper; @@ -65,6 +67,8 @@ public CommandManager(Game game) { new HealCommand(), new KillCommand(), new ListCommand(game), + new ListEffectsCommand(), + new ListMovesCommand(), new RemoveEffectCommand(), new SetEffectCommand() ); diff --git a/src/main/java/com/vamk/tbg/command/impl/ListEffectsCommand.java b/src/main/java/com/vamk/tbg/command/impl/ListEffectsCommand.java new file mode 100644 index 0000000..1519565 --- /dev/null +++ b/src/main/java/com/vamk/tbg/command/impl/ListEffectsCommand.java @@ -0,0 +1,47 @@ +package com.vamk.tbg.command.impl; + +import com.vamk.tbg.command.Argument; +import com.vamk.tbg.command.Command; +import com.vamk.tbg.command.CommandContext; +import com.vamk.tbg.command.CommandException; +import com.vamk.tbg.effect.StatusEffect; +import com.vamk.tbg.game.Entity; + +import java.util.Arrays; +import java.util.Set; +import java.util.stream.Collectors; + +public class ListEffectsCommand extends Command { + + public ListEffectsCommand() { + super( + "ls-eff", + "List status effects of an entity or all of them", + new Argument("target", "The entity whose active status effects should be displayed", true) + ); + } + + @Override + public void run(CommandContext context) throws CommandException { + if (context.remaining() > 0) { + Entity target = context.nextArg(Entity.class); + Set effects = target.getEffects().keySet(); + if (effects.isEmpty()) { + context.respond("Entity %d doesn't have active effects at the moment.".formatted(target.getId())); + } else { + String active = target.getEffects() + .keySet() + .stream() + .map(StatusEffect::name) + .collect(Collectors.joining(", ")); + context.respond("Entity %d's acitve effects: %s".formatted(target.getId(), active)); + } + } else { + String all = Arrays.stream(StatusEffect.values()) + .map(StatusEffect::name) + .collect(Collectors.joining(", ")); + + context.respond("Listing all available effects: %s".formatted(all)); + } + } +} diff --git a/src/main/java/com/vamk/tbg/command/impl/ListMovesCommand.java b/src/main/java/com/vamk/tbg/command/impl/ListMovesCommand.java new file mode 100644 index 0000000..b1fe96e --- /dev/null +++ b/src/main/java/com/vamk/tbg/command/impl/ListMovesCommand.java @@ -0,0 +1,30 @@ +package com.vamk.tbg.command.impl; + +import com.vamk.tbg.combat.Move; +import com.vamk.tbg.command.Argument; +import com.vamk.tbg.command.Command; +import com.vamk.tbg.command.CommandContext; +import com.vamk.tbg.command.CommandException; +import com.vamk.tbg.game.Entity; + +import java.util.stream.Collectors; + +public class ListMovesCommand extends Command { + + public ListMovesCommand() { + super( + "ls-mov", + "List moves of the specified entity", + new Argument("target", "The entity whose moves should be listed") + ); + } + + @Override + public void run(CommandContext context) throws CommandException { + Entity target = context.nextArg(Entity.class); + String moves = target.getMoves().stream() + .map(Move::getId) + .collect(Collectors.joining(", ")); + context.respond("Entity %d's moves: %s".formatted(target.getId(), moves)); + } +}