package config var Utils = manageController{} type manageController struct { } func (c *manageController) GetEventsByType(config map[int32]*BehaviourType, id int32) (res []int32) { data := map[int32][]int32{} for k, v := range config { if len(data[k]) == 0 { data[k] = []int32{} } data[k] = append(data[k], v.BehaviourEventId1) data[k] = append(data[k], v.BehaviourEventId2) data[k] = append(data[k], v.BehaviourEventId3) data[k] = append(data[k], v.BehaviourEventId4) } return data[id] } func (c *manageController) GetEventWeightsByType(config map[int32]*BehaviourType, id int32) (res []int32) { data := map[int32][]int32{} for k, v := range config { if len(data[k]) == 0 { data[k] = []int32{} } data[k] = append(data[k], v.InjuryProbability) data[k] = append(data[k], v.DistractedProbability) data[k] = append(data[k], v.SpecialItemProbability) data[k] = append(data[k], v.OtherProbability) data[k] = append(data[k], 100-v.InjuryProbability-v.DistractedProbability-v.SpecialItemProbability-v.OtherProbability) } return data[id] } func (c *manageController) GetIdByGroupIdAndIndex(config map[int32]*BehaviourEvent, id int32, index int32) int32 { data := map[int32][]int32{} for _, v := range config { if len(data[v.GroupId]) == 0 { data[v.GroupId] = []int32{} } data[v.GroupId] = append(data[v.GroupId], v.Id) } return data[id][index] } func (c *manageController) GetWeightsByGroupId(config map[int32]*BehaviourEvent, id int32) (res []int32) { data := map[int32][]int32{} for _, v := range config { if len(data[v.GroupId]) == 0 { data[v.GroupId] = []int32{} } data[v.GroupId] = append(data[v.GroupId], v.Weight) } return data[id] } func (c *manageController) Get(config map[int32]*BehaviourEvent, id int32) (res []int32) { data := map[int32][]int32{} for _, v := range config { if len(data[v.GroupId]) == 0 { data[v.GroupId] = []int32{} } data[v.GroupId] = append(data[v.GroupId], v.Weight) } return data[id] }