public Do Run( string input, AlchemyController controller, ICommunicator communicator ) { string elementname = input.TrimStart( '*' ); if( controller.ElementExists( elementname ) ) controller.ForeachNonterminalElement( ( e ) => controller.ReportChangedRule( new Rule( new[] { elementname, e.Name } ) ) ); return Do.AnotherRule; }
public Do Run( string input, AlchemyController controller, ICommunicator communicator ) { var splitinput = input.TrimStart( ' ', '#' ).Split( ':' ); if( splitinput.Length < 2 ) return Do.AnotherRule; var ingredients = splitinput[0].Split( ',' ); foreach( var ingredient in ingredients ) { if( !controller.ElementExists( ingredient ) ) { communicator.Display( "Bad data, element named '" + ingredient + "' isnt in list of known elements. If this isnt a typo, please add element using '>element', or, if possible, add rule that creates element" ); return Do.AnotherRule; } } var rule = new Rule( ingredients ); rule.SetResult( splitinput[1] ); controller.ReportChangedRule( rule, true ); return Do.AnotherRule; }