solitaire-utils
v1.0.0
Published
Node.js package providing card game logic and game dev utilities for building solitaire and card games. Open source game development tools.
Maintainers
Readme
Simple Solitaire Engine
A Node.js package providing card game logic and game dev utilities for building solitaire and card games. This open source JavaScript game engine offers essential algorithms for browser game development.
Features
- Fisher-Yates Shuffle Algorithm: Efficient and unbiased card shuffling
- Card Game Logic: Ready-to-use deck creation and dealing functions
- Game Dev Utilities: Essential tools for card game development
- Lightweight Node.js package with zero dependencies
- Perfect for browser game development
- Works in both Node.js and browser environments
Installation
NPM Package
npm install solitaire-utilsAlternative Installation
npm install simple-solitaire-engineOr include directly in your HTML:
<script src="shuffle.js"></script>Usage
Node.js Package Usage
const { shuffleArray, createDeck, dealCards } = require('solitaire-utils');
// Create and shuffle a deck using card game logic
const deck = createDeck();
const shuffledDeck = shuffleArray(deck);
// Deal cards using game dev utilities
const { dealt, remaining } = dealCards(shuffledDeck, 7);
console.log('Dealt cards:', dealt);
console.log('Remaining deck:', remaining.length);Browser Usage
// Create a deck of cards
const deck = [
'2♠', '3♠', '4♠', '5♠', '6♠', '7♠', '8♠', '9♠', '10♠', 'J♠', 'Q♠', 'K♠', 'A♠',
'2♥', '3♥', '4♥', '5♥', '6♥', '7♥', '8♥', '9♥', '10♥', 'J♥', 'Q♥', 'K♥', 'A♥',
'2♣', '3♣', '4♣', '5♣', '6♣', '7♣', '8♣', '9♣', '10♣', 'J♣', 'Q♣', 'K♣', 'A♣',
'2♦', '3♦', '4♦', '5♦', '6♦', '7♦', '8♦', '9♦', '10♦', 'J♦', 'Q♦', 'K♦', 'A♦'
];
// Shuffle the deck
const shuffledDeck = shuffleArray(deck);
console.log(shuffledDeck);API Reference
Game Dev Utilities
shuffleArray(array)
Shuffles an array using the Fisher-Yates algorithm. Core card game logic utility.
createDeck()
Creates a standard 52-card deck. Returns an array of card objects with rank, suit, and display properties.
dealCards(deck, count)
Deals a specified number of cards from a deck. Returns an object with dealt and remaining arrays.
About
This Node.js package delivers essential card game logic and game dev utilities for developers building card games. The package provides battle-tested algorithms and helper functions that simplify game development.
Perfect for:
- Solitaire games and variants
- Poker applications
- Blackjack games
- Educational card game projects
- Any game development requiring card mechanics
- Browser-based and Node.js card games
Related Projects
Visit Online Card Games for live examples and more card game resources.
License
MIT License - Free for personal and commercial use
Contributing
Contributions are welcome! This is an open source Node.js package aimed at helping developers build better card games with reliable game dev utilities.
