OSDN Git Service

編成時に空いた枠を詰める操作を修正
authormasakih <masakih@users.sourceforge.jp>
Fri, 24 Nov 2017 15:25:19 +0000 (00:25 +0900)
committermasakih <masakih@users.sourceforge.jp>
Fri, 24 Nov 2017 15:25:19 +0000 (00:25 +0900)
KCD/ChangeHenseiCommand.swift

index 72c0336..e673eb0 100644 (file)
@@ -158,22 +158,13 @@ final class ChangeHenseiCommand: JSONCommand {
         store.decksSortedById()
             .forEach { deck in
                 
-                var needsPack = false
-                (0..<6).forEach {
+                var ships = deck[0..<Deck.maxShipCount]
+                
+                (0..<Deck.maxShipCount).forEach {
                     
-                    let shipId = deck.shipId(of: $0)
-                    // TODO: うまいことする 強制アンラップを消す
-                    if (shipId == nil || shipId! == -1), !needsPack {
-                        
-                        needsPack = true
-                        
-                        return
-                    }
-                    if needsPack {
-                        
-                        deck.setShip(id: shipId!, for: $0 - 1)
-                        if $0 == 5 { deck.setShip(id: -1, for: 5) }
-                    }
+                    let shipId = ships.first?.id ?? -1
+                    deck.setShip(id: shipId, for: $0)
+                    if !ships.isEmpty { ships.removeFirst() }
                 }
         }
     }