소스 검색

fix gameid ophalen board

Harry de Boer 10 년 전
부모
커밋
5bbc2338cb
2개의 변경된 파일4개의 추가작업 그리고 5개의 파일을 삭제
  1. 1 2
      battlecamp-go-gameserver/gameserver/urlrouter.go
  2. 3 3
      board/board.go

+ 1 - 2
battlecamp-go-gameserver/gameserver/urlrouter.go

@@ -137,11 +137,10 @@ func showBoard(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
 	widthString := req.FormValue("cols")
 	heightString := req.FormValue("rows")
 
-	id, _ := strconv.ParseInt(ps.ByName("boardid"), 10, 64)
+	id, _ := strconv.ParseInt(ps.ByName("gameid"), 10, 64)
 	b := gameServer.GetGame(id).Board
 
 	if xString != "" && yString != "" && widthString != "" && heightString != "" {
-		log.Printf("showboard x %v y %v width %v height %v", )
 		x, _ := strconv.Atoi(xString)
 		y, _ := strconv.Atoi(yString)
 		width, _ := strconv.Atoi(widthString)

+ 3 - 3
board/board.go

@@ -41,7 +41,7 @@ func New(width, height int) *Board {
 }
 
 func NewRegion(startX, startY, width, height, totalWidth, totalHeight int) *Board {
-	r := rand.New(rand.NewSource(time.Now().UnixNano() + int64(startY*startY)))
+	r := rand.New(rand.NewSource(time.Now().UnixNano() + int64(startX*startY)))
 	return newRegion(startX, startY, width, height, totalWidth, totalHeight, r)
 }
 
@@ -215,7 +215,7 @@ func ReadJSON(ofsetX, ofsetY int, reader io.Reader) *Board {
 	jsonBoard := new(boardJSON)
 	json.Unmarshal(b, &jsonBoard)
 	board := newBlank(jsonBoard.Width, jsonBoard.Height)
-	
+
 	for _, t := range jsonBoard.Tiles {
 		board.Set(t.X-ofsetX, t.Y-ofsetY, FromName(t.Type))
 	}
@@ -268,7 +268,7 @@ func newRegion(startX, startY, width, height, totalWidth, totalHeight int, r *ra
 	leftLimit := (totalWidth-maxIceWidth)/2 - startX
 	rightLimit := totalWidth/2 + maxIceWidth/2 - startX
 	mid := totalWidth/2 - startX
-	
+
 	log.Printf("Creating new region width %v height %v", width, height)
 	for y := 0; y < height; y++ {
 		for x := 0; x < width; x++ {