Skip to content

Instantly share code, notes, and snippets.

View satan87's full-sized avatar
🏠
Working from home

nicolas satan87

🏠
Working from home
View GitHub Profile
MapKit GooglePlace Winner
Installation Embedded in iOS Registration + Pod MapKit
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) {
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"]
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
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)
}
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)
}
func play() {
let combination = generateCombination()
...
}
func play(combination: Combination) {
let combination = combination
...
}
func playDebug(combination: Combination) {
playCombination(combination: combination)
}
func play() {
playCombination(combination: generateCombination())
}
private func playCombination(combination: Combination) {
let combination = combination
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)
}