npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

the-game-domain

v1.2.120

Published

Complete domain layer for 'The Game' card game with rich business entities, automatic persistence, action tracking, and advanced game mechanics. Features Game, Player, Card, Deck, Pile entities with repository pattern, turn management, victory/defeat dete

Downloads

11

Readme

🎯 Domínio - The Game

Pacote de domínio do jogo "The Game" contendo toda a lógica de negócio e regras do jogo.

📋 Sobre

Este pacote contém as entidades de domínio, regras de negócio e lógica central do jogo "The Game", seguindo os princípios de Domain-Driven Design (DDD). É uma biblioteca TypeScript independente que pode ser usada em qualquer projeto que precise implementar as regras deste jogo de cartas.

🚀 Tecnologias

  • TypeScript - Tipagem estática
  • Jest - Testes unitários
  • Domain-Driven Design - Arquitetura de domínio
  • Clean Architecture - Separação de responsabilidades

📁 Estrutura

src/
├── entities/              # Entidades de domínio
│   ├── Card.ts            # Entidade Carta
│   ├── Deck.ts            # Entidade Baralho
│   ├── Game.ts            # Entidade Jogo
│   ├── GameAction.ts      # Entidade Ação
│   ├── Pile.ts            # Entidade Pilha
│   └── Player.ts          # Entidade Jogador
├── repositories/          # Interfaces de repositório
├── utils/                 # Utilitários
└── value-objects/         # Objetos de valor
docs/                      # 📚 Documentação

🚀 Quick Start

Pré-requisitos

  • Node.js 18+
  • npm ou yarn
  • Git

Instalação

  1. Clone o repositório

    git clone https://github.com/rtsarakaki/the-game-domain.git
    cd the-game-domain
  2. Configure o .npmrc localmente

    npm run setup:npmrc
  3. Instale as dependências

    npm install
  4. Execute os testes

    npm test

Para Usuários

# Instalar o pacote
npm install the-game-domain

# Usar no seu código
import { Game } from 'the-game-domain'
const game = new Game(2) // 2 jogadores

Para Desenvolvedores

# Instalar dependências
npm install

# Testes
npm test
npm test:watch

# Build
npm build

# Lint
npm lint

📋 Próximos Passos

  1. 📖 Leia a Documentação Completa para entender os conceitos
  2. 🎮 Comece com a Entidade Game - a principal do sistema
  3. 🃏 Explore as Entidades para entender cada componente
  4. 📦 Configure Publicação Local se quiser testar

📚 Documentação

🚀 Primeiros Passos

  1. 📖 Documentação Completa - Visão geral e conceitos
  2. 🐳 Verdaccio Docker - Configuração do registry local (obrigatório para publicação)
  3. 📦 Publicação Local - Como instalar e publicar localmente

🎯 Entidades de Negócio

  1. 🎮 Jogo - Entidade principal (comece aqui!)
  2. 🃏 Cartas - Entidade Card (validação de valores 1-100)
  3. 🎴 Baralho - Entidade Deck (gestão de cartas 2-99)
  4. 👤 Jogador - Entidade Player (gestão de mão e turnos)
  5. 📚 Pilha - Entidade Pile (regras de descarte)

⚙️ Recursos Avançados

  1. 🗄️ Repository System - Sistema de persistência in-memory
  2. 🚀 GitHub Actions - Publicação automática no npm público
  3. 🔢 Versionamento Automático - Semantic versioning automático
  4. 📦 NPM Registry Inteligente - Fallback automático entre Verdaccio e npm público

🎯 Entidades

Core Entities

  • Game - Estado do jogo e regras principais
  • Player - Jogador e suas cartas
  • Card - Carta individual
  • Deck - Baralho de cartas
  • Pile - Pilhas do jogo (crescente/decrescente)

Supporting Entities

  • GameAction - Histórico de ações do jogo

🎮 Regras do Jogo

Objetivo

Descartar todas as cartas antes dos outros jogadores.

Mecânicas

  • Cada jogador recebe 6 cartas
  • Cartas devem ser jogadas em ordem crescente ou decrescente
  • Diferença de 10 é permitida entre cartas
  • Jogador deve jogar pelo menos 1 carta por turno
  • Vitória: descartar todas as cartas
  • Derrota: não conseguir jogar cartas obrigatórias

🧪 Testes

O domínio possui cobertura completa de testes para garantir a integridade das regras de negócio:

# Executar todos os testes
npm test

# Testes em modo watch
npm test:watch

# Cobertura de testes
npm run test:coverage

📦 Uso

import { Game, Player, Card } from 'the-game-domain'

// Criar um novo jogo
const game = new Game(['Jogador 1', 'Jogador 2'])

// Jogar uma carta
game.moveCardToPile(playerId, cardId, pileId)

// Verificar estado
console.log(game.isFinished)
console.log(game.currentPlayerId)