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
@satan87
satan87 / cloudSettings
Last active November 11, 2020 05:07 — forked from ayoubkalil/cloudSettings
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-10-28T08:53:14.795Z","extensionVersion":"v3.4.3"}
#if DEBUG
func playDebug(combination: Combination) {
playCombination(combination: combination)
}
#endif
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)
}
func playDebug(combination: Combination) {
playCombination(combination: combination)
}
func play() {
playCombination(combination: generateCombination())
}
private func playCombination(combination: Combination) {
let combination = combination
func play(combination: Combination) {
let combination = combination
...
}
func play() {
let combination = generateCombination()
...
}
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 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)
}
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
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"]