93 lines
1.7 KiB
Go
93 lines
1.7 KiB
Go
package test
|
|
|
|
import (
|
|
"fmt"
|
|
fur_cfg "server/conf/fur"
|
|
"server/game"
|
|
"server/msg"
|
|
"testing"
|
|
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
func TestGetFurShopCost(t *testing.T) {
|
|
cost := fur_cfg.GetFurShopCost(1)
|
|
fmt.Printf("cost: %v", cost)
|
|
}
|
|
|
|
func TestGetFurShopFreeTimes(t *testing.T) {
|
|
freeTimes := fur_cfg.GetFurShopFreeTimes()
|
|
fmt.Printf("freeTimes: %d", freeTimes)
|
|
}
|
|
|
|
func TestGetFurShopTag(t *testing.T) {
|
|
tag := fur_cfg.GetFurShopTag(1)
|
|
fmt.Printf("tag: %d", tag)
|
|
}
|
|
|
|
func TestReqPetFur(t *testing.T) {
|
|
player := new(game.Player)
|
|
err := game.ReqPetFur(player, nil)
|
|
if err != nil {
|
|
t.Errorf("ReqPetFur error: %v", err)
|
|
}
|
|
}
|
|
|
|
func TestReqPetFurBuy(t *testing.T) {
|
|
player := new(game.Player)
|
|
player.InitPlayerByUid(100001)
|
|
m := msg.ReqPetFurBuy{
|
|
FurId: 1,
|
|
}
|
|
buf, err := proto.Marshal(&m)
|
|
if err != nil {
|
|
t.Errorf("marshal error: %v", err)
|
|
}
|
|
err = game.ReqPetFurBuy(player, buf)
|
|
if err != nil {
|
|
t.Errorf("ReqPetFurBuy error: %v", err)
|
|
}
|
|
|
|
m = msg.ReqPetFurBuy{
|
|
FurId: 2,
|
|
}
|
|
buf, err = proto.Marshal(&m)
|
|
if err != nil {
|
|
t.Errorf("marshal error: %v", err)
|
|
}
|
|
err = game.ReqPetFurBuy(player, buf)
|
|
if err != nil {
|
|
t.Errorf("ReqPetFurBuy error: %v", err)
|
|
}
|
|
}
|
|
|
|
func TestReqFurSet(t *testing.T) {
|
|
player := new(game.Player)
|
|
player.InitPlayerByUid(100001)
|
|
m := msg.ReqFurSet{
|
|
FurId: 1,
|
|
}
|
|
buf, err := proto.Marshal(&m)
|
|
if err != nil {
|
|
t.Errorf("marshal error: %v", err)
|
|
}
|
|
FurMod := player.GetFurMod()
|
|
FurMod.AddFurInfo(1, 0, 0)
|
|
err = game.ReqFurSet(player, buf)
|
|
if err != nil {
|
|
t.Errorf("ReqFurSet error: %v", err)
|
|
}
|
|
|
|
m = msg.ReqFurSet{
|
|
FurId: 0,
|
|
}
|
|
buf, err = proto.Marshal(&m)
|
|
if err != nil {
|
|
t.Errorf("marshal error: %v", err)
|
|
}
|
|
err = game.ReqFurSet(player, buf)
|
|
if err != nil {
|
|
t.Errorf("ReqFurSet error: %v", err)
|
|
}
|
|
}
|