remove game from player struct

This commit is contained in:
sm
2013-09-04 00:08:43 -07:00
parent 64477f5e47
commit 3e805d3da7
3 changed files with 10 additions and 7 deletions
+7 -5
View File
@@ -10,7 +10,6 @@ import (
type player struct {
ws *websocket.Conn
game *game
Robot bot.Robot
send chan *bot.Boardstate
Instruction instruction
@@ -61,9 +60,10 @@ func (p *player) nudge() {
p.Robot.Position.Y = newPos.Y
}
func (p *player) scan() {
func (p *player) scan(players map[*player]bool) {
// TODO: perhaps keep the same one around?
p.Robot.Scanners = make([]bot.Scanner, 0)
for player := range p.game.players {
for player, _ := range players {
if player.Robot.Id == p.Robot.Id || player.Robot.Health <= 0 {
continue
}
@@ -80,8 +80,10 @@ func (p *player) scan() {
}
}
func (p *player) fire() *bot.Projectile {
for proj := range p.game.projectiles {
func (p *player) fire(projectiles map[*bot.Projectile]bool) *bot.Projectile {
// XXX: is this to prevent us from having multiple projectiles from the
// same bot?
for proj := range projectiles {
if proj.Id == p.Robot.Id {
return nil
}