~nmh/log-parser-18xx

89a25bd6ba06fd9d20ac759347f965dd572862fe — nick hansen 3 years ago 08267b3
start support for 1861
2 files changed, 13 insertions(+), 1 deletions(-)

M src/LogParser/Parse.hs
M test/ParseSpec.hs
M src/LogParser/Parse.hs => src/LogParser/Parse.hs +8 -1
@@ 56,7 56,7 @@ data CurrencyType = PrefixCurrency Text

knownCurrencyPrefixes,knownCurrencySuffixes :: [Text]
knownCurrencyPrefixes = ["$", "¥", "£"]
knownCurrencySuffixes = [" F"]
knownCurrencySuffixes = [" F", "₽"]

parseLogEntries :: Monad m => Pipe Text LogEntry m (Either LogParserError a)
parseLogEntries = parseLogEntries' emptyParseState


@@ 208,6 208,7 @@ logEntry = (datestamp <|> (timestamp >> P.choice toplevelChoices)) <* P.eof
    , P.try newPlayerPass
    , P.try newCompanyFloat
    , P.try newCompanyAvailableFromBank
    , P.try newCompanyUpForAuction
    , P.try newPlayerBuysCompany
    , newPlayerChatMessage
    ]


@@ 353,6 354,12 @@ newCompanyAvailableFromBank :: Parser LogEntry
newCompanyAvailableFromBank =
  newCompany " is now available for purchase from the Bank" >> pure InformationalMessage

newCompanyUpForAuction :: Parser LogEntry
newCompanyUpForAuction =
  newCompany " is up for auction, minimum bid is "
  >> dollars
  >> pure InformationalMessage

companyReceivesSomething :: Company -> Parser LogEntry
companyReceivesSomething c = P.string " receives " >> P.choice
  [ P.string "no mail income as it has no trains"

M test/ParseSpec.hs => test/ParseSpec.hs +5 -0
@@ 678,6 678,11 @@ spec = do
        `shouldParseAsLogEntry`
        InformationalMessage

      it "parses InformationalMessage 20" $
        "[10:54]yoyodyne is up for auction, minimum bid is $20"
        `shouldParseAsLogEntry`
        InformationalMessage

      it "parses PlayerShareCompensation" $
        "[12:17]kanye west receives $40 in share compensation"
        `shouldParseAsLogEntry`