• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

LuciaCastellucci / PPS-24-whodunnit / 19210700935

09 Nov 2025 03:37PM UTC coverage: 81.818% (-4.7%) from 86.481%
19210700935

push

github

LuciaCastellucci
chore: merge branch 'feat/versioning' into dev

4 of 29 new or added lines in 2 files covered. (13.79%)

2 existing lines in 2 files now uncovered.

405 of 495 relevant lines covered (81.82%)

0.82 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/scala/model/ModelModule.scala
1
package model
2

3
import model.game.GameState
4

5
object ModelModule:
6

7
  trait Model:
8
    def state: GameState
9
    def updateState(updater: GameState => GameState): GameState
10
    def startTimer(): Unit
11
    def resetState(): GameState
12

13
    def addHint(hint: game.Hint): GameState =
×
14
      updateState(_.addHint(hint))
×
15

16
    def updateHistory(f: game.History => game.History): GameState =
×
17
      updateState(_.updateHistory(f))
×
18

19
    def addGraphToHistory(graph: game.CaseKnowledgeGraph): GameState =
×
20
      updateState(_.addGraphToHistory(graph))
×
21

NEW
22
    def undo(): Option[game.CaseKnowledgeGraph] =
×
NEW
23
      state.history.flatMap { history =>
×
NEW
24
        val (newHistory, previousGraph) = history.undo()
×
NEW
25
        previousGraph.map { graph =>
×
NEW
26
          updateState(_.withHistory(newHistory))
×
27
          graph
28
        }
29
      }
30

NEW
31
    def redo(): Option[game.CaseKnowledgeGraph] =
×
NEW
32
      state.history.flatMap { history =>
×
NEW
33
        val (newHistory, nextGraph) = history.redo()
×
NEW
34
        nextGraph.map { graph =>
×
NEW
35
          updateState(_.withHistory(newHistory))
×
36
          graph
37
        }
38
      }
39

NEW
40
    def saveSnapshot(): Unit =
×
NEW
41
      state.history.foreach { history =>
×
NEW
42
        state.timeMachine.foreach { tm =>
×
NEW
43
          tm.save(history)
×
44
        }
45
      }
46

NEW
47
    def restoreSnapshot(): Option[game.CaseKnowledgeGraph] =
×
NEW
48
      state.timeMachine.flatMap { tm =>
×
NEW
49
        tm.restore().map { restoredHistory =>
×
NEW
50
          updateState(_.withHistory(restoredHistory))
×
NEW
51
          tm.clear()
×
NEW
52
          restoredHistory.currentState.getOrElse(
×
NEW
53
            new game.CaseKnowledgeGraph()
×
54
          )
55
        }
56
      }
57

NEW
58
    def hasSnapshot: Boolean =
×
NEW
59
      state.timeMachine.exists(_.hasSnapshot)
×
60

NEW
61
    def clearSnapshot(): Unit =
×
NEW
62
      state.timeMachine.foreach(_.clear())
×
63

64
  trait Provider:
65
    def model: Model
66

67
  trait Component:
68

69
    class ModelImpl extends Model:
70

71
      @volatile private var currentState: GameState = GameState.empty()
×
72

73
      override def state: GameState = currentState
×
74

75
      override def updateState(updater: GameState => GameState): GameState =
×
76
        synchronized {
×
77
          currentState = updater(currentState)
×
78
          currentState
79
        }
80

81
      override def resetState(): GameState =
×
82
        synchronized {
×
83
          currentState = GameState.empty()
×
84
          currentState
85
        }
86

87
      override def startTimer(): Unit =
×
88
        synchronized {
×
89
          currentState.timer.foreach(_.start())
×
90
        }
91

92
  trait Interface extends Provider with Component:
93
    override lazy val model: Model = new ModelImpl()
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc