-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/main/java/com/vamk/tbg/command/impl/ListEffectsCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<StatusEffect> 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)); | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/com/vamk/tbg/command/impl/ListMovesCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
} | ||
} |