func TestJoinGame(t *testing.T) {
	manager := game.GetPlayerManagerInstance()
	manager.RemoveAllPlayer()

	players := joinGame("linwei", "gameId")
	testUtil.AssertEqual(1, manager.GetPlayerCount(), "TestJoinGame", t)
	testUtil.AssertEqual(1, len(players), "TestJoinGame", t)
	testUtil.AssertEqual("linwei", players[0].GetName(), "TestJoinGame", t)
}
func Talk2Others(resp http.ResponseWriter, req *http.Request) {
	game.CurrentContext = appengine.NewContext(req)
	userName := req.FormValue("userName")
	msg := req.FormValue("message")

	player := game.GetPlayerManagerInstance().GetPlayer(userName)
	if player != nil {
		player.Talk2OthersInGame(msg)
	}
}
func joinGame(name string, gameId string) []*game.Player {
	player := game.NewPlayer(name, 0, 0)
	gameManager := game.GetGameManagerInstance()
	iGameId, _ := strconv.Atoi(gameId)
	game.GetPlayerManagerInstance().AddPlayer(player)

	gameIn := gameManager.GetGame(iGameId)

	if gameIn != nil {
		gameIn.Join(player)
		return gameIn.GetAllPlayer()
	} else {
		game.Infof("joinGame not found game: %d", name, gameManager.GetGameCount())
		// 返回自己
		return []*game.Player{player}
	}
}
func TestGetAllPlayer(t *testing.T) {
	playerManager := game.GetPlayerManagerInstance()
	playerManager.RemoveAllPlayer()

	player := game.NewPlayer("na1", 0, 0)
	playerManager.AddPlayer(player)

	jsonContent := getAllPlayer()
	testUtil.AssertEqual("[{\"Name\":\"na1\",\"PosX\":0,\"PosY\":0}]", jsonContent, "TestGetJson", t)

	player2 := game.NewPlayer("na2", 2, 2)
	playerManager.AddPlayer(player2)

	jsonContent = getAllPlayer()
	testUtil.AssertEqual("[{\"Name\":\"na1\",\"PosX\":0,\"PosY\":0},{\"Name\":\"na2\",\"PosX\":2,\"PosY\":2}]", jsonContent, "TestGetJson", t)

}
func getAllPlayer() string {
	return getJsonContent(game.GetPlayerManagerInstance().GetAllPlayer())
}