How alejandrotejero/tacticalbattle works
Purpose and execution model
Tactical Battle is a Python 3 terminal-based, two-player tactical combat game using TCP client/server networking. The server owns connection lifecycle, lobby pairing, concurrent match capacity, and ranking persistence; each client owns its local board UI and unit state. Launch points are Game/servidor.py and Game/cliente.py.
Server: connection, lobby, and match orchestration
Game/servidor.py accepts a port, simultaneous-match limit, and ranking file path. It accepts client connections, collects player identities, places waiting players into a lobby, pairs them, selects the starting player, and manages multiple active games up to the configured capacity. The server is the control-plane boundary between independent client processes.
Paths: Game/servidor.py, Game/jugador.py, Game/ranking_simple.txt.
Client: terminal interaction and local game loop
Game/cliente.py is the interactive endpoint. It gathers player input, drives deployment and turn actions, renders or manages the player’s local 4x4 board, and exchanges game events with the server/opponent through the network protocol. Movement is processed locally; combat, intelligence, and other cross-player effects are communicated so the affected side applies them to its own board.
Paths: Game/cliente.py, Game/personajes.py, Game/utils.py.
Game domain: players, board units, and victory
Player/session state is modeled in Game/jugador.py; unit roles and their combat behavior are defined in Game/personajes.py. The domain includes Francotirador, Artillero, Inteligencia, and Médico, with movement, abilities, damage/healing, visibility effects, and cooldowns. Victory depends on eliminating the opposing military units (Artillero and Francotirador), rather than every support unit.
Paths: Game/jugador.py, Game/personajes.py.
Network protocol boundary
Game/protocol.py defines the custom TCP message framing layer, using message size framing to preserve application-message boundaries over a byte stream. Both Game/cliente.py and Game/servidor.py should communicate through this module rather than directly coupling game logic to raw socket reads/writes.
Paths: Game/protocol.py, Game/cliente.py, Game/servidor.py.
Core data structures and state handling
The project implements its own queue and doubly linked list, likely supporting lobby, player, turn, or collection management instead of relying exclusively on standard-library containers. These structures are internal implementation boundaries beneath the server and gameplay orchestration layers.
Paths: Game/queue.py, Game/doubly_linked_list.py, Game/servidor.py.
Persistence and external dependencies
There are no third-party dependencies or web infrastructure. Runtime requirements are Python 3, terminal I/O, local/network TCP sockets, and filesystem access. Ranking is persisted as plain text: after a game, clients submit statistics and the server calculates and writes score updates to the configured ranking file.
Paths: Game/servidor.py, Game/ranking_simple.txt, Game/protocol.py.
Main entry points: cliente.py Terminal client · servidor.py Server · jugador.py Player state · protocol.py TCP framing protocol
Components 13
Server runtime
Owns connections, pairing, matches, and rankings.
- Server · Accepts connections and orchestrates concurrent matches.
Game/servidor.py - Lobby & match manager · Pairs waiting players, selects starters, and enforces match capacity.
Game/servidor.py - Ranking persistence · Stores server-calculated post-game scores.
Game/ranking_simple.txt - Custom queue · Supports server-side waiting or game collections.
Game/queue.py
Client runtime
Each player runs a local terminal game client.
- Terminal client · Runs deployment, turns, input, and local board interaction.
Game/cliente.py - Local 4x4 board · Each client owns and updates its own board state.
Game/cliente.py - Game utilities
Game/utils.py
Game domain
- Player state
Game/jugador.py - Combat units · Francotirador, Artillero, Inteligencia, and Médico behaviors.
Game/personajes.py - Victory rules · Victory requires eliminating Artillero and Francotirador.
Game/personajes.py - Doubly linked list · Internal collection structure for orchestration or gameplay state.
Game/doubly_linked_list.py
Other components
- TCP framing protocol · Preserves application-message boundaries over TCP streams.
Game/protocol.py - TCP sockets
Connections 16
- Server → Lobby & match manager: manages
- Lobby & match manager → Custom queue: uses
- Server → Ranking persistence: updates scores
- Server → TCP framing protocol: uses
- Terminal client → TCP framing protocol: uses
- TCP framing protocol → TCP sockets: frames messages over
- TCP sockets → Server: connections
- TCP sockets → Terminal client: connections
- Lobby & match manager → Player state: creates sessions
- Terminal client → Local 4x4 board: drives
- Terminal client → Player state: tracks player
- Local 4x4 board → Combat units: places and updates
- Combat units → Victory rules: determines
- Terminal client → Game utilities: uses
- Player state → Doubly linked list: uses collections
- Terminal client → Server: game events and statistics