Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Latest commit

 

History

80 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

forthebadge

Djambi - A Strategic Board Game Implementation

Overview

Djambi is a turn-based strategy board game, also called the Machiavelli Chess Game. It has been implemented with Pygame and Python and official rules can be found on Wikipedia.

Djambi Game

Game Features

  • 4-Player Gameplay
  • Turn-Based Strategy: Players take turns moving their pieces to capture opponents. The last Chief standing wins !

Piece Types

Chief Assassin Diplomat Necromobile Reporter Militant Crown

Piece Abilities

Piece Description
Chief The most powerful piece. Can move to any adjacent square and is the only piece that can reach the center throne.
Assassin Can move up to the maximum range and eliminates pieces, leaving a corpse behind.
Diplomat Can move up to the maximum range and can capture pieces by exchange, moving the captured piece to where the diplomat was.
Militant Can move 2 squares and capture enemy pieces by replacing them with a corpse.
Necromobile Can only move to squares with corpses. Moves any number of squares to reach corpses.
Reporter Can move up to the maximum range but turns all neighboring enemy pieces into corpses.

How to Play

Objective

The goal is to eliminate the opposing Chief by surrounding or capturing it with your pieces.

Controls

  • Left Click on a piece to select it
  • Drag the piece to see possible moves (shown as circles)
  • Release on a highlighted move to execute the move
  • Click again on the same piece to re-drag it
  • Press 'Z' to undo your last move
  • Press 'Q' or close the window to quit

Installation

# Install dependencies and create a virtual environment
pip install uv
uv sync

# Run the game
uv run main.py

Project Structure

Djambi/
├── main.py                # Main game loop
├── config/
│   ├── const.py           # Game constants (board size, colors, etc.)
│   └── colors.json        # Color definitions for pieces
├── gameplay/
│   ├── game.py            # Game logic and rendering
│   ├── player.py          # Player class
│   └── dragger.py         # Piece dragging logic
├── board/
│   ├── board.py           # Board state and move validation
│   ├── piece.py           # Piece classes and properties
│   └── square.py          # Square/cell class
└── assets/
    └── images/
        └── pieces/        # SVG assets for all pieces and colors

Architecture

Key Classes

  • Game: Main game controller, handles rendering and turn management
  • Board: Manages board state, piece positions, and move validation
  • Piece: Base class for all piece types with type-specific subclasses
  • Player: Represents a player with name and color
  • Dragger: Handles piece dragging and movement visualization

Features in Development

  • AI opponents
  • Game saves/loads
  • Network multiplayer
  • Sound effects
  • Animation improvements
  • Support for 2, 3, 5, and 6 player variants

References

Structure

classDiagram
class AbstractBoard{
    boardMatrix 
        bool centerIsOccupied
        possibleNbPlayers=[]
        __init__()
        getPossibleMoves(self,piece,origincell)
        move(self,origincell,destcell)
}
class HexaBoard{possibleNbPlayers=[2,4]
    __init__(self)}
    class SquareBoard{
        __init__(self)
            possibleNbPlayers=[3,6]}
            class Game{
                int currentPlayer 
                    AbstractBoard gameBoard 
                    nextPlayer()
                    ...}
                    class Player{
                        string name
                            string color
                            int order
                    }
class Cell {
    int coordQ
        int coordS
        int coordR
        Piece piece
        isCenter()
}
class Piece {
    Image img
        string name
        string description
}
AbstractBoard <|-- HexaBoard
AbstractBoard <|-- SquareBoard

AbstractBoard "1" -- "1"Game
Game "1" -- "2..6" Player
AbstractBoard "1" -- "*" Cell
Cell "*" -- "1" Piece
Loading

About

A Python implementation of the Djambi board game

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages