Skip to content

Commit

Permalink
Tags.roundNumber
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Jun 13, 2024
1 parent 06be3bd commit 52a6d5a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion core/src/main/scala/format/pgn/Tag.scala
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,14 @@ case class Tags(value: List[Tag]) extends AnyVal:
Tags.tagIndex.getOrElse(tag.name, 999)
)

def roundNumber: Option[Int] =
// Round x.y is sometimes used for round x
apply(_.Round).map(_.takeWhile(_.isDigit)).flatMap(_.toIntOption)

def boardNumber: Option[Int] =
apply(_.Board)
.flatMap(_.toIntOption)
.orElse: // Round 1.x is sometimes used for board x
.orElse: // Round x.y is sometimes used for board y
apply(_.Round)
.flatMap(_.split('.').lift(1))
.flatMap(_.toIntOption)
Expand Down

0 comments on commit 52a6d5a

Please sign in to comment.