using System; using System.Collections.Generic; using UnityEngine; /// /// A class holding all information of a user /// [Serializable] public class User { /// /// User nickname /// public string username; /// /// The avatar of the user /// public Sprite avatar; /// /// The total playtime of the user /// /// TODO: needs to be implemented public double playtime; /// /// List of courses a user started/completed /// [SerializeField] public List courses = new List(); /// /// List of minigames a user played /// [SerializeField] public List minigames = new List(); /// /// Get a list of all recently started courses /// /// A List of Tuples, containing the CourseIndex /// and a float holding the progress (value between 0 and 1) of the user in this course public List> GetRecentCourses() { // TODO: return better results (for now only return all courses) List> recentCourses = new List>(); foreach (Progress courseProgress in courses) { CourseIndex idx = courseProgress.Get("courseIndex"); float progress = courseProgress.Get("courseProgress"); recentCourses.Add(Tuple.Create(idx, progress)); } return recentCourses; } /// /// Get a list of all recommended courses /// /// A List of Tuples, containing the CourseIndex /// and a float holding the progress (value between 0 and 1) of the user in this course public List> GetRecommendedCourses() { List> recommenedCourses = new List>(); if (courses.Count == 0) { recommenedCourses.Add(Tuple.Create(CourseIndex.FINGERSPELLING, 0.0f)); } else { // TODO: return better results (for now only return all courses) foreach (Progress courseProgress in courses) { CourseIndex idx = courseProgress.Get("courseIndex"); float progress = courseProgress.Get("courseProgress"); recommenedCourses.Add(Tuple.Create(idx, progress)); } } return recommenedCourses; } /// /// Get the progress of a certain course /// /// Index of course /// Progress belonging to the courseIndex, null if course was not found public Progress GetCourseProgress(CourseIndex courseIndex) { return courses.Find((p) => p.Get("courseIndex") == courseIndex); } /// /// Get the progress of certain minigame /// /// Index of the minigame /// Progress belonging to the minigameIndex, null if minigame was not found public Progress GetMinigameProgress(MinigameIndex minigameIndex) { return minigames.Find((p) => p.Get("minigameIndex") == minigameIndex); } }