package Replay;

import Constants.GameMode;
import Constants.Mod;
import com.google.auto.value.AutoValue;

import java.util.EnumSet;
import java.util.List;

/**
 * https://osu.ppy.sh/wiki/Osr_(file_format)
 */
@AutoValue
public abstract class Replay {
    public abstract GameMode gameMode();
    public abstract int gameVersion();
    public abstract String beatmapHash();

    public abstract long timestamp();
    public abstract String replayHash();
    public abstract String playerName();
    public abstract EnumSet<Mod> mods();

    public abstract int totalScore();
    public abstract short maxCombo();
    public abstract boolean isPerfect();

    public abstract short num300();
    public abstract short num100();
    public abstract short num50();
    public abstract short numGeki();
    public abstract short numKatu();
    public abstract short numMiss();

    public abstract List<LifeBarSample> lifebar();
    public abstract List<Action> events();

    public static Builder builder() {
        return new AutoValue_Replay.Builder();
    }

    @AutoValue.Builder
    public abstract static class Builder {
        public abstract Builder setGameMode(GameMode gameMode);
        public abstract Builder setGameVersion(int gameVersion);
        public abstract Builder setBeatmapHash(String beatmapHash);
        public abstract Builder setTimestamp(long timestamp);
        public abstract Builder setReplayHash(String replayHash);
        public abstract Builder setPlayerName(String playerName);
        public abstract Builder setMods(EnumSet<Mod> mods);
        public abstract Builder setTotalScore(int totalScore);
        public abstract Builder setMaxCombo(short maxCombo);
        public abstract Builder setIsPerfect(boolean isPerfect);
        public abstract Builder setNum300(short num300);
        public abstract Builder setNum100(short num100);
        public abstract Builder setNum50(short num50);
        public abstract Builder setNumGeki(short numGeki);
        public abstract Builder setNumKatu(short numKatu);
        public abstract Builder setNumMiss(short numMiss);
        public abstract Builder setLifebar(List<LifeBarSample> lifebar);
        public abstract Builder setEvents(List<Action> events);

        public abstract Replay build();

        public static Builder fromReplay(Replay source) {
            return new AutoValue_Replay.Builder()
                    .setGameMode(source.gameMode())
                    .setGameVersion(source.gameVersion())
                    .setBeatmapHash(source.beatmapHash())
                    .setTimestamp(source.timestamp())
                    .setReplayHash(source.replayHash())
                    .setPlayerName(source.playerName())
                    .setMods(source.mods())
                    .setTotalScore(source.totalScore())
                    .setMaxCombo(source.maxCombo())
                    .setIsPerfect(source.isPerfect())
                    .setNum300(source.num300())
                    .setNum100(source.num100())
                    .setNum50(source.num50())
                    .setNumGeki(source.numGeki())
                    .setNumKatu(source.numKatu())
                    .setNumMiss(source.numMiss())
                    .setLifebar(source.lifebar())
                    .setEvents(source.events());
        }
    }
}

@@ -282,24 +282,25 @@
 gameMode();%0A
+%0A
     public a
@@ -322,24 +322,25 @@
 eVersion();%0A
+%0A
     public a
@@ -404,24 +404,25 @@
 imestamp();%0A
+%0A
     public a
@@ -446,24 +446,25 @@
 playHash();%0A
+%0A
     public a
@@ -488,24 +488,25 @@
 ayerName();%0A
+%0A
     public a
@@ -569,24 +569,25 @@
 talScore();%0A
+%0A
     public a
@@ -608,24 +608,25 @@
 maxCombo();%0A
+%0A
     public a
@@ -687,24 +687,25 @@
 t num300();%0A
+%0A
     public a
@@ -724,24 +724,25 @@
 t num100();%0A
+%0A
     public a
@@ -760,24 +760,25 @@
 rt num50();%0A
+%0A
     public a
@@ -798,24 +798,25 @@
  numGeki();%0A
+%0A
     public a
@@ -836,24 +836,25 @@
  numKatu();%0A
+%0A
     public a
@@ -926,24 +926,25 @@
  lifebar();%0A
+%0A
     public a
@@ -1193,24 +1193,25 @@
  gameMode);%0A
+%0A
         publ
@@ -1263,16 +1263,17 @@
 rsion);%0A
+%0A
         
@@ -1328,24 +1328,25 @@
 atmapHash);%0A
+%0A
         publ
@@ -1395,16 +1395,17 @@
 stamp);%0A
+%0A
         
@@ -1462,16 +1462,17 @@
 yHash);%0A
+%0A
         
@@ -1525,24 +1525,25 @@
 layerName);%0A
+%0A
         publ
@@ -1586,24 +1586,25 @@
 Mod%3E mods);%0A
+%0A
         publ
@@ -1654,16 +1654,17 @@
 Score);%0A
+%0A
         
@@ -1716,16 +1716,17 @@
 Combo);%0A
+%0A
         
@@ -1782,16 +1782,17 @@
 rfect);%0A
+%0A
         
@@ -1836,24 +1836,25 @@
 rt num300);%0A
+%0A
         publ
@@ -1894,24 +1894,25 @@
 rt num100);%0A
+%0A
         publ
@@ -1954,16 +1954,17 @@
 num50);%0A
+%0A
         
@@ -2014,16 +2014,17 @@
 mGeki);%0A
+%0A
         
@@ -2074,16 +2074,17 @@
 mKatu);%0A
+%0A
         
@@ -2134,16 +2134,17 @@
 mMiss);%0A
+%0A
         
@@ -2208,16 +2208,17 @@
 febar);%0A
+%0A
         

Reformat Replay.java