feat(Go-Tool):

2020/12/31:新增项目案例(角色技能树)
               2020/12/31: 修改diliver包结构
This commit is contained in:
Huangzj
2020-12-31 14:25:25 +08:00
parent 84b5787dd8
commit f3c056f84e
23 changed files with 738 additions and 9 deletions
@@ -0,0 +1,106 @@
/*
* @Author : huangzj
* @Time : 2020/12/29 16:59
* @Description
*/
package SkillTopology
import (
"Go-Tool/ProgressTest/SkillTopology/model"
"fmt"
"testing"
)
//正确的输出应该是:
//SkillId:1,Parent:[],Children:[2 3 4]
//SkillId:2,Parent:[1],Children:[8]
//SkillId:3,Parent:[1],Children:[5 6]
//SkillId:4,Parent:[1],Children:[10 11]
//SkillId:5,Parent:[3],Children:[7]
//SkillId:6,Parent:[3],Children:[7]
//SkillId:10,Parent:[4],Children:[12]
//SkillId:11,Parent:[4],Children:[12]
//SkillId:8,Parent:[2],Children:[9]
//SkillId:9,Parent:[8],Children:[]
//SkillId:12,Parent:[10 11],Children:[]
//SkillId:7,Parent:[5 6],Children:[]
func TestGetTopologyHeadMap(t *testing.T) {
worker := NewSkilledWorker()
skill1 := SimulationSkills(worker)
//拓扑父关系
skill1 = BackSteppingHeadWithChildren(skill1)
for _, skill := range GetTopologyHeadMap(skill1) {
var pId []int
for _, p := range skill.Parent {
pId = append(pId, p.SkillId)
}
var cId []int
for _, c := range skill.Children {
cId = append(cId, c.SkillId)
}
fmt.Println(fmt.Sprintf("SkillId:%v,Parent:%v,Children:%v", skill.SkillId, pId, cId))
}
}
//正确的输出应该是:
//SkillId:1,Parent:[]
//SkillId:2,Parent:[1]
//SkillId:3,Parent:[1]
//SkillId:4,Parent:[1]
//SkillId:5,Parent:[3]
//SkillId:6,Parent:[3]
//SkillId:11,Parent:[4]
//SkillId:10,Parent:[4]
//SkillId:8,Parent:[2]
//SkillId:9,Parent:[8]
//SkillId:7,Parent:[5 6]
//SkillId:12,Parent:[10 11]
func TestBackSteppingHeadWithChildren(t *testing.T) {
worker := NewSkilledWorker()
skill1 := SimulationSkills(worker)
//拓扑父关系
skill1 = BackSteppingHeadWithChildren(skill1)
for _, skill := range GetTopologyHeadMap(skill1) {
var pId []int
for _, p := range skill.Parent {
pId = append(pId, p.SkillId)
}
fmt.Println(fmt.Sprintf("SkillId:%v,Parent:%v", skill.SkillId, pId))
}
}
//正确的输出为:
//
//我是技能11
//父节点Id为4,对应的Update的子节点的Id为:11,Level为:4
//子节点Id为12,对应的Update的父节点的Id为:11,Level为:4
func TestSkillUpdate(t *testing.T) {
topology := GetCounsellorSkillByDb(NewSkilledWorker(), model.CounsellorId)
SkillUpdate(topology, 11)
for _, skill := range GetTopologyHeadMap(topology.HeadSkillNode) {
for _, child := range skill.Children {
if child.SkillId == 11 {
fmt.Println(fmt.Sprintf("父节点Id为%v,对应的Update的子节点的Id为:%v,Level为:%v", skill.SkillId, child.SkillId, child.Level))
}
}
for _, p := range skill.Parent {
if p.SkillId == 11 {
fmt.Println(fmt.Sprintf("子节点Id为%v,对应的Update的父节点的Id为:%v,Level为:%v", skill.SkillId, p.SkillId, p.Level))
}
}
}
}