001package com.fs.starfarer.api.impl.campaign.intel.bar.events;
002
003import java.awt.Color;
004
005import com.fs.starfarer.api.campaign.econ.CommodityOnMarketAPI;
006import com.fs.starfarer.api.campaign.econ.MarketAPI;
007import com.fs.starfarer.api.characters.PersonAPI;
008import com.fs.starfarer.api.impl.campaign.econ.impl.BaseIndustry;
009import com.fs.starfarer.api.impl.campaign.ids.Commodities;
010import com.fs.starfarer.api.impl.campaign.ids.Factions;
011import com.fs.starfarer.api.impl.campaign.ids.Ranks;
012import com.fs.starfarer.api.impl.campaign.ids.Tags;
013import com.fs.starfarer.api.impl.campaign.intel.contacts.ContactIntel;
014import com.fs.starfarer.api.util.Misc;
015
016public class LuddicFarmerBarEvent extends BaseGetCommodityBarEvent {
017        
018        public LuddicFarmerBarEvent() {
019                super();
020        }
021        
022        public boolean shouldShowAtMarket(MarketAPI market) {
023                if (!super.shouldShowAtMarket(market)) return false;
024                regen(market);
025                
026                if (!market.getFactionId().equals(Factions.LUDDIC_CHURCH) &&
027                                !market.getFactionId().equals(Factions.LUDDIC_PATH)) {
028                        return false;
029                }
030                
031                if (market.getStabilityValue() < 4) return false;
032                
033                CommodityOnMarketAPI com = market.getCommodityData(commodity);
034                if (com.getMaxSupply() <= 0) return false;
035                if (com.getAvailable() < com.getMaxDemand()) return false;
036                
037                return true;
038        }
039
040        @Override
041        protected String getCommodityId() {
042                return Commodities.FOOD;
043        }
044        
045        @Override
046        protected void doExtraConfirmActions() {
047                ContactIntel.addPotentialContact(person, market, text);
048        }
049
050        @Override
051        protected void adjustPerson(PersonAPI person) {
052                super.adjustPerson(person);
053                person.setImportanceAndVoice(pickLowImportance(), random);
054                person.addTag(Tags.CONTACT_TRADE);
055        }
056        
057        @Override
058        protected String getPersonPost() {
059                return Ranks.POST_COMMUNE_LEADER;
060        }
061        
062        @Override
063        protected String getPersonFaction() {
064                return Factions.LUDDIC_CHURCH;
065        }
066        
067        @Override
068        protected String getPersonRank() {
069                return Ranks.CITIZEN;
070        }
071        
072        @Override
073        protected int computeQuantity() {
074                int quantity = 50 + 10 * random.nextInt(6);
075                
076                CommodityOnMarketAPI com = market.getCommodityData(commodity);
077                int size = Math.min(com.getAvailable(), com.getMaxSupply());
078                if (size < 1) size = 1;
079                //quantity *= BaseIndustry.getSizeMult(size);
080                quantity *= Math.max(1, BaseIndustry.getSizeMult(size) - 2);
081                return quantity;
082        }
083        
084        @Override
085        protected float getPriceMult() {
086                return 0.75f;
087        }
088        
089        @Override
090        protected String getPrompt() {
091                return "A weathered-looking " + getManOrWoman() + " whose worn but well-tailored " +
092                           "work suit bears the sigil of a farming commune sits at a table drinking small-beer.";
093        }
094        
095        @Override
096        protected String getOptionText() {
097                return "Chat up the weathered-looking " + getManOrWoman() + "";
098        }
099        
100        @Override
101        protected String getMainText() {
102                String heOrShe = getHeOrShe();
103                return Misc.ucFirst(heOrShe) + " turns out to be the master of a farming commune " +
104                           "and " + heOrShe + " has come \"to town\" to find distributors for their product. " +
105                           Misc.ucFirst(heOrShe) + "'s got %s units of food that has to be moved as soon as possible and " +
106                           "if you buy it all today, you'll get an under-market price of %s per unit. " +
107                           "And, " + heOrShe + " says with a wink, \"As pious folk, we need not bother with the Church’s tariff.\",";
108        }
109        
110        @Override
111        protected String [] getMainTextTokens() {
112                return new String [] { Misc.getWithDGS(quantity), Misc.getDGSCredits(unitPrice) };
113        }
114        @Override
115        protected Color [] getMainTextColors() {
116                return new Color [] { Misc.getHighlightColor(), Misc.getHighlightColor() };
117        }
118        
119        @Override
120        protected String getConfirmText() {
121                return "Accept with a firm handshake and cryptokey exchange";
122        }
123        
124        @Override
125        protected String getCancelText() {
126                return "Decline the deal, and thank " + getHimOrHer() + " for the proposal";
127        }
128
129        @Override
130        protected String getAcceptText() {
131                return "You make arrangements with the farm master for pickup of the cargo from a quiet warehouse " +
132                "on the outskirts of " + market.getName() + " and transmit the details " +
133                "to your quartermaster to handle.";
134        }
135        
136        @Override
137        protected String [] getAcceptTextTokens() {
138                return new String [] { };
139        }
140        @Override
141        protected Color [] getAcceptTextColors() {
142                return new Color [] { };
143        }
144        
145        
146}
147
148
149