46 lines
700 B
Go
46 lines
700 B
Go
package lib
|
|
|
|
import "github.com/sirupsen/logrus"
|
|
|
|
type IRobot interface {
|
|
// 启动机器人
|
|
Start() bool
|
|
// 选择场景
|
|
SelScene(scene *scene)
|
|
// 当前场景
|
|
GetCurrentScene() *scene
|
|
}
|
|
|
|
type myRobot struct {
|
|
scene *scene
|
|
}
|
|
|
|
func NewRobot() *myRobot {
|
|
robot := &myRobot{}
|
|
|
|
return robot
|
|
}
|
|
|
|
func (m *myRobot) SelScene(scene *scene) {
|
|
m.scene = scene
|
|
}
|
|
|
|
func (m *myRobot) GetCurrentScene() *scene {
|
|
return m.scene
|
|
}
|
|
|
|
func (m *myRobot) Start() bool {
|
|
if m.scene == nil {
|
|
logrus.Warn("选择一个测试场景")
|
|
return false
|
|
}
|
|
|
|
if len(m.scene.CallerList()) == 0 {
|
|
logrus.Warn("还没有给场景添加调用器")
|
|
return false
|
|
}
|
|
|
|
logrus.Debug("机器人运行了")
|
|
return true
|
|
}
|