randpg 0.12.0
randpg: ^0.12.0 copied to clipboard
A package for generating random rpg entities. This package allows generating many random entities for rpg fantasy games, from names and npcs to entire worlds!
Examples #
Table of Contents #
- Generating names
- Generating npcs
- Generating locations\buildings
- Generating settlements
- Generating landscapes
- Generating deities
- Generating guilds
- Generating kingdoms
- Generating emblems
- Generating worlds
- Generating companions
- Generating holidays
- Generate world map
Generating names #
Generating a male halfling name as an example:
final Gender gender = Gender.male;
final Race race = Halfling();
final nameGenerator = race.getNameGenerator(gender);
// if you want to seed the generator:
nameGenerator.seed(1234);
print(nameGenerator.generate()); // expected output: "Cormin Copperbrook"
output might be different since dart random seed is different on different machines
Generating npcs #
Generating an elf npc as an example:
final Race race = Elf();
final npcGenerator = NpcGenerator(race);
print(npcGenerator.generate());
Generating locations\buildings #
Generating a tavern whose owner is a dwarf as an example:
final LocationType locationType = Tavern();
final Race ownerRace = Dwarf();
final locationGenerator = LocationGenerator(locationType, ownerRace);
print(locationGenerator.generate());
Generating settlements #
Generating a town of mostly orcs as an example:
final SettlementType settlementType = Town();
final Race dominantRace = Orc();
final settlementGenerator = SettlementGenerator(settlementType, dominantRace);
print(settlementGenerator.generate());
Generating landscapes #
Generating a swamp as an example:
final LandscapeType landscapeType = Swamp();
final landscapeGenerator = LandscapeGenerator(landscapeType);
print(landscapeGenerator.generate());
Generating deities #
Generating a lawful good god/goddess as an example:
final Alignment alignment = Alignment(
ethical: EthicalAlignment.lawful,
moral: MoralAlignment.good,
);
final DeityType deityType = God();
final deityGenerator = DeityGenerator(deityType, alignment);
print(deityGenerator.generate());
Generating guilds #
Generating a thieves guild as an example:
final GuildType guildType = ThievesGuild();
final guildGenerator = GuildGenerator(guildType);
final Guild guild = guildGenerator.generate();
print(guild);
Generating kingdoms #
Generating a republic of dwarfs as an example:
final GovernmentType governmentType = Republic();
final Race race = Dwarf();
final KingdomType kingdomType = DefaultKingdomType();
final Kingdom kingdom = KingdomGenerator(kingdomType, race, governmentType).generate();
print(kingdom);
Generating emblems #
Generating an emblem with the default type:
final EmblemType type = DefaultEmblemType();
final emblemGenerator = EmblemGenerator(type);
emblemGenerator.seed(3979);
final Emblem emblem = emblemGenerator.generate();
print(emblem.buildSvg());
Expected results:
Generating worlds #
Generating a world with the default settings:
final WorldSettings settings = DefaultWorldSettings();
final worldGenerator = WorldGenerator(settings);
final World world = worldGenerator.generate();
print(world);
Generating companions #
Generating a dog companion as an example:
final CompanionType companionType = Dog();
final Gender gender = Gender.female;
final companionGenerator = CompanionGenerator(companionType, gender);
print(companionGenerator.generate());
Generating holidays #
final HolidayType holidayType = Celebration();
final holidayGenerator = HolidayGenerator(holidayType);
print(holidayGenerator.generate());
Generate world map #
final WorldMapSettings worldMapSettings = IslandsWorldMapSettings();
final worldMapGenerator = WorldMapGenerator(worldMapSettings, 100, 100);
worldMapGenerator.seed(1664)
final worldMap = worldMapGenerator.generate();
print(worldMap.toMap()["image"]) // Prints the image as base64
Expected results:

Generate world map with tiles (experimental) #
final WorldMapSettings worldMapSettings = IslandsWorldMapSettings();
final worldMapGenerator = WorldMapGenerator.withTiles(worldMapSettings, 16 * 100, 16 * 100); // 16 is the tile size
worldMapGenerator.seed(1664)
final worldMap = worldMapGenerator.generate(); // Note: this class is currently experimental and this method might throw `UnimplementedError`
print(worldMap.toMap()["image"]) // Prints the image as base64
Expected results:
