Skip to content

Class Model and Data

Annika Muecke edited this page Aug 3, 2022 · 5 revisions

class_diagram_final.svg

*Please note that Getters and Setters for private instances are omitted in the UML diagram.

Detailed Description

Gamestate and Database

When the app is started, utils/initializeLocalData.dart updates the variables with their respective values from the database so that all models are stored locally and don't have to be fetched every time from the database. Depending on their lifetime and frequency of change, the Controllers TempController and PersistentController store these objects so that every Flutter widget can access them throughout the app. The repository variable that is hold by both controllers is utilized to write changes/updates on the local objects to firestore.

Teams and Players

After the startup and during the entire lifecycle of the app teams and players are stored within the cachedTeamsList variable in PersistentController. Inside all the teams belonging to the loggedInClub are stored. Inside each team object all the respective players can be found. When a player, team or their properties are modified, the respective object inside cachedTeamsList is updated. The selectedTeam variable is a temporary variable that gets updated every time a new team is selected inside the setting screen.\ Additionally, TempController holds several players lists and instances that are utilized throughout a game, such as playersToChange, i.e. the list of players that is suggested when a substitution is performed during a game. All these instances operate based on reference, which means that all player instances only exist once and their copies are just pointers to the original instances. This is crucial to keep in mind e.g. for the Ef-Score calculation to work properly.

Ef-Score Calculation

initially implemented in the scope of Issue #47

Class EfScore

  • This class holds the Ef-Score of a Player instance in it's score-property
  • Additionally, it stores the amount of actions of each type in a map called actionStats, and, to enable faster updates, the overall sum of actions in a separate variable numOfActions
  • It also implements the calcluation of the Ef-Score based on the parameters explained above in the function calculate

Class LiveEfScore

  • This class is used to track the realtime Ef-Score of a player during a game.
  • It class includes the function addAction, that needs to be called every time a new action is added to a Player object. It automatically updates the score property to the current Ef-Score based on all actions the player has performed during the current game
  • Analogously, the removeAction function needs to be called every time an action is removed (in case of accidentally wrong user input) and automatically updates the Ef-Score accordingly

Ef-Score update after GameAction was entered

  • For this purpose, the setter method updatePlayerEfScore() in controllers/tempController.dart should be used
  • it automatically updates the correct instance of a player based on its ID and updates the Ef-Score displaying widgets

Clone this wiki locally