Skip to main content

models for representing and manipulating a game of catan

Project description

catan
-----

Package catan provides models for representing and manipulating a game of catan

Board coordinates must be specified as described in module [`hexgrid`](https://github.com/rosshamish/hexgrid).

`.catan` files will be written to the working directory by class Game (see [`catanlog`](https://github.com/rosshamish/catanlog)).

class Game also supports undo and redo, which is useful for building GUIs.

Supports Python 3. Might work in Python 2.

> Author: Ross Anderson ([rosshamish](https://github.com/rosshamish))

### Installation

```
pip install catan
```

### Usage

```
import catan.board
import catan.game
import catan.trading

players = [Player(1, 'ross', 'red'),
Player(2, 'josh', 'blue'),
Player(3, 'yuri', 'green'),
Player(4, 'zach', 'orange')]
board = catan.board.Board()
game = catan.game.Game(board=board)

game.start(players=players)
print(game.get_cur_player()) # -> ross (red)
game.buy_settlement(0x37)
game.buy_road(0x37)
game.end_turn()
...
game.roll(6)
game.trade(trade=catan.trading.CatanTrade(...))
game.undo()
game.redo()
game.play_knight(...)
game.end_turn()
...
game.end()
```

See [`catan-spectator`](https://github.com/rosshamish/catan-spectator) for extensive usage.

### File Format

<!-- remember to update this section in sync with "File Format" in github.com/rosshamish/catan-spectator/README.md -->

catan-spectator writes game logs in the `.catan` format described by package [`catanlog`](https://github.com/rosshamish/catanlog).

They look like this:

```
green rolls 6
blue buys settlement, builds at (1 NW)
orange buys city, builds at (1 SE)
red plays dev card: monopoly on ore
```

### Documentation

Most classes and modules are documented. Read the docstrings! If something is confusing or missing, open an issue.

### License

GPLv3

Project details


Release history Release notifications

This version
History Node

0.4.2

History Node

0.3.11

History Node

0.3.10

History Node

0.3.9

History Node

0.3.8

History Node

0.3.7

History Node

0.3.6

History Node

0.3.5

History Node

0.2.5

History Node

0.1.6

History Node

0.1.5

History Node

0.1.4

History Node

0.1.3

History Node

0.1.2

History Node

0.1.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
catan-0.4.2.tar.gz (26.4 kB) Copy SHA256 hash SHA256 Source None Feb 16, 2016

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page