parent
3d58303936
commit
3871273730
11 changed files with 196 additions and 32 deletions
@ -0,0 +1,12 @@ |
||||
FROM golang:1.16.2-alpine AS builder |
||||
RUN apk update |
||||
WORKDIR /app |
||||
COPY . /app |
||||
RUN GOOS=linux go build -o kartograph cmd/kartograph-map-generator/main.go |
||||
|
||||
FROM alpine:latest |
||||
RUN apk update |
||||
WORKDIR /app |
||||
COPY --from=builder /app/kartograph /app/ |
||||
EXPOSE 80 |
||||
ENTRYPOINT ["/app/kartograph"] |
@ -0,0 +1,34 @@ |
||||
# Der Kartograph Map Generator |
||||
|
||||
Generate your own maps for "Der Kartograph" easily. |
||||
|
||||
## Build |
||||
|
||||
You need to build the source first. The simplest way is to use the |
||||
provided Dockerfile, which will build the software and create a |
||||
convenient image (This is a multi stage Dockerfile, so the resulting |
||||
image is a small Alpine Linux image with ust the map generator binary.) |
||||
|
||||
$ docker build -t kartograph . |
||||
|
||||
## Run |
||||
|
||||
See all available options: |
||||
|
||||
$ docker run -it kartograph -help |
||||
|
||||
Spawn a webserver: |
||||
|
||||
$ docker run -it kartograph -web |
||||
|
||||
Generate a map with the seed "hey jim" and output it as a SVG image: |
||||
|
||||
$ docker run -it kartograph -output=svg -seed='hey jim' > map.svg |
||||
|
||||
You want an epic game? Lets generate a big map with a lot of wasteland |
||||
and ruins: |
||||
|
||||
$ docker run -it kartograph -seed=aaron \ |
||||
-size=20 -wastelands=100 -ruins=10 \ |
||||
-output=svg > map.svg |
||||
|
@ -1,7 +0,0 @@ |
||||
package generator |
||||
|
||||
import () |
||||
|
||||
func (w World) PDF() { |
||||
|
||||
} |
@ -0,0 +1,51 @@ |
||||
document.addEventListener('DOMContentLoaded', function() { |
||||
let generate = function(seed) { |
||||
let size = document.querySelector('input[name="size"]').value |
||||
let wastelands = document.querySelector('input[name="wastelands"]').value |
||||
let mountains = document.querySelector('input[name="mountains"]').value |
||||
let ruins = document.querySelector('input[name="ruins"]').value |
||||
|
||||
let map = document.querySelector('.map') |
||||
// Generate new random seed
|
||||
let newMapUrl = '/map.svg?seed=' + seed + |
||||
'&s=' + size + |
||||
'&w=' + wastelands + |
||||
'&m=' + mountains + |
||||
'&r=' + ruins |
||||
document.querySelector('.map').setAttribute('src', newMapUrl); |
||||
document.querySelector('#map-link').setAttribute('href', newMapUrl); |
||||
}; |
||||
|
||||
let buttons = document.querySelectorAll('input[type="button"]') |
||||
Array.prototype.forEach.call(buttons, function(button, i) { |
||||
button.addEventListener('click', function(e) { |
||||
// Reset to default buttons
|
||||
if (e.target.hasAttribute('data-default')) { |
||||
let defaultValue = e.target.getAttribute('data-default'); |
||||
let name = e.target.getAttribute('name').substr(8); |
||||
let targetInput = document.querySelector('input[type="text"][name="'+name+'"]') |
||||
targetInput.value = defaultValue; |
||||
} |
||||
|
||||
// Roll the dice
|
||||
if (e.target.getAttribute('name') === 'random-seed') { |
||||
let chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; |
||||
let seed = ''; |
||||
for (let i=0; i<10; i++) { |
||||
let index = Math.floor(Math.random() * 25) |
||||
seed += chars[index] |
||||
} |
||||
|
||||
let seedElement = document.querySelector('input[name="seed"]'); |
||||
seedElement.value = seed; |
||||
generate(seed); |
||||
} |
||||
|
||||
// Refresh
|
||||
if (e.target.getAttribute('name') === 'refresh') { |
||||
let seed = document.querySelector('input[name="seed"]').value; |
||||
generate(seed); |
||||
} |
||||
}) |
||||
}); |
||||
}); |
Before Width: | Height: | Size: 99 KiB After Width: | Height: | Size: 31 KiB |
@ -1,10 +1,38 @@ |
||||
body { |
||||
width: 900px; |
||||
margin: auto; |
||||
} |
||||
|
||||
h1 { |
||||
text-align: center; |
||||
} |
||||
|
||||
p > img { |
||||
float: left; |
||||
width: 100px; |
||||
margin: 10px; |
||||
} |
||||
|
||||
.map { |
||||
float: right; |
||||
width: 450px; |
||||
margin: 20px; |
||||
} |
||||
|
||||
label { |
||||
width: 100px; |
||||
display: inline-block; |
||||
text-align: right; |
||||
} |
||||
|
||||
input[type="text"] { |
||||
width: 90px; |
||||
} |
||||
input[name="seed"] { |
||||
width: 250px; |
||||
} |
||||
|
||||
.map { |
||||
margin: auto; |
||||
display: block; |
||||
width: 350px; |
||||
fieldset { |
||||
width: 370px; |
||||
margin: 10px 0; |
||||
} |
||||
|
Loading…
Reference in new issue