Skip to content

Commit

Permalink
Merge pull request #20 from AliceNovel/api-change
Browse files Browse the repository at this point in the history
API Change
  • Loading branch information
Lemon73-Computing authored Apr 27, 2024
2 parents 921cc48 + fcb75f3 commit 4bb209a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion AliceConsole/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
if (line == "")
Console.ReadLine();
else if (line is not null)
Anov.Read(line);
Console.WriteLine(Anov.Read(line));
}
Console.ReadLine();
}
19 changes: 11 additions & 8 deletions AnovSyntax/Anov.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,48 +8,51 @@ public class Anov
/// Read the text in anov syntax.
/// </summary>
/// <param name="str">The text in anov syntax</param>
public static void Read(string str)
public static string Read(string str)
{
Match match;
string _return = "";

// Unsupported
// Read "> place"
match = Regex.Match(str, @"> (.*)");
if (match.Success)
Console.WriteLine("<place>");
_return += "<place>";

// Unsupported
// Read "bgm: background-music"
match = Regex.Match(str, @"bgm: (.*)");
if (match.Success)
Console.WriteLine("<bgm>");
_return += "<bgm>";

// Unsupported
// Read "movie: movie"
match = Regex.Match(str, @"movie: (.*)");
if (match.Success)
Console.WriteLine("<movie>");
_return += "<movie>";

// Read "- people-name / emotion"
match = Regex.Match(str, @"- (.*?)/");
if (match.Success)
Console.Write(match.Groups[1].Value.Trim());
_return += match.Groups[1].Value.Trim();
else
{
// Read "- people-name"
match = Regex.Match(str, @"- (.*)");
if (match.Success)
Console.Write(match.Groups[1].Value.Trim());
_return += match.Groups[1].Value.Trim();
}

// Read "/ emotion"
match = Regex.Match(str, @"/ (.*)");
if (match.Success)
Console.Write(" (" + match.Groups[1].Value.Trim() + ")");
_return += " (" + match.Groups[1].Value.Trim() + ")";

// Read "[conversatioc-content]"
match = Regex.Match(str, @"\[(.*?)\]");
if (match.Success)
Console.WriteLine(" \"" + match.Groups[1].Value.Trim() + "\"");
_return += " \"" + match.Groups[1].Value.Trim() + "\"";

return _return;
}
}

0 comments on commit 4bb209a

Please sign in to comment.