9
Introduction
Doppelkopf is a traditional German card game for 4 players. The deck consists of 48 cards (9, 10, Jack, Queen, King, Ace of each suit while every card is in the game twice), so each player gets 12 at the start of a round.
There are always 2 teams which are determined by the distribution of the Queens of Clubs. The 2 players who are holding the Queens form a team and play against the other 2 players. The team with the Queens of Clubs are called the "Re"-team, the one without is the "Contra"-team.
At the start of the round noone knows who is on which team. The team distribution will be revealed in the progress of the round, which adds a lot of strategy to the game.
The game consists of 12 tricks. The players who wins a trick gets all the 4 cards in it. Every card has a certain value (King counts 4, Ace counts 11 for example), all cards together sum up to 240 points which is the highest possible result.
At the end of a round the points are counted and the team with the highest amount of points wins the round. Then then next round starts...
The Challenge
Every round has a certain score which is determined by the amount of points the winning team got and potential announcements. You will have to write a program that takes the point distribution and potential announcements (see explanation below) as input and outputs the score of the round and the winner.
The score calculation
As mentioned there is a Re- and a Contra-team. Also there is a maximum of 240 points possible in one round. The Re-team has to get 121 points to win, while the Contra-team only needs 120. There is also the possibility to announce "Re" or "Contra" at the start of the round if you think that you will win the game. By doing this you are raising the score.
Here are the scoring rules:
- +1 for winning the game
- +1 if the losing team has less than 90 points ("Keine 90")
- +1 if the losing team has less than 60 points ("Keine 60")
- +1 if the losing team has less than 30 points ("Keine 30")
- +1 if the losing team has 0 points ("Schwarz")
- +2 for an announcement of Contra
- +2 for an announcement of Re
- +1 if the Contra team won ("Gegen die Alten")
Note: Re/Contra-Announcements always apply, regardless of the winner. See examples in the testcases below.
Input and Output
The input to the program will be the score of the Re-team and potential announcements of Re or Contra. Since there are always 240 points in the game you can easly calculate the score of the Contra-team.
The input will be a single string which has the score of the Re-team first, followed by the potential announcements, while "R" is for Re and "C" is for Contra. If both got announced, Re will always come first.
Output will be the score of the game followed by the winning team ("C" for Contra, "R" for Re)
Rules
- Your submission can be a full program or a function. If you choose the latter include an example on how to invoke it.
- Input can be provided by function- or command line arguments or user input.
- Output can be provided as return value or printed to the screen.
- Standard loopholes apply.
- Lowest Byte-Count wins!
Testcases
Input -> Output (Explanation)
145R -> 3R (Re won, +1 for winning, +2 for Re-Announcement)
120 -> 2C (Contra won, +1 for winning, +1 for winning as Contra)
80C -> 5C (Contra won, +1 for winning, +1 for no 90, +1 for winning as Contra, +2 for Contra-Announcement)
240R -> 7R (Re won, +1 for winning, +1 for no 90, +1 for no 60, +1 for no 30, +1 for no points for the losing team, +2 for Re-announcedment)
90 -> 2C (Contra won, +1 for winning, +1 for winning as Contra)
110RC -> 6C (Contra won, +1 for winning, +1 for winning as Contra, +2 for Re-Announcement, +2 for Contra-Announcement)
110R -> 4C (Contra won, +1 for winning, +1 for winnins as Contra, +2 for Re-Announcement)
184C -> 5R (Re won, +1 for winning, +1 for no 90, +1 for no 60, +2 for Contra-Announcement)
Short note: I left out some rules (like solos and bonus points) on purpose to keep the challenge simple. So if you are already familiar with the game, don't be confused :)
Happy Coding!
Agreed, when I tried golfing this, I came to around 100 bytes with a golfing language. I gave up very soon after. – TheCoffeeCup – 2016-01-23T23:38:13.780