コード例 #1
0
func quitGame(w http.ResponseWriter, r *http.Request, enemy string) {
	player := GetCookie(r, CLIENT_COOKIE)
	DeleteCookie(w, r, OPPOSITE_COOKIE)
	fmt.Println(enemy)
	model.SetPlayerOpposite(player, "")
	model.SetPlayerOpposite(enemy, "")

	model.SetPlayerStatus(player, FREE)
	model.SetPlayerStatus(enemy, FREE)

	model.SetPlayerField(player, model.CreateNewField())
	model.SetPlayerField(enemy, model.CreateNewField())
	sendMessage(enemy, "EnemyQuit:")

}
コード例 #2
0
func acceptInvitation(names string, colons int, client string, w http.ResponseWriter) {
	enemyName := names[:colons]
	//fmt.Println("enemy="+enemyName)

	model.SetPlayerSide(enemyName, CROSS)
	model.SetPlayerSide(client, ZEROS)

	model.SetPlayerTurn(enemyName, TURN_NOW)
	model.SetPlayerTurn(client, TURN_AFTER)

	model.SetPlayerStatus(client, OCCUPIED)
	model.SetPlayerStatus(enemyName, OCCUPIED)

	field := model.CreateNewField()

	model.SetPlayerField(client, field)
	model.SetPlayerField(enemyName, field)
	model.SetPlayerOpposite(client, enemyName)
	model.SetPlayerOpposite(enemyName, client)

	sendMessage(enemyName, "Confirmed:"+client)
}