001package com.fs.starfarer.api.impl.campaign.intel.events; 002 003import java.awt.Color; 004 005import com.fs.starfarer.api.Global; 006import com.fs.starfarer.api.ui.TooltipMakerAPI; 007import com.fs.starfarer.api.util.Misc; 008 009public class BaseOneTimeFactor extends BaseEventFactor { 010 011 public static float SHOW_DURATION_DAYS = 30f; 012 013 protected int points; 014 protected long timestamp; 015 016 public BaseOneTimeFactor(int points) { 017 this.points = points; 018 timestamp = Global.getSector().getClock().getTimestamp(); 019 } 020 021 @Override 022 public int getProgress(BaseEventIntel intel) { 023 return points; 024 } 025 026 @Override 027 public boolean isOneTime() { 028 return true; 029 } 030 031 protected String getBulletPointText(BaseEventIntel intel) { 032 return null; 033 } 034 035 public void addBulletPointForOneTimeFactor(BaseEventIntel intel, TooltipMakerAPI info, Color tc, float initPad) { 036 String text = getBulletPointText(intel); 037 if (text == null) text = getDesc(intel); 038 if (text != null) { 039 info.addPara(text + ": %s", initPad, tc, getProgressColor(intel), 040 getProgressStr(intel)); 041 } 042 } 043 044 @Override 045 public boolean isExpired() { 046 return timestamp != 0 && Global.getSector().getClock().getElapsedDaysSince(timestamp) > SHOW_DURATION_DAYS; 047 } 048 049 public boolean hasOtherFactorsOfClass(BaseEventIntel intel, Class c) { 050 for (EventFactor factor : intel.getFactors()) { 051 if (factor != this && c.isInstance(factor)) { 052 return true; 053 } 054 } 055 return false; 056 } 057 058 @Override 059 public String getProgressStr(BaseEventIntel intel) { 060 if (getProgress(intel) == 0) { 061 return ""; 062 } 063 return super.getProgressStr(intel); 064 } 065 066 @Override 067 public Color getDescColor(BaseEventIntel intel) { 068 if (getProgress(intel) == 0) { 069 return Misc.getGrayColor(); 070 } 071 return super.getDescColor(intel); 072 } 073 074}