2014-06-29 23:04:51 -05:00
|
|
|
|
namespace Ficdown.Parser
|
|
|
|
|
{
|
|
|
|
|
using Engine;
|
|
|
|
|
using Model.Story;
|
|
|
|
|
|
|
|
|
|
public class FicdownParser
|
|
|
|
|
{
|
|
|
|
|
private IBlockHandler _blockHandler;
|
|
|
|
|
public IBlockHandler BlockHandler
|
|
|
|
|
{
|
|
|
|
|
get { return _blockHandler ?? (_blockHandler = new BlockHandler()); }
|
|
|
|
|
set { _blockHandler = value; }
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-30 11:59:56 -05:00
|
|
|
|
private ISceneLinker _sceneLinker;
|
|
|
|
|
|
|
|
|
|
public ISceneLinker SceneLinker
|
|
|
|
|
{
|
|
|
|
|
get { return _sceneLinker ?? (_sceneLinker = new SceneLinker()); }
|
|
|
|
|
set { _sceneLinker = value; }
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-30 16:57:14 -05:00
|
|
|
|
public Story ParseStory(string storyText)
|
2014-06-29 23:04:51 -05:00
|
|
|
|
{
|
2014-06-30 16:57:14 -05:00
|
|
|
|
var lines = storyText.Split('\n');
|
2014-06-29 23:04:51 -05:00
|
|
|
|
var blocks = BlockHandler.ExtractBlocks(lines);
|
2014-06-30 16:57:14 -05:00
|
|
|
|
var story = BlockHandler.ParseBlocks(blocks);
|
|
|
|
|
SceneLinker.ExpandScenes(story);
|
|
|
|
|
return story;
|
2014-06-29 23:04:51 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|