-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
65 lines (51 loc) · 2.17 KB
/
main.go
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
60
61
62
63
64
65
package main
import (
"github.com/jasdel/explore/entity"
"github.com/jasdel/explore/entity/player"
"github.com/jasdel/explore/region"
"github.com/jasdel/explore/util/uid"
// "github.com/pkg/profile"
"github.com/jasdel/explore/entity/npc"
)
//
// TODO add signal handling for os.Interrupt, os.Kill
// TODO clean shutdown, right now done ch just kills
// oll the goroutines, need to wait for them to empty
// and shutdown command processing.
//
func main() {
// defer profile.Start().Stop()
doneCh := make(chan struct{})
r1 := region.NewRegion("r1")
go r1.Run(doneCh)
r2 := region.NewRegion("r2")
go r2.Run(doneCh)
start := entity.NewLocation(<-uid.Next, "City Center", "Central location with in the city", r1.CmdCh, r1.MoveCh)
r1.AddLoc(start)
south := entity.NewLocation(<-uid.Next, "Southern plains", "Plains as far as the eyes can see.", r2.CmdCh, r2.MoveCh)
r2.AddLoc(south)
east := entity.NewLocation(<-uid.Next, "Market District", "Busy street full of merchants selling their goods.", r1.CmdCh, r1.MoveCh)
r1.AddLoc(east)
start.LinkExit(entity.Exit{Name: "south", Aliases: []string{"south", "s"}, Loc: south,
ExitMsg: entity.DirectionalExitMsgFmt, EnterMsg: entity.DirectionalEnterMsgFmt,
})
south.LinkExit(entity.Exit{Name: "north", Aliases: []string{"north", "n"}, Loc: start,
ExitMsg: entity.DirectionalExitMsgFmt, EnterMsg: entity.DirectionalEnterMsgFmt,
})
start.LinkExit(entity.Exit{Name: "east", Aliases: []string{"east", "e"}, Loc: east,
ExitMsg: entity.DirectionalExitMsgFmt, EnterMsg: entity.DirectionalEnterMsgFmt,
})
east.LinkExit(entity.Exit{Name: "west", Aliases: []string{"west", "w"}, Loc: start,
ExitMsg: entity.DirectionalExitMsgFmt, EnterMsg: entity.DirectionalEnterMsgFmt,
})
rnd := &npc.RndNPC{NPC: npc.NewNPC(<-uid.Next, "Billy Bob Thorton", "A mysterious wonderer.")}
p := &player.StdInPlayer{Player: player.NewPlayer(<-uid.Next, "You", "its you silly")}
p.Add(entity.NewItem(<-uid.Next, "Spoon", "a old four foot long wooden spoon", []string{"spoon"}))
act := entity.NewActor(<-uid.Next, "Place Holder Actor", "Place holder actor", []string{"actor"})
start.Spawn(rnd)
start.Spawn(p)
start.Spawn(act)
go p.Run()
go rnd.Run()
<-doneCh
}