public override void Parse(StreamReader inStream) { if (m_parseState == null) { m_parseState = new ParserState(); } bool lineHasOpenBrace = false; bool lineHasCloseBrace = false; m_baseReelset.Name = "BR_"; m_baseReelset.Type = ReelType.BASEREEL; m_freeReelset.Name = "FR_"; m_freeReelset.Type = ReelType.FREEREEL; m_baseModReelset.Name = "BR_M_"; m_baseModReelset.Type = ReelType.BASEMODREEL; m_freeModReelset.Name = "FR_M_"; m_freeModReelset.Type = ReelType.FREEMODREEL; BallyReel tmpReel = new BallyReel(); String line = ""; using (inStream) { while ((line = inStream.ReadLine()) != null) { if (line.Contains("/")) { int pos = line.IndexOf("/"); line = line.Remove(pos); } line = line.Trim(); if (line.Length == 0 || line == "") { continue; } // look for reels if (line == "reels") { m_parseState.EnterBaseReelSet(); continue; } if (line == "freegame_reels") { m_parseState.EnterFreeReelSet(); continue; } if (line == "modifierset") { m_parseState.EnterModifierReelSet(); continue; } if (line == "paytableoptions") { break; } if (m_parseState.ReelSetStart || m_parseState.FreeSetStart) { // check for braces if (line == m_util.openBrace) { m_parseState.EnterArrayLevel(); continue; } lineHasOpenBrace = line.Contains(m_util.openBrace); lineHasCloseBrace = line.Contains(m_util.closeBrace); if (!lineHasOpenBrace && !lineHasCloseBrace) { continue; } if ((line.Length > 1) && lineHasOpenBrace && (m_parseState.ReelSetStart || m_parseState.FreeSetStart || m_parseState.ModifierSetStart)) { if (!m_parseState.ReelStart && !m_parseState.FreeStart && !m_parseState.ModifierStart) { if (m_parseState.ReelSetStart && !m_parseState.ModifierSetStart) { m_parseState.EnterBaseReel(); } if (m_parseState.FreeSetStart && !m_parseState.ModifierSetStart) { m_parseState.EnterFreeReel(); } if (m_parseState.ModifierSetStart) { m_parseState.EnterModifierReel(); } } } if (lineHasCloseBrace) { if (line == m_util.closeBrace) { m_parseState.LeaveArrayLevel(); if (m_parseState.ModifierSetStart) { if (m_parseState.StateEnteredLevel[(int)ReelReadState.MODIFIERSETSTART] == m_parseState.ArrayDepth) { m_parseState.LeaveModifierReelSet(); } } else if (m_parseState.ReelSetStart) { if (m_parseState.StateEnteredLevel[(int)ReelReadState.REELSETSTART] == m_parseState.ArrayDepth) { m_parseState.LeaveBaseReelSet(); } } else if (m_parseState.FreeSetStart) { if (m_parseState.StateEnteredLevel[(int)ReelReadState.FREEREELSETSTART] == m_parseState.ArrayDepth) { m_parseState.LeaveFreeReelSet(); } } continue; } // could be end of a reelstop definition, or moving up a level if (line == m_util.arrayEnd) { m_parseState.LeaveArrayLevel(); if (m_parseState.ModifierSetStart) { if (m_parseState.StateEnteredLevel[(int)ReelReadState.MODIFIERSETSTART] == m_parseState.ArrayDepth) { m_parseState.LeaveModifierReelSet(); } } else if (m_parseState.ReelSetStart) { if (m_parseState.StateEnteredLevel[(int)ReelReadState.REELSETSTART] == m_parseState.ArrayDepth) { m_parseState.LeaveBaseReelSet(); } } else if (m_parseState.FreeSetStart) { if (m_parseState.StateEnteredLevel[(int)ReelReadState.FREEREELSETSTART] == m_parseState.ArrayDepth) { m_parseState.LeaveFreeReelSet(); } } continue; } } if (m_parseState.ReelStart || m_parseState.FreeStart || m_parseState.ModifierStart) { tmpReel = new BallyReel(); tmpReel.Parse(inStream, line, m_parseState); if (m_parseState.CurrentSetType == ReelSetType.BASEMODREEL) { m_baseModReelset.AddReel(tmpReel); m_parseState.ResetModifierReel(); } if (m_parseState.CurrentSetType == ReelSetType.BASEREEL) { m_baseReelset.AddReel(tmpReel); m_parseState.ResetBaseReel(); } if (m_parseState.CurrentSetType == ReelSetType.FREEMODREEL) { m_freeModReelset.AddReel(tmpReel); m_parseState.ResetModifierReel(); } if (m_parseState.CurrentSetType == ReelSetType.FREEREEL) { m_freeReelset.AddReel(tmpReel); m_parseState.ResetFreeReel(); } } } } } m_isValid = checkValid(); m_reelWidth = m_baseReelset.Count; }
public override void Parse(StreamReader inStream) { if (m_parseState == null) m_parseState = new ParserState(); bool lineHasOpenBrace = false; bool lineHasCloseBrace = false; m_baseReelset.Name = "BR_"; m_baseReelset.Type = ReelType.BASEREEL; m_freeReelset.Name = "FR_"; m_freeReelset.Type = ReelType.FREEREEL; m_baseModReelset.Name = "BR_M_"; m_baseModReelset.Type = ReelType.BASEMODREEL; m_freeModReelset.Name = "FR_M_"; m_freeModReelset.Type = ReelType.FREEMODREEL; BallyReel tmpReel = new BallyReel(); String line = ""; using (inStream) { while ((line = inStream.ReadLine()) != null) { if (line.Contains("/")) { int pos = line.IndexOf("/"); line = line.Remove(pos); } line = line.Trim(); if (line.Length == 0 || line == "") continue; // look for reels if (line == "reels") { m_parseState.EnterBaseReelSet(); continue; } if (line == "freegame_reels") { m_parseState.EnterFreeReelSet(); continue; } if (line == "modifierset") { m_parseState.EnterModifierReelSet(); continue; } if (line == "paytableoptions") { break; } if (m_parseState.ReelSetStart || m_parseState.FreeSetStart) { // check for braces if (line == m_util.openBrace) { m_parseState.EnterArrayLevel(); continue; } lineHasOpenBrace = line.Contains(m_util.openBrace); lineHasCloseBrace = line.Contains(m_util.closeBrace); if (!lineHasOpenBrace && !lineHasCloseBrace) continue; if ((line.Length > 1) && lineHasOpenBrace && (m_parseState.ReelSetStart || m_parseState.FreeSetStart || m_parseState.ModifierSetStart)) { if (!m_parseState.ReelStart && !m_parseState.FreeStart && !m_parseState.ModifierStart) { if (m_parseState.ReelSetStart && !m_parseState.ModifierSetStart) m_parseState.EnterBaseReel(); if (m_parseState.FreeSetStart && !m_parseState.ModifierSetStart) m_parseState.EnterFreeReel(); if (m_parseState.ModifierSetStart) m_parseState.EnterModifierReel(); } } if (lineHasCloseBrace) { if (line == m_util.closeBrace) { m_parseState.LeaveArrayLevel(); if (m_parseState.ModifierSetStart) { if (m_parseState.StateEnteredLevel[(int)ReelReadState.MODIFIERSETSTART] == m_parseState.ArrayDepth) m_parseState.LeaveModifierReelSet(); } else if (m_parseState.ReelSetStart) { if (m_parseState.StateEnteredLevel[(int)ReelReadState.REELSETSTART] == m_parseState.ArrayDepth) m_parseState.LeaveBaseReelSet(); } else if (m_parseState.FreeSetStart) { if (m_parseState.StateEnteredLevel[(int)ReelReadState.FREEREELSETSTART] == m_parseState.ArrayDepth) m_parseState.LeaveFreeReelSet(); } continue; } // could be end of a reelstop definition, or moving up a level if (line == m_util.arrayEnd) { m_parseState.LeaveArrayLevel(); if (m_parseState.ModifierSetStart) { if (m_parseState.StateEnteredLevel[(int)ReelReadState.MODIFIERSETSTART] == m_parseState.ArrayDepth) m_parseState.LeaveModifierReelSet(); } else if (m_parseState.ReelSetStart) { if (m_parseState.StateEnteredLevel[(int)ReelReadState.REELSETSTART] == m_parseState.ArrayDepth) m_parseState.LeaveBaseReelSet(); } else if (m_parseState.FreeSetStart) { if (m_parseState.StateEnteredLevel[(int)ReelReadState.FREEREELSETSTART] == m_parseState.ArrayDepth) m_parseState.LeaveFreeReelSet(); } continue; } } if (m_parseState.ReelStart || m_parseState.FreeStart || m_parseState.ModifierStart) { tmpReel = new BallyReel(); tmpReel.Parse(inStream, line, m_parseState); if (m_parseState.CurrentSetType == ReelSetType.BASEMODREEL) { m_baseModReelset.AddReel(tmpReel); m_parseState.ResetModifierReel(); } if (m_parseState.CurrentSetType == ReelSetType.BASEREEL) { m_baseReelset.AddReel(tmpReel); m_parseState.ResetBaseReel(); } if (m_parseState.CurrentSetType == ReelSetType.FREEMODREEL) { m_freeModReelset.AddReel(tmpReel); m_parseState.ResetModifierReel(); } if (m_parseState.CurrentSetType == ReelSetType.FREEREEL) { m_freeReelset.AddReel(tmpReel); m_parseState.ResetFreeReel(); } } } } } m_isValid = checkValid(); m_reelWidth = m_baseReelset.Count; }