Schafkopf-Server/Sources/App/Model/Trick.swift

17 lines
322 B
Swift
Raw Normal View History

2021-12-01 22:49:54 +01:00
import Foundation
typealias Trick = [Card]
extension Trick {
func winnerIndex(forGameType type: GameType) -> Int {
2021-12-03 18:03:29 +01:00
let highCard = sorted(cardOrder: type.sortingType).first!
2021-12-01 22:49:54 +01:00
return firstIndex(of: highCard)!
}
var points: Int {
map { $0.points }
.reduce(0, +)
}
}