-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extrapoints #34
base: master
Are you sure you want to change the base?
Extrapoints #34
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,39 +18,74 @@ func findExtraPoints(g *game.Game) (ans []ExtraPoint) { | |
if !extraPointsApply(g.Mode.Type()) { | ||
return | ||
} | ||
ans = append(ans, doppelkoepfe(g)...) | ||
ans = append(ans, fuechse(g)...) | ||
ans = append(ans, karlchen(g)...) | ||
ans = append(ans, doppelkopfs(g)...) | ||
ans = append(ans, foxesCaught(g)...) | ||
ans = append(ans, charlie(g)...) | ||
return | ||
} | ||
|
||
func doppelkoepfe(game *game.Game) []ExtraPoint { | ||
func EventsOccured(g *game.Game, trick *game.Trick) (ans []ExtraPointType) { | ||
if !extraPointsApply(g.Mode.Type()) { | ||
return | ||
} | ||
if scoresDoppelkopf(trick) { | ||
ans = append(ans, Doppelkopf) | ||
} | ||
for _, player := range game.Players() { | ||
if maybeFoxCaught(player, trick) { | ||
ans = append(ans, FoxCaught) | ||
} | ||
} | ||
if charlieWinLastTrick(g) { | ||
ans = append(ans, Charlie) | ||
} | ||
return ans | ||
} | ||
|
||
func scoresDoppelkopf(trick *game.Trick) bool { | ||
return trick.Score() >= 40 | ||
} | ||
|
||
func doppelkopfs(game *game.Game) []ExtraPoint { | ||
var ans []ExtraPoint | ||
for i, trick := range game.CompleteTricks { | ||
if trick.Score() >= 40 { | ||
if scoresDoppelkopf(&trick) { | ||
ep := ExtraPoint{Doppelkopf, trick.Winner, i} | ||
ans = append(ans, ep) | ||
} | ||
} | ||
return ans | ||
} | ||
|
||
func fuechse(g *game.Game) []ExtraPoint { | ||
//logic without party information | ||
func maybeFoxCaught(player game.Player, trick *game.Trick) bool { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: in the doppelkopf app I use regularly, party information is consirede public once a player has played a queen of clubs, which is then used to emit the „fox caught“ event more precisely. However in real games it is not uncommon to forget who played a »Dulle«, I think this should also be possibility in the app. ;-) |
||
return trick.CardsOf[player] == game.DiamondsA && player != trick.Winner | ||
} | ||
|
||
func foxesCaught(g *game.Game) []ExtraPoint { | ||
var ans []ExtraPoint | ||
for i, trick := range g.CompleteTricks { | ||
for _, player := range game.Players() { | ||
if trick.CardsOf[player] == game.DiamondsA && g.Mode.PartyOf(player) != g.Mode.PartyOf(trick.Winner) { | ||
ans = append(ans, ExtraPoint{FuchsGefangen, trick.Winner, i}) | ||
ans = append(ans, ExtraPoint{FoxCaught, trick.Winner, i}) | ||
} | ||
} | ||
} | ||
return ans | ||
} | ||
|
||
func karlchen(g *game.Game) []ExtraPoint { | ||
func charlieWinLastTrick(g *game.Game) bool { | ||
if !g.IsFinished() { | ||
return false | ||
} | ||
lastTrick := g.CompleteTricks[game.NumTricks-1] | ||
return lastTrick.CardsOf[lastTrick.Winner] == game.ClubsJ | ||
} | ||
|
||
func charlie(g *game.Game) []ExtraPoint { | ||
lastTrick := g.CompleteTricks[game.NumTricks-1] | ||
if lastTrick.CardsOf[lastTrick.Winner] == game.ClubsJ { | ||
ans := [1]ExtraPoint{{Karlchen, lastTrick.Winner, game.NumTricks - 1}} | ||
if charlieWinLastTrick(g) { | ||
ans := [1]ExtraPoint{{Charlie, lastTrick.Winner, game.NumTricks - 1}} | ||
return ans[:] | ||
} | ||
return []ExtraPoint{} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer sepating words by underscores (in line with the style guide):