Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/baret/colsurtechtree

A Techtree DSL and visualization for Colony Survival
https://github.com/baret/colsurtechtree

kotlin

Last synced: about 1 month ago
JSON representation

A Techtree DSL and visualization for Colony Survival

Awesome Lists containing this project

README

        

# DSL to define techtree and production lines

This project is written in Kotlin. This offers the possibility to create a simple DSL that describes production dependencies of the game Colony Survival.

**Example:**
```
job("Berry Farmer") {
worksIn("Berryfarm") {
produces("Berry Seed")
produces("Berries") {
needs("Berry Seed")
}
}
}

job("Forester") {
worksIn("Forest") {
produces(2, "Log") {
needs("Sapling")
}
produces("Sapling")
}
}

science("Bread Production") {
unlocksJobs("Farmer", "Miller", "Baker")
}
```

This snippet creates *buildings*, *jobs*, *products* and *science*. These are all entities saved in a singleton *techtree* object. It can be written to the console via `println(Techtree)`. The output would be:

```
Full techtree:
Jobs (5):
Job Baker (assignable buildings: [])
Job Berry Farmer (assignable buildings: [Building Berryfarm produces [1 Berry Seed, 1 Berries (needs [1 Berry Seed])]])
Job Farmer (assignable buildings: [])
Job Forester (assignable buildings: [Building Forest produces [2 Log (needs [1 Sapling]), 1 Sapling]])
Job Miller (assignable buildings: [])
Buildings (2):
Building Berryfarm produces [1 Berry Seed, 1 Berries (needs [1 Berry Seed])]
Building Forest produces [2 Log (needs [1 Sapling]), 1 Sapling]
Products (4):
Product Berries
Product Berry Seed
Product Log
Product Sapling
Science (1):
Science Bread Production requires nothing, unlocks [Job Farmer (assignable buildings: []), Job Miller (assignable buildings: []), Job Baker (assignable buildings: [])]
```

# Visualization of the tree (coming soon)

After defining production lines and dependencies between jobs and products (the full techtree the game currently has or just a portion of that) you can display an interactive diagram of this tree to see for example how many colonists you need to produce a specific item or how much you will need to produce to unlock a science.