-
Notifications
You must be signed in to change notification settings - Fork 0
/
role_factory.go
56 lines (49 loc) · 1.13 KB
/
role_factory.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
package roles
import (
"fmt"
"github.com/GSamuel/werewolves-of-millers-hollow/game"
)
const (
UNDEFINED = "Undefined"
VILLAGER = "Villager"
WEREWOLF = "Werewolf"
HUNTER = "Hunter"
HEALER = "Healer"
VILLAGE_ELDER = "Village Elder"
WITCH = "Witch"
CUPID = "Cupid"
SEER = "Seer"
SLUT = "Slut"
)
type RoleFactory struct {
}
func (r RoleFactory) New(role string, id int) (game.Role, error) {
base := &BaseRole{NewState(id)}
var result game.Role
switch role {
case WEREWOLF:
result = &Werewolf{base}
result.SetAlliance(game.ALLIANCE_EVIL)
return result, nil
case VILLAGER:
return &Villager{base}, nil
case HUNTER:
return &Hunter{base}, nil
case HEALER:
return &Healer{base, -1, -1}, nil
case VILLAGE_ELDER:
return &VillageElder{base, true}, nil
case WITCH:
return &Witch{base, true, true}, nil
case CUPID:
return &Cupid{base, -1, -1}, nil
case SEER:
return &Seer{base}, nil
case SLUT:
return &Slut{base, -1}, nil
}
return nil, fmt.Errorf("Role %v does not exist in role factory", role)
}
func NewFactory() RoleFactory {
return RoleFactory{}
}