Multi-target slapping in the house.
This commit is contained in:
@@ -26,6 +26,7 @@ type ClientData struct {
|
|||||||
Position gamedata.Coordinates
|
Position gamedata.Coordinates
|
||||||
Hit bool
|
Hit bool
|
||||||
Target int
|
Target int
|
||||||
|
Targets []int
|
||||||
Slapping bool
|
Slapping bool
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,6 +138,7 @@ func (s *Server) HandleClient(conn net.Conn, id int) {
|
|||||||
//collision, mark it
|
//collision, mark it
|
||||||
cd.Hit = true
|
cd.Hit = true
|
||||||
cd.Target = client.Id
|
cd.Target = client.Id
|
||||||
|
cd.Targets = append(cd.Targets, client.Id)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -145,11 +147,15 @@ func (s *Server) HandleClient(conn net.Conn, id int) {
|
|||||||
s.clientlist[conn] = cd
|
s.clientlist[conn] = cd
|
||||||
s.mu.Unlock()
|
s.mu.Unlock()
|
||||||
case *pb.ClientEnvelope_Slap:
|
case *pb.ClientEnvelope_Slap:
|
||||||
if s.clientlist[conn].Target != 0 && s.clientlist[conn].Hit {
|
|
||||||
s.BroadcastSlap(id, s.clientlist[conn].Target)
|
s.mu.Lock()
|
||||||
} else {
|
slapper := s.clientlist[conn]
|
||||||
fmt.Println("Invalid slap detected.")
|
s.mu.Unlock()
|
||||||
|
|
||||||
|
for _, target := range slapper.Targets {
|
||||||
|
s.BroadcastSlap(id, target)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user