language: Go (gc-2010-07-14)
date: 195 days 1 hour ago
link:
visibility: public
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
84
85
86
87
88
package main
 
import (
        "fmt"
        "rand"
        "time"
)
 
type Crafter struct {
        MSkill int
        RSkill int
        CSkill int
}
 
func (c *Crafter) Mine() *Ore {
        fmt.Println("Crafter mines...")
        if rand.Intn(100) > 25 {
                fmt.Println("Crafter gets something!")
                r := new(Ore)
                r.Material = "iron"
                r.Quality = rand.Intn(1000)
                fmt.Println("Ore Material:", r.Material)
                fmt.Println("Ore Quality:", r.Quality)
                return r
        }
        fmt.Println("Crafter got nothing!")
        return nil
}
 
func (c *Crafter) Chop() *Resource {
        // for trees
        return nil
}
 
func (c *Crafter) Smelt(o *Ore) *Bar {
        // define smelting
        return nil
}
 
func (c *Crafter) Smith(bars []*Bar) {
        // smithing would go here
        return nil
}
 
type Vein struct {
        Material
        QualityMin int
        QualityMax int
}
 
func (v *Vein) Yield() *Ore {
        // vein giving ore after a successful mine
        return nil
}
 
type Material string
type Quality int
 
type Resource struct {
        Material
        Quality
}
 
type Ore struct {
        Material
        Quality
}
 
type Bar struct {
        Material
        Quality
}
 
type Gem struct {
        Material
        Quality
        Size int
}
 
func main() {
        rand.Seed(time.Nanoseconds())
        fmt.Println("Crafter outline")
        c := &Crafter{200, 200, 200}
        c.Mine()
        c.Mine()
        c.Mine()
}
 
prog.go:21: cannot use rand.Intn(1000) (type int) as type Quality in assignment
prog.go:42: too many arguments to return