Skip to content
This repository has been archived by the owner on Oct 1, 2022. It is now read-only.

Only select wounded in selection #746

Merged
merged 9 commits into from
Jan 19, 2019

Conversation

PayDay1
Copy link
Contributor

@PayDay1 PayDay1 commented Jul 13, 2018

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.

@@ -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;
Copy link
Member

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) {
Copy link
Member

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)
Copy link
Member

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)
Copy link
Member

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.

@PayDay1
Copy link
Contributor Author

PayDay1 commented Jul 25, 2018

I implemented the changes that you guys have mentioned.
There is one questionable behaviour: If the selection only has unwounded objects in it, should it just do nothing or clear the selection (like it does now)?

@michaelzangl
Copy link
Member

I'm for clearing the selection.
So that you don't have to think about it when sending the wounded out of the battlefield. If there are no wounded, no soldiers will be sent.

@andreas-eberle
Copy link
Member

I would also say clear the selection.

@andreas-eberle andreas-eberle merged commit fd584a4 into jsettlers:master Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants