Beispiel #1
0
        private async void GetPlayers()
        {
            bool[] canExecuteFunction = await CanExecuteFunction();

            if (!canExecuteFunction[0])
            {
                return;
            }
            Player player;
            Player selectedPlayer = SelectedPlayer;

            Players?.Clear();
            uint maxClient = PS3.Extension.ReadUInt32(Addresses.MaxClients_a);

            for (uint i = 0; i < maxClient; i++)
            {
                player = new Player(PS3)
                {
                    Id = i
                }.GetInfo();
                if (!string.IsNullOrEmpty(player.Name) && !string.IsNullOrEmpty(player.Name))
                {
                    Players?.Add(player);
                }
            }
            SelectedPlayer = Players?.SingleOrDefault(p => p.Id == selectedPlayer?.Id);
        }
Beispiel #2
0
        public bool Join(IUser user, long bet)
        {
            lock (locker)
            {
                if (State != GameState.Starting)
                {
                    return(false);
                }

                if (Players.Count >= 5)
                {
                    return(false);
                }

                if (!_cs.Remove(user.Id, "BlackJack-gamble", bet, gamble: true, user: user))
                {
                    return(false);
                }

                //add it to the stake, in case bot crashes or gets restarted during the game
                //funds will be refunded to the players on next startup
                using (var uow = _db.UnitOfWork)
                {
                    var s = new Stake()
                    {
                        Amount = bet,
                        UserId = user.Id,
                        Source = "BlackJack",
                    };
                    s = uow._context.Set <Stake>().Add(s).Entity;
                    _stakes.Add(s);
                    uow.Complete();
                }

                Players.Add(new User(user, bet));
                PrintState();
                return(true);
            }
        }
Beispiel #3
0
        public void Join(Player player)
        {
            if (player.SpaceShip == null)
            {
                return;
            }

            rwl.AcquireReaderLock(-1);
            Stamp = DateTime.Now;
            try {
                if (!Players.ContainsKey(player))
                {
                    var lc = rwl.UpgradeToWriterLock(-1);
                    try {
                        if (!Players.ContainsKey(player))
                        {
                            Console.WriteLine("Enter system Area {0} - {1}", player.Name, SystemId);
                            Players.Add(player, DateTime.Now);
                            if (!SpaceShips.Contains(player.SpaceShip))
                            {
                                SpaceShips.Add(player.SpaceShip);
                            }
                        }
                    } finally {
                        rwl.DowngradeFromWriterLock(ref lc);
                    }

                    foreach (var p in Players.Keys)
                    {
                        if (p != player)
                        {
                            p.Send_ShipEnterSystem(player.SpaceShip);
                        }
                    }
                }
            } finally {
                rwl.ReleaseReaderLock();
            }
        }
Beispiel #4
0
        public Choice Start(Player startingPlayer, Player otherPlayer)
        {
            Players.Add(startingPlayer);
            Players.Add(otherPlayer);

            foreach (var card in Players.SelectMany(x => x.AllCards))
            {
                card.InitializeAbilities();
            }

            // 103.2. After the starting player has been determined, each player shuffles their deck so that the cards are in a random order.
            startingPlayer.ShuffleDeck(this);
            otherPlayer.ShuffleDeck(this);

            startingPlayer.PutFromTopOfDeckIntoShieldZone(InitialNumberOfShields, this);
            otherPlayer.PutFromTopOfDeckIntoShieldZone(InitialNumberOfShields, this);

            startingPlayer.DrawCards(InitialNumberOfHandCards, this);
            otherPlayer.DrawCards(InitialNumberOfHandCards, this);

            return(StartNewTurn(startingPlayer.Id, otherPlayer.Id));
        }
Beispiel #5
0
 /// <summary>
 /// Add Player in List
 /// </summary>
 /// <param name="player"></param>
 /// <returns></returns>
 public bool AddPlayer(Session player)
 {
     if (null == player)
     {
         if (GameType == GameTypeFlag.GM_EVENT)
         {
             SetOwner(uint.MaxValue);
             return(false);
         }
         return(false);
     }
     if (Players.Any(c => c.UserInfo.GetLogin == player.UserInfo.GetLogin) == false)
     {
         player.Game = this;
         Players.Add(player);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Beispiel #6
0
        /// <summary>
        /// Обработчик события появления нового человека в поиске
        /// </summary>
        /// <param name="sender">Собственно User(будет, а пока ClientState)</param>
        /// <param name="e">//TODO: </param>
        public void OnNewSearcher(object sender, NewFinderArgs e)
        {
            Player player = new Player(sender as User);

            if (MatchManager.Instance.FindMatchByParticipantID(player.UserId) != null)
            {
                return;
            }

            if (Players.Where(x => x.UserId == player.UserId).Count() != 0)
            {
                return;
            }

            Players.Add(player);
            foreach (var p in Players)
            {
                Longpool.Longpool.Instance.PushMessageToUser(p.UserId, new AsyncMessage(MessageType.QueueStatus, Players.Count));
            }
            ResetTimer();
            CalculateMatches();
        }
Beispiel #7
0
        /// <summary>
        /// Load the map of the given name.
        /// </summary>
        public static async void LoadMap(String name)
        {
            ActivePlayer = new Player(new Point(32000, 32000));
            FileStream        f = new FileStream(name, FileMode.Open, FileAccess.ReadWrite, FileShare.None);
            CancellationToken c = CTS.Token;
            await Task.Run(() => InitializeGameState(f, c));

            if (!c.IsCancellationRequested)
            {
                DrawSet.Add(ActivePlayer);
                Players.Add(ActivePlayer);
                WorldName = name.Substring(0, name.IndexOf('.'));
                TitleState.Initialized = false;
            }
            else
            {
                CurrentGameState = GameStatus.Title;
            }
            LoadText     = null;
            LoadProgress = 0;
            f.Dispose();
        }
        /// <summary>
        /// Welcome banner for Card Game Screen Options
        /// </summary>
        public void Welcome()
        {
            Players.Clear(); //reset players
            // Get complete list of reviewers from the database
            var reviewers = DbContext.Reviewers();
            // Get random reviewers as player from the database
            var randomPlayer = DeckHelper.GetPlayers(reviewers?.ToList());
            // Add reviewers as random players
            var playerId = 1;

            foreach (var player in randomPlayer)
            {
                Players.Add(new CardPlayer <RestaurantReviewer>(playerId++, player,
                                                                () => player.FirstName + " " + player.LastName));
            }
            // Shuffle all the cards for each player
            ShuffleCards();
            PrintResult();
            Console.Write("Press any key to go back to main menu ...");
            Console.ReadLine();
            GoBackToMainMenu();
        }
Beispiel #9
0
        public void RefreshPlayerInfo()
        {
            Players.Clear();
            GetChallengeData();

            _challengeBytes[0] = A2S_PLAYER;
            Send(_challengeBytes);
            var playerData = Receive();

            using (var br = new BinaryReader(new MemoryStream(playerData)))
            {
                if (br.ReadByte() != 0x44)
                {
                    throw new Exception("Invalid data received in response to A2S_PLAYER request");
                }
                var numPlayers = br.ReadByte();
                for (int index = 0; index < numPlayers; index++)
                {
                    Players.Add(PlayerInfo.FromBinaryReader(br));
                }
            }
        }
        public PlayerAvatar add(CharacterData data, Vector3f position, float rotation = 0, bool isLocal = false)
        {
            PlayerAvatar avatar;

            if (!isLocal)
            {
                avatar = new PlayerAvatar(data)
                {
                    Position = position, Rotation = rotation
                };
            }
            else
            {
                avatar = new LocalPlayerAvatar(m_NetClient)
                {
                    Position = position, Rotation = rotation
                };
            }

            Players.Add(avatar);
            return(avatar);
        }
        protected IPlayerStatisticsViewModel AddNewPlayerToPlayersIfNotFound(IPlayerStatisticsViewModel matchingPlayer)
        {
            if (matchingPlayer == null)
            {
                matchingPlayer = _playerStatisticsViewModelMake.New;

                matchingPlayer.SelectedStatisticsSetEvent +=
                    sequenceStatisticsSet => {
                    DetailedStatisticsAnalyzer.InitializeWith(sequenceStatisticsSet);
                    UserSelectedStatisticsSet(sequenceStatisticsSet);
                };

                matchingPlayer.BrowseAllMyHandsRequested += player => {
                    BrowseAllHandsOf(player);
                    UserBrowsedAllHands(player);
                };

                Players.Add(matchingPlayer);
            }

            return(matchingPlayer);
        }
Beispiel #12
0
        private void NewGame()
        {
            if (Player1 == null)
            {
                Player1 = new Player("Player1", Piece.Color.RED);
            }
            if (Player2 == null)
            {
                Player2 = new Player("Player2", Piece.Color.WHITE);
            }
            Players.Add(Player1);
            Players.Add(Player2);

            Player oldPlayer;

            if (Players.TryGetValue(Player1, out oldPlayer))
            {
                Player1.Wins   = oldPlayer.Wins;
                Player1.Losses = oldPlayer.Losses;
                Player1.Draws  = oldPlayer.Draws;
            }
            if (Players.TryGetValue(Player2, out oldPlayer))
            {
                Player2.Wins   = oldPlayer.Wins;
                Player2.Losses = oldPlayer.Losses;
                Player2.Draws  = oldPlayer.Draws;
            }
            if (Player1.HasTurn == Player2.HasTurn)
            {
                Player1.HasTurn = true;
                Player2.HasTurn = false;
            }
            if (Player1.Color == Player2.Color)
            {
                Player1.Color = Piece.Color.RED;
                Player2.Color = Piece.Color.WHITE;
            }
        }
Beispiel #13
0
        /// <summary>
        /// Update this server instance with information from the supplied heartbeat packet
        /// </summary>
        /// <param name="data"></param>
        public void Update(byte packetType, UDPPacket data)
        {
            switch ((UDPServerQueryClient.UDPServerQueryType)packetType)
            {
            case UDPServerQueryClient.UDPServerQueryType.Basic:
                /* this.serverID = */ data.PopInt();
                /* this.serverIP = */ data.PopString();
                this.Port = data.PopInt();
                /* this.QueryPort = */ data.PopInt();
                this.Name           = data.PopString();
                this.Map            = data.PopString();
                this.GameType       = data.PopString();
                this.CurrentPlayers = data.PopInt();
                this.MaxPlayers     = data.PopInt();
                /* this.Ping = */ data.PopInt();

                this.Active     = true;
                this.LastUpdate = DateTime.Now;
                this.listEntry  = new ServerListEntry(Address, (ushort)Port, (ushort)QueryPort, Name, Map, GameType, (byte)CurrentPlayers, (byte)MaxPlayers, Flags);

                break;

            case UDPServerQueryClient.UDPServerQueryType.GameInfo:
                Properties = data.PopKeyValues();

                break;

            case UDPServerQueryClient.UDPServerQueryType.PlayerInfo:
                Players.Clear();

                while (!data.EOF)
                {
                    Players.Add(new Player(this, data, ""));
                }

                break;
            }
        }
Beispiel #14
0
        public ServerStatus(string status) : this()
        {
            if (string.IsNullOrEmpty(status))
            {
                throw new ArgumentException($"Argument can't be null '{nameof(status)}'");
            }

            var lines = status.Split('\n', StringSplitOptions.RemoveEmptyEntries).Select(l => l.Trim());

            foreach (var line in lines)
            {
                if (line.StartsWith("????") || line.StartsWith("cl ") || line.StartsWith("-- "))
                {
                    continue;
                }

                if (line.StartsWith("map: "))
                {
                    Map = line.Substring(5);
                }

                var match = LineParserRegex.Match(line);
                if (!match.Success)
                {
                    continue;
                }

                var player = new Player {
                    CL    = int.Parse(match.Groups["cl"].Value),
                    Score = int.Parse(match.Groups["score"].Value),
                    Ping  = int.Parse(match.Groups["ping"].Value),
                    Name  = Regex.Replace(match.Groups["name"].Value, @"\^\d", ""),
                    Rate  = int.Parse(match.Groups["rate"].Value)
                };

                Players.Add(player);
            }
        }
Beispiel #15
0
        public void UpdateOnlyGuildWithNoChars(ExportMethodEnum ExportMethod)
        {
            int count = 0;

            if (CheckLastUpdateWithCurrent(ExportMethodEnum.Database))
            {
                for (int i = 0; i < PlayerNames.Count; i++)
                {
                    count++;
                    SWGoH.PlayerDto player = new PlayerDto(PlayerNames[i]);
                    int             ret    = player.ParseSwGoh(ExportMethod, false, false);
                    if (ret == 1)
                    {
                        if (Players == null)
                        {
                            Players = new List <PlayerDto>();
                        }
                        player.LastClassUpdated = null;
                        Players.Add(player);
                        SWGoH.Log.ConsoleMessage("Added Player : " + player.PlayerName + " aka " + player.PlayerNameInGame);
                    }
                    else if (ret == 0)
                    {
                        Thread.Sleep(Settings.appSettings.DelayErrorPerPlayerAtGuildSearch);
                        i--;
                    }
                    else
                    {
                        if (Players == null)
                        {
                            Players = new List <PlayerDto>();
                        }
                        Players.Add(player);
                    }
                }
                Export(ExportMethod, false);
            }
        }
Beispiel #16
0
 public bool Join(User user)
 {
     if (currentPhase == Phase.Join)
     {
         if (Players.Any(x => x.UserId == user.UserId))
         {
             Bot.Say(user.Username, "Olet jo blackjack pelissä.");
         }
         else
         {
             var player = new BlackjackPlayer(user);
             HitPlayer(player, 2);
             Players.Add(player);
             Bot.Say(user.Username, "Liityit blackjack peliin.");
             return(true);
         }
     }
     else
     {
         Bot.Say(user.Username, "Et voi enää liittyä blackjack peliin.");
     }
     return(false);
 }
    private GameManager()
    {
        if ((NbPlayers < GameConsts.MIN_PLAYERS) || (NbPlayers > GameConsts.MAX_PLAYERS))
        {
            throw new WrongGameSettingsException("Wrong number of players: " + NbPlayers);
        }

        this.Players = new List <Player>();
        for (int i = 0; i < NbPlayers; i++)
        {
            Player player = new Player();
            player.Name          = (i == 0) ? "You" : GameConsts.PLAYERS_NAME[i - 1];
            player.City          = new CityManager(player);
            player.WonderManager = new WonderManager(player);
            if (i == 0)
            {
                player.IsHuman = true;
            }
            Players.Add(player);
        }
        Age         = 1;
        DiscardPile = new List <Playable>();
    }
        public Tournament(TournamentModel _model)
        {
            if (null == _model)
            {
                throw new ArgumentNullException("_model");
            }

            this.Title = _model.Title;

            this.Players = new List <IPlayer>();
            foreach (TournamentUserModel userModel in _model.TournamentUsers)
            {
                Players.Add(new Player(userModel));
            }

            this.Brackets = new List <IBracket>();
            foreach (BracketModel bModel in _model.Brackets)
            {
                AddBracket(RestoreBracket(bModel));
            }

            this.PrizePool = (float)(_model.PrizePurse);
        }
Beispiel #19
0
        public Player Ready(User user)
        {
            CheckNotDistributed();

            var maxCount = GameState.NewGameState.PlayersDistribution.Distributions.Length;

            if (Players.Count == maxCount)
            {
                throw new GameCommandException(LocalizedStrings.Game_TooMuchPlayers);
            }
            var player = new Player(user);

            if (Players.Contains(player))
            {
                throw new GameCommandException(LocalizedStrings.Game_YouAreInGameAlready);
            }
            if (Players.Any(pl => pl.Id == player.Id))
            {
                throw new GameCommandException(LocalizedStrings.Fault_TheSameId);
            }
            Players.Add(player);
            return(player);
        }
Beispiel #20
0
    private PlayerController CreatePlayer(PlayerController prefab, PlayerInfo pInfo, SpawnPoint spawn)
    {
        // Create the Player
        PlayerController player = Instantiate <PlayerController>(prefab);

        player.Game = this;
        player.Info = pInfo;
        player.transform.position = spawn.transform.position;

        // Add the player to the Game
        Players.Add(player);
        CameraController.m_Targets.Add(player.transform);

        // Create player's UI
        PlayerUIPanelController playerUI = Instantiate <PlayerUIPanelController>(PlayerUIPanelPrefab);

        playerUI.Player = player;
        playerUI.transform.SetParent(PlayerUIPanel);
        // playerUI.heroImg = // Future assignments

        // Return the player
        return(player);
    }
Beispiel #21
0
        private IEnumerator UpdateSetups()
        {
            while (true)
            {
                yield return(null);

                Players.Clear();
                AllPlayerEntities.Clear();
                for (int i = 0; i < Scene.SceneTracker.allPlayers.Count; i++)
                {
                    Players.Add(Scene.SceneTracker.allPlayers[i]);
                    BoltEntity b = Scene.SceneTracker.allPlayers[i].GetComponent <BoltEntity>();
                    if (b != null)
                    {
                        AllPlayerEntities.Add(b);
                    }
                }



                yield return(new WaitForSeconds(10));
            }
        }
Beispiel #22
0
        protected void PopulateForTeaching(int quantity, string[] names)
        {
            MonteCarloUpgradePlayer monteCarloUpgradePlayer = new MonteCarloUpgradePlayer(names[0]);

            monteCarloUpgradePlayer.id = 0;
            Players.Add(monteCarloUpgradePlayer);

            MonteCarloPlayer monteCarloPlayer = new MonteCarloPlayer(names[1]);

            monteCarloPlayer.id = 1;
            Players.Add(monteCarloPlayer);

            DynamicGreedyPlayer dynamicGreedyPlayer = new DynamicGreedyPlayer(names[2]);

            dynamicGreedyPlayer.id = 2;
            Players.Add(dynamicGreedyPlayer);


            RandomPlayer randomPlayer = new RandomPlayer(names[3]);

            randomPlayer.id = 3;
            Players.Add(randomPlayer);
        }
Beispiel #23
0
        public override void Deserialize(byte[] data, Pointer p, bool includeSubComponents)
        {
            // General match info
            Owner  = BitPacker.GetInt(data, p);
            GameID = new Guid(BitPacker.GetString(data, p));

            // Options
            Properties = BitPacker.GetPropertyBag(data, p);

            // Players
            int numPlayers = BitPacker.GetInt(data, p);

            for (int i = 0; i < numPlayers; i++)
            {
                CharacterInfo ci = new CharacterInfo();
                ci.Properties = BitPacker.GetPropertyBag(data, p);
                ci.Stats      = BitPacker.GetStatBag(data, p);
                ci.ID         = BitPacker.GetInt(data, p);
                Players.Add(ci.ID, ci);
            }

            base.Deserialize(data, p, includeSubComponents);
        }
Beispiel #24
0
        public void Start()
        {
            if (State != State.Lobby && State != State.Created)
            {
                throw new WrongMatchStateException();
            }

            // todo: define somewhere
            if (Players.Count != 4)
            {
                for (int i = Players.Count; i < 4; i++)
                {
                    Players.Add(new Player());
                }
                //throw new NotEnoughPlayersException();
            }

            State = State.InGame;

            BoardState = new BoardState(Players);
            SetRandomStartPlayer();
            SendMessageToPlayers(new AsyncMessage(MessageType.GameStarted));
        }
Beispiel #25
0
        /*
         *
         * Methods
         *
         */
        public Player GetPlayer(UInt32 id)
        {
            if (id == Me.Id)
            {
                return(Me);
            }
            else
            {
                Player temp;
                bool   success = Players.TryGetValue(id, out temp);

                if (success)
                {
                    return(temp);
                }
                else
                {
                    Players.Add(id, new Player());
                    Players[id].Id = id;
                    return(Players[id]);
                }
            }
        }
Beispiel #26
0
        public void AddPlayer(User player)
        {
            if (Players.Select(member => member.UserId).Contains(player.Id))
            {
                return;
            }

            Players.Add(new Membership()
            {
                TeamId = Id, UserId = player.Id
            });

            foreach (var evt in Events)
            {
                evt.Participations.Add(new Participation()
                {
                    Confirmed = false,
                    Created   = DateTime.Now,
                    EventId   = evt.Id,
                    UserId    = player.Id
                });
            }
        }
Beispiel #27
0
        public ClientPlayer GetOrCreateClientPlayer(string uid)
        {
            if (uid == null)
            {
                return(null);
            }

            PlayerEntity pl;

            if (Players.GetPlayer(uid, out pl))
            {
                return((ClientPlayer)pl);
            }
            if (uid == MainBehaviour.Player.UserID)
            {
                Players.Add(MainBehaviour.Player);
                return(MainBehaviour.Player);
            }
            pl        = new ClientPlayer();
            pl.UserID = uid;
            Players.Add(pl);
            return((ClientPlayer)pl);
        }
        internal void PlayerAssign(AssignPlayerPacket packet)
        {
            if (packet.Name == ClientCharacter.Name && packet.Class == ClientCharacter.Class)
            {
                if (Me == null)
                {
                    Me = new Self(packet);
                }

                Me.Location = packet.Location;
            }

            var player = Players.Where(p => p.Id == packet.Id).FirstOrDefault();

            if (player == null)
            {
                Players.Add(new Player(packet));
            }
            else
            {
                player.Location = packet.Location;
            }
        }
Beispiel #29
0
        /// <summary>
        /// Will add player object to game players dict and will check game fullfilment
        /// </summary>
        /// <param name="player">Player object</param>
        public void AddPlayer(Player player)
        {
            if (Status != GameState.Locked)
            {
                //GamePropertyChanged("Players");

                player.PropertyChanged += PlayerPropertyChanged;

                Players.Add(player.Guid, player);

                CheckGameFulfillment();

                ListChanged = true;

                PropChanged = true;

                Log.Information("Game: Player '{0}' added to the game '{1}'", player.Name, this.Name);
            }
            else
            {
                Log.Information("Can't allow add player {0} to game {1}. Game is locked", player.Name, this.Name);
            }
        }
Beispiel #30
0
        /// <summary>
        /// Récupère les données d'un joueur connecté au serveur, soit les personnages et leur position et leur vitalité
        /// er instancie le joueur s'il n'est pas dans la liste de joueur du client
        /// </summary>
        /// <param name="inc"></param>
        private void ReadPlayer(NetIncomingMessage inc)
        {
            var player = new Player();

            inc.ReadAllProperties(player);
            for (int i = 0; i < player.Personnages.Capacity; ++i)
            {
                player.Personnages.Add(ReadPersonnage(inc, player.Username));
            }
            if (Players.Any(p => p.Username == player.Username))
            {
                var oldPlayer = Players.FirstOrDefault(p => p.Username == player.Username);
                for (int i = 0; i < player.Personnages.Count; ++i)
                {
                    if (player.Personnages[i].Position != oldPlayer.Personnages[i].Position)
                    {
                        oldPlayer.Personnages[i].GérerPositionObjet(player.Personnages[i].Position);
                    }
                    if (player.Personnages[i].PtsDeVie != oldPlayer.Personnages[i].PtsDeVie)
                    {
                        oldPlayer.Personnages[i].ChangerVitalité(player.Personnages[i].PtsDeVie);
                    }
                }
            }
            else
            {
                Players.Add(player);
                foreach (Personnage p in player.Personnages)
                {
                    Jeu.Components.Add(p);
                    IdentificateurPersonnage identificateur = new IdentificateurPersonnage(Jeu, p);
                    identificateur.DrawOrder = (int)OrdreDraw.AVANT_PLAN;
                    Jeu.Components.Add(identificateur);
                    AjouterIcôneEffet(Jeu, p, identificateur);
                }
            }
        }