Scripting
Here is a guide how to write the rules.
The principle is simple:
You write JavaScript-Code to modify the game variables.
The principle is simple:
You write JavaScript-Code to modify the game variables.
Standard
At the beginning of a completely new game there are only the standard rules.
Everybody have three handcards. Each card has a color and number.
You can play a card, when the card on the stack has the same number or same color as your card. The turns are anti clockwise. In each turn you must play a card or take a card from the upturned stack. The person, who first have played all handcards is the winner.
Everybody have three handcards. Each card has a color and number.
You can play a card, when the card on the stack has the same number or same color as your card. The turns are anti clockwise. In each turn you must play a card or take a card from the upturned stack. The person, who first have played all handcards is the winner.
How Rules work
When somebody win in Mau you can make a new rule or reset all rules.
The new rules can override nearly everthing.
In the selection of the rules you can always select "None", "Reset" or "Random".
None add no rule when you win.
Reset deletes all rules when you win.
Random select a random rule from the online database.
When you make a rule you should follow this recommendations:
The new rules can override nearly everthing.
In the selection of the rules you can always select "None", "Reset" or "Random".
None add no rule when you win.
Reset deletes all rules when you win.
Random select a random rule from the online database.
When you make a rule you should follow this recommendations:
- keep it simple
- make it objectively and fair
- don't destroy the game (make it impossible to win)
- only do one thing in one rule (you should be able to describe the rule in one short sentence)
- make it fun not exhausting
Use Scripts
Scripts can be online or local.
The local Scripts must be placed in the folder Scripts.
Scripts in an other folder or subfolder of Scripts will be ignored.
The online Scripts can be accessed with your Username and Password.
The available rules will be loaded at start or when the user is changed.
When you want to start with some simple rules download a standard pack here.
The local Scripts must be placed in the folder Scripts.
Scripts in an other folder or subfolder of Scripts will be ignored.
The online Scripts can be accessed with your Username and Password.
The available rules will be loaded at start or when the user is changed.
When you want to start with some simple rules download a standard pack here.
Types of Scripts
There are currently two types of scripts.
The first are Start-Rules.
These rules are executed when a new gameround begin.
With this scripts it is possible to change the player, who begin a round or the count of handcards.
Startscripts must have "//#Start" as first line to be recognized as startscripts.
The second type are normal scripts.
Normalscripts can change everthing in the game behavior like a "Take two card", a dropout card, which cards you can play on which, should there be an other stack, how much cards can be played in one turn, when can you wish a color to be played or how the order of players should be.
The first are Start-Rules.
These rules are executed when a new gameround begin.
With this scripts it is possible to change the player, who begin a round or the count of handcards.
Startscripts must have "//#Start" as first line to be recognized as startscripts.
The second type are normal scripts.
Normalscripts can change everthing in the game behavior like a "Take two card", a dropout card, which cards you can play on which, should there be an other stack, how much cards can be played in one turn, when can you wish a color to be played or how the order of players should be.
Constants
These Constants can be accessed in both types and give information about the game. They can be accessed with "Constants.[Constant-Name]". These variables shouldn't be changed.
Constant-Name |
Type |
Standard-value |
Meaning |
COUNT_STACK |
Integer |
2 |
How many card stacks can be there. |
COUNT_PLAYER |
Integer |
4 |
How many players are there. |
COUNT_NUMBER |
Integer |
10 |
How many different numbers exists on cards |
COUNT_COLOR |
Integer |
4 |
How many colors exists on cards |
TAKE |
Integer |
-4 |
Value for allowing taking a card |
NEXT |
Integer |
-3 |
allow to end the turn (when there is no other possibility the turn will be ended automatically) |
ALL |
Integer |
-1 |
stands for all numbers or all colors |
RED |
Integer |
0 |
the color red for cards |
YELLOW |
Integer |
1 |
the color yellow for cards |
BLUE |
Integer |
2 |
the color blue for cards |
GREEN |
Integer |
3 |
the color green for cards |
Start-scripts
Variable |
Type |
Value |
possible Usage |
startcount |
Integer[] |
How many handcards each player get |
how many handcards each player will have |
wincount |
Integer[] |
how many times each player won |
make it more difficult for the winner |
won |
Integer |
which player won the last game |
make it more difficult for the winner |
currplayerid |
Integer |
which player whould be after last turn |
change the startplayer |
currplayerturn |
Integer |
how many turns the last round had |
maybe useful |
othercount |
Integer[] |
how many cards the player have |
useful information for unusual rules |
Normal-Scripts
Some of the variables without a notice to change can be changed but it is often not recommend or have no effect.
Variable |
Type |
Meaning |
possible Usage |
instance.copyPossible() |
Set<CKarte> |
make a copy of possible for memory (Don't put possible direct in memory this would just be a reference) |
copy possibilities for later usage or comparison |
topcard |
CKarte |
the card at top of the stacks |
many rules |
output |
String |
output that will be displayed from rules |
give the players a hint |
println(String) |
void |
function to add something to output |
say something |
new CKarte(int color, int number, int stacknumber, int playerid) |
CKarte |
create a new card |
add new possibilities |
Mau.CKarteAllToAny(possible) |
void |
converts possibilities with "ALL" to single [ALL,5]=>[Red,5],[Yellow,5],[Blue,5],[Green,5] |
handling of possibilities with specific color |
currturn |
Integer |
the turn in which the current player is (0=No Card player,1=One Card played/taken) |
only allow one action per turn |
currplayerid |
Integer |
The id of the played who can play. This can be changed in the script. |
suspend a player or change order |
currplayerturn |
Integer |
count up after each player |
compare current turn to turn when the topcard was played |
stack |
List<CKarte>[] |
Reference to the stacks. |
get cards on the stacks |
wincount |
Integer[] |
how often a player won |
maybe useful |
possible |
Set<CKarte> |
most important variable: Manage all possibile moves even "Take a card" and "Next Player". This Variable can be changed. |
most of the rules will change this |
lastaction |
CKarte |
the last action a player has taken |
make something special after a player took a card |
addcards |
Integer[] |
how many card are added or taken from the players. Change this to give or take cards. |
automatically give the player cards |
rand |
Random |
a "Random" object from java. |
make it random flip a coin |
owncards |
List<AKarte> |
depreced |
depreced |
othercount |
Integer[] |
the number of handcards from the player |
make something again the player with fewest handcards |
memory |
Map<String,Object> |
save values for later usage |
remember something |
rulenumber |
Integer |
the number of the rule (if your rule is the third rule this would be 2) |
distinguish between your data in memory |
removeLines(String) |
void |
remove all lines with a String in them from output |
a second rule overwrite an old an so there shouldn't be two conflicting outputs |
Classes
Here is an UML-Diagram with some important classes and functions.
playerround is the round a card was played.
stack is the stack a card in possible can be played on.
player is the id of the player who can play / had played the card.
playerround is the round a card was played.
stack is the stack a card in possible can be played on.
player is the id of the player who can play / had played the card.
Possibilities and Challenges
Here are some ideas what rules you can make:
- After a normal turn you can play again matching cards as long as you have such cards
- after you played a seven you get one card less and the player with fewest hand cards get one card more
- after each eight the playing order is reversed
- after a six the next player suspended
- after you take a card you are allowed to play a matching card
- when you take a card you can play this card on the second stack
- each player get five handcards at start (make this with normal rules not start rules)
- when a player has more than four cards he lose cards until he has four cards
- at the beginning of the game a card gets revealed on the second stack without meaning
- save and compare possibilities to determine what the other rules might be.
Example
Rule: "Reset but formulated as script."
Rule: "You can always play green cards in your turn."
Rule: "You can play any card on green cards in your turn."
Start-Rule: "Everybody get five handcards."
Get the topcards