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