-
Notifications
You must be signed in to change notification settings - Fork 101
Only select wounded in selection #746
Only select wounded in selection #746
Conversation
…onverter; Changed wounded selection key from v to TAB;
@@ -608,6 +614,21 @@ private boolean canSelectPlayer(byte playerIdOfSelected) { | |||
return MatchConstants.ENABLE_ALL_PLAYER_SELECTION || playerIdOfSelected == playerId; | |||
} | |||
|
|||
private void filterWounded() { | |||
if(currentSelection.getSelectionType() != ESelectionType.SOLDIERS && currentSelection.getSelectionType() != ESelectionType.PEOPLE && currentSelection.getSelectionType() != ESelectionType.SPECIALISTS) | |||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Always use the curly brackets for ifs, even if they have only one line.
|
||
final List<ISelectable> selected = new LinkedList<>(); | ||
|
||
for(ISelectable selectable : currentSelection) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use currentSelection.stream().filter(<condition>).collect(Collectors.toList())
instead of the loop.
@@ -608,6 +614,21 @@ private boolean canSelectPlayer(byte playerIdOfSelected) { | |||
return MatchConstants.ENABLE_ALL_PLAYER_SELECTION || playerIdOfSelected == playerId; | |||
} | |||
|
|||
private void filterWounded() { | |||
if(currentSelection.getSelectionType() != ESelectionType.SOLDIERS && currentSelection.getSelectionType() != ESelectionType.PEOPLE && currentSelection.getSelectionType() != ESelectionType.SPECIALISTS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a new Property to ESelectionType. Then use
if (currentSelection.getSelectionType().allowsFilterForWounded()) { ... }
|
||
for(ISelectable selectable : currentSelection) { | ||
Movable movable = (Movable)selectable; | ||
if(movable.getHealth() < movable.getMovableType().health) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a new Method to ISelectable. Then use:
if (selectable.isWounded()) { ... }
Buildings always return false.
Then you can skip the test at the beginning of the method as well, since all selectables support the same interface.
…ementing it); Simplified filterWounded method in GuiInterface by using Java 8 stream filtering.
…ection-modification
I implemented the changes that you guys have mentioned. |
I'm for clearing the selection. |
I would also say clear the selection. |
These changes allow you to filter your selection by wounded (key is TAB).
I also wanted to implement things like SHIFT while selecting to add to the selection, but I thought it is better to wait for #709 to be merged into master (because it already includes key modifiers for input events).
There is no UI for this in Android yet.
Should improve #661.