Skip to content

Commit

Permalink
lint: verify that each line contains only one jump
Browse files Browse the repository at this point in the history
As discussed in entropia#231 and entropia#238, TipToi pens handle a jump after all other
actions (even if they are earlier in the list). If there are multiple
jumps, only the last has an effect. This lint check verifies that a GME
only contains one jump, and that the jump is the last action. This check
is true for all GMEs published by Ravensburger.
  • Loading branch information
Thomas Bleher committed Dec 5, 2020
1 parent 9313000 commit 002bff7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Lint.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ lintTipToi :: TipToiFile -> Segments -> IO ()
lintTipToi tt segments = do
let hyps = [ (hyp1, "play indicies are correct")
, (hyp2, "media indicies are correct")
, (hyp3, "at most one jump per line, as last action")
]
forM_ hyps $ \(hyp, desc) -> do
let wrong = filter (not . hyp) (concat (mapMaybe snd (ttScripts tt)))
Expand Down Expand Up @@ -46,6 +47,13 @@ lintTipToi tt segments = do
hyp2 :: Line ResReg -> Bool
hyp2 (Line _ _ _ mi) = all (< media_count) mi

max_one_jump_at_end [] = True
max_one_jump_at_end (Jump x : acts) = null acts
max_one_jump_at_end (x : acts) = max_one_jump_at_end acts

hyp3 :: Line ResReg -> Bool
hyp3 (Line _ _ as _) = max_one_jump_at_end as

report :: Segment -> Segment -> IO ()
report (o1,l1,d1) (o2,l2,d2)
| l1 == l2 && o1 == o2
Expand Down

0 comments on commit 002bff7

Please sign in to comment.