Go-carcassonne is a Go implementation of the board game Carcassonne.
Check out carcassonne.quibbble.com to play a live version of this game. This website utilizes carcassonne frontend code, go-carcassonne game logic, and go-quibbble server logic.
To play a game create a new Carcassonne instance:
builder := Builder{}
game, err := builder.Create(&bg.BoardGameOptions{
Teams: []string{"TeamA", "TeamB"}, // must contain at least 2 and at most 5 teams
MoreOptions: CarcassonneMoreOptions{
Seed: 123, // seed used to generate deterministic randomness
}
})
To rotate the play tile (the tile about to be placed by the current team) do the following action:
err := game.Do(&bg.BoardGameAction{
Team: "TeamA",
ActionType: "RotateTileRight", // can also be "RotateTileLeft"
})
To place the play tile on the board do the following action:
err := game.Do(&bg.BoardGameAction{
Team: "TeamA",
ActionType: "PlaceTile",
MoreDetails: PlaceTileActionDetails{
X: 0,
Y: 1,
},
})
To place a token on the last placed tile do the following action:
err := game.Do(&bg.BoardGameAction{
Team: "TeamA",
ActionType: "PlaceToken",
MoreDetails: PlaceTokenActionDetails{
Pass: false, // true if you wish to pass placing a token
X: 0,
Y: 1,
Type: "Knight", // can be "Farmer", "Knight", "Thief", or "Monk"
Side: "Top", // if "Knight" or "Thief" can be "Top", "Right", "Bottom", "Left"; if "Farmer" can be "TopA", "TopB", "RightA", ...; if "Monk" then ""
},
})
To get the current state of the game call the following:
snapshot, err := game.GetSnapshot("TeamA")