// Player.ReadFromStream
public virtual void ReadFromStream(System.IO.Stream stream)
{
System.IO.StreamReader streamReader = new System.IO.StreamReader(stream);
// THIS VARIABLE IS NULL!
string textToExtractVariablesFrom = streamReader.ReadLine(); // The text to extract variables from
if (textToExtractVariablesFrom == null) return;
string nameValue = textToExtractVariablesFrom.Substring(textToExtractVariablesFrom.IndexOf('=') + 1, textToExtractVariablesFrom.Length - 1 - textToExtractVariablesFrom.IndexOf('='));
Name = nameValue;
}
// InbetweenerPlayer.ReadFromStream
public override void ReadFromStream(System.IO.Stream stream)
{
base.ReadFromStream(stream);
System.IO.StreamReader streamReader = new System.IO.StreamReader(stream);
string betAmountText = streamReader.ReadLine(); // Bet Amount= xxx
string creditsText = streamReader.ReadLine(); // Credits= xxx
// Extract it from the string's
int newBetAmount = Convert.ToInt32(betAmountText.Substring(betAmountText.IndexOf('=') + 1, betAmountText.Length - 1 - betAmountText.IndexOf('=')));
int newCredits = Convert.ToInt32(creditsText.Substring(creditsText.IndexOf('=') + 1, creditsText.Length - 1 - creditsText.IndexOf('=')));
// Set the variables
BetAmount = newBetAmount;
Credits = newCredits;
}
// InbetweenersGame.ReadFromStream
public void ReadFromStream(System.IO.Stream stream)
{
////////////////////////////////////////////// FROM HERE ////////////////////////////////////////////
StreamReader streamReader = new StreamReader(stream);
// Get the information out of the stream reader.
string amountOfPlayersTextToParse = streamReader.ReadLine();
string amountOfCreditsGivenToAPlayerTextToParse = streamReader.ReadLine();
string amountOfCreditsGivenToAPlayerWhenNoCreditsLeftTextToParse = streamReader.ReadLine();
string minimumRandomNumberTextToParse = streamReader.ReadLine();
string maximumRandomNumberTextToParse = streamReader.ReadLine();
// Grab the variables from the strings
int newAmountOfPlayers = Convert.ToInt32(amountOfPlayersTextToParse.Substring(amountOfPlayersTextToParse.IndexOf('=') + 1,
amountOfPlayersTextToParse.Length - 1 - amountOfPlayersTextToParse.IndexOf('=')));
int newAmountOfCreditsGivenToAPlayer = Convert.ToInt32(amountOfCreditsGivenToAPlayerTextToParse.Substring(amountOfCreditsGivenToAPlayerTextToParse.IndexOf('=') + 1,
amountOfCreditsGivenToAPlayerTextToParse.Length - 1 - amountOfCreditsGivenToAPlayerTextToParse.IndexOf('=')));
int newAmountOfCreditsGivenToAPlayerWhenNoCreditsLeft = Convert.ToInt32(amountOfCreditsGivenToAPlayerWhenNoCreditsLeftTextToParse.Substring(amountOfCreditsGivenToAPlayerWhenNoCreditsLeftTextToParse.IndexOf('=') + 1,
amountOfCreditsGivenToAPlayerWhenNoCreditsLeftTextToParse.Length - 1 - amountOfCreditsGivenToAPlayerWhenNoCreditsLeftTextToParse.IndexOf('=')));
int newMinimumRandomNumber = Convert.ToInt32(minimumRandomNumberTextToParse.Substring(minimumRandomNumberTextToParse.IndexOf('=') + 1,
minimumRandomNumberTextToParse.Length - 1 - minimumRandomNumberTextToParse.IndexOf('=')));
int newMaximumRandomNumber = Convert.ToInt32(maximumRandomNumberTextToParse.Substring(maximumRandomNumberTextToParse.IndexOf('=') + 1,
maximumRandomNumberTextToParse.Length - 1 - maximumRandomNumberTextToParse.IndexOf('=')));
// set the variables
InbetweenerPlayer.AmountOfCreditsGivenWhenNoCreditsLeft = newAmountOfCreditsGivenToAPlayerWhenNoCreditsLeft;
InbetweenerPlayer.DefaultAmountOfCredits = newAmountOfCreditsGivenToAPlayer;
AmountOfPlayers = newAmountOfPlayers;
this.MinimumRandomNumberToGenerate = newMinimumRandomNumber;
this.MaximumRandomNumberToGenerate = newMaximumRandomNumber;
////////////////////////////////////////////////////// To here is fine /////////////////////////////////
for (int i = 0; i < AmountOfPlayers; ++i)
{
players[i].ReadFromStream(stream); // This stuffs up
}
}