2 new map, fix map name 4+ players

This commit is contained in:
v.holodov
2022-10-05 23:22:08 +03:00
parent d3e90fb01e
commit 750ea483b6
10 changed files with 146 additions and 68 deletions
+8 -10
View File
@@ -13,10 +13,13 @@ import scala.concurrent.duration.DurationInt
import scala.util.{Failure, Success}
class UserActor(out: ActorRef,
userParentActor: ActorRef) extends Actor with LazyLogging {
userParentActor: ActorRef,
ip: String) extends Actor with LazyLogging {
implicit val timeout: Timeout = 3.seconds
val ipAddress: String = ip
var lobbieActor: Option[ActorRef] = None
implicit val mapJson: Writes[DeciderMap] = new Writes[DeciderMap] {
@@ -42,7 +45,6 @@ class UserActor(out: ActorRef,
"status" -> lobby.status,
"playerTurn" -> lobby.playerTurn,
"selectedType" -> lobby.selectedType,
"isNecrons" -> lobby.isNecrons,
"maps" -> Json.toJson(lobby.maps)
)
}
@@ -62,7 +64,6 @@ class UserActor(out: ActorRef,
"status" -> lobby.status,
"playerTurn" -> lobby.playerTurn,
"selectedType" -> lobby.selectedType,
"isNecrons" -> lobby.isNecrons,
"maps" -> Json.toJson(lobby.maps)
)))
}
@@ -154,10 +155,6 @@ class UserActor(out: ActorRef,
val lobbyType = (json \ "lobbyType").as[String]
lobbieActor.foreach(lobby => lobby ! ChangeLobbyType(lobbyType))
case Some("changeIsNecronSelected") =>
val isNecronSelected = (json \ "isNecronSelected").as[Boolean]
lobbieActor.foreach(lobby => lobby ! ChangeIsNecronSelected(isNecronSelected))
case Some("kickSecondPlayer") =>
lobbieActor.foreach(lobby => lobby ! KickSecondPlayer)
@@ -210,10 +207,11 @@ class UserParentActor(actorSystem: ActorSystem) extends Actor with ActorLogging
import UserParentActor._
override def receive: Receive = LoggingReceive {
case Create(id, out) =>
val child: ActorRef = actorSystem.actorOf(Props(classOf[UserActor], out, self), s"userActor-$id")
case Create(id, ipAddress, out) =>
val child: ActorRef = actorSystem.actorOf(Props(classOf[UserActor], out, self, ipAddress), s"userActor-$id")
sender() ! child
case GetAllUsers =>
System.out.print("12123" + context.children)
sender() ! context.children
}
}
@@ -221,7 +219,7 @@ class UserParentActor(actorSystem: ActorSystem) extends Actor with ActorLogging
object UserParentActor {
case class Create(id: String, out: ActorRef)
case class Create(id: String, ipAddress: String, out: ActorRef)
case object GetAllUsers