package test

import (
	"testing"

	"google.golang.org/protobuf/proto"

	"server/game"
	"server/msg"
)

func TestCatnipBackData(t *testing.T) {
	p1 := new(game.Player)
	p1.InitPlayer("aaa001")
	game.G_GameLogicPtr.SetPlayer(p1)
	p1.CatnipBackData()
}

func TestReqCatnipEmoji(t *testing.T) {
	p1 := new(game.Player)
	p1.InitPlayer("aaa001")
	game.G_GameLogicPtr.SetPlayer(p1)

	req := &msg.ReqCatnipEmoji{
		Id:      1,
		EmojiId: 1,
	}
	data, err := proto.Marshal(req)
	if err != nil {
		t.Fatalf("proto.Marshal error: %v", err)
	}

	if err := game.ReqCatnipEmoji(p1, data); err != nil {
		t.Fatalf("ReqCatnipEmoji returned error: %v", err)
	}
}

func TestReqCatnipReward(t *testing.T) {
	p1 := new(game.Player)
	p1.InitPlayer("aaa001")
	game.G_GameLogicPtr.SetPlayer(p1)
	req := &msg.ReqCatnipReward{
		Id: 2,
	}
	data, err := proto.Marshal(req)
	if err != nil {
		t.Fatalf("proto.Marshal error: %v", err)
	}
	if err := game.ReqCatnipReward(p1, data); err != nil {
		t.Fatalf("ReqCatnipReward returned error: %v", err)
	}
}
