001package com.fs.starfarer.api.impl.campaign.plog;
002
003import java.awt.Color;
004import java.util.ArrayList;
005import java.util.List;
006
007import com.fs.starfarer.api.util.Misc;
008
009public class BasePLStat implements PLStat {
010        
011        List<Long> accrued = new ArrayList<Long>();
012        
013        protected Object readResolve() {
014                if (accrued == null) {
015                        accrued = new ArrayList<Long>();
016                }
017                return this;
018        }
019        
020        
021        public Color getGraphColor() {
022                return Color.white;
023        }
024
025        public String getGraphLabel() {
026                return "Override getGraphLabel()";
027        }
028
029        public String getId() {
030                return getClass().getSimpleName();
031        }
032
033        public void accrueValue() {
034                accrued.add(getCurrentValue());
035        }
036
037        public long getValueForAllAccrued() {
038                long prev = PlaythroughLog.getInstance().getPrevValue(getId());
039                long best = 0;
040                long maxDiff = Integer.MIN_VALUE;
041                for (Long curr : accrued) {
042                        long diff = Math.abs(curr - prev);
043                        if (diff > maxDiff) {
044                                maxDiff = diff;
045                                best = curr;
046                        }
047                }
048                accrued.clear();
049                
050                return best;
051        }
052        
053        public long getCurrentValue() {
054                return 0;
055        }
056
057
058        public long getGraphMax() {
059                return -1;
060        }
061
062        public String getHoverText(long value) {
063                return getGraphLabel() + ": " + Misc.getWithDGS(value);
064        }
065
066
067        public String getSharedCategory() {
068                return null;
069        }
070
071}
072
073