trismegiste / rpg-name-generator
Library for generating random names (for table-top roleplaying games)
v1.3
2023-11-23 16:35 UTC
Requires
- php: >7.3
- symfony/finder: >5.3
- symfony/yaml: >5.3
Requires (Dev)
- phpunit/phpunit: ^9.5
This package is not auto-updated.
Last update: 2024-11-07 20:56:16 UTC
README
The RPG character name generator library is designed to create list of random names used for table-top role-playing games.
This library was extracted from the website PHP-Character-Name-Generator from Mark Tasaka after a heavy overhaul and with the help of nikic/PHP-Parser (by the way, this tool is awesome)
This library is fully tested with PhpUnit, 100% code coverage.
Install
With Composer :
composer require trismegiste/rpg-name-generator
Usage
See phpunit tests for how to use this library :
$repo = new FileRepository(); print_r($repo->getSurnameListFor('japanese')); print_r($repo->getGivenNameListFor('female', 'japanese'));
RandomizerDecorator class is a decorator for adding randomizing capabilities :
$repo = new RandomizerDecorator(new FileRepository()); print_r($repo->getSurnameListFor('random')); // gets the list of surnames from a random language echo $repo->getRandomGivenNameFor('female', 'chinese'); // picks one random chinese female given name echo $repo->getRandomSurnameFor('french'); // picks one random french surname echo $repo->getRandomSurnameFor('random'); // picks one random surname from a random language (full random)
Test
With PhpUnit :
vendor/bin/phpunit
Code coverage
With phpdbg :
phpdbg -qrr vendor/bin/phpunit firefox doc/coverage/index.html