Skip to content
This repository has been archived by the owner on Jan 29, 2023. It is now read-only.

Commit

Permalink
Add filter for include locking ships
Browse files Browse the repository at this point in the history
Rename checkbox name
  • Loading branch information
kphrx committed Oct 9, 2018
1 parent ac3094b commit 991eda4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ public class KanmusuListGeneratorController extends WindowController {
private TextField kanmusuList;

@FXML
private CheckBox isExclusionDuplicateLv1;
private CheckBox exclusionDuplicateLv1;

@FXML
private CheckBox inclusionDuplicateLocked;

@FXML
void copyToClipboard(ActionEvent event) {
Expand All @@ -58,40 +61,38 @@ void create(ActionEvent event) {
}

private void generate() {
this.shipIdAndBeforeId = this.generateShipIdAndBeforeId();
Map<Integer, List<SimpleEntry<Integer, Integer>>> ships = new HashMap<>();
for (Ship ship : ShipCollection.get().getShipMap().values()) {
int lv = ship.getLv();
int shipId = ship.getShipId();
this.generateShipIdAndBeforeId();

Map<Integer, List<SimpleEntry<Integer, Ship>>> ships = new HashMap<>();
for (Ship ship : ShipCollection.get().getShipMap().values()) {
// 初期のShip IDと改造数を取得する
SimpleEntry<Integer, Integer> charIdAndLvSuffix = this.getCharIdAndLvSuffix(shipId);
SimpleEntry<Integer, Integer> charIdAndLvSuffix = this.getCharIdAndLvSuffix(ship.getShipId());
int charId = charIdAndLvSuffix.getKey();
int lvSuffix = charIdAndLvSuffix.getValue();

if (! ships.containsKey(charId)) {
ships.put(charId, new ArrayList<>());
}
ships.get(charId).add(new SimpleEntry<>(lv, lvSuffix));
ships.get(charId).add(new SimpleEntry<>(lvSuffix, ship));
}

this.format = ships.entrySet().stream()
.map(shipEntry -> shipEntry.getValue().stream()
.filter(level -> shipEntry.getValue().size() == 1 || !(level.getKey() == 1 && this.isExclusionDuplicateLv1.isSelected()))
.map(level -> level.getKey() + "." + level.getValue())
.filter(ship -> shipEntry.getValue().size() == 1
|| !(this.exclusionDuplicateLv1.isSelected() && ship.getValue().getLv() == 1)
|| (this.inclusionDuplicateLocked.isSelected() && ship.getValue().getLocked()))
.map(ship -> ship.getValue().getLv() + "." + ship.getKey())
.collect(joining(",", shipEntry.getKey() + ":", "")))
.collect(joining("|", ".2|", ""));

this.kanmusuList.setText(this.format);
}

private Map<Integer, Integer> generateShipIdAndBeforeId() {
private void generateShipIdAndBeforeId() {
// マスターデータから改造前と後のMapを作成する
Map<Integer, Integer> shipIdAndBeforeId = ShipMstCollection.get().getShipMap().values().stream()
this.shipIdAndBeforeId = ShipMstCollection.get().getShipMap().values().stream()
.filter(ship -> ship.getAftershipid() != null) // 改造先がない場合は含まない
.collect(toMap(ship -> ship.getAftershipid(), ship -> ship.getId(), (old, shipId) -> shipId > old ? old : shipId)); // 既に追加されていてShipIDが追加されているものより大きい場合(コンバート改装)は変更しない

return shipIdAndBeforeId;
}

private SimpleEntry<Integer, Integer> charIdAndLvSuffix(int shipId, int count) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/kanmusulist/gui/KanmusuListGenerator.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
<Label fx:id="result" />
</children>
</HBox>
<CheckBox fx:id="isExclusionDuplicateLv1" mnemonicParsing="false" text="重複した艦娘からLv1を除外する" />
<CheckBox fx:id="exclusionDuplicateLv1" mnemonicParsing="false" text="重複した艦娘からLv1を除外する" />
<CheckBox fx:id="inclusionDuplicateLocked" mnemonicParsing="false" text="重複しているロック済みの艦娘を含む" />
<TextField fx:id="kanmusuList" />
</children>
</VBox>

0 comments on commit 991eda4

Please sign in to comment.