Esempio n. 1
0
        public int CreateLobby(Vector3 position, int maxPlayers)
        {
            int id = ++_lobbyCounter;

            _lobbies.Add(id, new PokerLobby(id, true, position, maxPlayers, API.createObject));

            _lobbies[id].OnLobbyRoundEnd += parameters => { if (OnLobbyRoundEnd != null)
                                                            {
                                                                OnLobbyRoundEnd.Invoke(id);
                                                            }
            };
            _lobbies[id].OnLobbyRoundStart += parameters => { if (OnLobbyRoundStart != null)
                                                              {
                                                                  OnLobbyRoundStart.Invoke(id);
                                                              }
            };
            _lobbies[id].OnPlayerLoseRound += parameters => { if (OnPlayerLoseRound != null)
                                                              {
                                                                  OnPlayerLoseRound.Invoke(id, parameters[0]);
                                                              }
            };                                                                                                                               // id, client
            _lobbies[id].OnPlayerWinRound += parameters => { if (OnPlayerWinRound != null)
                                                             {
                                                                 OnPlayerWinRound.Invoke(id, parameters[0], parameters[1], parameters[2]);
                                                             }
            };                                                                                                                                                          // id, client, take, handname
            _lobbies[id].OnPlayerMoneyChange += parameters => { if (OnPlayerMoneyChange != null)
                                                                {
                                                                    OnPlayerMoneyChange.Invoke(id, parameters[0], parameters[1]);
                                                                }
            };                                                                                                                                                    // id, client, newmoney

            return(id);
        }
Esempio n. 2
0
        private void EndRound()
        {
            for (int i = Players.Count - 1; i >= 0; i--)
            {
                var player = Players[i];
                player.Money -= player.CurrentBet;
                player.Client.triggerEvent("UPDATE_MONEY", player.Money, 0);

                if (OnPlayerMoneyChange != null)
                {
                    OnPlayerMoneyChange.Invoke(player.Client, player.Money);
                }

                if (player.Money <= 0)
                {
                    SendToPlayers("Player ~n~" + player.Client.name + "~n~ has lost all their money!");
                    RemovePlayer(player.Client);
                }
            }

            RebuildCash();
            if (OnLobbyRoundEnd != null)
            {
                OnLobbyRoundEnd.Invoke();
            }
            // TODO: remove
            API.shared.sleep(5000);
            State = GameState.NewRound;
        }