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

Only select wounded in selection - #746

Merged
andreas-repp merged 9 commits into
jsettlers:masterfrom
christti98:selection-modification
Jan 19, 2019
Merged

Only select wounded in selection#746
andreas-repp merged 9 commits into
jsettlers:masterfrom
christti98:selection-modification

Conversation

@ghost

@ghost ghost commented Jul 13, 2018

Copy link
Copy Markdown

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.


private void filterWounded() {
if(currentSelection.getSelectionType() != ESelectionType.SOLDIERS && currentSelection.getSelectionType() != ESelectionType.PEOPLE && currentSelection.getSelectionType() != ESelectionType.SPECIALISTS)
return;

Copy link
Copy Markdown
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
Copy Markdown
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.

}

private void filterWounded() {
if(currentSelection.getSelectionType() != ESelectionType.SOLDIERS && currentSelection.getSelectionType() != ESelectionType.PEOPLE && currentSelection.getSelectionType() != ESelectionType.SPECIALISTS)

Copy link
Copy Markdown
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
Copy Markdown
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.

@ghost

ghost commented Jul 25, 2018

Copy link
Copy Markdown
Author

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
Copy Markdown
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-repp

Copy link
Copy Markdown
Member

I would also say clear the selection.

@andreas-repp
andreas-repp 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