2 // MainTabVIewItemViewController.swift
5 // Created by Hori,Masaki on 2016/12/27.
6 // Copyright © 2016年 Hori,Masaki. All rights reserved.
12 enum ShipTabType: Int {
18 case aircraftCarrier = 4
24 class MainTabVIewItemViewController: NSViewController {
26 let shipTypeCategories: [[Int]] = [
29 [3, 4], // leght cruiser
30 [5, 6], // heavy crusier
31 [7, 11, 16, 18], // aircraft carrier
32 [8, 9, 10, 12], // battle ship
33 [13, 14], // submarine
34 [1, 15, 17, 19, 20, 21, 22]
37 dynamic var hasShipTypeSelector: Bool { return false }
38 dynamic var selectedShipType: ShipTabType = .all
40 var shipTypePredicte: NSPredicate? {
42 switch selectedShipType {
46 case .destroyer, .lightCruiser, .heavyCruiser,
47 .aircraftCarrier, .battleShip, .submarine:
48 return NSPredicate(format: "master_ship.stype.id IN %@", shipTypeCategories[selectedShipType.rawValue])
51 let omitTypes = shipTypeCategories
53 .filter { $0.offset != 0 && $0.offset != 7 }
54 .flatMap { $0.element }
55 return NSPredicate(format: "NOT master_ship.stype.id IN %@", omitTypes)