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 LuddicCraftBarEvent extends BaseGetCommodityBarEvent { 017 018 public LuddicCraftBarEvent() { 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.DOMESTIC_GOODS; 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(pickMediumImportance(), random); 054 person.addTag(Tags.CONTACT_TRADE); 055 } 056 057 @Override 058 protected String getPersonPost() { 059 return Ranks.POST_GUILDMASTER; 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 = 30 + 10 * random.nextInt(4); 075 076 CommodityOnMarketAPI com = market.getCommodityData(commodity); 077 int size = Math.min(com.getAvailable(), com.getMaxSupply()); 078 if (size < 1) size = 1; 079 quantity *= Math.max(1, BaseIndustry.getSizeMult(size) - 2); 080 return quantity; 081 } 082 083 @Override 084 protected float getPriceMult() { 085 return 0.75f; 086 } 087 088 @Override 089 protected String getPrompt() { 090 return "A tough looking " + getManOrWoman() + " whose worn but well-tailored work suit bears the " + 091 "sigil of a crafts guild sits at a corner table bearing the remnants of a spare meal."; 092 093 } 094 095 @Override 096 protected String getOptionText() { 097 return "Strike up a conversation with the tough-looking " + getManOrWoman() + ""; 098 } 099 100 @Override 101 protected String getMainText() { 102 String heOrShe = getHeOrShe(); 103 String himOrHer = getHimOrHer(); 104 105 return "You buy " + himOrHer + " a drink and strike up a conversation. " + 106 Misc.ucFirst(heOrShe) + " turns out to be one of the masters of a local craft guild " + 107 " with a bit of a problem. \"His holiness, the Curate Astropolitan, turns his mind to spiritual " + 108 "rather than practical matters.\" " + 109 Misc.ucFirst(heOrShe) + " explains that the commercial bureaucracy of " + market.getName() + 110 " is understaffed and overworked. \"Ludd forgive me, but bills aren't paid by prayer.\"\n\n" + 111 Misc.ucFirst(heOrShe) + " explains that there are %s units of domestic goods gathering dust " + 112 "in a guild warehouse. If they could be quietly sold at even the under-market price " + 113 "of %s each, don't mind the tariffs, it'd be nothing more than an act of charity."; 114 } 115 116 @Override 117 protected String [] getMainTextTokens() { 118 return new String [] { Misc.getWithDGS(quantity), Misc.getDGSCredits(unitPrice) }; 119 } 120 @Override 121 protected Color [] getMainTextColors() { 122 return new Color [] { Misc.getHighlightColor(), Misc.getHighlightColor() }; 123 } 124 125 @Override 126 protected String getConfirmText() { 127 return "Accept the deal and transfer " + Misc.getDGSCredits(unitPrice * quantity) + " to the guild"; 128 } 129 130 @Override 131 protected String getCancelText() { 132 return "Decline the deal; \"Patience is a virtue, after all\""; 133 } 134 135 @Override 136 protected String getAcceptText() { 137 return "\"Praise be to Providence for bringing you to me!\" exclaims the guild-master " + 138 "with a broad smile and a clap on the back. Soon enough, your cargo manifest " + 139 "counts %s additional units of domestic goods, \"recovered from deep space salvage\"."; 140 } 141 142 @Override 143 protected String [] getAcceptTextTokens() { 144 return new String [] { Misc.getWithDGS(quantity)}; 145 } 146 @Override 147 protected Color [] getAcceptTextColors() { 148 return new Color [] {Misc.getHighlightColor() }; 149 } 150 151} 152 153 154