2020-04-21 17:50:21 +03:00
|
|
|
|
package visitor
|
|
|
|
|
|
2020-05-04 11:12:01 +03:00
|
|
|
|
import "testing"
|
|
|
|
|
|
2020-05-04 18:05:00 +03:00
|
|
|
|
func TestSingleVisitor(t *testing.T) {
|
2020-05-04 11:12:01 +03:00
|
|
|
|
|
|
|
|
|
//汽油提供给,制衣工厂
|
|
|
|
|
g := gas{density: 100}
|
|
|
|
|
|
|
|
|
|
//柴油,提供给军工厂
|
|
|
|
|
d := diesel{energy: 897}
|
|
|
|
|
|
|
|
|
|
//购买石油的客户
|
|
|
|
|
m := &militaryFactory{}
|
|
|
|
|
|
|
|
|
|
c := &clothFactory{}
|
|
|
|
|
|
|
|
|
|
g.Accept(c)
|
|
|
|
|
|
|
|
|
|
d.Accept(m)
|
|
|
|
|
|
2020-04-21 17:50:21 +03:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-04 11:41:42 +03:00
|
|
|
|
func TestGameVisitorsList(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
retriveSetting := SettingVisitor{}
|
|
|
|
|
attacker := Attacker{}
|
|
|
|
|
|
|
|
|
|
pA := Player{"snow dance", 100} //角色名名:snow dance 100级
|
|
|
|
|
pB := Player{"fire dragon", 120}
|
|
|
|
|
npc := NPC{"groceries", true} //卖杂货的NPC,是能被打死的
|
|
|
|
|
env := SystemEnv{"made by china", "v1.2.11"}
|
|
|
|
|
|
|
|
|
|
//游戏对象
|
2020-05-04 18:05:00 +03:00
|
|
|
|
gameObjects := []IGameObject{pA, npc, env, pB}
|
2020-05-04 11:41:42 +03:00
|
|
|
|
|
|
|
|
|
for _, v := range gameObjects {
|
|
|
|
|
v.Accept(retriveSetting)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
t.Log("\n---- !!!attack!!!- --")
|
|
|
|
|
|
|
|
|
|
for _, v := range gameObjects {
|
|
|
|
|
v.Accept(attacker)
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-21 17:50:21 +03:00
|
|
|
|
}
|