This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| MapKit | GooglePlace | Winner | ||
|---|---|---|---|---|
| Installation | Embedded in iOS | Registration + Pod | MapKit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| import MapKit | |
| final class MapKitService { | |
| // Map the Apple Category to your own category | |
| private let typesToDrink: [MKPointOfInterestCategory] = [.brewery, .cafe, .winery] | |
| private let typesToEat: [MKPointOfInterestCategory] = [.foodMarket, .restaurant] | |
| func retrieve(from: String, completionBlock: @escaping ([Place]) -> Void) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| import GooglePlaces | |
| final class GooglePlaceService { | |
| private var placesClient: GMSPlacesClient! | |
| private var filter = GMSAutocompleteFilter() | |
| // Map the Google Category to your own category | |
| private let typesToDrink = ["bar", "cafe"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func play() { | |
| // We Check we are in Phase One | |
| if phase == Phase.phase1 { | |
| // We need to clean the result from previous turn | |
| emptyTurnCombinationIfNecessary() | |
| //We get a new random combination | |
| var dice = Dice() | |
| dice.roll() | |
| let valueOne = dice.value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func testGamePhaseOneprint() { | |
| let game = Game(players: [Player(name: "Player1"), Player(name: "Player2")]) | |
| game.play() | |
| game.play() | |
| XCTAssertEqual(1, game.tokenPlayers[0]) | |
| XCTAssertEqual(0, game.tokenPlayers[1]) | |
| XCTAssertEqual(14, game.tokenToDistribute) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private func generateCombination() -> Combination { | |
| var dice = Dice() | |
| dice.roll() | |
| let valueOne = dice.value | |
| dice.roll() | |
| let valueTwo = dice.value | |
| dice.roll() | |
| let valueThree = dice.value | |
| return Combination(one: valueOne, two: valueTwo, three: valueThree) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func play() { | |
| let combination = generateCombination() | |
| ... | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func play(combination: Combination) { | |
| let combination = combination | |
| ... | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func playDebug(combination: Combination) { | |
| playCombination(combination: combination) | |
| } | |
| func play() { | |
| playCombination(combination: generateCombination()) | |
| } | |
| private func playCombination(combination: Combination) { | |
| let combination = combination |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func testGamePhaseOneDirectEndGame() { | |
| let game = Game(players: [Player(name: "Player1"), Player(name: "Player2")]) | |
| game.playDebug(combination: Combination(one: 4, two: 2, three: 1)) // 421 -> 10 tokens | |
| game.playDebug(combination: Combination(one: 1, two: 1, three: 1)) // 111 -> 6 tokens | |
| XCTAssertEqual(0, game.tokenPlayers[0]) | |
| XCTAssertEqual(15, game.tokenPlayers[1]) | |
| XCTAssertEqual(0, game.tokenToDistribute) | |
| XCTAssertTrue(game.isOver) | |
| } |