genfurnishing

package
v0.0.0-...-ce97658 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 17, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

README

genfurnishing

Simple generator for furnishing of rooms.

Heavily inspired by https://github.com/GadgetBlaster/JavaScript-DnD-Dungeon-Generator

Documentation

Index

Constants

View Source
const (
	TypeKeep       = "Keep"
	TypeGreatHouse = "Great House"
)
View Source
const (
	RoomFurnishingAlchemy   = "alchemy"
	RoomFurnishingAnvil     = "anvil"
	RoomFurnishingBed       = "bed"
	RoomFurnishingBench     = "bench"
	RoomFurnishingBookcase  = "bookcase"
	RoomFurnishingCabinet   = "cabinet"
	RoomFurnishingCarpet    = "carpet"
	RoomFurnishingChair     = "chair"
	RoomFurnishingCupboard  = "cupboard"
	RoomFurnishingDesk      = "desk"
	RoomFurnishingDresser   = "dresser"
	RoomFurnishingFirePit   = "firePit"
	RoomFurnishingFireplace = "fireplace"
	RoomFurnishingForge     = "forge"
	RoomFurnishingLamp      = "lamp"
	RoomFurnishingMirror    = "mirror"
	RoomFurnishingPainting  = "painting"
	RoomFurnishingPillar    = "pillar"
	RoomFurnishingRack      = "rack"
	RoomFurnishingShelf     = "shelf"
	RoomFurnishingShrine    = "shrine"
	RoomFurnishingSpit      = "spit"
	RoomFurnishingTableLg   = "tableLg"
	RoomFurnishingTableSm   = "tableSm"
	RoomFurnishingTapestry  = "tapestry"
	RoomFurnishingThrone    = "throne"
	RoomFurnishingTorch     = "torch"
	RoomFurnishingWardrobe  = "wardrobe"
	RoomFurnishingWorkbench = "workbench"
)
View Source
const (
	CapacitySmall   = 1
	CapacityMedium  = 3
	CapacityLarge   = 9
	CapacityMassive = 27
)

Storage capacities.

View Source
const (
	ItemTypeAmmo          = "ammo"
	ItemTypeArmor         = "armor"
	ItemTypeChancery      = "chancery"
	ItemTypeClothing      = "clothing"
	ItemTypeCoin          = "coin"
	ItemTypeContainer     = "container"
	ItemTypeFood          = "food"
	ItemTypeFurnishing    = "furnishing"
	ItemTypeKitchen       = "kitchen"
	ItemTypeLiquid        = "liquid"
	ItemTypeMiscellaneous = "miscellaneous"
	ItemTypeMysterious    = "mysterious"
	ItemTypeMystic        = "mystic"
	ItemTypePotion        = "potion"
	ItemTypeSurvival      = "survival"
	ItemTypeStationary    = "stationary"
	ItemTypeTack          = "tack"
	ItemTypeTool          = "tool"
	ItemTypeTreasure      = "treasure"
	ItemTypeTrinket       = "trinket"
	ItemTypeWeapon        = "weapon"
)
View Source
const (
	ClothingNameCloak  = "cloak"
	ClothingNameCoat   = "coat"
	ClothingNameGloves = "gloves"
	ClothingNameHat    = "hat"
	ClothingNamePants  = "pants"
	ClothingNameShirt  = "shirt"
)

Clothing

View Source
const (
	StationaryNameLedger = "ledger"
	StationaryNameQuill  = "quill"
	StationaryNameScroll = "scroll"
)

Stationary

View Source
const (
	RoomTypeArmory     = "armory"
	RoomTypeAtrium     = "atrium"
	RoomTypeBallroom   = "ballroom"
	RoomTypeBathhouse  = "bathhouse"
	RoomTypeBedroom    = "bedroom"
	RoomTypeChamber    = "chamber"
	RoomTypeDining     = "dining"
	RoomTypeDormitory  = "dormitory"
	RoomTypeGreatHall  = "greatHall"
	RoomTypeHallway    = "hallway"
	RoomTypeKitchen    = "kitchen"
	RoomTypeLaboratory = "laboratory"
	RoomTypeLibrary    = "library"
	RoomTypePantry     = "pantry"
	RoomTypeParlour    = "parlour"
	RoomTypePrison     = "prison"
	RoomTypeRoom       = "room"
	RoomTypeShrine     = "shrine"
	RoomTypeSmithy     = "smithy"
	RoomTypeStorage    = "storage"
	RoomTypeStudy      = "study"
	RoomTypeThrone     = "throne"
	RoomTypeTorture    = "torture"
	RoomTypeTreasury   = "treasury"
)

Variables

View Source
var (
	QuantityNone = &FurnishingQuantity{
		Name:        "none",
		Min:         0,
		Max:         0,
		Probability: 0.25,
	}
	QuantityMinimum = &FurnishingQuantity{
		Name:        "minimum",
		Min:         1,
		Max:         1,
		Probability: 0.75,
	}
	QuantitySparse = &FurnishingQuantity{
		Name:        "sparse",
		Min:         2,
		Max:         2,
		Probability: 0.92,
	}
	QuantityAverage = &FurnishingQuantity{
		Name:        "average",
		Min:         3,
		Max:         4,
		Probability: 0.98,
	}
	QuantityFurnished = &FurnishingQuantity{
		Name:        "furnished",
		Min:         5,
		Max:         6,
		Probability: 1.0,
	}
)
View Source
var (
	RarityAbundant = &Rarity{
		Name:           "abundant",
		Probability:    25,
		IndicateRarity: false,
	}
	RarityCommon = &Rarity{
		Name:           "common",
		Probability:    45,
		IndicateRarity: false,
	}
	RarityAverage = &Rarity{
		Name:           "average",
		Probability:    65,
		IndicateRarity: false,
	}
	RarityUncommon = &Rarity{
		Name:           "uncommon",
		Probability:    80,
		IndicateRarity: true,
	}
	RarityRare = &Rarity{
		Name:           "rare",
		Probability:    93,
		IndicateRarity: true,
	}
	RarityExotic = &Rarity{
		Name:           "exotic",
		Probability:    99,
		IndicateRarity: true,
	}
	RarityLegendary = &Rarity{
		Name:           "legendary",
		Probability:    100,
		IndicateRarity: true,
	}
)
View Source
var (
	RoomArmory = NewRoomConfig(RoomTypeArmory,
		[]string{
			RoomFurnishingRack},
		[]string{
			RoomFurnishingAnvil,
			RoomFurnishingBench,
			RoomFurnishingCabinet,
			RoomFurnishingForge,
			RoomFurnishingLamp,
			RoomFurnishingRack,
			RoomFurnishingTableLg,
			RoomFurnishingShelf,
			RoomFurnishingTorch,
			RoomFurnishingWorkbench},
	)
	RoomAtrium = NewRoomConfig(RoomTypeAtrium,
		nil,
		[]string{
			RoomFurnishingBench,
			RoomFurnishingCarpet,
			RoomFurnishingPillar},
	)
	RoomBallroom = NewRoomConfig(RoomTypeBallroom,
		nil,
		[]string{
			RoomFurnishingBench,
			RoomFurnishingCarpet,
			RoomFurnishingChair,
			RoomFurnishingFireplace,
			RoomFurnishingLamp,
			RoomFurnishingTableLg,
			RoomFurnishingTableSm},
	)
	RoomBathhouse = NewRoomConfig(RoomTypeBathhouse,
		nil,
		[]string{
			RoomFurnishingBench,
			RoomFurnishingRack,
			RoomFurnishingShelf},
	)
	RoomBedroom = NewRoomConfig(RoomTypeBedroom,
		[]string{
			RoomFurnishingBed},
		[]string{
			RoomFurnishingBed,
			RoomFurnishingBench,
			RoomFurnishingBookcase,
			RoomFurnishingCarpet,
			RoomFurnishingChair,
			RoomFurnishingDesk,
			RoomFurnishingDresser,
			RoomFurnishingFireplace,
			RoomFurnishingLamp,
			RoomFurnishingMirror,
			RoomFurnishingTableSm,
			RoomFurnishingShelf,
			RoomFurnishingShrine,
			RoomFurnishingWardrobe},
	)
	RoomChamber = NewRoomConfig(RoomTypeChamber,
		nil,
		[]string{
			RoomFurnishingBookcase,
			RoomFurnishingCabinet,
			RoomFurnishingCarpet,
			RoomFurnishingChair,
			RoomFurnishingDesk,
			RoomFurnishingFireplace,
			RoomFurnishingLamp,
			RoomFurnishingTableSm,
			RoomFurnishingShelf,
			RoomFurnishingTorch},
	)
	RoomDining = NewRoomConfig(RoomTypeDining,
		[]string{
			RoomFurnishingTableLg},
		[]string{
			RoomFurnishingBench,
			RoomFurnishingCabinet,
			RoomFurnishingCarpet,
			RoomFurnishingChair,
			RoomFurnishingCupboard,
			RoomFurnishingFireplace,
			RoomFurnishingLamp,
			RoomFurnishingTableLg,
			RoomFurnishingTableSm,
			RoomFurnishingSpit,
			RoomFurnishingTorch},
	)
	RoomDormitory = NewRoomConfig(RoomTypeDormitory,
		[]string{
			RoomFurnishingBed},
		[]string{
			RoomFurnishingBed,
			RoomFurnishingCarpet,
			RoomFurnishingBench,
			RoomFurnishingBookcase,
			RoomFurnishingChair,
			RoomFurnishingCupboard,
			RoomFurnishingDesk,
			RoomFurnishingDresser,
			RoomFurnishingFireplace,
			RoomFurnishingPillar,
			RoomFurnishingRack,
			RoomFurnishingTableSm,
			RoomFurnishingShelf,
			RoomFurnishingTorch},
	)
	RoomGreatHall = NewRoomConfig(RoomTypeGreatHall,
		nil,
		[]string{
			RoomFurnishingBench,
			RoomFurnishingCarpet,
			RoomFurnishingBookcase,
			RoomFurnishingFireplace,
			RoomFurnishingForge,
			RoomFurnishingLamp,
			RoomFurnishingPillar,
			RoomFurnishingRack,
			RoomFurnishingTableLg,
			RoomFurnishingThrone,
			RoomFurnishingShrine,
			RoomFurnishingTorch},
	)
	RoomHallway = NewRoomConfig(RoomTypeHallway,
		nil,
		[]string{
			RoomFurnishingCarpet,
			RoomFurnishingShelf,
			RoomFurnishingTorch},
	)
	RoomKitchen = NewRoomConfig(RoomTypeKitchen,
		[]string{
			RoomFurnishingTableSm,
			RoomFurnishingSpit},
		[]string{
			RoomFurnishingFirePit,
			RoomFurnishingFireplace,
			RoomFurnishingLamp,
			RoomFurnishingRack,
			RoomFurnishingTableLg,
			RoomFurnishingTableSm,
			RoomFurnishingShelf,
			RoomFurnishingSpit,
			RoomFurnishingWorkbench},
	)
	RoomLaboratory = NewRoomConfig(RoomTypeLaboratory,
		[]string{
			RoomFurnishingAlchemy,
			RoomFurnishingWorkbench},
		[]string{
			RoomFurnishingAlchemy,
			RoomFurnishingBench,
			RoomFurnishingBookcase,
			RoomFurnishingCabinet,
			RoomFurnishingCarpet,
			RoomFurnishingChair,
			RoomFurnishingDesk,
			RoomFurnishingFireplace,
			RoomFurnishingLamp,
			RoomFurnishingMirror,
			RoomFurnishingRack,
			RoomFurnishingTableSm,
			RoomFurnishingTableLg,
			RoomFurnishingShelf,
			RoomFurnishingTorch,
			RoomFurnishingWorkbench},
	)
	RoomLibrary = NewRoomConfig(RoomTypeLibrary,
		[]string{
			RoomFurnishingBookcase},
		[]string{
			RoomFurnishingBench,
			RoomFurnishingBookcase,
			RoomFurnishingCabinet,
			RoomFurnishingCarpet,
			RoomFurnishingChair,
			RoomFurnishingDesk,
			RoomFurnishingFireplace,
			RoomFurnishingLamp,
			RoomFurnishingTableLg,
			RoomFurnishingTableSm,
			RoomFurnishingShelf},
	)
	RoomPantry = NewRoomConfig(RoomTypePantry,
		[]string{
			RoomFurnishingShelf},
		[]string{
			RoomFurnishingCabinet,
			RoomFurnishingCupboard,
			RoomFurnishingRack,
			RoomFurnishingShelf},
	)
	RoomParlour = NewRoomConfig(RoomTypeParlour,
		nil,
		[]string{
			RoomFurnishingBench,
			RoomFurnishingBookcase,
			RoomFurnishingCabinet,
			RoomFurnishingCarpet,
			RoomFurnishingChair,
			RoomFurnishingDesk,
			RoomFurnishingTableSm},
	)
	RoomPrison = NewRoomConfig(RoomTypePrison,
		nil, nil)
	RoomRoom = NewRoomConfig(RoomTypeRoom,
		nil,
		[]string{
			RoomFurnishingCarpet,
			RoomFurnishingFirePit,
			RoomFurnishingTableSm,
			RoomFurnishingTorch},
	)
	RoomShrine = NewRoomConfig(RoomTypeShrine,
		[]string{
			RoomFurnishingShrine},
		[]string{
			RoomFurnishingCarpet,
			RoomFurnishingLamp,
			RoomFurnishingShrine,
			RoomFurnishingTorch},
	)
	RoomSmithy = NewRoomConfig(RoomTypeSmithy,
		[]string{
			RoomFurnishingAnvil,
			RoomFurnishingForge,
			RoomFurnishingWorkbench},
		nil,
	)
	RoomStorage = NewRoomConfig(RoomTypeStorage,
		[]string{
			RoomFurnishingRack},
		[]string{
			RoomFurnishingCabinet,
			RoomFurnishingCupboard,
			RoomFurnishingRack,
			RoomFurnishingTableSm,
			RoomFurnishingShelf},
	)
	RoomStudy = NewRoomConfig(RoomTypeStudy,
		[]string{
			RoomFurnishingChair,
			RoomFurnishingDesk},
		[]string{
			RoomFurnishingBookcase,
			RoomFurnishingCabinet,
			RoomFurnishingCarpet,
			RoomFurnishingChair,
			RoomFurnishingDesk,
			RoomFurnishingLamp,
			RoomFurnishingTableSm,
			RoomFurnishingShelf},
	)
	RoomThrone = NewRoomConfig(RoomTypeThrone,
		[]string{
			RoomFurnishingThrone},
		[]string{
			RoomFurnishingBench,
			RoomFurnishingCarpet,
			RoomFurnishingLamp,
			RoomFurnishingPillar,
			RoomFurnishingTableLg,
			RoomFurnishingThrone,
			RoomFurnishingTorch},
	)
	RoomTorture = NewRoomConfig(RoomTypeTorture,
		[]string{
			RoomFurnishingChair},
		[]string{
			RoomFurnishingFireplace,
			RoomFurnishingTorch,
			RoomFurnishingWorkbench},
	)
	RoomTreasury = NewRoomConfig(RoomTypeTreasury,
		nil,
		[]string{
			RoomFurnishingCarpet,
			RoomFurnishingDesk,
			RoomFurnishingLamp,
			RoomFurnishingMirror,
			RoomFurnishingRack,
			RoomFurnishingTableLg,
			RoomFurnishingTableSm},
	)
)
View Source
var StationarySet = &ItemSet{
	Name: "stationary",
	Items: []*ItemBase{
		NewItemBase(StationaryNameLedger, ItemTypeStationary, func(i *ItemBase) {
			i.Rarity = RarityCommon
			i.Size = SizeMedium
		}),
		NewItemBase(StationaryNameQuill, ItemTypeStationary, func(i *ItemBase) {
			i.Rarity = RarityCommon
			i.Size = SizeTiny
		}),
		NewItemBase(StationaryNameScroll, ItemTypeStationary, func(i *ItemBase) {
			i.Rarity = RarityCommon
			i.Size = SizeTiny
		}),
	},
}

Functions

This section is empty.

Types

type Building

type Building struct {
	Name  string  // Name of the building.
	Rooms []*Room // Rooms in the building.
	Size  int     // Size of the building.
}

A building is a collection of rooms serving a purpose with a total size and a number of inhabitants with a certain social status, profession, and hobbies.

func (*Building) Log

func (b *Building) Log()

Log the building.

type BuildingConfig

type BuildingConfig struct {
	Name     string   // Name of the building type.
	Required []string // Required rooms
	Possible []string // Possible rooms
	Size     [2]int   // Minimum/Maximum size of the building.
}

BuildingConfig represents a building prototype and all the possible variations of rooms that can be found in it.

func NewBuildingConfig

func NewBuildingConfig(name string, required, possible []string, minSize, maxSize int) *BuildingConfig

NewBuildingConfig returns a new building configuration for generating a specific type of building.

func (*BuildingConfig) Generate

func (bc *BuildingConfig) Generate() *Building

Generate a building from the config.

type FurnishingQuantity

type FurnishingQuantity struct {
	Name        string
	Min, Max    int
	Probability float64
}

type Item

type Item struct {
	*ItemBase
	Variant  string
	Contains []*Item
}

Item represents a generated item.

func (*Item) Name

func (it *Item) Name() string

type ItemBase

type ItemBase struct {
	Name     string
	Rarity   *Rarity
	Size     Size
	Capacity int
	Type     string
	Variants []string
	Set      *ItemSet // TODO: Allow multiple sets.
}

ItemBase represents a base item prototype.

func NewItemBase

func NewItemBase(name, iType string, setFunc func(*ItemBase)) *ItemBase

NewItemBase returns a new item base.

func (*ItemBase) Generate

func (it *ItemBase) Generate() *Item

Generate returns a new item based on this item base.

type ItemSet

type ItemSet struct {
	Name  string
	Items []*ItemBase
}

func (*ItemSet) Generate

func (is *ItemSet) Generate() *Item

func (*ItemSet) GenerateN

func (is *ItemSet) GenerateN(n int) []*Item

type Rarity

type Rarity struct {
	Name           string // Name of this rarity
	Probability    int    // Probability of this rarity (the higher the more rare)
	IndicateRarity bool   // Indicate rarity in item name
}

Rarity represents the rarity of an item.

func (*Rarity) Roll

func (r *Rarity) Roll() bool

Roll returns true if the item should be generated.

type Room

type Room struct {
	Name  string
	Items []*Item
}

Room is a generated room.

func (*Room) Log

func (r *Room) Log()

Log the room.

type RoomConfig

type RoomConfig struct {
	Name     string
	Required []string
	Possible []string
}

RoomConfig represents a room prototype and all the possible variations of items and furniture that can be found in it.

func NewRoomConfig

func NewRoomConfig(name string, required, possible []string) *RoomConfig

NewRoomConfig returns a new room configuration.

func (*RoomConfig) Generate

func (rc *RoomConfig) Generate() *Room

Generate a room from the config.

type Size

type Size string

Size is the size of an item.

const (
	SizeTiny    Size = "tiny"
	SizeSmall   Size = "small"
	SizeMedium  Size = "medium"
	SizeLarge   Size = "large"
	SizeMassive Size = "massive"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL