001package com.fs.starfarer.api.impl.campaign.skills; 002 003import com.fs.starfarer.api.campaign.econ.MarketAPI; 004import com.fs.starfarer.api.characters.FleetStatsSkillEffect; 005import com.fs.starfarer.api.characters.MarketSkillEffect; 006import com.fs.starfarer.api.characters.ShipSkillEffect; 007import com.fs.starfarer.api.combat.MutableShipStatsAPI; 008import com.fs.starfarer.api.combat.ShipAPI.HullSize; 009import com.fs.starfarer.api.fleet.MutableFleetStatsAPI; 010import com.fs.starfarer.api.impl.campaign.ids.Stats; 011 012public class FleetLogistics { 013 014 public static final float ACCESS_1 = 0.15f; 015 public static final float ACCESS_2 = 0.15f; 016 public static final float FLEET_SIZE = 25f; 017 018 public static final float REPAIR_RATE_INCREASE = 25f; 019 020 public static final float OFFICER_SHIP_RECOVERY_MOD = 1000f; 021 public static final float MAINTENANCE_COST_REDUCTION = 25f; 022 public static final float MAX_CR_BONUS = 15f; 023 024 025 026 public static class Level1 implements ShipSkillEffect { 027 028 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) { 029 stats.getRepairRatePercentPerDay().modifyPercent(id, REPAIR_RATE_INCREASE); 030 } 031 032 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) { 033 stats.getRepairRatePercentPerDay().unmodify(id); 034 } 035 036 public String getEffectDescription(float level) { 037 return "" + (int)(REPAIR_RATE_INCREASE) + "% faster repair rate"; 038 } 039 040 public String getEffectPerLevelDescription() { 041 return null; 042 } 043 044 public ScopeDescription getScopeDescription() { 045 return ScopeDescription.ALL_SHIPS; 046 } 047 } 048 049 public static class Level1B implements FleetStatsSkillEffect { 050 public void apply(MutableFleetStatsAPI stats, String id, float level) { 051 stats.getDynamic().getMod(Stats.OFFICER_SHIP_RECOVERY_MOD).modifyFlat(id, OFFICER_SHIP_RECOVERY_MOD * 0.01f); 052 } 053 054 public void unapply(MutableFleetStatsAPI stats, String id) { 055 stats.getDynamic().getMod(Stats.OFFICER_SHIP_RECOVERY_MOD).unmodify(id); 056 } 057 058 public String getEffectDescription(float level) { 059 return "Flagship and ships with an officer in command nearly guaranteed to be recoverable if lost"; 060 } 061 062 public String getEffectPerLevelDescription() { 063 return null; 064 } 065 066 public ScopeDescription getScopeDescription() { 067 return ScopeDescription.FLEET; 068 } 069 } 070 071 public static class Level2 implements ShipSkillEffect { 072 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) { 073 stats.getSuppliesPerMonth().modifyMult(id, 1f - MAINTENANCE_COST_REDUCTION/100f, "Fleet logistics skill"); 074 } 075 076 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) { 077 stats.getSuppliesPerMonth().unmodify(id); 078 } 079 080 public String getEffectDescription(float level) { 081 return "-" + (int) (MAINTENANCE_COST_REDUCTION) + "% supply use for maintenance"; 082 } 083 084 public String getEffectPerLevelDescription() { 085 return null; 086 } 087 088 public ScopeDescription getScopeDescription() { 089 return ScopeDescription.ALL_SHIPS; 090 } 091 } 092 093 public static class Level3 implements ShipSkillEffect { 094 095 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) { 096 stats.getMaxCombatReadiness().modifyFlat(id, MAX_CR_BONUS * 0.01f, "Fleet logistics skill"); 097 } 098 099 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) { 100 stats.getMaxCombatReadiness().unmodify(id); 101 } 102 103 public String getEffectDescription(float level) { 104 return "+" + (int)(MAX_CR_BONUS) + "% maximum combat readiness"; 105 } 106 107 public String getEffectPerLevelDescription() { 108 return null; 109 } 110 111 public ScopeDescription getScopeDescription() { 112 return ScopeDescription.ALL_SHIPS; 113 } 114 } 115 116 117 public static class Market1 implements MarketSkillEffect { 118 public void apply(MarketAPI market, String id, float level) { 119 if (level <= 1) { 120 market.getAccessibilityMod().modifyFlat(id, ACCESS_1, "Fleet logistics"); 121 } else if (level >= 2) { 122 market.getAccessibilityMod().modifyFlat(id, ACCESS_1 + ACCESS_2, "Fleet logistics"); 123 } 124 } 125 126 public void unapply(MarketAPI market, String id) { 127 market.getAccessibilityMod().unmodifyFlat(id); 128 } 129 130 public String getEffectDescription(float level) { 131 return "+" + (int)Math.round(ACCESS_1 * 100f) + "% accessibility"; 132 } 133 134 public String getEffectPerLevelDescription() { 135 return null; 136 } 137 138 public ScopeDescription getScopeDescription() { 139 return ScopeDescription.GOVERNED_OUTPOST; 140 } 141 } 142 143 public static class Market2 implements MarketSkillEffect { 144 public void apply(MarketAPI market, String id, float level) { 145 //market.getAccessibilityMod().modifyFlat(id, ACCESS_2, "Fleet logistics"); 146 } 147 148 public void unapply(MarketAPI market, String id) { 149 //market.getAccessibilityMod().unmodifyFlat(id); 150 } 151 152 public String getEffectDescription(float level) { 153 return "+" + (int)Math.round(ACCESS_2 * 100f) + "% accessibility"; 154 } 155 156 public String getEffectPerLevelDescription() { 157 return null; 158 } 159 160 public ScopeDescription getScopeDescription() { 161 return ScopeDescription.GOVERNED_OUTPOST; 162 } 163 } 164 public static class Market3 implements MarketSkillEffect { 165 public void apply(MarketAPI market, String id, float level) { 166 market.getStats().getDynamic().getMod(Stats.COMBAT_FLEET_SIZE_MULT).modifyFlat(id, FLEET_SIZE / 100f, "Fleet logistics"); 167 } 168 169 public void unapply(MarketAPI market, String id) { 170 market.getStats().getDynamic().getMod(Stats.COMBAT_FLEET_SIZE_MULT).unmodifyFlat(id); 171 } 172 173 public String getEffectDescription(float level) { 174 return "" + (int)Math.round(FLEET_SIZE) + "% larger fleets"; 175 } 176 177 public String getEffectPerLevelDescription() { 178 return null; 179 } 180 181 public ScopeDescription getScopeDescription() { 182 return ScopeDescription.GOVERNED_OUTPOST; 183 } 184 } 185}