summaryrefslogtreecommitdiff
path: root/newguy.go
blob: cb6d0e4f475090253fd5fb8aa18e27151d49bd32 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package main

import (
	"math/rand"
	"time"

	"dim13.org/pq/internal/character"
)

func init() {
	rand.Seed(time.Now().UnixNano())
}

func Roll() int {
	return 3 + rand.Intn(6) + rand.Intn(6) + rand.Intn(6)
}

type Guy struct {
	Name, Race, Klass string
	Level             int
	Attr              map[character.Attr]int
	Inventory         map[string]int
	queue             chan Queue
	Spells            []string
}

func NewGuy() *Guy {
	r := character.Races.Pick()
	k := character.Klasses.Pick()
	g := Guy{
		Name:      character.NewName(),
		Race:      r.Name,
		Klass:     k.Name,
		Level:     1,
		Attr:      make(map[character.Attr]int),
		Inventory: make(map[string]int),
		queue:     make(chan Queue, 10),
	}
	for i := character.Attr(0); i < character.Nattr; i++ {
		g.Attr[i] = Roll()
	}
	for _, v := range r.Attr {
		g.Attr[v] += 1
	}
	for _, v := range k.Attr {
		g.Attr[v] += 1
	}
	g.Inventory["Gold"] = 0
	g.queue <- Queue{Task, 10, "Experiencing an enigmatic and foreboding night vision"}
	g.queue <- Queue{Task, 6, "Much is revealed about that wise old bastard you'd underestimated"}
	g.queue <- Queue{Task, 6, "A shocking series of events leaves you alone and bewildered, but resolute"}
	g.queue <- Queue{Task, 4, "Drawing upon an unrealized reserve of determination, you set out on a long and dangerous journey"}
	g.queue <- Queue{Plot, 2, "Loading"}

	// DEBUG
	close(g.queue)

	return &g
}