GmAction.go
771 Bytes
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
package action
import (
"pro2d/common/logger"
"pro2d/models"
"pro2d/pb"
"strconv"
)
type GmAction struct {
}
func (gm *GmAction) AddExp(role *models.RoleModel, properties map[string]interface{}) int {
logger.Debug(properties)
exp, _ := strconv.Atoi(properties["exp"].(string))
role.IncrPropertyChan("exp", int64(exp), true)
return 0
}
func (gm *GmAction) AddEquip(role *models.RoleModel, properties map[string]interface{}) int {
logger.Debug(properties)
equip := &pb.Equipment{
Id: role.IncreEquipByKey(1),
RoleId: role.Role.Id,
Type: properties["id"].(string),
}
//TODO 验证装备是否存在
if role.GetConn() != nil {
role.GetConn().CustomChan() <- func() {
role.AddEquip(equip)
}
} else {
role.AddEquip(equip)
}
return 0
}