/// Methods for searching the pattern collection /// /// <summary> /// Get all the Patterns that start with a given identifier ie CD /// </summary> /// <param name="identifier"></param> /// <returns></returns> public virtual BasicGamePatternCollection GetAllPatternsWithIdentifer(string identifier) { BasicGamePatternCollection unit = new BasicGamePatternCollection(); for (int i = 0; i < arrayPatterns.Count; i++) { if ((( BasicGamePattern )arrayPatterns[i]).StartsWith(identifier) == true) { unit.AddPattern(new BasicGamePattern(( BasicGamePattern )arrayPatterns[i])); } } return(unit); }
public void UpdatePattern(BasicGamePattern basicGamePattern) { /// nothing to update here /// BasicGamePatternCollection collection = GetAllPatternsWithIdentifer(basicGamePattern.GetStartsWith()); if (collection.Count == 0) { System.Diagnostics.Debug.Assert(collection.Count != 0, "Error updating the pattern", "Error the pattern has been identified as " + basicGamePattern.GetStartsWith() + " but GetAllPatternsWithIdentifier returns a count of 0 "); return; } for (int i = 0; i < collection.Count; i++) { if ((( BasicGamePattern )collection.Patterns[i]) == basicGamePattern) { (( BasicGamePattern )collection.Patterns[i]).UpdatePattern(basicGamePattern); return; } } }