Inheritance: MonoBehaviour
Exemplo n.º 1
0
 public Game(IEnumerable<Connection> connections, Server server, Lobby lobby, GameSpecificationInfo gameSpecification)
 {
     this.connections.AddRange(connections);
     this.server = server;
     this.lobby = lobby;
     this.gameSpecification = gameSpecification;
 }
Exemplo n.º 2
0
	// Use this for initialization
	void Start () {
		S = this;
		_numKeysInLock = 0;
		finalDoorFrame = GameObject.Find("FinalDoorFrame");

		BuildLobbyFloorAndWalls();
	}
 public DataProcessor(IInvokable invoke, INotifiable notify, ILobby lobby) {
     if(invoke != null)
         _invokable = new Invokable(invoke);
     if(notify != null)
         _notifiable = new Notifiable(notify);
     if (lobby != null)
         _lobby = new Lobby(lobby);
 }
 public GameRoomSession(SessionManager manager, Lobby.LobbySession lobbySession, Lobby.GameRoomItem gameRoom)
     : base(manager)
 {
     _lobbySession = lobbySession;
     GameRoom = gameRoom;
     _lobbySession.GameRoomJoining(this);
     _lobbySession.DisplayToggled += _lobbySession_DisplayToggled;
 }
Exemplo n.º 5
0
        public void Creating_a_new_game(string gameName, Lobby lobby)
        {
            "Given a game name"
                .Given(() => gameName = "Test");

            "When I create a new game"
                .When(() => lobby = new Lobby(gameName));

            "A game is created with a name"
                .Then(() => lobby.GameName.ShouldBe(gameName));
        }
Exemplo n.º 6
0
        public void Inviting_player_to_game(string playerName, Guid invitationToken, Lobby lobby)
        {
            "Given a game"
                .Given(() => lobby = new Lobby("Test"));

            "And a player name".And(
                () => playerName = "Bryan");

            "And a invitation token".And(
                () => invitationToken = new Guid("7d9b4a47-b0e3-4aa3-965a-631b5a535de5"));

            "When I invite the player"
                .When(() => lobby.InvitePlayer(playerName, invitationToken));

            "A user is added to the invited players"
                .Then(() => lobby.InvitedPlayers.ShouldContain(new KeyValuePair<Guid, string>(invitationToken, playerName)));
        }
Exemplo n.º 7
0
        public void Cannot_accept_invitation_as_not_invited(Guid playerId, string playerName, Guid invitationToken, Lobby lobby)
        {
            "Given a game"
                .Given(() => lobby = new Lobby("Test"));

            "And a player id".And(
                () => playerId = new Guid("7d9b4a47-b0e3-4aa3-965a-631b5a535de5"));

            "And a player name".And(
                () => playerName = "Bryan");

            "And an invalid token"
                .And(() => invitationToken = Guid.NewGuid());

            "Then an error is thrown when trying to accept an invitation"
                .Then(() => Assert.Throws<InvalidInvitationToken>(() => lobby.AcceptInvitation(playerId, playerName, invitationToken)));
        }
 public void UpdatePlayerListPanel(Lobby lobby)
 {
     for (int i = playerListPnael.childCount - 1; i >= 0; i--)
     {
         Destroy(playerListPnael.GetChild(i).gameObject);
     }
     var playerEnumerator = lobby.users.Values.GetEnumerator();
     playerEnumerator.MoveNext();
     for (int i = 0; i < lobby.users.Count; i++)
     {
         RectTransform block = Instantiate(playerNamePrefab);
         block.transform.SetParent(playerListPnael);
         block.localScale = Vector3.one;
         block.localPosition = new Vector3(0,100 - 30*i);
         block.GetComponent<Text>().text = playerEnumerator.Current.userName;
         playerEnumerator.MoveNext();
     }
 }
 public void UpdateRoomPanel(Lobby lobby)
 {
     for (int i = roomPanel.childCount - 1; i >= 0; i--)
     {
         Destroy(roomPanel.GetChild(i).gameObject);
     }
     var roomEnumerator = lobby.rooms.GetEnumerator();
     roomEnumerator.MoveNext();
     for (int i = 0; i < lobby.rooms.Count; i++)
     {
         RectTransform block = Instantiate(roomButtonPrefab);
         block.transform.SetParent(roomPanel);
         block.localScale = Vector3.one;
         block.localPosition = new Vector3(-180 + 120f * (i%4), 55f - 105f*(i/4), 0f);
         block.GetChild(0).GetComponent<Text>().text = roomEnumerator.Current.Value.name;
         block.GetChild(1).GetComponent<Text>().text = roomEnumerator.Current.Value.users.Count.ToString() + "/4";
         int roomID = roomEnumerator.Current.Value.id;
         block.GetComponent<Button>().onClick.AddListener(() => joinRoomController.SelectRoom(roomID));
         roomEnumerator.MoveNext();
     }
 }
Exemplo n.º 10
0
        public void Accepting_an_invitation_to_game(Guid playerId, string playerName, Guid invitationToken, Lobby lobby)
        {
            "Given a game"
                .Given(() => lobby = new Lobby("Test"));

            "With an invited player"
                .And(() =>
                    {
                        playerName = "Bryan";
                        invitationToken = new Guid("7d9b4a47-b0e3-4aa3-965a-631b5a535de5");
                        lobby.InvitePlayer(playerName, invitationToken);
                    });

            "When they accept the invitation with a valid token"
                .When(() =>
                    {
                        playerId = new Guid("7d9b4a47-b0e3-4aa3-965a-631b5a535de5");
                        lobby.AcceptInvitation(playerId, playerName, invitationToken);
                    });

            "The player is added to the joined players"
                .Then(() => lobby.JoinedPlayers.ShouldContain(new KeyValuePair<Guid, string>(playerId, playerName)));
        }
Exemplo n.º 11
0
 public GameState(Lobby lobby, Contract contract) : base("Game", lobby)
 {
     Contract = contract;
 }
 private void JoinLobbyAndGameRoom(Lobby.GameRoomItem room)
 {
     ChatroomSessionBase session;
     if (_chatroomUsage.TryGetValue(PrefixGameLobby + room.GameId, out session))
     {
         var lobbySession = (Lobby.LobbySession)session;
         Lobby.GameRoomItem gameRoomItem;
         if (lobbySession.GameRoomManager.TryGetItemById(room.Id, out gameRoomItem))
             JoinChatroom(PrefixGameRoom + room.Id);
     }
     else
     {
         _gameRoomsToJoinAfterLobbyJoin.Add(room.Id);
         JoinChatroom(PrefixGameLobby + room.GameId);
     }
 }
Exemplo n.º 13
0
    public static void Connect(int lobbyId)
    {
        joinLobby = false;
        ws        = new WebSocket(uri);
        List <string> log = new List <string>();

        ws.OnMessage += (senders, d) =>
        {
            try
            {
                WSResponse res;
                res = JsonConvert.DeserializeObject <WSResponse>(d.Data.ToString());
                //Console.Title = res.identifier;

                if (res.identifier == "order")
                {
                    //Console.Title = "Recieved order";
                    if (res.msg == "reload")
                    {
                        getLobby = true;
                    }
                    if (res.msg == "start")
                    {
                        Terminal.WriteLine("Received start order");
                        start = true;
                        //Console.Title = "Starting game!";
                    }
                }

                if (res.identifier == "setUserId")
                {
                    if (res.type == "txt")
                    {
                        Lobby.user.userId = int.Parse(res.msg);
                    }
                }

                if (res.identifier == "update")
                {
                    try
                    {
                        GameInfo gameInfo = JsonConvert.DeserializeObject <GameInfo>(res.msg);
                        //File.WriteAllLines("res.json", new string[] { JsonConvert.SerializeObject(gameInfo) });

                        players = gameInfo.players;
                        if (playerCount != players.Count)
                        {
                            placePlayers = true;
                        }
                        playerCount = players.Count;

                        map    = gameInfo.mapIndex;
                        update = true;
                    }
                    catch (System.Exception ex)
                    {
                        Terminal.WriteLine(ex.Message);
                    }
                }

                if (res.identifier == "fireResponse")
                {
                    FireResponse fireResponse = JsonConvert.DeserializeObject <FireResponse>(res.msg);
                    Terminal.WriteLine("Fireresponse: Status: " + fireResponse.status + ", msg: " + fireResponse.msg);
                }

                if (res.identifier == "fireInfo")
                {
                    Terminal.WriteLine("Received bullet info - " + res.msg);
                    try
                    {
                        FireInfo _fireInfo = JsonConvert.DeserializeObject <FireInfo>(res.msg);
                        fireInfo = _fireInfo;
                        fired    = true;
                    }
                    catch (System.Exception ex)
                    {
                        Terminal.WriteLine(ex.Message);
                    }
                }

                if (res.identifier == "joinResponse")
                {
                    JoinRequestResponse joinRequestResponse = JsonConvert.DeserializeObject <JoinRequestResponse>(res.msg);

                    if (joinRequestResponse.status == "success")
                    {
                        joinLobby = true;
                        joinId    = lobbyId;
                    }
                    else
                    {
                        display        = true;
                        displayMessage = joinRequestResponse.msg;
                        displayTitle   = joinRequestResponse.status;
                    }
                }

                if (res.identifier == "promoteResponse")
                {
                    PromoteRequestResponse promoteRequestResponse = JsonConvert.DeserializeObject <PromoteRequestResponse>(res.msg);

                    //Console.Title = (kickRequestResponse.msg);
                    if (promoteRequestResponse.status == "success")
                    {
                    }
                    else
                    {
                        display        = true;
                        displayMessage = promoteRequestResponse.msg;
                        displayTitle   = promoteRequestResponse.status;
                    }
                }
                if (res.identifier == "swapTeamResponse")
                {
                    SwapTeamRequestResponse swapTeamRequestResponse = JsonConvert.DeserializeObject <SwapTeamRequestResponse>(res.msg);

                    //Console.Title = (kickRequestResponse.msg);
                    if (swapTeamRequestResponse.status == "success")
                    {
                    }
                    else
                    {
                        display        = true;
                        displayMessage = swapTeamRequestResponse.msg;
                        displayTitle   = swapTeamRequestResponse.status;
                    }
                }
                if (res.identifier == "kickResponse")
                {
                    KickRequestResponse kickRequestResponse = JsonConvert.DeserializeObject <KickRequestResponse>(res.msg);

                    //Console.Title = (kickRequestResponse.msg);

                    if (kickRequestResponse.status == "success")
                    {
                        if (int.Parse(kickRequestResponse.msg) == Lobby.user.userId)
                        {
                            Disconnect();
                            kicked         = true;
                            display        = true;
                            displayTitle   = "Oops";
                            displayMessage = "You were kicked";
                        }
                    }
                }
                if (res.identifier == "startResponse")
                {
                    StartRequestResponse startRequestResponse = JsonConvert.DeserializeObject <StartRequestResponse>(res.msg);

                    //Console.Title = (kickRequestResponse.msg);

                    if (startRequestResponse.status == "success")
                    {
                    }
                    else
                    {
                        display        = true;
                        displayMessage = startRequestResponse.msg;
                        displayTitle   = startRequestResponse.status;
                    }
                }

                if (res.identifier == "displayUpdateResponse")
                {
                    UpdataDisplayInfoResponse updataDisplayInfoResponse = JsonConvert.DeserializeObject <UpdataDisplayInfoResponse>(res.msg);

                    if (updataDisplayInfoResponse.status == "success")
                    {
                        //Console.Title = "I666 - Updated display info";
                    }
                }

                if (res.identifier == "positionUpdateResponse")
                {
                    PositionUpdateResponse updataDisplayInfoResponse = JsonConvert.DeserializeObject <PositionUpdateResponse>(res.msg);

                    //Console.Title = (kickRequestResponse.msg);
                    if (updataDisplayInfoResponse.status == "success")
                    {
                    }
                    else
                    {
                        Console.Title = updataDisplayInfoResponse.msg;
                    }
                }

                if (res.identifier == "pingResponse")
                {
                    Lobby.user.ping = (int)stopWatch.ElapsedMilliseconds;
                    Lobby.DisplayUpdate();
                    stopWatch.Stop();
                    stopWatch.Reset();
                    getLobby = true;
                    //Console.Title = "I666 : " + Lobby.user.ping;
                }

                log.Add("Received message -  " + d.Data.ToString() + " " + senders.ToString());
                //File.WriteAllLines("res.json", log.ToArray());
            }
            catch (System.Exception ex)
            {
                Terminal.WriteLine(ex.Message);
                //File.WriteAllLines("res.json", new string[] { "Something went wrong - " + ex.Message + ", " + d.Data.ToString() });
            }
        };

        ws.OnClose += (senders, d) =>
        {
            Terminal.WriteLine("Closed connection");
            log.Add("Connection closed - " + d.ToString() + " " + senders.ToString());
            //File.WriteAllLines("res.json", log.ToArray());

            return;
        };

        ws.Connect();
        Lobby.Join(lobbyId);
    }
Exemplo n.º 14
0
 private void SetLobby(object parameter)
 {
     _lobby = _proxy.GetLobbyById((Guid)parameter);
 }
Exemplo n.º 15
0
    public override bool DoDialog()
    {
        if (target < 0 || target == MyInfoManager.Instance.Seq)
        {
            return(true);
        }
        bool    result = false;
        GUISkin skin   = GUI.skin;

        GUI.skin = GUISkinFinder.Instance.GetGUISkin();
        Rect rc = crdBtnBase;

        if (RoomManager.Instance.HaveCurrentRoomInfo)
        {
            if (GlobalVars.Instance.MyButton(rc, StringMgr.Instance.Get("INVITE_MENU"), "BtnBlue"))
            {
                CSNetManager.Instance.Sock.SendCS_INVITE_REQ(target, targetNickname);
                result = true;
            }
            rc.y += crdBtnBase.height + 4f;
        }
        else
        {
            if (GlobalVars.Instance.MyButton(rc, StringMgr.Instance.Get("JOIN_MENU"), "BtnBlue"))
            {
                CSNetManager.Instance.Sock.SendCS_FOLLOWING_REQ(target, targetNickname);
                result = true;
            }
            rc.y += crdBtnBase.height + 4f;
        }
        if (!MyInfoManager.Instance.IsFriend(target) && !MyInfoManager.Instance.IsBan(target))
        {
            if (GlobalVars.Instance.MyButton(rc, StringMgr.Instance.Get("ADD_FRIEND"), "BtnBlue"))
            {
                CSNetManager.Instance.Sock.SendCS_ADD_FRIEND_REQ(target);
                result = true;
            }
            rc.y += crdBtnBase.height + 4f;
            if (GlobalVars.Instance.MyButton(rc, StringMgr.Instance.Get("ADD_BAN"), "BtnBlue"))
            {
                CSNetManager.Instance.Sock.SendCS_ADD_BAN_REQ(target);
                result = true;
            }
            rc.y += crdBtnBase.height + 4f;
        }
        else
        {
            if (MyInfoManager.Instance.IsFriend(target))
            {
                if (GlobalVars.Instance.MyButton(rc, StringMgr.Instance.Get("DEL_FRIEND"), "BtnBlue"))
                {
                    CSNetManager.Instance.Sock.SendCS_DEL_FRIEND_REQ(target);
                    result = true;
                }
                rc.y += crdBtnBase.height + 4f;
            }
            if (MyInfoManager.Instance.IsBan(target))
            {
                if (GlobalVars.Instance.MyButton(rc, StringMgr.Instance.Get("DEL_BAN"), "BtnBlue"))
                {
                    CSNetManager.Instance.Sock.SendCS_DEL_BAN_REQ(target);
                    result = true;
                }
                rc.y += crdBtnBase.height + 4f;
            }
        }
        if (MyInfoManager.Instance.IsClanStaff && isClanInvitable)
        {
            if (GlobalVars.Instance.MyButton(rc, StringMgr.Instance.Get("CLAN_INVITATION"), "BtnBlue"))
            {
                string title    = "CLAN_INVITATION";
                string contents = "CLAN_INVITATION_COMMENT" + GlobalVars.DELIMITER + "n" + MyInfoManager.Instance.Nickname + GlobalVars.DELIMITER + "n" + MyInfoManager.Instance.ClanName;
                CSNetManager.Instance.Sock.SendCS_SEND_CLAN_INVITATION_REQ(target, targetNickname, title, contents);
                result = true;
            }
            rc.y += crdBtnBase.height + 4f;
        }
        if (isMasterAssign)
        {
            if (GlobalVars.Instance.MyButton(rc, StringMgr.Instance.Get("MASTER_ASSIGN"), "BtnBlue"))
            {
                CSNetManager.Instance.Sock.SendCS_DELEGATE_MASTER_REQ(target);
                result = true;
            }
            rc.y += crdBtnBase.height + 4f;
        }
        if (GlobalVars.Instance.MyButton(rc, StringMgr.Instance.Get("WHISPER"), "BtnBlue"))
        {
            DialogManager.Instance.CloseAll();
            GameObject gameObject = GameObject.Find("Main");
            if (gameObject != null)
            {
                Lobby component = gameObject.GetComponent <Lobby>();
                if (component != null)
                {
                    component.lobbyChat.Message = "/w " + targetNickname + " ";
                    component.lobbyChat.ApplyFocus();
                    component.lobbyChat.CursorToEnd = true;
                }
                Briefing4TeamMatch component2 = gameObject.GetComponent <Briefing4TeamMatch>();
                if (component2 != null)
                {
                    component2.IsMessenger       = false;
                    component2.lobbyChat.Message = "/w " + targetNickname + " ";
                    component2.lobbyChat.ApplyFocus();
                    component2.lobbyChat.CursorToEnd = true;
                }
            }
            result = true;
        }
        rc.y += crdBtnBase.height + 4f;
        if (GlobalVars.Instance.MyButton(rc, StringMgr.Instance.Get("SEND_MEMO"), "BtnBlue"))
        {
            result = true;
            DialogManager.Instance.CloseAll();
            DialogManager.Instance.Push(DialogManager.DIALOG_INDEX.MEMO, targetNickname);
        }
        rc.y += crdBtnBase.height + 4f;
        if (BuildOption.Instance.Props.UseAccuse)
        {
            if (GlobalVars.Instance.MyButton(rc, StringMgr.Instance.Get("REPORT_GM_TITLE_01"), "BtnBlue"))
            {
                AccusationDialog accusationDialog = (AccusationDialog)DialogManager.Instance.Popup(DialogManager.DIALOG_INDEX.ACCUSATION, exclusive: true);
                string[]         users            = new string[1]
                {
                    targetNickname
                };
                accusationDialog?.InitDialog(users);
                result = true;
            }
            rc.y += crdBtnBase.height + 4f;
        }
        if (GlobalVars.Instance.MyButton(rc, StringMgr.Instance.Get("SHOW_PLAYER_INFO"), "BtnBlue"))
        {
            CSNetManager.Instance.Sock.SendCS_PLAYER_DETAIL_REQ(target);
            result = true;
        }
        rc.y += crdBtnBase.height + 4f;
        WindowUtil.EatEvent();
        GUI.skin = skin;
        return(result);
    }
Exemplo n.º 16
0
 private void HandleLobbyMemberJoined(Lobby lobby, Friend friend)
 {
     ConstructPlayersText();
 }
Exemplo n.º 17
0
        public override void AfterInvoke (InvocationInfo info, ref object returnValue)
        //public override bool BeforeInvoke(InvocationInfo info, out object returnValue)
        {
           
            if (info.target is ChatUI && info.targetMethod.Equals("AdjustToResolution"))//get style
            {
                this.chatLogStyle = new GUIStyle((GUIStyle)chatMsgStylefield.GetValue(info.target));

                this.chatButtonSkin = (GUISkin)chatButtonSkinfield.GetValue(info.target);

                //Console.WriteLine("AdjustToResolution");
            }

            if (info.target is Store && info.targetMethod.Equals("Start"))//update rects in store
            {
                this.menueheight = (float)Screen.width / 25.6f;
                selfsearchstring = "";
                this.store = (Store)info.target;
                this.sellFrame = (CardListPopup)typeof(Store).GetField("sellFrame", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(info.target);
                Rect sellrect = new Rect((float)Screen.width * 0.01f, (float)Screen.height * 0.18f, (float)Screen.height * 0.5f, (float)Screen.height * 0.7f);
                Rect searchFieldRect = new Rect(-10, -10, 1, 1);

                float BOTTOM_MARGIN_EXTRA = (float)Screen.height * 0.047f;
                float num = 0.005f * (float)Screen.width;
                Vector4 margins = new Vector4(0f, 0f, 0f, 0f + BOTTOM_MARGIN_EXTRA);
                float num2 = BOTTOM_MARGIN_EXTRA - 0.01f * (float)Screen.height;
                float num3 = num2 * 1.28f;



                Rect outerRect = new Rect((Rect)outerRectfield.GetValue(sellFrame));
                Rect innerBGRect = new Rect((Rect)innerBGRectfield.GetValue(sellFrame));
                Rect innerRect = new Rect((Rect)innerRectfield.GetValue(sellFrame));
                innerBGRect.height = innerBGRect.height + num3;
                innerRect.height = innerRect.height + num3;
                searchFieldRectfield.SetValue(sellFrame, searchFieldRect);
                innerBGRectfield.SetValue(sellFrame, innerBGRect);
                innerRectfield.SetValue(sellFrame, innerRect);
                this.p1cf = CardFilter.from("");
                this.p1rectsearchmenu = new Rect(outerRect.x, sellrect.y + sellrect.height + num, (float)Screen.width / 2, this.menueheight);
                this.p1searchrect = new Rect(p1rectsearchmenu.x + num+2, p1rectsearchmenu.y + num + 2, sellrect.width / 2, p1rectsearchmenu.height - 2f * num - 4);
                this.p1growthrect = new Rect(p1searchrect.x + p1searchrect.width + 3, p1rectsearchmenu.y + num + 2, p1rectsearchmenu.height - 2f * num - 4, p1rectsearchmenu.height - 2f * num - 4);
                this.p1orderrect = new Rect(p1growthrect.x + p1growthrect.width + 3, p1rectsearchmenu.y + num + 2, p1rectsearchmenu.height - 2f * num - 4, p1rectsearchmenu.height - 2f * num - 4);
                this.p1energyrect = new Rect(p1orderrect.x + p1orderrect.width + 3, p1rectsearchmenu.y + num + 2, p1rectsearchmenu.height - 2f * num - 4, p1rectsearchmenu.height - 2f * num - 4);
                this.p1decayrect = new Rect(p1energyrect.x + p1energyrect.width + 3, p1rectsearchmenu.y + num + 2, p1rectsearchmenu.height - 2f * num - 4, p1rectsearchmenu.height - 2f * num - 4);
                this.p1commonrect = new Rect(p1decayrect.x + p1decayrect.width + 3, p1rectsearchmenu.y + num + 2, p1rectsearchmenu.height - 2f * num - 4, p1rectsearchmenu.height - 2f * num - 4);
                this.p1uncommonrect = new Rect(p1commonrect.x + p1commonrect.width + 3, p1rectsearchmenu.y + num + 2, p1rectsearchmenu.height - 2f * num - 4, p1rectsearchmenu.height - 2f * num - 4);
                this.p1rarerect = new Rect(p1uncommonrect.x + p1uncommonrect.width + 3, p1rectsearchmenu.y + num + 2, p1rectsearchmenu.height - 2f * num - 4, p1rectsearchmenu.height - 2f * num - 4);
                this.p1mt3rect = new Rect(p1rarerect.x + p1rarerect.width + 3, p1rectsearchmenu.y + num + 2, p1rectsearchmenu.height - 2f * num - 4, p1rectsearchmenu.height - 2f * num - 4);
                this.p1clearrect = new Rect(p1mt3rect.x + p1mt3rect.width + 3, p1rectsearchmenu.y + num + 2, p1rectsearchmenu.height - 2f * num - 4, p1rectsearchmenu.height - 2f * num - 4);
                this.p1rectsearchmenu.width = p1clearrect.x + p1clearrect.width + num +2 - p1rectsearchmenu.x;


                this.orgicardsPlayer1.Clear();

            }

            if (info.target is Store && info.targetMethod.Equals("handleMessage"))// update orginal cards!
            {

                Message msg = (Message)info.arguments[0];
                if (msg is LibraryViewMessage)
                {
                    if (!(((LibraryViewMessage)msg).profileId==123))
                    {
                        this.selfsearchstring = "";
                        p1growthbool = true;
                        p1orderbool = true;
                        p1energybool = true;
                        p1decaybool = true;
                        p1commonbool = true;
                        p1uncommonbool = true;
                        p1rarebool = true;
                        p1mt3bool = false;
                        this.orgicardsPlayer1.Clear();
                        this.orgicardsPlayer1.AddRange(((LibraryViewMessage)msg).cards);
                        this.p1moddedlist.Clear();
                        this.p1moddedlist.AddRange(this.orgicardsPlayer1);
                    }
                }
            }

            if (info.target is Store && info.targetMethod.Equals("OnGUI"))//draw menu
            {
                float offset = 0f;
                if (sellFrame != null)
                {
                    float offX = (float)offxInfo.GetValue(sellFrame);
                    offset = offX;
                }
                if (true)
                {
                    sliderectsp1(offset);
                    //outerFrame1.Draw();
                    GUI.color = new Color(1f, 1f, 1f, 1f);
                    GUI.skin = this.chatButtonSkin;
                    GUI.Box(this.p1rectsearchmenu, string.Empty);

                    Color dblack = new Color(1f, 1f, 1f, 0.2f);
                    GUI.color = new Color(1f, 1f, 1f, 0.6f);
                    GUI.skin = this.chatButtonSkin;
                    GUI.Box(this.p1searchrect, string.Empty);
                    GUI.color = Color.white;
                    string selfcopy = this.selfsearchstring;
                    this.selfsearchstring = GUI.TextField(this.p1searchrect, this.selfsearchstring, this.chatLogStyle);
                    GUI.contentColor = Color.white;
                    GUI.color = Color.white;
                    if (!p1growthbool) { GUI.color = dblack; }
                    bool p1growthclick = GUI.Button(p1growthrect, growthres);
                    GUI.color = Color.white;
                    if (!p1orderbool) { GUI.color = dblack; }
                    bool p1orderclick = GUI.Button(p1orderrect, orderres);
                    GUI.color = Color.white;
                    if (!p1energybool) { GUI.color = dblack; }
                    bool p1energyclick = GUI.Button(p1energyrect, energyres);
                    GUI.color = Color.white;
                    if (!p1decaybool) { GUI.color = dblack; }
                    bool p1decayclick = GUI.Button(p1decayrect, decayres);
                    GUI.color = Color.white;
                    if (!p1commonbool) { GUI.color = dblack; }
                    GUI.contentColor = Color.gray;
                    bool p1commonclick = GUI.Button(p1commonrect, "C");
                    GUI.color = Color.white;
                    if (!p1uncommonbool) { GUI.color = dblack; }
                    GUI.contentColor = Color.white;
                    bool p1uncommonclick = GUI.Button(p1uncommonrect, "U");
                    GUI.color = Color.white;
                    if (!p1rarebool) { GUI.color = dblack; }
                    GUI.contentColor = Color.yellow;
                    bool p1rareclick = GUI.Button(p1rarerect, "R");
                    GUI.contentColor = Color.white;
                    GUI.color = Color.white;
                    if (!p1mt3bool) { GUI.color = dblack; }
                    bool p1mt3click = GUI.Button(p1mt3rect, ">3");
                    GUI.color = Color.white;
                    GUI.contentColor = Color.red;
                    bool p1closeclick = GUI.Button(p1clearrect, "X");

                    if (p1growthclick) { p1growthbool = !p1growthbool; };
                    if (p1orderclick) { p1orderbool = !p1orderbool; }
                    if (p1energyclick) { p1energybool = !p1energybool; };
                    if (p1decayclick) { p1decaybool = !p1decaybool; }
                    if (p1commonclick) { p1commonbool = !p1commonbool; };
                    if (p1uncommonclick) { p1uncommonbool = !p1uncommonbool; }
                    if (p1rareclick) { p1rarebool = !p1rarebool; };
                    if (p1mt3click) { p1mt3bool = !p1mt3bool; }
                    if (p1closeclick)
                    {
                        this.selfsearchstring = "";
                        this.p1cf = CardFilter.from("");
                        p1growthbool = true;
                        p1orderbool = true;
                        p1energybool = true;
                        p1decaybool = true;
                        p1commonbool = true;
                        p1uncommonbool = true;
                        p1rarebool = true;
                        p1mt3bool = false;
                    }

                    //clear p1moddedlist only if necessary
                    if (selfcopy != this.selfsearchstring || p1closeclick || (p1growthclick && p1growthbool) || (p1orderclick && p1orderbool) || (p1energyclick && p1energybool) || (p1decayclick && p1decaybool) || (p1commonclick && p1commonbool) || (p1uncommonclick && p1uncommonbool) || (p1rareclick && p1rarebool) || p1mt3click)
                    {
                        //Console.WriteLine("delete dings####");
                        this.p1moddedlist.Clear();
                        this.p1moddedlist.AddRange(this.orgicardsPlayer1);
                        string[] res = { "", "", "", "" };
                        if (p1decaybool) { res[0] = "decay"; };
                        if (p1energybool) { res[1] = "energy"; };
                        if (p1growthbool) { res[2] = "growth"; };
                        if (p1orderbool) { res[3] = "order"; };
                        int[] rare = { -1, -1, -1 };
                        if (p1rarebool) { rare[2] = 2; };
                        if (p1uncommonbool) { rare[1] = 1; };
                        if (p1commonbool) { rare[0] = 0; };
                        if (this.p1mt3bool)
                        {
                            this.searchmorethan3();
                        }
                        //this.onlytradeableself();
                        this.p1cf = CardFilter.from("");
                        if (this.selfsearchstring != "")
                        {
                            this.p1cf = CardFilter.from(this.selfsearchstring);
                            this.containsname(this.selfsearchstring);
                        }
                        this.searchforownenergy(res);
                        this.searchforownrarity(rare);
                        this.updatestoreself();

                    }
                    else
                    {

                        if (selfcopy != this.selfsearchstring)
                        {
                            this.p1cf = CardFilter.from("");
                            if (this.selfsearchstring != "")
                            {
                                this.p1cf = CardFilter.from(this.selfsearchstring);
                                this.containsname(this.selfsearchstring);
                                this.updatestoreself();
                            }


                        }
                        if (p1growthclick || p1orderclick || p1energyclick || p1decayclick)
                        {
                            string[] res = { "", "", "", "" };
                            if (p1decaybool) { res[0] = "decay"; };
                            if (p1energybool) { res[1] = "energy"; };
                            if (p1growthbool) { res[2] = "growth"; };
                            if (p1orderbool) { res[3] = "order"; };
                            this.searchforownenergy(res);
                            this.updatestoreself();

                        }
                        if (p1commonclick || p1uncommonclick || p1rareclick)
                        {

                            int[] rare = { -1, -1, -1 };
                            if (p1rarebool) { rare[2] = 2; };
                            if (p1uncommonbool) { rare[1] = 1; };
                            if (p1commonbool) { rare[0] = 0; };
                            this.searchforownrarity(rare);
                            this.updatestoreself();
                        }

                    }
                    sliderectsp1(-1*offset);
                }
                      
                    
                }
            



            if (info.target is TradeSystem && info.targetMethod.Equals("Init"))//update rects
            {
                Rect searchFieldRect= new Rect(-10,-10,1,1);
                //Console.WriteLine("INIT ");
                this.menueheight = (float)Screen.width / 25.6f;
                Rect outerArea1 = (Rect)outerArea1field.GetValue(info.target);
                Rect outerArea2 = (Rect)outerArea2field.GetValue(info.target);
                Rect innerArea = (Rect)innerAreafield.GetValue(info.target);
                Rect rectInvP1 = (Rect)rectInvP1field.GetValue(info.target);
                Rect rectOfferP1 = (Rect)rectOfferP1field.GetValue(info.target);
                Rect rectInvP2 = (Rect)rectInvP2field.GetValue(info.target);
                Rect rectOfferP2 = (Rect)rectOfferP2field.GetValue(info.target);
                outerArea1.height = outerArea1.height - this.menueheight;
                outerArea2.height = outerArea2.height - this.menueheight;
                innerArea.height = innerArea.height - this.menueheight;
                rectInvP1.height = rectInvP1.height - this.menueheight;
                rectOfferP1.height = rectOfferP1.height - this.menueheight;
                rectInvP2.height = rectInvP2.height - this.menueheight;
                rectOfferP2.height = rectOfferP2.height - this.menueheight;
                this.p1cf = CardFilter.from("");
                this.p2cf = CardFilter.from("");
                

                outerArea1field.SetValue(info.target, outerArea1);
                outerArea2field.SetValue(info.target, outerArea2);
                innerAreafield.SetValue(info.target, innerArea);
                rectInvP1field.SetValue(info.target, rectInvP1);
                rectOfferP1field.SetValue(info.target, rectOfferP1);
                rectInvP2field.SetValue(info.target, rectInvP2);
                rectOfferP2field.SetValue(info.target, rectOfferP2);


                CardListPopup clInventoryP1 = (CardListPopup)clInventoryP1field.GetValue(info.target);
                CardListPopup clOfferP1 = (CardListPopup)clOfferP1field.GetValue(info.target);
                CardListPopup clInventoryP2 = (CardListPopup)clInventoryP2field.GetValue(info.target);
                CardListPopup clOfferP2 = (CardListPopup)clOfferP2field.GetValue(info.target);
                
                
                float BOTTOM_MARGIN_EXTRA = (float)Screen.height * 0.047f;
                float num = 0.005f * (float)Screen.width;
                Vector4 margins = new Vector4(0f, 0f, 0f, 0f + BOTTOM_MARGIN_EXTRA);
                float num2 = BOTTOM_MARGIN_EXTRA - 0.01f * (float)Screen.height;

                //update clinventoryp1 (same calculation of the rect like in CardListPopup.Init(...))
                Rect outerRect = rectInvP1;
                Rect innerBGRect = new Rect(outerRect.x + margins.x, outerRect.y + margins.y, outerRect.width - (margins.x + margins.z), outerRect.height - (margins.y + margins.w));
                Rect innerRect = new Rect(innerBGRect.x + num, innerBGRect.y + num, innerBGRect.width - 2f * num, innerBGRect.height - 2f * num);
                Rect buttonLeftRect = new Rect(innerRect.x + innerRect.width * 0.03f, innerBGRect.yMax + num2 * 0.28f, innerRect.width * 0.45f, num2);
                Rect buttonRightRect = new Rect(innerRect.xMax - innerRect.width * 0.48f, innerBGRect.yMax + num2 * 0.28f, innerRect.width * 0.45f, num2);

                outerRectfield.SetValue(clInventoryP1, outerRect);
                innerBGRectfield.SetValue(clInventoryP1, innerBGRect);
                innerRectfield.SetValue(clInventoryP1, innerRect);
                buttonLeftRectfield.SetValue(clInventoryP1, buttonLeftRect);
                buttonRightRectfield.SetValue(clInventoryP1, buttonRightRect);
                searchFieldRectfield.SetValue(clInventoryP1, searchFieldRect);

                //update clinventoryp2
                outerRect = rectInvP2;
                innerBGRect = new Rect(outerRect.x + margins.x, outerRect.y + margins.y, outerRect.width - (margins.x + margins.z), outerRect.height - (margins.y + margins.w));
                innerRect = new Rect(innerBGRect.x + num, innerBGRect.y + num, innerBGRect.width - 2f * num, innerBGRect.height - 2f * num);
                buttonLeftRect = new Rect(innerRect.x + innerRect.width * 0.03f, innerBGRect.yMax + num2 * 0.28f, innerRect.width * 0.45f, num2);
                buttonRightRect = new Rect(innerRect.xMax - innerRect.width * 0.48f, innerBGRect.yMax + num2 * 0.28f, innerRect.width * 0.45f, num2);

                outerRectfield.SetValue(clInventoryP2, outerRect);
                innerBGRectfield.SetValue(clInventoryP2, innerBGRect);
                innerRectfield.SetValue(clInventoryP2, innerRect);
                buttonLeftRectfield.SetValue(clInventoryP2, buttonLeftRect);
                buttonRightRectfield.SetValue(clInventoryP2, buttonRightRect);
                searchFieldRectfield.SetValue(clInventoryP2, searchFieldRect);

                //update clOfferP1
                outerRect = rectOfferP1;
                innerBGRect = new Rect(outerRect.x + margins.x, outerRect.y + margins.y, outerRect.width - (margins.x + margins.z), outerRect.height - (margins.y + margins.w));
                innerRect = new Rect(innerBGRect.x + num, innerBGRect.y + num, innerBGRect.width - 2f * num, innerBGRect.height - 2f * num);
                buttonLeftRect = new Rect(innerRect.x + innerRect.width * 0.03f, innerBGRect.yMax + num2 * 0.28f, innerRect.width * 0.45f, num2);
                buttonRightRect = new Rect(innerRect.xMax - innerRect.width * 0.48f, innerBGRect.yMax + num2 * 0.28f, innerRect.width * 0.45f, num2);

                outerRectfield.SetValue(clOfferP1, outerRect);
                innerBGRectfield.SetValue(clOfferP1, innerBGRect);
                innerRectfield.SetValue(clOfferP1, innerRect);
                buttonLeftRectfield.SetValue(clOfferP1, buttonLeftRect);
                buttonRightRectfield.SetValue(clOfferP1, buttonRightRect);
                searchFieldRectfield.SetValue(clOfferP1, searchFieldRect);

                //update clOfferP2
                outerRect = rectOfferP2;
                innerBGRect = new Rect(outerRect.x + margins.x, outerRect.y + margins.y, outerRect.width - (margins.x + margins.z), outerRect.height - (margins.y + margins.w));
                innerRect = new Rect(innerBGRect.x + num, innerBGRect.y + num, innerBGRect.width - 2f * num, innerBGRect.height - 2f * num);
                buttonLeftRect = new Rect(innerRect.x + innerRect.width * 0.03f, innerBGRect.yMax + num2 * 0.28f, innerRect.width * 0.45f, num2);
                buttonRightRect = new Rect(innerRect.xMax - innerRect.width * 0.48f, innerBGRect.yMax + num2 * 0.28f, innerRect.width * 0.45f, num2);

                outerRectfield.SetValue(clOfferP2, outerRect);
                innerBGRectfield.SetValue(clOfferP2, innerBGRect);
                innerRectfield.SetValue(clOfferP2, innerRect);
                buttonLeftRectfield.SetValue(clOfferP2, buttonLeftRect);
                buttonRightRectfield.SetValue(clOfferP2, buttonRightRect);
                searchFieldRectfield.SetValue(clOfferP2, searchFieldRect);

                this.p1rectsearchmenu = new Rect(outerArea1.x, outerArea1.y + outerArea1.height, outerArea1.width, this.menueheight);
                this.p2rectsearchmenu = new Rect(outerArea2.x, outerArea2.y + outerArea2.height, outerArea2.width, this.menueheight);

                this.p1searchrect = new Rect(p1rectsearchmenu.x + 5*num, p1rectsearchmenu.y + num+2, outerArea1.width/3, p1rectsearchmenu.height -  2f*num-4);
                this.p2searchrect = new Rect(p2rectsearchmenu.x + 5*num, p2rectsearchmenu.y + num+2, outerArea2.width / 3, p2rectsearchmenu.height - 2f*num-4);

                this.outerFrame1 = new ScrollsFrame(this.p1rectsearchmenu).AddNinePatch(ScrollsFrame.Border.DARK_CURVED, NinePatch.Patches.TOP | NinePatch.Patches.TOP_RIGHT | NinePatch.Patches.CENTER | NinePatch.Patches.RIGHT | NinePatch.Patches.BOTTOM | NinePatch.Patches.BOTTOM_RIGHT).AddNinePatch(ScrollsFrame.Border.DARK_SHARP, NinePatch.Patches.TOP_LEFT | NinePatch.Patches.LEFT | NinePatch.Patches.CENTER | NinePatch.Patches.BOTTOM_LEFT);
                this.outerFrame2 = new ScrollsFrame(this.p2rectsearchmenu).AddNinePatch(ScrollsFrame.Border.DARK_CURVED, NinePatch.Patches.TOP_LEFT | NinePatch.Patches.TOP | NinePatch.Patches.LEFT | NinePatch.Patches.CENTER | NinePatch.Patches.BOTTOM_LEFT | NinePatch.Patches.BOTTOM).AddNinePatch(ScrollsFrame.Border.DARK_SHARP, NinePatch.Patches.TOP_RIGHT | NinePatch.Patches.CENTER | NinePatch.Patches.RIGHT | NinePatch.Patches.BOTTOM_RIGHT);


                this.p1growthrect = new Rect(p1searchrect.x + p1searchrect.width + 3, p1rectsearchmenu.y + num + 2, p1rectsearchmenu.height - 2f * num - 4, p1rectsearchmenu.height - 2f * num - 4);
                this.p1orderrect = new Rect(p1growthrect.x + p1growthrect.width + 3, p1rectsearchmenu.y + num + 2, p1rectsearchmenu.height - 2f * num - 4, p1rectsearchmenu.height - 2f * num - 4);
                this.p1energyrect = new Rect(p1orderrect.x + p1orderrect.width + 3, p1rectsearchmenu.y + num + 2, p1rectsearchmenu.height - 2f * num - 4, p1rectsearchmenu.height - 2f * num - 4);
                this.p1decayrect = new Rect(p1energyrect.x + p1energyrect.width + 3, p1rectsearchmenu.y + num + 2, p1rectsearchmenu.height - 2f * num - 4, p1rectsearchmenu.height - 2f * num - 4);
                this.p1commonrect = new Rect(p1decayrect.x + p1decayrect.width + 3, p1rectsearchmenu.y + num + 2, p1rectsearchmenu.height - 2f * num - 4, p1rectsearchmenu.height - 2f * num - 4);
                this.p1uncommonrect = new Rect(p1commonrect.x + p1commonrect.width + 3, p1rectsearchmenu.y + num + 2, p1rectsearchmenu.height - 2f * num - 4, p1rectsearchmenu.height - 2f * num - 4);
                this.p1rarerect = new Rect(p1uncommonrect.x + p1uncommonrect.width + 3, p1rectsearchmenu.y + num + 2, p1rectsearchmenu.height - 2f * num - 4, p1rectsearchmenu.height - 2f * num - 4);
                this.p1mt3rect = new Rect(p1rarerect.x + p1rarerect.width + 3, p1rectsearchmenu.y + num + 2, p1rectsearchmenu.height - 2f * num - 4, p1rectsearchmenu.height - 2f * num - 4);
                this.p1clearrect = new Rect(p1rectsearchmenu.x + p1rectsearchmenu.width - p1rectsearchmenu.height-num, p1rectsearchmenu.y + num + 2, p1rectsearchmenu.height - 2f * num - 4, p1rectsearchmenu.height - 2f * num - 4);

                this.p2growthrect = new Rect(p2searchrect.x + p2searchrect.width + 3, p2rectsearchmenu.y + num + 2, p2rectsearchmenu.height - 2f * num - 4, p2rectsearchmenu.height - 2f * num - 4);
                this.p2orderrect = new Rect(p2growthrect.x + p2growthrect.width + 3, p2rectsearchmenu.y + num + 2, p2rectsearchmenu.height - 2f * num - 4, p2rectsearchmenu.height - 2f * num - 4);
                this.p2energyrect = new Rect(p2orderrect.x + p2orderrect.width + 3, p2rectsearchmenu.y + num + 2, p2rectsearchmenu.height - 2f * num - 4, p2rectsearchmenu.height - 2f * num - 4);
                this.p2decayrect = new Rect(p2energyrect.x + p2energyrect.width + 3, p2rectsearchmenu.y + num + 2, p2rectsearchmenu.height - 2f * num - 4, p2rectsearchmenu.height - 2f * num - 4);
                this.p2commonrect = new Rect(p2decayrect.x + p2decayrect.width + 3, p2rectsearchmenu.y + num + 2, p2rectsearchmenu.height - 2f * num - 4, p2rectsearchmenu.height - 2f * num - 4);
                this.p2uncommonrect = new Rect(p2commonrect.x + p2commonrect.width + 3, p2rectsearchmenu.y + num + 2, p2rectsearchmenu.height - 2f * num - 4, p2rectsearchmenu.height - 2f * num - 4);
                this.p2rarerect = new Rect(p2uncommonrect.x + p2uncommonrect.width + 3, p2rectsearchmenu.y + num + 2, p2rectsearchmenu.height - 2f * num - 4, p2rectsearchmenu.height - 2f * num - 4);
                this.p2mt3rect = new Rect(p2rarerect.x + p2rarerect.width + 3, p2rectsearchmenu.y + num + 2, p2rectsearchmenu.height - 2f * num - 4, p2rectsearchmenu.height - 2f * num - 4);
                this.p2clearrect = new Rect(p2rectsearchmenu.x + p2rectsearchmenu.width - p2rectsearchmenu.height-num, p2rectsearchmenu.y + num + 2, p2rectsearchmenu.height - 2f * num - 4, p2rectsearchmenu.height - 2f * num - 4);
                


            }

            if (info.target is TradeSystem && info.targetMethod.Equals("OnGUI"))//draw menu
            {
                //int state = (int)typeof(TradeSystem).GetField("state", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(info.target);
                if (trading)
                {
                    outerFrame1.Draw();
                    outerFrame2.Draw();
                    Color dblack = new Color(1f, 1f, 1f, 0.2f);
                    GUI.color = new Color(1f, 1f, 1f, 0.6f);
                    GUI.skin = this.chatButtonSkin;
                    GUI.Box(this.p1searchrect, string.Empty);
                    GUI.Box(this.p2searchrect, string.Empty);
                    GUI.color = Color.white;
                    string selfcopy = this.selfsearchstring;
                    string oppocopy = this.opposearchstring;
                    this.selfsearchstring = GUI.TextField(this.p1searchrect, this.selfsearchstring, this.chatLogStyle);
                    this.opposearchstring = GUI.TextField(this.p2searchrect, this.opposearchstring, this.chatLogStyle);

                    GUI.contentColor = Color.white;
                    GUI.color = Color.white;
                    if (!p1growthbool) { GUI.color = dblack; }
                    bool p1growthclick = GUI.Button(p1growthrect, growthres);
                    GUI.color = Color.white;
                    if (!p1orderbool) { GUI.color = dblack; }
                    bool p1orderclick = GUI.Button(p1orderrect, orderres);
                    GUI.color = Color.white;
                    if (!p1energybool) { GUI.color = dblack; }
                    bool p1energyclick = GUI.Button(p1energyrect, energyres);
                    GUI.color = Color.white;
                    if (!p1decaybool) { GUI.color = dblack; }
                    bool p1decayclick = GUI.Button(p1decayrect, decayres);
                    GUI.color = Color.white;
                    if (!p1commonbool) { GUI.color = dblack; }
                    GUI.contentColor = Color.gray;
                    bool p1commonclick = GUI.Button(p1commonrect,"C");
                    GUI.color = Color.white;
                    if (!p1uncommonbool) { GUI.color = dblack; }
                    GUI.contentColor = Color.white;
                    bool p1uncommonclick = GUI.Button(p1uncommonrect, "U");
                    GUI.color = Color.white;
                    if (!p1rarebool) { GUI.color = dblack; }
                    GUI.contentColor = Color.yellow;
                    bool p1rareclick = GUI.Button(p1rarerect, "R");
                    GUI.contentColor = Color.white;
                    GUI.color = Color.white;
                    if (!p1mt3bool) { GUI.color = dblack; }
                    bool p1mt3click = GUI.Button(p1mt3rect, ">3");
                    GUI.color = Color.white;
                    GUI.contentColor = Color.red;
                    bool p1closeclick = GUI.Button(p1clearrect, "X");

                    if (p1growthclick) { p1growthbool = !p1growthbool; };
                    if (p1orderclick) { p1orderbool = !p1orderbool; }
                    if (p1energyclick) { p1energybool = !p1energybool; };
                    if (p1decayclick) { p1decaybool = !p1decaybool; }
                    if (p1commonclick) { p1commonbool = !p1commonbool; };
                    if (p1uncommonclick) { p1uncommonbool = !p1uncommonbool; }
                    if (p1rareclick) { p1rarebool = !p1rarebool; };
                    if (p1mt3click) { p1mt3bool = !p1mt3bool; }
                    if (p1closeclick) 
                    {
                        this.selfsearchstring = "";
                        this.p1cf = CardFilter.from("");
                        p1growthbool = true;
                        p1orderbool = true;
                        p1energybool = true;
                        p1decaybool = true;
                        p1commonbool = true;
                        p1uncommonbool = true;
                        p1rarebool = true;
                        p1mt3bool = false;
                    }

                    //clear p1moddedlist only if necessary
                    if (selfcopy != this.selfsearchstring || p1closeclick || (p1growthclick && p1growthbool) || (p1orderclick && p1orderbool) || (p1energyclick && p1energybool) || (p1decayclick && p1decaybool) || (p1commonclick && p1commonbool) || (p1uncommonclick && p1uncommonbool) || (p1rareclick && p1rarebool) || p1mt3click)
                    {
                        //Console.WriteLine("delete dings####");
                        this.p1moddedlist.Clear();
                        this.p1moddedlist.AddRange(this.orgicardsPlayer1);
                        string[] res = { "", "", "", "" };
                        if (p1decaybool) { res[0] = "decay"; };
                        if (p1energybool) { res[1] = "energy"; };
                        if (p1growthbool) { res[2] = "growth"; };
                        if (p1orderbool) { res[3] = "order"; };
                        int[] rare = { -1, -1, -1 };
                        if (p1rarebool) { rare[2] = 2; };
                        if (p1uncommonbool) { rare[1] = 1; };
                        if (p1commonbool) { rare[0] = 0; };
                        if (this.p1mt3bool)
                        {
                            this.searchmorethan3();
                        }
                        this.onlytradeableself();
                        this.p1cf = CardFilter.from("");
                        if (this.selfsearchstring != "")
                        {
                            this.p1cf = CardFilter.from(this.selfsearchstring);
                            this.containsname(this.selfsearchstring);
                        }
                        this.searchforownenergy(res);
                        this.searchforownrarity(rare);
                        this.updatetradeself();

                    }
                    else
                    {

                        if (selfcopy != this.selfsearchstring )
                        {
                            this.p1cf = CardFilter.from("");
                            if (this.selfsearchstring != "")
                            {
                                this.p1cf = CardFilter.from(this.selfsearchstring);
                                this.containsname(this.selfsearchstring);
                                this.updatetradeself();
                            }
                            

                        }
                        if (p1growthclick || p1orderclick || p1energyclick || p1decayclick )
                        {
                            string[] res = { "", "", "", "" };
                            if (p1decaybool) { res[0] = "decay"; };
                            if (p1energybool) { res[1] = "energy"; };
                            if (p1growthbool) { res[2] = "growth"; };
                            if (p1orderbool) { res[3] = "order"; };
                            this.searchforownenergy(res);
                            this.updatetradeself();

                        }
                        if (p1commonclick || p1uncommonclick || p1rareclick)
                        {

                            int[] rare = { -1, -1, -1 };
                            if (p1rarebool) { rare[2] = 2; };
                            if (p1uncommonbool) { rare[1] = 1; };
                            if (p1commonbool) { rare[0] = 0; };
                            this.searchforownrarity(rare);
                            this.updatetradeself();
                        }
                        
                    }

                    GUI.contentColor = Color.white;
                    GUI.color = Color.white;
                    if (!p2growthbool) { GUI.color = dblack; }
                    bool p2growthclick = GUI.Button(p2growthrect, growthres );
                    GUI.color = Color.white;
                    if (!p2orderbool) { GUI.color = dblack; }
                    bool p2orderclick = GUI.Button(p2orderrect, orderres);
                    GUI.color = Color.white;
                    if (!p2energybool) { GUI.color = dblack; }
                    bool p2energyclick = GUI.Button(p2energyrect, energyres);
                    GUI.color = Color.white;
                    if (!p2decaybool) { GUI.color = dblack; }
                    bool p2decayclick = GUI.Button(p2decayrect, decayres);
                    GUI.color = Color.white;
                    if (!p2commonbool) { GUI.color = dblack; }
                    GUI.contentColor = Color.gray;
                    bool p2commonclick = GUI.Button(p2commonrect, "C");
                    GUI.color = Color.white;
                    if (!p2uncommonbool) { GUI.color = dblack; }
                    GUI.contentColor = Color.white;
                    bool p2uncommonclick = GUI.Button(p2uncommonrect, "U");
                    GUI.color = Color.white;
                    if (!p2rarebool) { GUI.color = dblack; }
                    GUI.contentColor = Color.yellow;
                    bool p2rareclick = GUI.Button(p2rarerect, "R");
                    GUI.contentColor = Color.white;
                    GUI.color = Color.white;
                    if (!p2mt3bool) { GUI.color = dblack; }
                    bool p2mt3click = GUI.Button(p2mt3rect, ">3");
                    GUI.color = Color.white;
                    GUI.contentColor = Color.red;
                    bool p2closeclick = GUI.Button(p2clearrect, "X");

                    if (p2growthclick) { p2growthbool = !p2growthbool; };
                    if (p2orderclick) { p2orderbool = !p2orderbool; }
                    if (p2energyclick) { p2energybool = !p2energybool; };
                    if (p2decayclick) { p2decaybool = !p2decaybool; }
                    if (p2commonclick) { p2commonbool = !p2commonbool; };
                    if (p2uncommonclick) { p2uncommonbool = !p2uncommonbool; }
                    if (p2rareclick) { p2rarebool = !p2rarebool; };
                    if (p2mt3click) { p2mt3bool = !p2mt3bool; }
                    if (p2closeclick)
                    {
                        this.opposearchstring = "";
                        this.p2cf = CardFilter.from("");
                        p2growthbool = true;
                        p2orderbool = true;
                        p2energybool = true;
                        p2decaybool = true;
                        p2commonbool = true;
                        p2uncommonbool = true;
                        p2rarebool = true;
                        p2mt3bool = false;
                    }

                    //clear p1moddedlist only if necessary
                    if (oppocopy != this.opposearchstring || p2closeclick || (p2growthclick && p2growthbool) || (p2orderclick && p2orderbool) || (p2energyclick && p2energybool) || (p2decayclick && p2decaybool) || (p2commonclick && p2commonbool) || (p2uncommonclick && p2uncommonbool) || (p2rareclick && p2rarebool) || p2mt3click)
                    {
                        //Console.WriteLine("delete dings####");
                        this.p2moddedlist.Clear();
                        this.p2moddedlist.AddRange(this.orgicardsPlayer2);

                        string[] res = { "", "", "", "" };
                        if (p2decaybool) { res[0] = "decay"; };
                        if (p2energybool) { res[1] = "energy"; };
                        if (p2growthbool) { res[2] = "growth"; };
                        if (p2orderbool) { res[3] = "order"; };
                        int[] rare = { -1, -1, -1 };
                        if (p2rarebool) { rare[2] = 2; };
                        if (p2uncommonbool) { rare[1] = 1; };
                        if (p2commonbool) { rare[0] = 0; };

                        this.onlytradeableoppo();
                        this.p2cf = CardFilter.from("");
                        if (this.opposearchstring != "")
                        {
                            this.p2cf = CardFilter.from(this.opposearchstring);
                            this.containsopponentname(this.opposearchstring);
                        }
                        this.searchforoppoenergy(res);
                        this.searchforopporarity(rare);
                        if (this.p2mt3bool)
                        {
                            this.searchmorethan3oppo();
                        }

                        this.updatetradeoppo();

                    }
                    else
                    {

                        if (oppocopy != this.opposearchstring)
                        {
                            this.p2cf = CardFilter.from("");
                            if (this.opposearchstring != "")
                            {
                                this.p2cf = CardFilter.from(this.opposearchstring);
                                this.containsopponentname(this.opposearchstring);
                                this.updatetradeoppo();
                            }


                        }
                        if (p2growthclick || p2orderclick || p2energyclick || p2decayclick)
                        {
                            string[] res = { "", "", "", "" };
                            if (p2decaybool) { res[0] = "decay"; };
                            if (p2energybool) { res[1] = "energy"; };
                            if (p2growthbool) { res[2] = "growth"; };
                            if (p2orderbool) { res[3] = "order"; };
                            this.searchforoppoenergy(res);
                            this.updatetradeoppo();

                        }
                        if (p2commonclick || p2uncommonclick || p2rareclick)
                        {

                            int[] rare = { -1, -1, -1 };
                            if (p2rarebool) { rare[2] = 2; };
                            if (p2uncommonbool) { rare[1] = 1; };
                            if (p2commonbool) { rare[0] = 0; };
                            this.searchforopporarity(rare);
                            this.updatetradeoppo();
                        }

                    }

                    /*
                    if (oppocopy != this.opposearchstring || p2growthclick || p2orderclick || p2energyclick || p2decayclick || p2commonclick || p2uncommonclick || p2rareclick || p2mt3click || p2closeclick)
                    {
                        this.p2moddedlist.Clear();
                        this.p2moddedlist.AddRange(this.orgicardsPlayer2);

                        string[] res = { "", "", "", "" };
                        if (p2decaybool) { res[0] = "decay"; };
                        if (p2energybool) { res[1] = "energy"; };
                        if (p2growthbool) { res[2] = "growth"; };
                        if (p2orderbool) { res[3] = "order"; };
                        int[] rare = { -1, -1, -1 };
                        if (p2rarebool) { rare[2] = 2; };
                        if (p2uncommonbool) { rare[1] = 1; };
                        if (p2commonbool) { rare[0] = 0; };

                        this.onlytradeableoppo();
                        if (this.opposearchstring != "")
                        {
                            this.containsopponentname(this.opposearchstring);
                        }
                        this.searchforoppoenergy(res);
                        this.searchforopporarity(rare);
                        if (this.p2mt3bool)
                        {
                            this.searchmorethan3oppo();
                        }

                        this.updatetrade();

                    }*/
                }
            }

            if (info.target is Lobby && info.targetMethod.Equals("Start"))
            {
                //Console.WriteLine("startlobby");
                if (lby == null)
                {
                    lby = (Lobby)info.target;
                    lbyinfo = info;
                    this.p1cards = (List<Card>)cardsPlayer1field.GetValue(lbyinfo.target);
                    this.p2cards = (List<Card>)cardsPlayer2field.GetValue(lbyinfo.target);
                    anzupdates = 0;
                    this.searchedself = false;
                    this.searchedoppo = false;

                }


            }

            if (info.target is TradeSystem && info.targetMethod.Equals("SetTradeRoomName"))
            {
                this.traderoomname = (string)info.arguments[0];


            }


            if (info.target is TradeSystem && info.targetMethod.Equals("StartTrade"))
            {
                //Console.WriteLine("STARTTRAD2E");
                if (ts == null)
                {
                    trading = true;
                    ts = (TradeSystem)info.target;
                    this.p1moddedlist.Clear();
                    this.p2moddedlist.Clear();
                    this.orginalp1name = (string)info.arguments[2];
                    this.orginalp2name = (string)info.arguments[3];
                    this.orginalint = (int)info.arguments[4];
                    this.selfsearchstring = "";
                    this.opposearchstring = "";
                    

                }


            }

            if (info.target is TradeSystem && info.targetMethod.Equals("UpdateView"))
            {
                //Console.WriteLine("updateview"+anzupdates.ToString());
                if ((Boolean)info.arguments[0] == false && this.anzupdates<=1)
                {
                    

                    this.orgicardsPlayer1.Clear();
                    this.orgicardsPlayer2.Clear();
                    this.orgicardsPlayer1.AddRange(p1cards);
                    this.orgicardsPlayer2.AddRange(p2cards);
                    this.p1moddedlist.Clear();
                    this.p2moddedlist.Clear();
                    this.p1moddedlist.AddRange(this.orgicardsPlayer1);
                    this.p2moddedlist.AddRange(this.orgicardsPlayer2);
                    
                    //Console.WriteLine("cards");
                    //foreach (Card c in this.orgicardsPlayer1) { Console.WriteLine(c.getName()); };
                    //foreach (Card c in this.orgicardsPlayer2) { Console.WriteLine(c.getName()); };


                    //Rect outerArea1 = (Rect)typeof(Lobby).GetField("outerArea1", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(lbyinfo.target);

                    //Console.WriteLine("outer area" + outerArea1.height);


                    if (anzupdates == 1) // only show at the second time (first time you get own cards, second time you get opponent cards)
                    {
                        this.onlytradeable();
                        this.updatetrade();
                    }
                    
                }
                anzupdates++;
                //collect tradeview changes:
                if ((Boolean)info.arguments[0] == true)
                {
                    this.player1 = (TradeInfo)info.arguments[1];
                    this.player2 = (TradeInfo)info.arguments[2];
                    this.updatetrade();
                }
            }

            if (info.target is TradeSystem && info.targetMethod.Equals("CloseTrade"))
            {
                ts = null;
                lby = null;
                player1 = new TradeInfo();
                player2 = new TradeInfo();
                trading = false;
                this.traderoomname = "";

            }




            return;
        }
Exemplo n.º 18
0
        protected override BaseSerializer PerformAction(ClientConnection conn, BaseSerializer requestData)
        {
            RequestSerializer  data = (RequestSerializer)requestData;
            ResponseSerializer resp = (ResponseSerializer)InitializeResponseSerializer();

            resp.Status = "OK";

            Lobby lobby = (Lobby)conn.Session.Get("joined-lobby");
            Match game  = lobby.Game;

            if (lobby.LobbyState != LobbyState.IN_GAME)
            {
                data.AddError(null, "INVALID_LOBBY_STATE", "Nie można wyłożyć karty w tym stanie lobby");
                data.ThrowException();
            }

            if (game.GameState != GameState.PLAYING)
            {
                data.AddError(null, "INVALID_GAME_STATE", "Gra nie jest w poprawnym stanie do tej akcji");
                data.ThrowException();
            }

            var username = conn.Session.Get <string>("username");

            Console.WriteLine(username + "> Card attempt: " + data.CardOwnerPosition + " " + data.Figure + " " + ((CardColor)data.Color).ToString());
            if (!conn.Session.Has("player"))
            {
                data.AddError(null, "INVALID_USER", "Podany użytkownik nie jest uczestnikiem rozgrywki");
                data.ThrowException();
            }
            var player    = conn.Session.Get <Player>("player");
            var cardOwner = game.GetPlayerAt((PlayerTag)data.CardOwnerPosition);

            // Inny gracz niz my (gracz musi byc dziadkiem)
            if (player != game.GetPlayerAt((PlayerTag)data.CardOwnerPosition))
            {
                if (player.Tag != game.CurrentBidding.Declarer)
                {
                    data.AddError(null, "INVALID_HAND", "Nie można wyłożyć karty z ręki tego gracza");
                    data.ThrowException();
                }

                if (((int)player.Tag + 2) % 4 == (int)game.CurrentBidding.Declarer)
                {
                    // Próbujemy wyłożyć kartę kogoś innego niż dziadka
                    data.AddError(null, "INVALID_HAND", "Nie można wyłożyć karty jako dziadek");
                    data.ThrowException();
                }
            }
            else
            {
                if (((int)player.Tag + 2) % 4 == (int)game.CurrentBidding.Declarer)
                {
                    // Jesteśmy dziadkiem
                    data.AddError(null, "INVALID_HAND", "Nie można wyłożyć karty jako dziadek");
                    data.ThrowException();
                }
            }

            // czy gracz ma taką kartę na ręce
            bool cardFound = false;
            Card card      = null;

            for (int i = 0; i < cardOwner.Hand.Length; i++)
            {
                if (cardOwner.Hand[i].Color == (CardColor)data.Color && cardOwner.Hand[i].Figure == (CardFigure)data.Figure)
                {
                    cardFound = true;
                    card      = cardOwner.Hand[i];
                    break;
                }
            }

            // gracz nie ma takiej karty na ręce
            if (!cardFound)
            {
                data.AddError(null, "INVALID_CARD", "Gracz nie posiada takiej karty na ręce");
                data.ThrowException();
            }

            bool canPlayerPutCard = game.CheckNextCard(cardOwner.Tag, card.Color, card.Figure);

            // gracz nie może wyłożyć tej karty
            if (!canPlayerPutCard)
            {
                data.AddError(null, "INVALID_CARD", "Nie można wyłożyć tej karty");
                data.ThrowException();
            }

            game.NextCard((PlayerTag)data.CardOwnerPosition, card.Color, card.Figure);

            Console.WriteLine(username + "> Card: " + data.CardOwnerPosition + " " + (int)card.Figure + " " + card.Color.ToString());

            var broadcastData = new PutCardSignalSerializer()
            {
                Signal        = PutCardSignalSerializer.SIGNAL_USER_PUT_CARD,
                Username      = username,
                OwnerPosition = data.CardOwnerPosition,
                CardFigure    = data.Figure,
                CardColor     = data.Color
            };
            var broadcastWrapper = new StandardCommunicateSerializer()
            {
                CommunicateType = StandardCommunicateSerializer.TYPE_LOBBY_SIGNAL,
                Data            = broadcastData.GetApiObject()
            };

            lobby.Broadcast(broadcastWrapper.GetApiObject());

            if (game.GameState == GameState.BIDDING)
            {
                var bData = new LobbySignalGameStartedNextBiddingSerializer()
                {
                    Signal = LobbySignalGameStartedNextBiddingSerializer.SIGNAL_GAME_STARTED_NEXT_BIDDING,

                    PointsNSAboveLine = game.PointsNS[1],
                    PointsNSBelowLine = game.PointsNS[0],
                    PointsWEAboveLine = game.PointsWE[1],
                    PointsWEBelowLine = game.PointsWE[0],

                    RoundsNS = game.RoundsNS,
                    RoundsWE = game.RoundsWE
                };
                var bWrapper = new StandardCommunicateSerializer()
                {
                    CommunicateType = StandardCommunicateSerializer.TYPE_LOBBY_SIGNAL,
                    Data            = bData.GetApiObject()
                };
                lobby.Broadcast(bWrapper.GetApiObject());
            }
            else if (game.GameState == GameState.GAME_FINISHED)
            {
                var bData = new LobbySignalGameFinishedSerializer()
                {
                    Signal   = LobbySignalGameFinishedSerializer.SIGNAL_GAME_FINISHED,
                    Winner   = (game.RoundsNS == 2) ? (short)0 : (short)1,
                    PointsNS = game.PointsNS[0] + game.PointsNS[1],
                    PointsWE = game.PointsWE[0] + game.PointsWE[1],
                    RoundsNS = game.RoundsNS,
                    RoundsWE = game.RoundsWE
                };
                var bWrapper = new StandardCommunicateSerializer()
                {
                    CommunicateType = StandardCommunicateSerializer.TYPE_LOBBY_SIGNAL,
                    Data            = bData.GetApiObject()
                };
                lobby.Broadcast(bWrapper.GetApiObject());
            }

            resp.CardFigure    = (int)card.Figure;
            resp.CardColor     = (int)card.Color;
            resp.OwnerPosition = (int)data.CardOwnerPosition;
            return(resp);
        }
Exemplo n.º 19
0
        public void AddPlayer_NullPlayerShouldThrowException()
        {
            var lobby = new Lobby();

            Assert.Throws <ArgumentNullException>(() => lobby.AddPlayer(null));
        }
Exemplo n.º 20
0
        void Host_can_create_a_new_lobby(string gameName, string hostName, Guid hostId, Guid lobbyId, Guid gameId, Lobby lobby)
        {
            "Given a game name, id and host id"
            .Given(() => { });

            "And a lobby id"
            .And(() => lobbyId = new Guid("8e17de3f-7833-47a6-8f92-cf220cf953e2"));

            "And a game id"
            .And(() => gameId = new Guid("8e17de3f-7833-47a6-8f92-cf220cf953e2"));

            "And a host"
            .And(() => hostId = new Guid("8e17de3f-7833-47a6-8f92-cf220cf953e2"));

            "When we create a lobby"
            .When(() =>
            {
                lobby = new Lobby(lobbyId, gameId, gameName, hostId, hostName);
            });

            "A lobby should be created with a game name and host"
            .Then(() =>
            {
                lobby.ShouldNotBeNull();

                var @event = lobby.LastEvent <LobbyCreated>();
                @event.GameName.ShouldBe(gameName);
                @event.GameId.ShouldBe(gameId);
                @event.LobbyId.ShouldBe(lobbyId);
                @event.HostId.ShouldBe(hostId);
                @event.HostName.ShouldBe(hostName);
            });
        }
Exemplo n.º 21
0
 internal static Message JoinedRoom(Lobby lobby)
 {
     return(new Message("srv", "joinedroom=" + lobby.Identifier + "="));
 }
Exemplo n.º 22
0
 public RoomManager(Lobby lobby)
 {
     Rooms = new List <Room>();
     Owner = lobby;
 }
Exemplo n.º 23
0
    void UpdateLobbyInfo(ref Lobby outLobby)
    {
        outLobby.m_SteamID     = Sender.roomid;
        outLobby.m_Owner       = SteamMatchmaking.GetLobbyOwner(Sender.roomid);
        outLobby.m_Members     = new LobbyMembers[SteamMatchmaking.GetNumLobbyMembers(Sender.roomid)];
        outLobby.m_MemberLimit = SteamMatchmaking.GetLobbyMemberLimit(Sender.roomid);

        int nDataCount = SteamMatchmaking.GetLobbyDataCount(Sender.roomid);

        outLobby.m_Data = new LobbyMetaData[nDataCount];

        int Ucount = SteamMatchmaking.GetNumLobbyMembers(Sender.roomid);

        //ULS.CreateDs(Ucount);
        for (int i = 0; i < nDataCount; ++i)
        {
            bool lobby_data_ret = SteamMatchmaking.GetLobbyDataByIndex(Sender.roomid, i, out outLobby.m_Data[i].m_Key, Constants.k_nMaxLobbyKeyLength, out outLobby.m_Data[i].m_Value, Constants.k_cubChatMetadataMax);
            if (lobby_data_ret)
            {
                continue;
            }
            Debug.LogError("SteamMatchmaking.GetLobbyDataByIndex returned false.");
            continue;
        }
        //Notready.text = SteamMatchmaking.GetLobbyMemberData(Sender.roomid, SteamUser.GetSteamID(), "key_ready");
        int rc = 0;
        int gc = 0;

        for (int i = 0; i < outLobby.m_Members.Length; i++)
        {
            outLobby.m_Members[i].m_SteamID = SteamMatchmaking.GetLobbyMemberByIndex(Sender.roomid, i);
            //ULS.UDs[i].GetComponent<UserDetailScript>().HomeWork(outLobby.m_Members[i].m_SteamID);
            outLobby.m_Members[i].m_Data = new LobbyMetaData[1];
            LobbyMetaData lmd = new LobbyMetaData();
            lmd.m_Key   = "key_ready";
            lmd.m_Value = SteamMatchmaking.GetLobbyMemberData(Sender.roomid, outLobby.m_Members[i].m_SteamID, lmd.m_Key);
            if (lmd.m_Value == "READY")
            {
                rc++;
            }
            if (lmd.m_Value == "GREEN")
            {
                gc++;
            }
            outLobby.m_Members[i].m_Data[0] = lmd;
            //ULS.UDs[i].GetComponent<UserDetailScript>().Uready.text = lmd.m_Value;
            if (outLobby.m_Members[i].m_SteamID == SteamUser.GetSteamID())
            {
                MPControl(lmd.m_Value);
            }
        }
        if (rc == outLobby.m_MemberLimit)
        {
            GameStart(rc);
        }
        if (gc == outLobby.m_MemberLimit && SteamMatchmaking.GetLobbyOwner(Sender.roomid) == SteamUser.GetSteamID())
        {
            Debug.Log("All Players Green");
            Startbutton.interactable = true;
        }
    }
Exemplo n.º 24
0
 // Start a spectator session.
 //
 // cb - A BackrollSessionCallbacks structure which contains the callbacks you implement
 // to help Backroll.net synchronize the two games.  You must implement all functions in
 // cb, even if they do nothing but 'return true';
 //
 // game - The name of the game.  This is used internally for Backroll for logging purposes only.
 //
 // num_players - The number of players which will be in this game.  The number of players
 // per session is fixed.  If you need to change the number of players or any player
 // disconnects, you must start a new session.
 public static BackrollSession <T> StartSpectating <T>(Lobby lobby) where T : struct
 {
     throw new NotImplementedException();
 }
 public JoinRoomFailedScriptClient(TripleThunderOnlineClient Owner, Lobby ScreenOwner)
     : base(ScriptName)
 {
     this.Owner       = Owner;
     this.ScreenOwner = ScreenOwner;
 }
        protected override NetworkEntity CreateNetworkEntity(GameTime gameTime, GameSession gameSession, Lobby lobby, int clientIndex, int entityIndex)
        {
            NetworkPlayer networkPlayer = new NetworkPlayer();

            networkPlayer.LoadPlayer(playerType, gameSession, lobby, clientIndex, entityIndex);
            return(networkPlayer);
        }
Exemplo n.º 27
0
 private void OnGetLobbyDataAction(Lobby lobby)
 {
     roomPanelUIController.UpdateRoomPanel(lobby);
     playerListUIController.UpdatePlayerListPanel(lobby);
 }
Exemplo n.º 28
0
        public void User_leaving_pregame(Guid playerId, string playerName, Guid invitationToken, Lobby lobby)
        {
            "Given a game"
                .Given(() => lobby = new Lobby("Test"));

            "With a player"
                .And(() =>
                    {
                        playerId = new Guid("7d9b4a47-b0e3-4aa3-965a-631b5a535de5");
                        playerName = "Bryan";
                        invitationToken = new Guid("7d9b4a47-b0e3-4aa3-965a-631b5a535de5");
                        lobby.InvitePlayer(playerName, invitationToken);
                        lobby.AcceptInvitation(playerId, playerName, invitationToken);
                    });

            "When the player leaves the game"
                .And(() => lobby.LeaveGame(playerId));

            "Then the player is removed from the joined players"
                .Then(() => lobby.JoinedPlayers.ShouldNotContain(new KeyValuePair<Guid, string>(playerId, playerName)));
        }
Exemplo n.º 29
0
    void RequestLobbyList(Action onReceive)
    {
        WaitForResponse(RequestLobbyListPackage.factory.Id,
        x =>
        {
            lobbies.Clear();

            string body = x.ResponseMessage;
            const char lobbySeperator = '|';
            const char lobbyEntrySeperator = ';';

            string[] newLobbies = body.Split(lobbySeperator);
            foreach (string l in newLobbies)
            {
                Lobby newLobby = new Lobby();
                string[] entries = l.Split(lobbyEntrySeperator);
                if (entries.Length == 0)
                    continue;

                int lobbyId;
                if (!int.TryParse(entries[0], out lobbyId))
                    continue;

                for (int i = 1; i < entries.Length; i += 2)
                {
                    bool ready;
                    if (!bool.TryParse(entries[i + 1], out ready))
                        break;
                    newLobby.clients.Add(entries[i], ready);
                }

                lobbies.Add(lobbyId, newLobby);
            }

            if (onReceive != null)
                onReceive();
        });
        c2s.WriteAll(new RequestLobbyListPackage());
    }
Exemplo n.º 30
0
        public void When_too_many_people_accept_the_invitation_then_an_exception_is_thrown(string playerName, IList<Guid> invitationTokens, IList<Guid> playerIds, Lobby lobby)
        {
            "Given the a game"
                .Given(() => lobby = new Lobby("Test"));

            "And 10 invitations"
                .And(() =>
                    {
                        invitationTokens = new List<Guid>();
                        for (var x = 0; x <= 10; x++)
                        {
                            var invitationToken = Guid.NewGuid();
                            invitationTokens.Add(invitationToken);
                            lobby.InvitePlayer("Bryan", invitationToken);
                        }
                    });

            "When I invite 6 players"
                .When(() =>
                    {
                        playerIds = new List<Guid>();
                        for (var x = 1; x <= 6; x++)
                        {
                            var invitationToken = invitationTokens[x];
                            var playerId = Guid.NewGuid();
                            playerIds.Add(playerId);
                            lobby.AcceptInvitation(playerId, playerName, invitationToken);
                        }
                    });

            "Then I invite one more player an exception is thrown"
                .Then(() => Assert.Throws<TooManyPlayersException>(() =>
                    {
                        var playerId = playerIds.First();
                        lobby.AcceptInvitation(playerId, playerName, invitationTokens[6]);
                    }));
        }
        private void OnLobbyCreated(object sender, LobbyEventArgs args)
        {
            Lobby lobby = args.Lobby;

            Mediator.Notify("LobbyCreated", lobby.Id);
        }
        private bool TryGetGameLobby(string gameId, out Lobby.LobbySession lobby)
        {
            lobby = null;

            var lobbyId = PrefixGameLobby + gameId;
            ChatroomSessionBase usage;
            if (!_chatroomUsage.TryGetValue(lobbyId, out usage))
                return false;

            lobby = (Lobby.LobbySession)usage;
            return true;
        }
Exemplo n.º 33
0
    // Awake
    void Awake()
    {
        // TODO: Checks...
        instance = this;

        // This will be reset later if -batchmode was specified
#if UNITY_STANDALONE_WIN
        isTestServer = true;
#else
        isTestServer = false;
#endif

        // Default values
        serverPort = defaultServerPort;
        partyCount = 1;

        // -party0 account1 -party1 account2
        // -batchmode -port7100
        // taskkill /IM
        LogManager.General.Log("Parsing command line arguments");
        string[] args    = System.Environment.GetCommandLineArgs();
        int      partyId = GameServerParty.Undefined;

        foreach (string arg in args)
        {
            LogManager.General.Log("Command line argument: '" + arg + "'");

            // Overwrite port
            if (arg.StartsWith("-port") && arg.Length > "-port".Length)
            {
                serverPort = int.Parse(arg.Substring(5));
                // Batchmode
            }
            else if (arg == "-batchmode")
            {
                batchMode    = true;
                isTestServer = false;
                // Party count
            }
            else if (arg.StartsWith("-partycount") && arg.Length > "-partycount".Length)
            {
                partyCount = int.Parse(arg.Substring("-partycount".Length));

                LogManager.General.Log(string.Format("Creating parties: {0}", partyCount));
                GameServerParty.partyList.Clear();
                GameServerParty.CreateParties(partyCount);
                // Teams
            }
            else if (arg.StartsWith("-party") && arg.Length > "-party".Length)
            {
                partyId            = int.Parse(arg.Substring("-party".Length));
                restrictedAccounts = true;
                // Map
            }
            else if (arg.StartsWith("-map") && arg.Length > "-map".Length)
            {
                mapName = arg.Substring("-map".Length);
                // Lobby IP
            }
            else if (arg.StartsWith("-lobbyIP") && arg.Length > "-lobbyIP".Length)
            {
                lobbyIP = arg.Substring("-lobbyIP".Length);
                // Lobby Port
            }
            else if (arg.StartsWith("-lobbyPort") && arg.Length > "-lobbyPort".Length)
            {
                lobbyPort = int.Parse(arg.Substring("-lobbyPort".Length));
                // Server type
            }
            else if (arg.StartsWith("-type") && arg.Length > "-type".Length)
            {
                string serverTypeString = arg.Substring("-type".Length);
                switch (serverTypeString)
                {
                case "Arena":
                    GameManager.serverType = ServerType.Arena;
                    break;

                case "Town":
                    GameManager.serverType = ServerType.Town;
                    break;

                case "FFA":
                    GameManager.serverType = ServerType.FFA;
                    break;

                case "World":
                    GameManager.serverType = ServerType.World;
                    break;
                }
                // Database IP
            }
            else if (arg.StartsWith("-databaseIP") && arg.Length > "-databaseIP".Length)
            {
                databaseIP = arg.Substring("-databaseIP".Length);
                // Database Port
            }
            else if (arg.StartsWith("-databasePort") && arg.Length > "-databasePort".Length)
            {
                databasePort = int.Parse(arg.Substring("-databasePort".Length));
                // Account ID
            }
            else
            {
                if (partyId >= 0 && partyId < GameServerParty.partyList.Count)
                {
                    var currentParty = GameServerParty.partyList[partyId];
                    accountToParty[arg] = currentParty;
                    currentParty.expectedMemberCount += 1;
                }
            }
        }

        // For testing
        if (isTestServer)
        {
            GameManager.serverType = testServerType;
        }
        else
        {
            if (!string.IsNullOrEmpty(databaseIP))
            {
                Database.AddNode("riak", databaseIP, databasePort, 10, Defaults.WriteTimeout, Defaults.ReadTimeout);
                Database.Connect();
            }
            else
            {
                LogManager.DB.LogError("No database address specified, can't connect to the database");
            }
        }

        // Create at least 1 party if no party count has been specified
        if (GameServerParty.partyList.Count != partyCount)
        {
            switch (GameManager.serverType)
            {
            case ServerType.Arena:
                partyCount = 2;
                break;

            case ServerType.FFA:
                partyCount = 10;
                break;
            }

            LogManager.General.Log(string.Format("Creating parties: {0}", partyCount));
            GameServerParty.partyList.Clear();
            GameServerParty.CreateParties(partyCount);
        }

        // Server type
        LogManager.General.Log("Server type: " + GameManager.serverType);
        MapManager.InitPhysics(GameManager.serverType);

        if (restrictedAccounts)
        {
            LogManager.General.Log("Server is restricted to the following accounts: " + accountToParty.Keys);
        }

        if (GameManager.isArena)
        {
            QueueSettings.queueIndex = accountToParty.Count / 2 - 1;
            LogManager.General.Log("Queue type is: " + (QueueSettings.queueIndex + 1) + "v" + (QueueSettings.queueIndex + 1));
        }
        else if (GameManager.isFFA)
        {
            QueueSettings.queueIndex = 0;
            LogManager.General.Log("Queue type is: " + (QueueSettings.queueIndex + 1) + "v" + (QueueSettings.queueIndex + 1));
        }

        // Server batchmode
        //if(batchMode) {
        LogManager.General.Log("Batchmode is being used: Destroy the camera and disable renderers");

        // Destroy the camera
        Destroy(Camera.main);

        // Disable renderers in batchmode
        DisableRenderers(creatorPrefab);

        // No statistics GUI
#if UNITY_EDITOR
        GetComponent <uLinkStatisticsGUI>().enabled = true;
#endif

        // No audio
        AudioListener.pause = true;

        // Disable all game modes just to be safe
        var gameModes = GetComponents <GameMode>();
        foreach (var mode in gameModes)
        {
            mode.enabled = false;
        }

        // Pick correct game mode
        int maxPlayerCount = 0;
        switch (GameManager.serverType)
        {
        case ServerType.Arena:
            gameMode = GetComponent <ArenaGameMode>();
            int maxSpectators = 10;
            maxPlayerCount = 10 + maxSpectators;
            break;

        case ServerType.Town:
            gameMode       = GetComponent <TownGameMode>();
            maxPlayerCount = 1024;
            break;

        case ServerType.FFA:
            gameMode       = GetComponent <FFAGameMode>();
            maxPlayerCount = 10;
            break;

        case ServerType.World:
            gameMode       = GetComponent <WorldGameMode>();
            maxPlayerCount = 1024;
            break;
        }

        // FFA
        if (GameManager.isFFA)
        {
            GameServerParty.partyList.Clear();
            GameServerParty.CreateParties(10, 1);
        }

        // Public key
        NetworkHelper.InitPublicLobbyKey();

        // Started by uZone?
        if (uZone.Instance.wasStartedByuZone)
        {
            // Listen to lobby events and RPCs
            Lobby.AddListener(this);

            IPAndPortCallBack connectToServices = (host, port) => {
                // Connect to lobby
                LogManager.General.Log(string.Format("Connecting to lobby as server {0}:{1}", host, port));
                Lobby.ConnectAsServer(host, port);

                // Update members in case we downloaded the info
                lobbyIP   = host;
                lobbyPort = port;

                // Set up callback
                uZone.Instance.GlobalEvents events = new uZone.Instance.GlobalEvents();
                events.onInitialized = uZone_OnInitialized;

                // This will tell uZone that the instance is ready
                // and we can let other players connect to it
                LogManager.General.Log("Initializing the uZone instance");
                uZone.Instance.Initialize(events);
            };

            // uLobby and uZone
#if UNITY_STANDALONE_WIN
            lobbyIP   = "127.0.0.1";
            lobbyPort = 1310;

            connectToServices(lobbyIP, lobbyPort);
#else
            if (string.IsNullOrEmpty(lobbyIP))
            {
                StartCoroutine(NetworkHelper.DownloadIPAndPort("https://battleofmages.com/scripts/login-server-ip.php", connectToServices));
            }
            else
            {
                connectToServices(lobbyIP, lobbyPort);
            }
#endif
        }

        // Load map
        StartCoroutine(MapManager.LoadMapAsync(
                           mapName,

                           // Map is loaded asynchronously...
                           // When it's finished, we use the callback:
                           () => {
            // Register codecs for serialization
            GameDB.InitCodecs();

            // Server port
            if (!isTestServer)
            {
                try {
                    serverPort = uZone.Instance.port;
                    LogManager.General.Log("Using port assigned from uZone: " + serverPort);
                } catch {
                    LogManager.General.Log("Failed to retrieve port info from uZone! Using port " + serverPort);
                }
            }
            else
            {
                LogManager.General.Log("Using test server port: " + serverPort);
            }

            // Init server
            LogManager.General.Log("Initializing the server on port " + serverPort);
            uLink.Network.InitializeServer(maxPlayerCount, serverPort);

            // Encryption
            LogManager.General.Log("Initializing security");
            uLink.Network.InitializeSecurity(true);

#if !UNITY_EDITOR
            // Clean up
            DestroyServerAssets();
#endif
            // Send ready message if we didn't do it yet
            SendReadyMessage();
        }
                           ));
    }
Exemplo n.º 34
0
        public void SpecificSituation2()
        {
            lobbyManager.createLobby(4, "bob", 5, "no", (WebSocketSharp.WebSocket)null);
            Lobby lobby = new Lobby("1", 0);

            lobby.game             = new GameState(10, 10);
            lobby.game.board.board = new int[, ] {
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 1, 2 },
                { 0, 0, 1, 1, 1, 1, 0, 0, 2, 2 },
                { 1, 2, 1, 1, 2, 1, 0, 0, 1, 2 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 2, 2, 1, 2, 0, 1, 0, 0, 1, 3 }
            };
            lobbyManager.shiftRows(lobby, false);
            int[,] resBoard  = lobby.game.board.board;
            int[,] testBoard = new int[, ] {
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 1, 2 },
                { 0, 0, 1, 1, 0, 1, 0, 0, 2, 2 },
                { 1, 2, 1, 1, 1, 1, 0, 0, 1, 2 },
                { 2, 2, 1, 2, 2, 1, 0, 0, 1, 3 }
            };
            bool isSameBoard = true;

            for (int i = 0; i < testBoard.GetLength(0); i++)
            {
                for (int j = 0; j < testBoard.GetLength(1); j++)
                {
                    if (resBoard[i, j] != testBoard[i, j])
                    {
                        isSameBoard = false;
                    }
                }
            }
            Prints prints = new Prints();

            Console.WriteLine("RESULTING BOARD");
            prints.PrintMultiDimArr(lobby.game.board.board);
            Assert.That(isSameBoard, Is.EqualTo(true));
        }
Exemplo n.º 35
0
 private void HandleLobbyMemberDisconnected(Lobby lobby, Friend friend)
 {
     ConstructPlayersText();
 }
Exemplo n.º 36
0
 public void SendChatMessage(LMS_Chat.ChatMsg msg)
 {
     Lobby.RPC("ChatMessage", LobbyPeer.lobby, JsonMapper.ToJson(msg));
 }
 void session_LoadGameRoomsComplete(Lobby.LobbySession obj)
 {
     List<string> removes = new List<string>();
     foreach (var id in _gameRoomsToJoinAfterLobbyJoin)
     {
         Lobby.GameRoomItem item;
         if (obj.GameRoomManager.TryGetItemById(id, out item))
         {
             JoinChatroom(PrefixGameRoom + id);
             removes.Add(id);
         }
     }
     foreach (var item in removes)
         _gameRoomsToJoinAfterLobbyJoin.Remove(item);
 }
Exemplo n.º 38
0
        protected override BaseSerializer PerformAction(ClientConnection conn, BaseSerializer requestData)
        {
            RequestSerializer  data = (RequestSerializer)requestData;
            ResponseSerializer resp = (ResponseSerializer)InitializeResponseSerializer();

            resp.Status = "OK";

            Lobby lobby = conn.Session.Get <Lobby>("joined-lobby");
            Match game  = lobby.Game;

            // Check czy ktokolwiek w ogóle siedzi na tym miejscu
            var playerAtPlace = lobby.Game.GetPlayerAt((PlayerTag)data.PlaceTag);

            if (playerAtPlace == null)
            {
                data.AddError("PlaceTag", "NO_PLAYER_HERE", "Żaden gracz nie siedzi na tym miejscu");
                data.ThrowException();
            }

            // Check uprawnień w przypadku, gdy nie jesteśmy właścicielem Lobby
            if (lobby.LobbyOwner != conn)
            {
                if (playerAtPlace.Name != conn.Session.Get <string>("username"))
                {
                    data.AddError(null, "FORBIDDEN", "Brak uprawnień do tej czynności.");
                    data.ThrowException();
                }
            }

            // Lepiej jeśli cokolwiek zepsuje się po usunięciu gracza ze stołu. Wtedy rozgrywkę będzie można kontynuować mimo błędu
            lobby.Game.RemovePlayer(playerAtPlace);

            lobby.SetLobbyState(LobbyState.IDLE); // Jeśli Lobby miało rozpoczętą grę, zostanie zapauzowane

            var username = playerAtPlace.Name;
            var signal   = new LobbySignalUserSittedOutSerializer()
            {
                Signal   = LobbySignalUserSittedOutSerializer.SIGNAL_USER_SITTED_OUT,
                Message  = "User " + username + " joined the lobby",
                Username = username,
                PlaceTag = (int)playerAtPlace.Tag
            };
            var result = new StandardCommunicateSerializer()
            {
                CommunicateType = StandardCommunicateSerializer.TYPE_LOBBY_SIGNAL,
                Data            = signal.GetApiObject()
            };

            lobby.Broadcast(result.GetApiObject());

            var index = lobby.ConnectedClients.FindIndex((client) => {
                return(client.Session.Get <string>("username") == playerAtPlace.Name);
            });

            if (index != -1)
            {
                var client = lobby.ConnectedClients[index];
                client.Session.Remove("player");
            }

            return(resp);
        }
        private bool TryGetGameRoomAndSession(string id, out Lobby.LobbySession session, out Lobby.GameRoomItem room)
        {
            foreach (var chatSession in _chatroomUsage.Values)
            {
                if (chatSession is Lobby.LobbySession)
                {
                    session = chatSession as Lobby.LobbySession;
                    if (session.GameRoomManager.TryGetItemById(id, out room))
                    {
                        return true;
                    }
                }
            }

            session = null;
            room = null;
            return false;
        }
Exemplo n.º 40
0
 public bool Get(int topicId, out Lobby obj)
 {
     obj = Lobbies.SingleOrDefault(lobby => lobby.TopicId == topicId);
     return(obj != null);
 }
 public JoinRoomFailedScriptClient(BattleMapOnlineClient Owner, Lobby ScreenOwner)
     : base(ScriptName)
 {
     this.Owner       = Owner;
     this.ScreenOwner = ScreenOwner;
 }
Exemplo n.º 42
0
 void OnAccountLoggedIn(Account account)
 {
     Lobby.RPC("CrystalBalanceRequest", Lobby.lobby);
     pendingCrystalBalanceRequests += 1;
 }
Exemplo n.º 43
0
        public MimicGameMode(Lobby lobby, List <ConfigureLobbyRequest.GameModeOptionRequest> gameModeOptions, StandardGameModeOptions standardOptions)
        {
            GameDuration duration = standardOptions.GameDuration;
            int          numStartingDrawingsPerUser = 1;
            int          maxDrawingsBeforeVoteInput = (int)gameModeOptions[(int)GameModeOptions.MaxDrawingsBeforeVote].ValueParsed;
            int          maxVoteDrawings            = 12; // Everybody's drawing should show up, but it gets a little prohibitive past 12 so limit it here.
            TimeSpan?    drawingTimer = null;
            TimeSpan?    votingTimer  = null;

            if (standardOptions.TimerEnabled)
            {
                drawingTimer = MimicConstants.DrawingTimer[duration];
                votingTimer  = MimicConstants.VotingTimer[duration];
            }
            TimeSpan?extendedDrawingTimer = drawingTimer.MultipliedBy(MimicConstants.MimicTimerMultiplier);
            int      numPlayers           = lobby.GetAllUsers().Count();
            int      numRounds            = Math.Min(MimicConstants.MaxRounds[duration], numPlayers);

            this.Lobby = lobby;

            Setup = new Setup_GS(
                lobby: lobby,
                drawings: Drawings,
                numDrawingsPerUser: numStartingDrawingsPerUser,
                drawingTimeDuration: drawingTimer);
            List <UserDrawing> randomizedDrawings = new List <UserDrawing>();

            Setup.AddExitListener(() =>
            {
                randomizedDrawings = this.Drawings
                                     .OrderBy(_ => Rand.Next())
                                     .ToList()
                                     .Take(numRounds) // Limit number of rounds based on game duration.
                                     .ToList();
            });
            StateChain CreateGamePlayLoop()
            {
                bool       timeToShowScores = true;
                StateChain gamePlayLoop     = new StateChain(stateGenerator: (int counter) =>
                {
                    if (randomizedDrawings.Count > 0)
                    {
                        StateChain CreateMultiRoundLoop()
                        {
                            int maxDrawingsBeforeVote = Math.Min(maxDrawingsBeforeVoteInput, randomizedDrawings.Count);
                            if (randomizedDrawings.Count == 0)
                            {
                                throw new Exception("Something went wrong while setting up the game");
                            }
                            List <RoundTracker> roundTrackers = new List <RoundTracker>();
                            return(new StateChain(stateGenerator: (int counter) =>
                            {
                                if (counter < maxDrawingsBeforeVote)
                                {
                                    UserDrawing originalDrawing = randomizedDrawings.First();
                                    randomizedDrawings.RemoveAt(0);

                                    RoundTracker drawingsRoundTracker = new RoundTracker();
                                    roundTrackers.Add(drawingsRoundTracker);
                                    drawingsRoundTracker.originalDrawer = originalDrawing.Owner;
                                    drawingsRoundTracker.UsersToUserDrawings.AddOrUpdate(originalDrawing.Owner, originalDrawing, (User user, UserDrawing drawing) => originalDrawing);

                                    DisplayOriginal_GS displayGS = new DisplayOriginal_GS(
                                        lobby: lobby,
                                        displayTimeDuration: MimicConstants.MemorizeTimerLength,
                                        displayDrawing: originalDrawing);
                                    CreateMimics_GS mimicsGS = new CreateMimics_GS(
                                        lobby: lobby,
                                        roundTracker: drawingsRoundTracker,
                                        drawingTimeDuration: extendedDrawingTimer
                                        );
                                    mimicsGS.AddExitListener(() =>
                                    {
                                        List <User> randomizedUsersToDisplay = new List <User>();
                                        List <User> randomizedKeys = drawingsRoundTracker.UsersToUserDrawings.Keys.OrderBy(_ => Rand.Next()).ToList();
                                        for (int i = 0; i < maxVoteDrawings && i < randomizedKeys.Count; i++)
                                        {
                                            randomizedUsersToDisplay.Add(randomizedKeys[i]);
                                        }
                                        if (!randomizedUsersToDisplay.Contains(drawingsRoundTracker.originalDrawer))
                                        {
                                            randomizedUsersToDisplay.RemoveAt(0);
                                            randomizedUsersToDisplay.Add(drawingsRoundTracker.originalDrawer);
                                        }
                                        randomizedUsersToDisplay = randomizedUsersToDisplay.OrderBy(_ => Rand.Next()).ToList();
                                        drawingsRoundTracker.UsersToDisplay = randomizedUsersToDisplay;
                                    });
                                    return new StateChain(states: new List <State>()
                                    {
                                        displayGS, mimicsGS
                                    }, exit: null);
                                }
                                else if (counter < maxDrawingsBeforeVote * 2)
                                {
                                    return GetVotingAndRevealState(roundTrackers[counter - maxDrawingsBeforeVote], votingTimer);
                                }
                                else
                                {
                                    return null;
                                }
                            }));
                        }
                        return(CreateMultiRoundLoop());
                    }
                    else
                    {
                        if (timeToShowScores)
                        {
                            timeToShowScores = false;
                            return(new ScoreBoardGameState(
                                       lobby: lobby,
                                       title: "Final Scores"));
                        }
                        else
                        {
                            //Ends the chain
                            return(null);
                        }
                    }
                });

                gamePlayLoop.Transition(this.Exit);
                return(gamePlayLoop);
            }

            this.Entrance.Transition(Setup);
            Setup.Transition(CreateGamePlayLoop);
        }
    public Lobby[] GetLobbies()
    {
        // Using Lobby as a wrapper for RoomInfo to
        //  restrict PUN-specific things to this file
        RoomInfo[] rooms = PhotonNetwork.GetRoomList ();
        int numLobbies = rooms.Length;
        Lobby[] lobbies = new Lobby[numLobbies];
        for (int i = 0; i < numLobbies; i++){
            lobbies[i] = new Lobby(rooms[i].name, rooms[i].playerCount, rooms[i].maxPlayers);
        }

        return lobbies;
    }
Exemplo n.º 45
0
 private void DisplayTurnMessage()
 {
     Lobby.Broadcast("This is the turn of " + Lobby.Info.Clients[Turn].Name + " to play a card.");
 }
    private void Awake()
    {
        mode = NetMode.initial;
        connectFailed = false;
        // Connect to the main photon server.
        if (!PhotonNetwork.connected)
        {
            PhotonNetwork.ConnectUsingSettings("1.0");
        }

        //Load our name from PlayerPrefs
        PhotonNetwork.playerName = "Guest" + Random.Range(1, 9999);
        Lobby = new Lobby ("Default");
    }
Exemplo n.º 47
0
 void Start()
 {
     lobby = GetComponent<Lobby> ();
     rom = GetComponent<Rom> ();
     spawnControl = GetComponent<SpawnControl> ();
 }
Exemplo n.º 48
0
    void JoinLobby(Lobby l, Action<bool> onReceive)
    {
        WaitForResponse(JoinLobbyPackage.factory.Id,
        x =>
        {
            bool success = false;
            bool.TryParse(x.ResponseMessage, out success);

            if (success)
                currentLobby = l;

            if (onReceive != null)
                onReceive(success);
        });

        JoinLobbyPackage jlp = new JoinLobbyPackage();
        jlp.LobbyId = GetLobbyId(l);
        c2s.WriteAll(jlp);
    }
Exemplo n.º 49
0
 // Use this for initialization
 void Start()
 {
     lobbyScript = transform.parent.GetComponent<Lobby>();            
 }
Exemplo n.º 50
0
 public void OnRoomCreated(Lobby lobby, string roomId)
 {
     Entries.Add(roomId, lobby);
 }
Exemplo n.º 51
0
Arquivo: Menu.cs Projeto: MizzKii/WarB
	void Start ()
	{
		lobby = GetComponent<Lobby>(); 
		difficulty = PlayerPrefs.GetInt("Difficulty",1);
	}
Exemplo n.º 52
0
        public void Starting_a_game_with_not_enough_players_throws_exception(int numberOfPlayers, Lobby lobby)
        {
            "Given a game"
                .Given(() => lobby = new Lobby("Test"));

            "With a number of invited and accepted players"
                .And(() =>
                {
                    for (var x = 1; x <= numberOfPlayers; x++)
                    {
                        var invitationToken = Guid.NewGuid();
                        lobby.InvitePlayer("Bryan", invitationToken);
                        lobby.AcceptInvitation(Guid.NewGuid(), "Bryan", invitationToken);
                    }
                });

            "Then an exception is thrown when trying to start the game"
                .Then(() => Assert.Throws<NotEnoughPlayersException>(() => lobby.StartGame()));
        }
    public void startNetworkedGame(Lobby lobby)
    {
        //Update gui state and number of players for everyone
        //photonView.RPC("RPC_setGUIStage", PhotonTargets.All, (int)GuiStage.inGame);
        photonView.RPC ("RPC_SetPlayerCount", PhotonTargets.All, PhotonNetwork.room.playerCount);

        //Update  game info for everyone
        foreach(Option option in lobby.LobbyOptions) {
            photonView.RPC("RPC_SetOption", PhotonTargets.All, (int)option, true);
        }
        photonView.RPC ("RPC_SetExpansion", PhotonTargets.All, (int)lobby.LobbyExpansion);
        photonView.RPC ("RPC_SetScenario", PhotonTargets.All, (int)lobby.LobbyScenario);

        //Start game for everyone
        PhotonNetwork.LoadLevel ("Game");
        //photonView.RPC ("RPC_StartGame", PhotonTargets.All);
    }
Exemplo n.º 54
0
 public void CacheLobby(uint appId, Lobby lobby)
 {
     GetAppLobbies(appId)[lobby.SteamID] = lobby;
 }
Exemplo n.º 55
0
 int GetLobbyId(Lobby l)
 {
     foreach (var v in lobbies)
     {
         if (v.Value == l)
             return v.Key;
     }
     return -1;
 }
Exemplo n.º 56
0
 public void UpdateLobbyMembers(uint appId, Lobby lobby, List <Lobby.Member> members)
 {
     UpdateLobbyMembers(appId, lobby, lobby.OwnerSteamID, members.AsReadOnly());
 }
Exemplo n.º 57
0
    void OnJoinLobbyPressed(Lobby l)
    {
        JoinLobby(l, x =>
        {
            if (!x)
                return;

            AnimateBackground(lobbyWidth, lobbyHeight);
            State = MenuState.Lobby;
        });
    }
Exemplo n.º 58
0
    // Start
    void Start()
    {
        // Player
        playerCommands = new ChatCommand <LobbyPlayer>[] {
            // practice
            new ChatCommand <LobbyPlayer>(
                @"^practice$",
                (player, args) => {
                if (!player.inMatch)
                {
                    LobbyQueue.CreatePracticeMatch(player);
                }
                else
                {
                    // Notify player ...
                }
            }
                ),

            // online
            new ChatCommand <LobbyPlayer>(
                @"^online$",
                (player, args) => {
                LobbyServer.SendSystemMessage(player, "Players online: " + LobbyPlayer.list.Count);
            }
                )
        };

        // VIP
        vipCommands = new ChatCommand <LobbyPlayer>[] {
            // list
            new ChatCommand <LobbyPlayer>(
                @"^list$",
                (player, args) => {
                LobbyServer.SendSystemMessage(player, "Town: " + LobbyTown.running.Count);
                LobbyServer.SendSystemMessage(player, "World: " + LobbyWorld.running.Count);
                LobbyServer.SendSystemMessage(player, "Arena: " + LobbyMatch.running.Count);
                LobbyServer.SendSystemMessage(player, "FFA: " + LobbyFFA.running.Count);
            }
                )
        };

        // Community Manager
        communityManagerCommands = new ChatCommand <LobbyPlayer>[] {
            // goto
            new ChatCommand <LobbyPlayer>(
                @"^goto ([^ ]+) (.*)$",
                (player, args) => {
                var serverType = ChatServer.GetServerType(args[0]);
                var mapName    = args[1];

                player.location = new PlayerLocation(mapName, serverType);
            }
                ),

            // moveToPlayer
            new ChatCommand <LobbyPlayer>(
                @"^moveToPlayer (.*)$",
                (player, args) => {
                var playerName = args[1];

                LobbyGameDB.GetAccountIdByPlayerName(playerName, accountId => {
                    if (accountId == null)
                    {
                        return;
                    }

                    PositionsDB.GetPosition(accountId, position => {
                        if (position == null)
                        {
                            position = new PlayerPosition();
                        }

                        LocationsDB.GetLocation(accountId, location => {
                            if (location == null)
                            {
                                return;
                            }

                            // TODO: This is not 100% correct as it might get overwritten by the server
                            PositionsDB.SetPosition(player.accountId, position);

                            player.location = location;
                        });
                    });
                });
            }
                ),
        };

        // Game Master
        gameMasterCommands = new ChatCommand <LobbyPlayer>[] {
            // start
            new ChatCommand <LobbyPlayer>(
                @"^start ([^ ]+) (.*)$",
                (player, args) => {
                var serverType = ChatServer.GetServerType(args[0]);
                var mapName    = args[1];

                switch (serverType)
                {
                case ServerType.FFA:
                    new LobbyFFA(mapName).Register();
                    break;

                case ServerType.Town:
                    new LobbyTown(mapName).Register();
                    break;
                }
            }
                ),
        };

        // Admin
        adminCommands = new ChatCommand <LobbyPlayer>[] {
        };

        // Make this class listen to lobby events
        Lobby.AddListener(this);
    }
Exemplo n.º 59
0
        public static void Main(string[] args)
        {
            // Make our window nice and big
            Console.SetWindowSize(140, 36);
            LogLevel = Hybrasyl.Constants.DEFAULT_LOG_LEVEL;
            Assemblyinfo = new AssemblyInfo(Assembly.GetEntryAssembly());

            Constants.DataDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Hybrasyl");

            if (!Directory.Exists(Constants.DataDirectory))
            {
                Logger.InfoFormat("Creating data directory {0}", Constants.DataDirectory);
                try
                {
                    // Create the various directories we need
                    Directory.CreateDirectory(Constants.DataDirectory);
                    Directory.CreateDirectory(Path.Combine(Constants.DataDirectory, "maps"));
                    Directory.CreateDirectory(Path.Combine(Constants.DataDirectory, "scripts"));

                }
                catch (Exception e)
                {
                    Logger.ErrorFormat("Can't create data directory: {0}", e.ToString());
                    return;
                }
            }
            
            var hybconfig = Path.Combine(Constants.DataDirectory, "config.xml");

            if (File.Exists(hybconfig))
            {
                var xml = File.ReadAllText(hybconfig);
                HybrasylConfig newConfig;
                Exception parseException;
                if (XML.Config.HybrasylConfig.Deserialize(xml, out newConfig, out parseException))
                    Config = newConfig;
                else
                {
                    Logger.ErrorFormat("Error parsing Hybrasyl configuration: {1}", hybconfig, parseException);
                    Environment.Exit(0);
                }
            }
            else
            {

                Console.ForegroundColor = ConsoleColor.White;

                Console.Write("Welcome to Project Hybrasyl: this is Hybrasyl server {0}\n", Assemblyinfo.Version);
                Console.Write("I need to ask some questions before we can go on. You'll also need to\n");
                Console.Write("make sure that an app.config exists in the Hybrasyl server directory,\n");
                Console.Write("and that the database specified there exists and is properly loaded.\n");
                Console.Write("Otherwise, you're gonna have a bad time.\n\n");
                Console.Write("These questions will only be asked once - if you need to make changes\n");
                Console.Write("in the future, edit config.xml in the Hybrasyl server directory.\n\n");

                Console.Write("Enter this server's IP address, or what IP we should bind to (default is 127.0.0.1): ");
                var serverIp = Console.ReadLine();
                Console.Write("Enter the Lobby Port (default is 2610): ");
                var lobbyPort = Console.ReadLine();
                Console.Write("Enter the Login Port: (default is 2611): ");
                var loginPort = Console.ReadLine();
                Console.Write("Enter the World Port (default is 2612): ");
                var worldPort = Console.ReadLine();

                if (String.IsNullOrEmpty(serverIp))
                    serverIp = "127.0.0.1";

                if (String.IsNullOrEmpty(lobbyPort))
                    lobbyPort = "2610";

                if (String.IsNullOrEmpty(loginPort))
                    loginPort = "2611";

                if (String.IsNullOrEmpty(worldPort))
                    worldPort = "2612";

                Logger.InfoFormat("Using {0}: {1}, {2}, {3}", serverIp, lobbyPort, loginPort, worldPort);

                Console.Write("Now, we will configure the Redis store.\n\n");
                Console.Write("Redis IP or hostname (default is localhost): ");
                var redisHost = Console.ReadLine();

                Console.Write("Redis authentication information (optional - if you don't have these, just hit enter)");
                Console.Write("Username: "******"Password: "******"localhost";

                Config = new HybrasylConfig {datastore = {host = redisHost}, network =
                {
                    lobby = new NetworkInfo { bindaddress = serverIp, port = Convert.ToUInt16(lobbyPort) },
                    login = new NetworkInfo { bindaddress = serverIp, port = Convert.ToUInt16(loginPort) },
                    world = new NetworkInfo { bindaddress = serverIp, port = Convert.ToUInt16(worldPort) }
                }};

                if (String.IsNullOrEmpty(redisUser))
                    Config.datastore.username = redisUser;

                if (String.IsNullOrEmpty(redisPass))
                    Config.datastore.username = redisPass;

                Config.SaveToFile(Path.Combine(Constants.DataDirectory, "config.xml"));
            }
            ((log4net.Repository.Hierarchy.Hierarchy)LogManager.GetRepository()).Root.Level = Level.Debug;
            ((log4net.Repository.Hierarchy.Hierarchy)LogManager.GetRepository()).RaiseConfigurationChanged(
                EventArgs.Empty);
            // Set console buffer, so we can scroll back a bunch
            Console.BufferHeight = Int16.MaxValue - 1;

            Logger.InfoFormat("Hybrasyl {0} starting.", Assemblyinfo.Version);
            Logger.InfoFormat("{0} - this program is licensed under the GNU AGPL, version 3.", Assemblyinfo.Copyright);

            LoadCollisions();

            // For right now we don't support binding to different addresses; the support in the XML
            // is for a distant future where that may be desirable.
            IpAddress = IPAddress.Parse(Config.network.lobby.bindaddress); 
            Lobby = new Lobby(Config.network.lobby.port);
            Login = new Login(Config.network.login.port);
            World = new World(Config.network.world.port, Config.datastore);
            World.InitWorld();

            byte[] addressBytes;
            addressBytes = IpAddress.GetAddressBytes();
            Array.Reverse(addressBytes);

            var stream = new MemoryStream();
            var writer = new BinaryWriter(stream, Encoding.GetEncoding(949));

            writer.Write((byte)1);
            writer.Write((byte)1);
            writer.Write(addressBytes);
            writer.Write((byte)(2611 / 256));
            writer.Write((byte)(2611 % 256));
            writer.Write(Encoding.GetEncoding(949).GetBytes("Hybrasyl;Hybrasyl Production\0"));
            writer.Flush();

            var serverTable = stream.ToArray();
            ServerTableCrc = ~Crc32.Calculate(serverTable);
            ServerTable = Zlib.Compress(stream).ToArray();

            writer.Close();
            stream.Close();
            var serverMsg = Path.Combine(Constants.DataDirectory, "server.msg");
            
            if (File.Exists(serverMsg))
            {
                stream = new MemoryStream(Encoding.GetEncoding(949).GetBytes(File.ReadAllText(serverMsg)));

            }
            else
            {
                stream = new MemoryStream(Encoding.GetEncoding(949).GetBytes(String.Format("Welcome to Hybrasyl!\n\nThis is Hybrasyl (version {0}).\n\nFor more information please visit http://www.hybrasyl.com",
                    Assemblyinfo.Version)));
            }

            var notification = stream.ToArray();
            NotificationCrc = ~Crc32.Calculate(notification);
            Notification = Zlib.Compress(stream).ToArray();

            World.StartTimers();
            World.StartQueueConsumer();

            ToggleActive();

            while (true)
            {
                Lobby.AcceptConnection();
                Login.AcceptConnection();
                World.AcceptConnection();
                if (!IsActive())
                    break;
                Thread.Sleep(10);
                
            }
            Logger.Warn("Hybrasyl: all servers shutting down");
            // Server is shutting down. For Lobby and Login, this terminates the TCP listeners;
            // for World, this triggers a logoff for all logged in users and then terminates. After
            // termination, the queue consumer is stopped as well.
            // For a true restart we'll need to do a few other things; stop timers, etc.
            Lobby.Shutdown();
            Login.Shutdown();
            World.Shutdown();
            World.StopQueueConsumer();
            Logger.WarnFormat("Hybrasyl {0}: shutdown complete.", Assemblyinfo.Version);
            Environment.Exit(0);

        }
Exemplo n.º 60
0
        //returns a list of userIds and the amount of points they received/lost for the win/loss, and if the user lost/gained a rank
        //UserId, Points added/removed, rank before, rank modify state, rank after
        /// <summary>
        /// Retrieves and updates player scores/wins
        /// </summary>
        /// <returns>
        /// A list containing a value tuple with the
        /// Player object
        /// Amount of points received/lost
        /// The player's current rank
        /// The player's rank change state (rank up, derank, none)
        /// The players new rank (if changed)
        /// </returns>
        public List <(Player, int, Rank, RankChangeState, Rank)> UpdateTeamScoresAsync(Competition competition, Lobby lobby, GameResult game, Rank[] ranks, bool win, HashSet <ulong> userIds, Database db)
        {
            var updates = new List <(Player, int, Rank, RankChangeState, Rank)>();

            foreach (var userId in userIds)
            {
                var player = db.Players.Find(competition.GuildId, userId);
                if (player == null)
                {
                    continue;
                }

                //This represents the current user's rank
                var maxRank = ranks.Where(x => x.Points < player.Points).OrderByDescending(x => x.Points).FirstOrDefault();

                int             updateVal;
                RankChangeState state   = RankChangeState.None;
                Rank            newRank = null;

                if (win)
                {
                    updateVal = (int)((maxRank?.WinModifier ?? competition.DefaultWinModifier) * lobby.LobbyMultiplier);
                    if (lobby.HighLimit != null)
                    {
                        if (player.Points > lobby.HighLimit)
                        {
                            updateVal = (int)(updateVal * lobby.ReductionPercent);
                        }
                    }
                    player.Points += updateVal;
                    player.Wins++;
                    newRank = ranks.Where(x => x.Points <= player.Points).OrderByDescending(x => x.Points).FirstOrDefault();
                    if (newRank != null)
                    {
                        if (maxRank == null)
                        {
                            state = RankChangeState.RankUp;
                        }
                        else if (newRank.RoleId != maxRank.RoleId)
                        {
                            state = RankChangeState.RankUp;
                        }
                    }
                }
                else
                {
                    //Loss modifiers are always positive values that are to be subtracted
                    updateVal = maxRank?.LossModifier ?? competition.DefaultLossModifier;
                    if (lobby.MultiplyLossValue)
                    {
                        updateVal = (int)(updateVal * lobby.LobbyMultiplier);
                    }

                    player.Points -= updateVal;
                    if (!competition.AllowNegativeScore && player.Points < 0)
                    {
                        player.Points = 0;
                    }
                    player.Losses++;
                    //Set the update value to a negative value for returning purposes.
                    updateVal = -Math.Abs(updateVal);

                    if (maxRank != null)
                    {
                        if (player.Points < maxRank.Points)
                        {
                            state   = RankChangeState.DeRank;
                            newRank = ranks.Where(x => x.Points <= player.Points).OrderByDescending(x => x.Points).FirstOrDefault();
                        }
                    }
                }

                updates.Add((player, updateVal, maxRank, state, newRank));
                var oldUpdate = db.ScoreUpdates.FirstOrDefault(x => x.ChannelId == lobby.ChannelId && x.GameNumber == game.GameId && x.UserId == userId);
                if (oldUpdate == null)
                {
                    var update = new ScoreUpdate
                    {
                        GuildId      = competition.GuildId,
                        ChannelId    = game.LobbyId,
                        UserId       = userId,
                        GameNumber   = game.GameId,
                        ModifyAmount = updateVal
                    };
                    db.ScoreUpdates.Add(update);
                }
                else
                {
                    oldUpdate.ModifyAmount = updateVal;
                    db.ScoreUpdates.Update(oldUpdate);
                }

                db.Update(player);
            }
            db.SaveChanges();
            return(updates);
        }