Upgrade to Pro — share decks privately, control downloads, hide ads and more …

🀄️

giginet
September 02, 2018

 🀄️

iOSDC 2018 LT

giginet

September 02, 2018
Tweet

More Decks by giginet

Other Decks in Technology

Transcript

  1. extension Tile: CustomPlaygroundDisplayConvertible { public var playgroundDescription: Any { //

    ṛͷը૾ΛFramework͔ΒऔΓग़ͯ͠ੜ੒ let bundle = Bundle(for: BundleIndicator.self) let path = bundle.path(forResource: String(describing: index), ofType: "png")! return NSImage(contentsOfFile: path)! } } 1MBZHSPVOE্ʹ೚ҙͷ෺ΛඳըͰ͖Δ 'SBNFXPSLͷը૾औ͖ͬͯͯฦ͢
  2. extension Array: CustomPlaygroundDisplayConvertible where Element == Tile { public var

    playgroundDescription: Any { return createTilesImage(of: self) as Any } } /4(SBQIJD$POUFYUͰख഍ͷը૾Λಈతʹੜ੒ʢུʣ $POEJUJPOBM$POGPSNBODFͰ<5JMF>ʹ $VTUPN1MBZHSPVOE%JTQMBZ$POWFSUJCMFΛ࣮૷
  3. /// ௨ৗ࿨ྃܗ public typealias MeldedForm = (PairToken, MeldToken, MeldToken, MeldToken,

    MeldToken) /// ࣣରࢠܥ public typealias SevenPairsForm = (PairToken, PairToken, PairToken, PairToken, PairToken, PairToken, PairToken) /// ࠃ࢜ແ૒ܥ public typealias ThirteenOrphansForm = (PairToken, Tile, Tile, Tile, Tile, Tile, Tile, Tile, Tile, Tile, Tile, Tile, Tile) public enum WinningForm { case melded(MeldedForm) case sevenPairs(SevenPairsForm) case thirteenOrphans(ThirteenOrphansForm) } ରࢠ ໘ࢠ  ࿨ྃܗ ରࢠ  ରࢠ ഍ 
  4. /// ໾ public protocol YakuProtocol: Hashable, CustomStringConvertible { var name:

    String { get } /// ຋ var concealedFan: Int { get } /// ͍ᷰԼ͕Γ຋ var openedFan: Int? { get } var isYakuman: Bool { get } static func make(with tiles: [Tile], form: WinningForm, picked: Tile, context: GameContext) -> Self? } खṛ ࿨ྃܗ ࿨ྃṛ ήʔϜঢ়ଶ ໾Λද͢QSPUPDPM
  5. public struct அϠΦ۝: YakuProtocol { public let openedFan: Int? =

    1 public let concealedFan: Int = 1 public let name = "அϠΦ" public static func make(with tiles: [Tile], ɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹ form: WinningForm, ɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹ picked: Tile, ɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹ context: GameContext) -> அϠΦ۝? { if tiles.allSatisfy({ !$0.isYaochu }) { return அϠΦ۝() } return nil } } શͯϠΦ۝ṛͰͳ͍͜ͱΛνΣοΫ 4XJGU͔Β ͍۬அ͸ೝΊͯΔ