66 lines
1.4 KiB
Go
66 lines
1.4 KiB
Go
package test
|
|
|
|
import (
|
|
"fmt"
|
|
friendTreasureCfg "server/conf/friend_treasure"
|
|
"server/game"
|
|
GoUtil "server/game_util"
|
|
"server/msg"
|
|
"testing"
|
|
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
func TestFriendInit(t *testing.T) {
|
|
p1 := new(game.Player)
|
|
p1.InitPlayer("3625212")
|
|
FriendMod := p1.GetFriendMod()
|
|
if FriendMod == nil {
|
|
t.Error("FriendMod init failed")
|
|
}
|
|
}
|
|
|
|
func TestFriendApply(t *testing.T) {
|
|
p1 := new(game.Player)
|
|
p1.InitPlayer("3625212")
|
|
FriendMod := p1.GetFriendMod()
|
|
FriendMod.AddFriendApply(100002, 0, 1698000000)
|
|
if !FriendMod.CheckApply(100002) {
|
|
t.Error("FriendMod AddFriendApply failed")
|
|
}
|
|
}
|
|
|
|
func TestFriendRecommendList(t *testing.T) {
|
|
p1 := new(game.Player)
|
|
p1.InitPlayer("3625212")
|
|
l1 := game.GetRecommendPlayer(p1, 3)
|
|
fmt.Printf("Recommend List: %v\n", l1)
|
|
}
|
|
|
|
func TestReqApplyFriend(t *testing.T) {
|
|
p1 := new(game.Player)
|
|
p1.InitPlayer("3625212")
|
|
req := &msg.ReqApplyFriend{
|
|
Uid: 100002,
|
|
Type: 0,
|
|
}
|
|
buf, _ := proto.Marshal(req)
|
|
game.ReqApplyFriend(p1, buf)
|
|
p1.FriendListBackData()
|
|
}
|
|
|
|
func TestFriendBackData(t *testing.T) {
|
|
p1 := new(game.Player)
|
|
p1.InitPlayerByUid(100001)
|
|
p1.M_DwUin = 100100129
|
|
p1.FriendLogBackData()
|
|
p1.FriendCardBackData()
|
|
}
|
|
|
|
func TestFriendTreasureInit(t *testing.T) {
|
|
probMap := friendTreasureCfg.GetChestProb()
|
|
prob := GoUtil.RandMap(probMap)
|
|
items := friendTreasureCfg.GetChestItems(prob)
|
|
fmt.Printf("Prob: %v, Items: %v\n", prob, items)
|
|
}
|