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

🀄️

giginet
PRO
September 02, 2018

 🀄️

iOSDC 2018 LT

giginet
PRO

September 02, 2018
Tweet

More Decks by giginet

Other Decks in Technology

Transcript

  1. @giginet

  2. giginet/Peafowl

  3. None
  4. 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ͷը૾औ͖ͬͯͯฦ͢
  5. None
  6. 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Λ࣮૷
  7. None
  8. None
  9. ੃಄ ໘ࢠ ໘ࢠ ໘ࢠ ໘ࢠ ࿨ྃܗ ॱࢠʢ࿈ଓͨ͠ṛʣ ࠁࢠʢಉ͡ṛʣ

  10. ελοΫ

  11. ੃಄Λ164)

  12. ໘ࢠΛ164)

  13. ࡞Εͳ͘ͳͬͨΒ

  14. 101ͯ͠

  15. ࣍ͷΛ164)

  16. None
  17. ࣣରࢠܗ ࠃ࢜ແ૒ܗ ରࢠ ରࢠ

  18. /// ௨ৗ࿨ྃܗ 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) } ରࢠ ໘ࢠ  ࿨ྃܗ ରࢠ  ରࢠ ഍ 
  19. func detectForms(of: tiles: [Tile]) -> [WinningForm]? ṛ͔Β ࿨ྃܗΛ୳ࡧ

  20. /// ໾ 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
  21. 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͔Β ͍۬அ͸ೝΊͯΔ
  22. None
  23. ଘࡏܕͰ͸ͳ͍

  24. let yaku: Set<AnyYaku> = [ AnyYaku(அϠΦ۝()), AnyYaku(ฏ࿨()), AnyYaku(໳લਗ਼ࣗ໚࿨()), ] ܕফڈ

  25. ҎԼলུ #PYͰϥοϓͯ͠ܕΛফ͢

  26. ੃಄͸λϓϧ ໘ࢠ΋λϓϧ

  27. ήʔϜঢ়ଶ ූᠹ఺

  28. ߴ఺๏ ෳ਺ͷ఺਺ղऍ͕Ͱ͖Δͱ͖ʹ࠷ߴͷ݁ՌΛ࠾༻͢Δ͜ͱ

  29. ࣣରࢠɺஅϠΦූᠹ఺ ෳ਺ͷ࿨ྃܗͱͯ͠ղऍͰ͖Δέʔε ࣣରࢠܗ

  30. ೋഌޱɺஅϠΦූᠹຬ؏఺ ࣣରࢠɺஅϠΦූᠹ఺ ࿨ྃṛ ෳ਺ͷ࿨ྃܗͱͯ͠ղऍͰ͖Δέʔε ࣣରࢠܗ ௨ৗ࿨ྃܗ

  31. ࣣରࢠܗ ௨ৗܗ ߴ͍ํΛ࠾༻ ղऍ͕ͭ

  32. ࿨ྃ഍ͷղऍͰූ͕มΘΔέʔε ࿨ྃṛ ࿨ྃṛʢ྆໘଴ͪʣ ࿨ྃṛʢቕு଴ͪʣ πϞɺ໾഍ූᠹ఺ πϞɺ໾഍ූᠹ఺

  33. ղऍ͕ͭ ໾͸ಉ͡ ූ ූ

  34. None
  35. "WBJMBCMFPOXBUDI04

  36. giginet/Peafowl