001package com.fs.starfarer.api.impl.campaign.skills; 002 003import java.awt.Color; 004 005import com.fs.starfarer.api.characters.DescriptionSkillEffect; 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.impl.campaign.ids.Stats; 010import com.fs.starfarer.api.util.Misc; 011 012public class ElectronicWarfare { 013 014// public static final float LEVEL_1_BONUS = 0f; 015// public static final float LEVEL_2_BONUS = 5f; 016// public static final float LEVEL_3_BONUS = 5f; 017 018 public static float PER_SHIP_BONUS = 1f; 019 020 public static float CAP_RANGE = 500f; 021 public static float CAP_RATE = 5f; 022 023 024// public static float getBase(HullSize hullSize) { 025// float value = 0f; 026// switch (hullSize) { 027// case CAPITAL_SHIP: value = 4f; break; 028// case CRUISER: value = 3f; break; 029// case DESTROYER: value = 2f; break; 030// case FRIGATE: value = 1f; break; 031// } 032// return value; 033// } 034 035 public static class Level0 implements DescriptionSkillEffect { 036 public String getString() { 037 String max = (int)ElectronicWarfareScript.BASE_MAXIMUM + "%"; 038// return "*Enemy weapon range is reduced by half of the total ECM rating of the deployed ships, " + 039// "up to a maximum of " + max + 040// ". Does not apply to fighters, affects all weapons including missiles."; 041// return "*Reduces enemy weapon range. The total reduction is the lesser of " + max + 042// " and the combined ECM rating for both sides. " + 043// "The side with the lower ECM rating gets a higher penalty. " + 044// "Does not apply to fighters, affects all weapons including missiles."; 045 046 return "*Enemy weapon range is reduced by the total ECM rating of your deployed ships, " 047 + "up to a maximum of " + max + ". This penalty is reduced by the ratio " 048 + "of the enemy ECM rating to yours." + 049 "Does not apply to fighters, affects all weapons including missiles."; 050 } 051 public Color[] getHighlightColors() { 052 Color h = Misc.getHighlightColor(); 053 h = Misc.getDarkHighlightColor(); 054 return new Color[] {h, h, h}; 055 } 056 public String[] getHighlights() { 057 String max = (int)ElectronicWarfareScript.BASE_MAXIMUM + "%"; 058// String jammer = "+" + (int)ElectronicWarfareScript.PER_JAMMER + "%"; 059// return new String [] {jammer, max}; 060 //return new String [] {max, "combined", "relative"}; 061 //return new String [] {"half", max}; 062 return new String [] {max}; 063 //return new String [] {"half", "maximum of " + max}; 064 } 065 public Color getTextColor() { 066 return null; 067 } 068 } 069 070 public static class Level0WithNewline extends Level0 { 071 public String getString() { 072 return "\n" + super.getString(); 073 } 074 } 075 076 public static class Level1A implements ShipSkillEffect { 077 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) { 078 if (!BaseSkillEffectDescription.isCivilian(stats)) { 079 stats.getDynamic().getMod(Stats.ELECTRONIC_WARFARE_FLAT).modifyFlat(id, PER_SHIP_BONUS); 080 } 081 } 082 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) { 083 stats.getDynamic().getMod(Stats.ELECTRONIC_WARFARE_FLAT).unmodify(id); 084 } 085 public String getEffectDescription(float level) { 086 //return "+1-4" + "% to ECM rating of ships, depending on ship size"; 087 //return "Every deployed ship increases ECM rating* of fleet by " + (int) PER_SHIP_BONUS + "%"; 088 return "Every deployed combat ship contributes +" + (int) PER_SHIP_BONUS + "% to ECM rating* of fleet"; 089 } 090 public String getEffectPerLevelDescription() { 091 return null; 092 } 093 public ScopeDescription getScopeDescription() { 094 return ScopeDescription.ALL_SHIPS; 095 } 096 } 097 098 099 public static class Level1B implements ShipSkillEffect { 100 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) { 101 if (!BaseSkillEffectDescription.isCivilian(stats)) { 102 stats.getDynamic().getMod(Stats.SHIP_OBJECTIVE_CAP_RANGE_MOD).modifyFlat(id, CAP_RANGE); 103 stats.getDynamic().getStat(Stats.SHIP_OBJECTIVE_CAP_RATE_MULT).modifyMult(id, CAP_RATE); 104 } 105 } 106 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) { 107 stats.getDynamic().getMod(Stats.SHIP_OBJECTIVE_CAP_RANGE_MOD).unmodifyFlat(id); 108 stats.getDynamic().getStat(Stats.SHIP_OBJECTIVE_CAP_RATE_MULT).unmodifyMult(id); 109 } 110 public String getEffectDescription(float level) { 111 return "Combat objectives are captured much more quickly and from longer range"; 112 } 113 public String getEffectPerLevelDescription() { 114 return null; 115 } 116 public ScopeDescription getScopeDescription() { 117 return ScopeDescription.ALL_SHIPS; 118 } 119 } 120 121 public static class Level1C implements ShipSkillEffect { 122 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) { 123 stats.getDynamic().getMod(Stats.SHIP_BELONGS_TO_FLEET_THAT_CAN_COUNTER_EW).modifyFlat(id, 1f); 124 } 125 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) { 126 stats.getDynamic().getMod(Stats.SHIP_BELONGS_TO_FLEET_THAT_CAN_COUNTER_EW).unmodifyFlat(id); 127 } 128 public String getEffectDescription(float level) { 129 String excess = "" + (int)Math.round(ElectronicWarfareScript.BASE_MAXIMUM * 2f); 130 return "Half of your fleet's excess (above " + excess + "%) ECM rating reduces the maximum range penalty due to enemy ECM"; 131 } 132 public String getEffectPerLevelDescription() { 133 return null; 134 } 135 public ScopeDescription getScopeDescription() { 136 return ScopeDescription.ALL_SHIPS; 137 } 138 } 139 140}