-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.go
100 lines (88 loc) · 2.57 KB
/
types.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// Copyright (c) 2024 Michael D Henderson. All rights reserved.
package sb
// Agent is a player or NPC in the game.
// Agents receive "commissions" from the Family for their work.
type Agent struct {
Name string
GoldCoins int
VictoryPoints int
Favors int
}
// Family is a group of NPCs that sponsor the arts and employ the actors.
type Family struct {
Name string
Crest string
Avatar string // an image of the family crest
}
type FAMILY int
const (
FAMILY_NONE FAMILY = iota
FAMILY_COOPER
FAMILY_WALKER
FAMILY_PAYNE
FAMILY_HUGHES
FAMILY_FLETCHER
FAMILY_NASH
)
type Actor struct {
Name string // must be first name followed by last name to make the sort work
Rank int // from 1 through 9
Benefactor FAMILY
Avatar string
Page, Row, Col int
}
// Compare returns the tie-fighter result (-1,0,1) of two actors
// by comparing their ranks. Ties are resolved by comparing the names.
// Results:
//
// -1 --- a has a lower rank than b
// 0 --- a and b are the same actor
// 1 --- a has a higher rank than b
func (a Actor) Compare(b Actor) int {
if a.Rank < b.Rank {
return -1
} else if a.Rank == b.Rank {
if a.Name < b.Name {
return -1
} else if a.Name == b.Name {
return 0
}
}
return 1
}
// Play is a theatrical production. Agents compete to place their actors in a Play.
// Doing so earns them commissions in the form of gold coins, favors, and victory points.
//
// A Play is considered finished when the sum of the ranks of the actors is
// greater than or equal to the theatrical value.
//
// If the play has a Benefactor, the Play is worth an additional 1 Victory Point to the final score.
//
// I believe that the initial PointValue is also the number of favors to assign to the Play.
type Play struct {
Name string
TheatricalValue int
Category Category
PointValue int
Benefactor FAMILY // the Family that sponsored the Play
Favors []FavorToken // randomly assigned to the Play when it is created
Actors []Actor // Actors are assigned to the Play by Agents
Page, Row, Col int
}
type Category int
const (
COMEDY Category = iota
HISTORY
TRAGEDY
)
// IsFinished returns true if the play has accrued enough points to be
// considered finished. The play is considered finished when the sum of
// the ranks of the actors is greater than or equal to the theatrical value.
func (p Play) IsFinished() bool {
accruedValue := 0
for _, actor := range p.Actors {
accruedValue += actor.Rank
}
return accruedValue >= p.TheatricalValue
}
type FavorToken struct{}