Descent.Messaging.Events.PlayersInGameEventArgs.PopulateWithArgs C# (CSharp) Method

PopulateWithArgs() public method

public PopulateWithArgs ( string stringArgs ) : void
stringArgs string
return void
        public override void PopulateWithArgs(string[] stringArgs)
        {
            Contract.Requires(stringArgs != null);
            Contract.Requires(stringArgs.Length >= 3);

            Contract.Requires(EventContractHelper.TryParseInt(stringArgs[0]) && int.Parse(stringArgs[0]) >= 1);
            Contract.Requires(Contract.ForAll(1, stringArgs.Length, i => (i % 2 == 1) ? EventContractHelper.TryParseInt(stringArgs[i]) : true));

            NumberOfPlayers = int.Parse(stringArgs[0]);
            Players = new PlayerInGame[NumberOfPlayers];

            string[] playerStrings = stringArgs.Skip(1).ToArray();

            int currPlayer = 0;
            for (int i = 0; i < playerStrings.Length; i += 2)
            {
                int id = int.Parse(playerStrings[i]);
                string nick = playerStrings[i + 1];
                Players[currPlayer] = new PlayerInGame(id, nick);
                currPlayer++;
            }
        }