ficdown/Ficdown.Parser/FicDownParser.cs

44 lines
1.4 KiB
C#
Raw Normal View History

using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("Ficdown.Parser.Tests")]
namespace Ficdown.Parser
{
using System;
using System.Collections.Generic;
using Model.Parser;
using Parser;
using Player;
public class FicdownParser
{
private IBlockHandler _blockHandler;
internal IBlockHandler BlockHandler
{
get { return _blockHandler ?? (_blockHandler = new BlockHandler()); }
set { _blockHandler = value; }
}
private IGameTraverser _gameTraverser;
internal IGameTraverser GameTraverser
{
get { return _gameTraverser ?? (_gameTraverser = new GameTraverser()); }
set { _gameTraverser = value; }
}
2014-06-30 11:59:56 -05:00
private IStateResolver _stateResolver;
internal IStateResolver StateResolver
2014-06-30 11:59:56 -05:00
{
get { return _stateResolver ?? (_stateResolver = new StateResolver()); }
set { _stateResolver = value; }
2014-06-30 11:59:56 -05:00
}
public IEnumerable<ResolvedPage> ParseStory(string storyText)
{
var lines = storyText.Split(new[] {"\n", "\r\n"}, StringSplitOptions.None);
var blocks = BlockHandler.ExtractBlocks(lines);
GameTraverser.Story = BlockHandler.ParseBlocks(blocks);
return StateResolver.Resolve(GameTraverser.Enumerate());
}
}
}