Exemplo n.º 1
0
    private async Task FetchChapter(ChapterId chapter)
    {
        if (!Global.Online)
        {
            GD.Print("Fetching info online not allowed");
            return;
        }
        requestKey++;
        int thisRequest = requestKey;

        await ToSignal((Godot.Object) SWS.Call("get_high_scores", 10, $"chapter-{(int) chapter}"), "sw_scores_received");

        if (thisRequest != requestKey)
        {
            GD.PrintErr("Fetched Multiple Chapters at the same time");
        }
        ChapterScore chapterScore = new ChapterScore {
            Chapter = chapter, TimeStamp = DateTime.Now
        };
        int rank = 1;

        foreach (Godot.Collections.Dictionary line in (Godot.Collections.Array)SWS.Get("scores"))
        {
            // GD.Print(line["player_name"].GetType(), " ", line["player_name"]);
            // GD.Print(line["score"].GetType(), " ", line["score"]);
            chapterScore.Scores.Add(new ScoreLine {
                Rank = rank, Name = (string)line["player_name"], Time = (int)-((float)line["score"])
            });
            rank++;
        }
        cachedScores[chapter] = chapterScore;
        EmitSignal(nameof(RefreshChapterScore), chapter);
    }
Exemplo n.º 2
0
 public async Task <ChapterScore> GetChapterScore(ChapterId chapter, float cacheTime = 15f)
 {
     if (!cachedScores.ContainsKey(chapter) || (DateTime.Now - cachedScores[chapter].TimeStamp).Seconds > cacheTime)
     {
         await FetchChapter(chapter);
     }
     return(cachedScores[chapter]);
 }
Exemplo n.º 3
0
    private static string Scene(ChapterId chapter, int level)
    {
        if (chapter >= ChapterId.TOTAL)
        {
            return($"res://Scenes/MainMenu.tscn");
        }
        int chap = (int)(chapter);

        return($"res://Scenes/Levels/Chapter{chap}/Level{chap}-{level}.tscn");
    }
Exemplo n.º 4
0
 public bool Equals(DbStats?other)
 {
     return(other != null &&
            Id.Equals(other.Id) &&
            ProfileId.Equals(other.ProfileId) &&
            ChapterId.Equals(other.ChapterId) &&
            Completed == other.Completed &&
            Tips.SequenceEqual(other.Tips) &&
            Submits.SequenceEqual(other.Submits) &&
            Failures.SequenceEqual(other.Failures));
 }
Exemplo n.º 5
0
 public static void LoadChapter(ChapterId chapter)
 {
     Chapter = chapter;
     Level   = 1;
     Instance.GetTree().ChangeScene(CHAPTER_INTRO);
 }
Exemplo n.º 6
0
 internal ChapterContext(MangaContext root, ChapterId chapter, ProjectDirectoryListingProvider listing)
 {
     this.root    = root;
     this.chapter = chapter;
     this.listing = listing;
 }
Exemplo n.º 7
0
 public async Task WipeChapter(ChapterId chapter)
 {
     await ToSignal((Godot.Object) SWS.Call("wipe_leaderboard", $"chapter-{(int) chapter}"), "sw_leaderboard_wiped");
 }
Exemplo n.º 8
0
 public async Task AddScoreLine(ChapterId chapter, string player, int time)
 {
     await ToSignal((Godot.Object) SWS.Call("persist_score", player, -time, $"chapter-{(int) chapter}"), "sw_score_posted");
 }
Exemplo n.º 9
0
 public ChapterScore GetCachedChapterScore(ChapterId chapter)
 {
     return(cachedScores.ContainsKey(chapter) ? cachedScores[chapter] : null);
 }
Exemplo n.º 10
0
 public static ChapterId Next(this ChapterId chapter)
 {
     return(chapter < ChapterId.TOTAL ? chapter + 1 : ChapterId.NONE);
 }
Exemplo n.º 11
0
 public bool Equals(Submit?other)
 {
     return(other != null && ChapterId.Equals(other.ChapterId) && PageIndex == other.PageIndex && Solution == other.Solution);
 }
Exemplo n.º 12
0
 protected override int GetHashCodeInternal()
 {
     return((ChapterId?.GetHashCode() ?? 0) * 19 + BlockId.GetHashCode() * 7 + LineId.GetHashCode());
 }