Autum cup 2 decider
This commit is contained in:
parent
f94bf511a3
commit
ec519889dc
@ -130,12 +130,12 @@ class LobbieActor(hostUser: LobbyUser) extends Actor with LazyLogging {
|
|||||||
sender ! SetUserAsObs(getLobbyInfoResponse)
|
sender ! SetUserAsObs(getLobbyInfoResponse)
|
||||||
case LeaveLobby =>
|
case LeaveLobby =>
|
||||||
users = users - sender
|
users = users - sender
|
||||||
if(secondPlayer.exists(sp => sp.actorRef == sender)) secondPlayer = None
|
|
||||||
if(host.actorRef == sender()){
|
if(host.actorRef == sender()){
|
||||||
users.foreach(_ ! HostLeaveLobby)
|
users.foreach(_ ! HostLeaveLobby)
|
||||||
context.stop(self)
|
context.stop(self)
|
||||||
}else if(secondPlayer.exists(_.actorRef == sender())){
|
}else if(secondPlayer.exists(_.actorRef == sender())){
|
||||||
users.foreach(_ ! SecondPlayerLeaveLobby)
|
users.foreach(_ ! SecondPlayerLeaveLobby)
|
||||||
|
secondPlayer = None
|
||||||
context.stop(self)
|
context.stop(self)
|
||||||
}
|
}
|
||||||
if (users.isEmpty) {
|
if (users.isEmpty) {
|
||||||
@ -165,12 +165,12 @@ case class MapsUpdate(maps: Set[String])
|
|||||||
|
|
||||||
case class CreateLobby(userName: String)
|
case class CreateLobby(userName: String)
|
||||||
|
|
||||||
case class WatchLobby(lobbyName: String)
|
|
||||||
|
|
||||||
case class JoinLobbyAsPlayer(lobbyUser: LobbyUser)
|
case class JoinLobbyAsPlayer(lobbyUser: LobbyUser)
|
||||||
|
|
||||||
case object KickSecondPlayer
|
case object KickSecondPlayer
|
||||||
|
|
||||||
|
case class WatchLobby(lobbyName: String)
|
||||||
|
|
||||||
case object LeaveLobby
|
case object LeaveLobby
|
||||||
|
|
||||||
case object SetReady
|
case object SetReady
|
||||||
|
|||||||
@ -30,6 +30,13 @@ class LobbiesActor extends Actor with LazyLogging {
|
|||||||
case Some(lobbyActor) => lobbyActor ! JoinLobbyAsPlayer(LobbyUser(userName, user))
|
case Some(lobbyActor) => lobbyActor ! JoinLobbyAsPlayer(LobbyUser(userName, user))
|
||||||
case None => logger.error(s"Can't watch lobby $lobbyName - lobby not exists")
|
case None => logger.error(s"Can't watch lobby $lobbyName - lobby not exists")
|
||||||
}
|
}
|
||||||
|
case ObserveLobbyByActorName(lobbyName) =>
|
||||||
|
// get or create the StockActor for the symbol and forward this message
|
||||||
|
val user = sender
|
||||||
|
context.child(lobbyName) match {
|
||||||
|
case Some(lobbyActor) => lobbyActor.tell(WatchLobby("watchIt"), user)
|
||||||
|
case None => logger.error(s"Can't watch lobby $lobbyName - lobby not exists")
|
||||||
|
}
|
||||||
case watchLobby@WatchLobby(lobbyName) =>
|
case watchLobby@WatchLobby(lobbyName) =>
|
||||||
// get or create the StockActor for the symbol and forward this message
|
// get or create the StockActor for the symbol and forward this message
|
||||||
context.child(lobbyName) match {
|
context.child(lobbyName) match {
|
||||||
@ -50,4 +57,6 @@ case object GetAllLobbies
|
|||||||
|
|
||||||
case class JoinLobbyByActorName(actorName: String, userName: String)
|
case class JoinLobbyByActorName(actorName: String, userName: String)
|
||||||
|
|
||||||
|
case class ObserveLobbyByActorName(actorName: String)
|
||||||
|
|
||||||
case object UnWatchAllLobbies
|
case object UnWatchAllLobbies
|
||||||
@ -1,6 +1,6 @@
|
|||||||
package actors
|
package actors
|
||||||
|
|
||||||
import actors.UserActor.{GetName, HostLeaveLobby, LobbyFatal, RefreshLobbyInfo, SecondPlayerLeaveLobby, SetUserAsHost, SetUserAsSecondPlayer}
|
import actors.UserActor.{GetName, HostLeaveLobby, LobbyFatal, RefreshLobbyInfo, SecondPlayerLeaveLobby, SetUserAsHost, SetUserAsObs, SetUserAsSecondPlayer}
|
||||||
import akka.actor._
|
import akka.actor._
|
||||||
import akka.event.LoggingReceive
|
import akka.event.LoggingReceive
|
||||||
import akka.pattern.ask
|
import akka.pattern.ask
|
||||||
@ -67,6 +67,11 @@ class UserActor(out: ActorRef,
|
|||||||
logger.info(s"Receive set user ${self.path.name} as second player from ${lobbyActor.path.name}")
|
logger.info(s"Receive set user ${self.path.name} as second player from ${lobbyActor.path.name}")
|
||||||
setUserAsJoinedOrCreatedLobby(lobbyActor, lobbyInfo)
|
setUserAsJoinedOrCreatedLobby(lobbyActor, lobbyInfo)
|
||||||
|
|
||||||
|
case SetUserAsObs(lobbyInfo) =>
|
||||||
|
val lobbyActor = sender()
|
||||||
|
logger.info(s"Receive set user ${self.path.name} as second player from ${lobbyActor.path.name}")
|
||||||
|
setUserAsJoinedOrCreatedLobby(lobbyActor, lobbyInfo)
|
||||||
|
|
||||||
case HostLeaveLobby =>
|
case HostLeaveLobby =>
|
||||||
logger.info(s"Host leave from lobby ${sender.path.name}")
|
logger.info(s"Host leave from lobby ${sender.path.name}")
|
||||||
out ! Json.obj("type" -> "lobbyError", "error" -> "Host leave lobby")
|
out ! Json.obj("type" -> "lobbyError", "error" -> "Host leave lobby")
|
||||||
@ -122,6 +127,11 @@ class UserActor(out: ActorRef,
|
|||||||
logger.info(s"Player ${self.path.name} join lobby $lobbyActorName")
|
logger.info(s"Player ${self.path.name} join lobby $lobbyActorName")
|
||||||
lobbiesActor ! JoinLobbyByActorName(lobbyActorName, name)
|
lobbiesActor ! JoinLobbyByActorName(lobbyActorName, name)
|
||||||
|
|
||||||
|
case Some("observerDecider") =>
|
||||||
|
val lobbyActorName = (json \ "lobbyActorName").as[String]
|
||||||
|
logger.info(s"Player ${self.path.name} observe lobby $lobbyActorName")
|
||||||
|
lobbiesActor ! ObserveLobbyByActorName(lobbyActorName)
|
||||||
|
|
||||||
case Some("banMap") =>
|
case Some("banMap") =>
|
||||||
val map = (json \ "map").as[String]
|
val map = (json \ "map").as[String]
|
||||||
lobbieActor.foreach(lobby => lobby ! BanMap(map))
|
lobbieActor.foreach(lobby => lobby ! BanMap(map))
|
||||||
|
|||||||
@ -40,7 +40,7 @@ window.onload = function() {
|
|||||||
var joinButton = (lobby.status === "NotStarted()") ? '<button class="btn btn-primary join-as-player" onclick="joinDecider(\''+lobby.lobbyActorName+'\')">' +
|
var joinButton = (lobby.status === "NotStarted()") ? '<button class="btn btn-primary join-as-player" onclick="joinDecider(\''+lobby.lobbyActorName+'\')">' +
|
||||||
'<img src="assets/images/buttons/isAuto.png" style="height: 25px;"> Join lobby <img src="assets/images/buttons/isAuto.png" style="height: 25px;">' +
|
'<img src="assets/images/buttons/isAuto.png" style="height: 25px;"> Join lobby <img src="assets/images/buttons/isAuto.png" style="height: 25px;">' +
|
||||||
'</button>' : "";
|
'</button>' : "";
|
||||||
var observerButton = '<button class="btn btn-success join-as-observer" lobbyId="'+lobby.lobbyActorName+'">' +
|
var observerButton = '<button class="btn btn-success join-as-observer" onclick="observerDecider(\''+lobby.lobbyActorName+'\')">' +
|
||||||
'<img src="assets/images/buttons/Ulthwe.png" style="height: 25px;"> Observer <img src="assets/images/buttons/Ulthwe.png" style="height: 25px;">' +
|
'<img src="assets/images/buttons/Ulthwe.png" style="height: 25px;"> Observer <img src="assets/images/buttons/Ulthwe.png" style="height: 25px;">' +
|
||||||
'</button>';
|
'</button>';
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ window.onload = function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if($.cookie('user')=== undefined){
|
if($.cookie('user')=== undefined){
|
||||||
var result = prompt("Введите ник", );
|
var result = prompt("Enter nickname: ", );
|
||||||
$.cookie('user', result, { expires: 7 });
|
$.cookie('user', result, { expires: 7 });
|
||||||
userName = result;
|
userName = result;
|
||||||
}else{
|
}else{
|
||||||
@ -211,12 +211,13 @@ function renderPlayersAndStats(lobby) {
|
|||||||
var player2ReadyBtn = "";
|
var player2ReadyBtn = "";
|
||||||
var readyImg = "<img src='/assets/images/buttons/isAuto.png' class='readyImg'/>";
|
var readyImg = "<img src='/assets/images/buttons/isAuto.png' class='readyImg'/>";
|
||||||
var notReadyImg = "<img src='/assets/images/buttons/isNotAuto.png' class='readyImg'/>";
|
var notReadyImg = "<img src='/assets/images/buttons/isNotAuto.png' class='readyImg'/>";
|
||||||
|
var warningClass = (lobby.user2Info.name !== "") ? "warningButton" : "";
|
||||||
|
|
||||||
if(lobby.user1Info.name === userName){
|
if(lobby.user1Info.name === userName){
|
||||||
if(lobby.user1Info.isReady){
|
if(lobby.user1Info.isReady){
|
||||||
player1ReadyBtn = "<button class='btn btn-default' onclick='setNotReady()'>"+readyImg+" Ready "+readyImg+"</button>"
|
player1ReadyBtn = "<button class='btn btn-default' onclick='setNotReady()'>"+readyImg+" Ready "+readyImg+"</button>"
|
||||||
}else{
|
}else{
|
||||||
player1ReadyBtn = "<button class='btn btn-default' onclick='setReady()'>"+notReadyImg+" Not ready "+notReadyImg+"</button>"
|
player1ReadyBtn = "<button class='btn btn-default "+warningClass+"' onclick='setReady()'>"+notReadyImg+" Not ready "+notReadyImg+"</button>"
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if(lobby.user1Info.isReady){
|
if(lobby.user1Info.isReady){
|
||||||
@ -230,7 +231,7 @@ function renderPlayersAndStats(lobby) {
|
|||||||
if(lobby.user2Info.isReady){
|
if(lobby.user2Info.isReady){
|
||||||
player2ReadyBtn = "<button class='btn btn-default' onclick='setNotReady()'>"+readyImg+" Ready "+readyImg+"</button>"
|
player2ReadyBtn = "<button class='btn btn-default' onclick='setNotReady()'>"+readyImg+" Ready "+readyImg+"</button>"
|
||||||
}else{
|
}else{
|
||||||
player2ReadyBtn = "<button class='btn btn-default' onclick='setReady()'>"+notReadyImg+" Not ready "+notReadyImg+"</button>"
|
player2ReadyBtn = "<button class='btn btn-default "+warningClass+"' onclick='setReady()'>"+notReadyImg+" Not ready "+notReadyImg+"</button>"
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(lobby.user2Info.isReady){
|
if(lobby.user2Info.isReady){
|
||||||
@ -290,13 +291,19 @@ function setNotReady(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function joinDecider(actorName){
|
function joinDecider(actorName){
|
||||||
console.log(actorName);
|
|
||||||
ws.send(JSON.stringify({
|
ws.send(JSON.stringify({
|
||||||
type: "joinDecider",
|
type: "joinDecider",
|
||||||
lobbyActorName: actorName
|
lobbyActorName: actorName
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function observerDecider(actorName){
|
||||||
|
ws.send(JSON.stringify({
|
||||||
|
type: "observerDecider",
|
||||||
|
lobbyActorName: actorName
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
function kickSecondPlayer(){
|
function kickSecondPlayer(){
|
||||||
ws.send(JSON.stringify({
|
ws.send(JSON.stringify({
|
||||||
type: "kickSecondPlayer"
|
type: "kickSecondPlayer"
|
||||||
|
|||||||
@ -97,6 +97,21 @@ body {
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@keyframes glowing {
|
||||||
|
0% {
|
||||||
|
box-shadow: 0 0 2px #074673;
|
||||||
|
}
|
||||||
|
50% {
|
||||||
|
box-shadow: 0 0 9px #0e87de;
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
box-shadow: 0 0 2px #094d7d;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.warningButton {
|
||||||
|
animation: glowing 1300ms infinite;
|
||||||
|
}
|
||||||
|
|
||||||
.chart-holder, .details-holder {
|
.chart-holder, .details-holder {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Reactive Stock News Dashboard</title>
|
<title>Second Autumn Cup decider</title>
|
||||||
<link rel='stylesheet' href='@routes.Assets.at("lib/bootstrap/css/bootstrap.min.css")'>
|
<link rel='stylesheet' href='@routes.Assets.at("lib/bootstrap/css/bootstrap.min.css")'>
|
||||||
<link rel="stylesheet" media="screen" href="@routes.Assets.at("stylesheets/main.css")">
|
<link rel="stylesheet" media="screen" href="@routes.Assets.at("stylesheets/main.css")">
|
||||||
<link rel="shortcut icon" type="image/png" href="@routes.Assets.at("images/favicon.png")">
|
<link rel="shortcut icon" type="image/png" href="@routes.Assets.at("images/favicon.png")">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user