-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpve_adventure.go
83 lines (72 loc) · 1.95 KB
/
pve_adventure.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package main
import (
"fmt"
"github.com/daviddengcn/go-colortext"
"math/rand"
)
const (
ADVENTURE_TYPE_ENCOUNTER AdventureType = 1
ADVENTURE_TYPE_WANDER AdventureType = 2
ADVENTURE_TYPE_DISCOVERY AdventureType = 3
)
type (
AdventureType int
Adventure struct {
Type AdventureType
*HeroSheet
}
)
func NewAdventure(h *HeroSheet) *Adventure {
return &Adventure{
Type: generateAdventure(),
HeroSheet: h,
}
}
func generateAdventure() AdventureType {
return AdventureType(random(1, 3))
}
func generateEnemy() string {
names := []string{
"Snorlax",
"Bear",
"Goblin",
"Hill Giant",
"Shark out of water",
}
return names[rand.Intn(len(names))]
}
func generateNothing() string {
messages := []string{
"You wandered around a bit, got bored, and went home.",
"You forgot to go to the bathroom before you left, and went home.",
"You got turned around somewhere and ended up at home.",
"You wandered around, saw a stump, a leaf, and a caterpillar, then went home.",
"You had an anticlimactic experience and wound up back at home with a cup of tea.",
}
return messages[rand.Intn(len(messages))]
}
func (a *Adventure) Embark(pve *PveFight) {
ct.ChangeColor(ct.Magenta, true, ct.None, false)
switch a.Type {
case ADVENTURE_TYPE_DISCOVERY:
fmt.Println("You didn't discover anything, too bad.")
case ADVENTURE_TYPE_ENCOUNTER:
enemyName := generateEnemy()
fmt.Printf("A wild %s appeared.\n", enemyName)
enemey := NewEnemy(a.HeroSheet, enemyName)
if enemey.Life > a.HeroSheet.BaseStats.Life {
fmt.Println(" It's a tough one!")
}
if enemey.Power > a.HeroSheet.BaseStats.Power {
fmt.Println(" It hits pretty hard...")
}
if enemey.Speed > a.HeroSheet.BaseStats.Speed {
fmt.Printf(" Faster than your average %s.\n", enemyName)
}
fmt.Printf("%s attacks you! Check 'log' to see the result.\n", enemyName)
pve.Fight(a.HeroSheet, enemey)
case ADVENTURE_TYPE_WANDER:
fmt.Println(generateNothing())
}
ct.ResetColor()
}