ignore new binary
Create new bserv binary Herein lie the following ideas: - change package visibility of many things - try to stash the globals into structs - the code is far from correct; it merely compiles
This commit is contained in:
+11
-11
@@ -1,4 +1,4 @@
|
||||
package main
|
||||
package botserv
|
||||
|
||||
import (
|
||||
"log"
|
||||
@@ -143,7 +143,7 @@ func NewFailure(reason string) *Failure {
|
||||
}
|
||||
}
|
||||
|
||||
func addPlayer(ws *websocket.Conn) {
|
||||
func (c *Controller) AddPlayer(ws *websocket.Conn) {
|
||||
var gid GameID
|
||||
err := websocket.JSON.Receive(ws, &gid)
|
||||
if err != nil {
|
||||
@@ -151,16 +151,16 @@ func addPlayer(ws *websocket.Conn) {
|
||||
return
|
||||
}
|
||||
|
||||
game := games.get(gid.Id)
|
||||
game := c.Games.get(gid.Id)
|
||||
if game == nil {
|
||||
var err error
|
||||
game, err = NewGame(
|
||||
gid.Id,
|
||||
float32(conf.Width),
|
||||
float32(conf.Height),
|
||||
conf.Obstacles,
|
||||
conf.Tick,
|
||||
conf.MaxPoints,
|
||||
float32(c.Conf.Width),
|
||||
float32(c.Conf.Height),
|
||||
c.Conf.Obstacles,
|
||||
c.Conf.Tick,
|
||||
c.Conf.MaxPoints,
|
||||
"",
|
||||
)
|
||||
if err != nil {
|
||||
@@ -169,10 +169,10 @@ func addPlayer(ws *websocket.Conn) {
|
||||
return
|
||||
}
|
||||
go game.run()
|
||||
games.add(game)
|
||||
c.Games.add(game)
|
||||
}
|
||||
|
||||
player_id := idg.Hash()
|
||||
player_id := c.Idg.Hash()
|
||||
err = websocket.JSON.Send(ws, NewPlayerID(player_id))
|
||||
if err != nil {
|
||||
log.Printf("game %s: unable to send player_id to player %s", gid.Id, player_id)
|
||||
@@ -284,7 +284,7 @@ encodingLoops:
|
||||
convertedStats[name] = dstat
|
||||
r := Robot{
|
||||
Stats: dstat,
|
||||
Id: idg.Hash(),
|
||||
Id: c.Idg.Hash(),
|
||||
Name: name,
|
||||
Health: 10,
|
||||
Heading: v.Vector2d{1, 0},
|
||||
|
||||
Reference in New Issue
Block a user