2 new map, fix map name 4+ players
This commit is contained in:
@@ -163,15 +163,6 @@ class LobbieActor(hostUser: LobbyUser, deciderName: String) extends Actor with L
|
||||
}
|
||||
users.foreach(_ ! RefreshLobbyInfo(getLobbyInfoResponse))
|
||||
|
||||
case ChangeIsNecronSelected(isSelected) =>
|
||||
isNecrons = isSelected
|
||||
if (isSelected) {
|
||||
mapsLobby.foreach(map => if (map.map == "2p_meeting_of_minds" || map.map == "2p_shrine_of_excellion_[Rem]") map.isBanned = true)
|
||||
} else {
|
||||
mapsLobby.foreach(map => map.isBanned = false)
|
||||
}
|
||||
users.foreach(_ ! RefreshLobbyInfo(getLobbyInfoResponse))
|
||||
|
||||
case KickSecondPlayer =>
|
||||
if (sender() == host.actorRef) {
|
||||
secondPlayer.foreach(player => player.actorRef ! LobbyFatal("You were kicked from lobby!"))
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 44 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 5.0 KiB |
@@ -272,7 +272,7 @@ function renderRaces() {
|
||||
}
|
||||
|
||||
if(raceCount >= 3){
|
||||
resHtml += "<div class='col-xs-4'><center><h2>Ban race</h2>";
|
||||
resHtml += "<div class='col-xs-4'><center><h2>Third race</h2>";
|
||||
for(var i = 1; i <= 9; i++){
|
||||
var selected = "raceNotSelected";
|
||||
var banned = "";
|
||||
@@ -281,7 +281,7 @@ function renderRaces() {
|
||||
banned = "bannedRace";
|
||||
selectedThirdRace = i;
|
||||
}
|
||||
resHtml += '<a href = "#" class="'+selected+' thirdRaceIcon" onclick="selectThirdRace(this, ' +i+')"><img class="raceIcon '+banned+'" src="'+getRaceImageByNumber(i)+'"></a> ';
|
||||
resHtml += '<a href = "#" class="'+selected+' thirdRaceIcon" onclick="selectThirdRace(this, ' +i+')"><img class="raceIcon" src="'+getRaceImageByNumber(i)+'"></a> ';
|
||||
}
|
||||
resHtml += "</center></div>";
|
||||
}
|
||||
@@ -327,12 +327,10 @@ function selectThirdRace(button, race){
|
||||
$.cookie("race3", race, { expires: 1 });
|
||||
_.each($(".thirdRaceIcon"), function (el){
|
||||
$(el).removeClass("raceSelected");
|
||||
$(el).children('img').removeClass("bannedRace");
|
||||
$(el).addClass("raceNotSelected");
|
||||
});
|
||||
$(button).removeClass("raceNotSelected");
|
||||
$(button).addClass("raceSelected");
|
||||
$(button).children("img").addClass("bannedRace");
|
||||
checkRaceSelectFinish();
|
||||
}
|
||||
|
||||
@@ -520,7 +518,7 @@ function renderPlayersAndStats(lobby) {
|
||||
"<option "+last1Selected+" value = 'last1'>Play on last map</option>" +
|
||||
"<option "+last3Selected+" value = 'last3'>Play on last 3 maps</option>" +
|
||||
"<option "+last5Selected+" value = 'last5'>Play on last 5 maps</option>" +
|
||||
/*"<option "+last7Selected+" value = 'last7'>Play on last 7 maps</option>" +*/
|
||||
"<option "+last7Selected+" value = 'last7'>Play on last 7 maps</option>" +
|
||||
"</select>";
|
||||
|
||||
if(lobby.user1Info.name !== userName && lobby.user2Info.name !== userName){
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package controllers
|
||||
|
||||
import actors.UserParentActor.GetAllUsers
|
||||
import actors._
|
||||
import akka.NotUsed
|
||||
import akka.actor._
|
||||
@@ -9,30 +10,37 @@ import akka.stream._
|
||||
import akka.stream.scaladsl._
|
||||
import akka.util.Timeout
|
||||
import com.typesafe.config.ConfigFactory
|
||||
|
||||
import javax.inject._
|
||||
import org.reactivestreams.Publisher
|
||||
import play.api.libs.json._
|
||||
import play.api.mvc._
|
||||
|
||||
import scala.concurrent.duration._
|
||||
import scala.concurrent.{ExecutionContext, Future}
|
||||
import scala.concurrent.{Await, ExecutionContext, Future}
|
||||
|
||||
/**
|
||||
* This class creates the actions and the websocket needed.
|
||||
*/
|
||||
@Singleton
|
||||
class AdminController @Inject()(cc: ControllerComponents) extends AbstractController(cc) {
|
||||
class AdminController @Inject()(cc: ControllerComponents, homeController: HomeController) extends AbstractController(cc) {
|
||||
|
||||
implicit val actorSystem: ActorSystem = ActorSystem()
|
||||
implicit val ec: ExecutionContext = defaultExecutionContext
|
||||
implicit val timeout = Timeout(100.millis)
|
||||
|
||||
// Use a direct reference to SLF4J
|
||||
private val logger = org.slf4j.LoggerFactory.getLogger("controllers.HomeController")
|
||||
|
||||
val userParentActor: ActorRef = homeController.userParentActor
|
||||
|
||||
// Home page that renders template
|
||||
def viewAllLobbies() = Action { implicit request =>
|
||||
def viewAllUsers() = Action { implicit request =>
|
||||
logger.info(s"Received request from: ${request.remoteAddress}")
|
||||
Ok(views.html.admin())
|
||||
|
||||
val allUsers = userParentActor ? GetAllUsers
|
||||
val res = Await.result(allUsers, Duration.Inf)
|
||||
Ok(res.toString)
|
||||
}
|
||||
|
||||
def banLobby(lobbyActorName: String): Unit = {
|
||||
|
||||
@@ -112,7 +112,7 @@ class HomeController @Inject()(cc: ControllerComponents) extends AbstractControl
|
||||
val (webSocketOut: ActorRef, webSocketIn: Publisher[JsValue]) = createWebSocketConnections()
|
||||
|
||||
// Create a user actor off the request id and attach it to the source
|
||||
val userActorFuture = createUserActor(request.id.toString, webSocketOut)
|
||||
val userActorFuture = createUserActor(request.id.toString, request.remoteAddress, webSocketOut)
|
||||
|
||||
// Once we have an actor available, create a flow...
|
||||
userActorFuture.map { userActor =>
|
||||
@@ -190,11 +190,11 @@ class HomeController @Inject()(cc: ControllerComponents) extends AbstractControl
|
||||
* @param webSocketOut the "write" side of the websocket, that the user actor sends JsValue to.
|
||||
* @return a user actor for this ws connection.
|
||||
*/
|
||||
private def createUserActor(name: String, webSocketOut: ActorRef): Future[ActorRef] = {
|
||||
private def createUserActor(name: String, remoteAddress: String, webSocketOut: ActorRef): Future[ActorRef] = {
|
||||
// Use guice assisted injection to instantiate and configure the child actor.
|
||||
val userActorFuture = {
|
||||
implicit val timeout = Timeout(100.millis)
|
||||
(userParentActor ? UserParentActor.Create(name, webSocketOut)).mapTo[ActorRef]
|
||||
(userParentActor ? UserParentActor.Create(name, remoteAddress, webSocketOut)).mapTo[ActorRef]
|
||||
}
|
||||
userActorFuture
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<script type='text/javascript' src='@routes.Assets.at("lib/underscore/underscore.js")'></script>
|
||||
<script type='text/javascript' src='@routes.Assets.at("lib/backbonejs/backbone.js")'></script>
|
||||
<script type="text/javascript" src="@routes.Assets.at("lib/jquery-cookie/jquery.cookie.js")"></script>
|
||||
<script type='text/javascript' src='@routes.Assets.at("javascripts/index.js?030622")'></script>
|
||||
<script type='text/javascript' src='@routes.Assets.at("javascripts/index.js?270822")'></script>
|
||||
</head>
|
||||
<body data-ws-url="@routes.HomeController.ws.webSocketURL()">
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
|
||||
Reference in New Issue
Block a user