Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Begin work on implementing CamOps Contract Market #4644

Merged
merged 49 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
f759068
WIP: initial work on refactoring contract markets to support other types
Algebro7 Aug 15, 2024
0acd2a1
use AtBContract for contractmarket interface
Algebro7 Aug 15, 2024
c5bb252
WIP: refactor to abstract contract market
Algebro7 Aug 15, 2024
adf5f3d
WIP: move over to abstractcontractmarket
Algebro7 Aug 15, 2024
ef3f8b2
remove unnecessary constructor and stub out abstract methods in camop…
Algebro7 Aug 15, 2024
8ec9cb2
stub out abstract methods
Algebro7 Aug 15, 2024
1bf626d
enable contract market setting
Algebro7 Aug 15, 2024
c596454
move to specific package
Algebro7 Aug 15, 2024
0ee9326
remove debug code
Algebro7 Aug 15, 2024
b75dd4f
add loading/saving from campaign files
Algebro7 Aug 15, 2024
5b9355d
add method to find best personnel with skill regardless of role and n…
Algebro7 Aug 16, 2024
ca49c1c
use abstractcontractmarket instead of contractmarket
Algebro7 Aug 16, 2024
6298607
WIP: implement camopscontractmarket
Algebro7 Aug 16, 2024
f032897
refactor hiring halls to support different levels; add new hiring halls
Algebro7 Aug 16, 2024
46f49b2
remove debugging code
Algebro7 Aug 16, 2024
3890ff3
WIP: adding more contract generation functionality
Algebro7 Aug 16, 2024
857e186
various fixes for merge conflicts
Algebro7 Sep 15, 2024
133b69d
remove unnecessary imports
Algebro7 Sep 16, 2024
de542b6
switch to correct MMLogger
Algebro7 Sep 16, 2024
f9f5b50
remove unneeded import
Algebro7 Sep 16, 2024
ad13ed3
move camops contract data XML
Algebro7 Sep 16, 2024
8748cba
WIP: camops contract data
Algebro7 Sep 17, 2024
27f8e93
remove XML camops contract data
Algebro7 Sep 17, 2024
545cbb9
add camops independent employer tags
Algebro7 Sep 18, 2024
7ae4cda
update allowed tags
Algebro7 Sep 18, 2024
33cb37f
add method for retrieving active factions
Algebro7 Sep 18, 2024
0e4a459
finish determine employer and begin work on determining mission type
Algebro7 Sep 18, 2024
4ca5d4e
add warning to camops contract market option
Algebro7 Sep 18, 2024
f5a514f
add word wrap
Algebro7 Sep 18, 2024
ea33475
extract getMissionType to abstract class
Algebro7 Sep 18, 2024
4b2227e
extract contract enemy code generation to abstract class
Algebro7 Sep 18, 2024
7c4a49b
extract riot duty adjustment
Algebro7 Sep 18, 2024
dacd82e
extract more methods; add isAttacker to the contract
Algebro7 Sep 18, 2024
6f2a615
fix whitespace
Algebro7 Sep 19, 2024
1cf7ee8
use class-specific logger in child classes
Algebro7 Sep 19, 2024
7691708
move abstract method to private; finish contract generation routine f…
Algebro7 Sep 19, 2024
76fc8a6
extract updateReport()
Algebro7 Sep 19, 2024
1b0260b
clear out old contracts at beginning of month
Algebro7 Sep 19, 2024
f73cc52
remove erroneous import
Algebro7 Sep 19, 2024
acd498a
move calculatePaymentMultiplier() to AbstractContractMarket
Algebro7 Sep 19, 2024
6ee08ac
add method to retrieve strategy skill of the commander
Algebro7 Sep 19, 2024
d478f7c
extract more methods from AtBContract to AbstractContractMarket
Algebro7 Sep 19, 2024
60650ed
fix error in employer name in contract
Algebro7 Sep 19, 2024
32373a8
remember to set required lances on contract
Algebro7 Sep 19, 2024
e20c7ad
add javadocs
Algebro7 Sep 19, 2024
8e02e7e
add more javadocs
Algebro7 Sep 19, 2024
19a8656
remove unneeded variables
Algebro7 Sep 19, 2024
a79000f
add TODOs
Algebro7 Sep 19, 2024
dcf55ed
implement addAtBContract
Algebro7 Sep 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 0 additions & 131 deletions MekHQ/data/CamOpsContractData2.xml

This file was deleted.

48 changes: 26 additions & 22 deletions MekHQ/data/universe/atbconfig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -138,28 +138,32 @@ of 4. An entry of the form <entry>option</entry> has a weight of 1.
*Note that start and end dates are optional, but must
follow yyyy-MM-dd format. Planet names much match the
name in planets.xml exactly.-->
<hiringHalls>
<hall start="3031-01-01" end="3067-10-15">Outreach</hall>
<hall start="2700-01-01">Solaris</hall>
<hall start="3057-01-01">Arc-Royal</hall>
<hall start="3058-01-01" end="3081-03-15">Fletcher</hall>
<hall start="2650-01-01">Galatea</hall>
<hall start="3000-01-01">Westerhand</hall>
<hall start="3057-01-01" end="3081-03-15">Northwind</hall>
<hall start="3020-01-01">Herotitus</hall>
</hiringHalls>

</contractGeneration>

<!-- Values used for searching for an available ship to purchase. -->
<shipSearch>
<!-- The total cost of the search process -->
<shipSearchCost>100000</shipSearchCost>

<!-- The number of weeks required to complete the ship search. -->
<shipSearchLengthWeeks>4</shipSearchLengthWeeks>

<!-- The target number to for the dice roll to determine whether the ship search
<hiringHalls>
<hall start="3031-01-01" end="3067-10-15" level="great">Outreach</hall>
<hall start="2700-01-01" level="minor">Solaris</hall>
<hall start="3057-01-01" level="standard">Arc-Royal</hall>
<hall start="3058-01-01" end="3081-03-15" level="minor" >Fletcher</hall>
<hall start="2650-01-01" level="great">Galatea</hall>
<hall start="3000-01-01" level="great">Westerhand</hall>
<hall start="3057-01-01" end="3081-03-15" level="great">Northwind</hall>
<hall start="3020-01-01" level="minor">Herotitus</hall>
<hall start="2694-01-01" level="questionable">Antallos (Port Krin)</hall>
<hall start="2912-01-01" level="questionable">Astrokaszy</hall>
<hall start="3052-01-01" level="minor">Noisiel</hall>
<hall start="2811-01-01" end="3045-01-01" level="minor">Le Blanc</hall>
</hiringHalls>

</contractGeneration>

<!-- Values used for searching for an available ship to purchase. -->
<shipSearch>
<!-- The total cost of the search process -->
<shipSearchCost>100000</shipSearchCost>

<!-- The number of weeks required to complete the ship search. -->
<shipSearchLengthWeeks>4</shipSearchLengthWeeks>

<!-- The target number to for the dice roll to determine whether the ship search
was successful. Acceptable values for unitType are Dropship, Jumpship, and Warship.
If the target number is missing or commented out, that type of ship is not available
in a search. -->
Expand Down
2 changes: 1 addition & 1 deletion MekHQ/data/universe/factions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ layeredForceIconLogoCategory - the category of the faction's logo piece
layeredForceIconLogoFilename - the filename of the faction's logo piece
tags - a comma-separated list of tags. Currently recognised tags: "is", "periphery",
"deep_periphery", "clan", "pirate", "merc", "trader", "minor", "rebel", "inactive", "hidden",
"abandoned", "chaos", "playable", "super"
"abandoned", "chaos", "playable", "super", "noble", "planetary_government", "corporation", "small"
start - the founding date of the faction
end - the date the faction ceases to exist
successor - unimplemented tag describing another faction code as the specified faction's successor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ botLance.CLAN=1:LLLLL,1:LLLLM,1:LLLMM|1:LLMMM,1:LMMMM,2:MMMMM,1:MMMMH,1:MMMHH|1:
botLance.CS=1:LLLLLL,2:LLLLLM,2:LLLLMM,1:LLLMMM|1:LLLMMM,1:LLMMMM,1:LMMMMM,1:MMMMMM,1:MMMMMH,1:MMMMHH|1:MMMHHH,1:MMHHHH,1:MHHHHH,1:HHHHHH,1:HHHHHA,1:HHHHAA|2:HHHAAA,1:HHAAAA,2:HAAAAA,1:AAAAAA

#The following are not required for AtB to function and are only used if atbconfig.xml is missing or broken
hiringHalls=3031-01-01,3067-10-15,Outreach|2700-01-01,,Solaris|3057-01-01,,Arc-Royal|3058-01-01,3081-03-15,Fletcher|2650-01-01,,Galatea|3000-01-01,,Westerhand|3057-01-01,3081-03-15,Northwind|3020-01-01,,Herotitus
hiringHalls=3031-01-01,3067-10-15,great,Outreach|2700-01-01,,minor,Solaris|3057-01-01,,standard,Arc-Royal|3058-01-01,3081-03-15,minor,Fletcher|2650-01-01,,great,Galatea|3000-01-01,,great,Westerhand|3057-01-01,3081-03-15,great,Northwind|3020-01-01,,minor,Herotitus|2694-01-01,,questionable,Antallos (Port Krin)|2912-01-01,,questionable,Astrokaszy|3052-01-01,,minor,Noisiel|2811-01-01,3045-01-01,minor,Le Blanc

shipSearchCost=100000
shipSearchLengthWeeks=4
Expand Down
2 changes: 2 additions & 0 deletions MekHQ/resources/mekhq/resources/Market.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ ContractMarketMethod.NONE.text=Disabled
ContractMarketMethod.NONE.toolTipText=The Contract Market is disabled.
ContractMarketMethod.ATB_MONTHLY.text=AtB Monthly
ContractMarketMethod.ATB_MONTHLY.toolTipText=This is the standard Against the Bot Contract Market, which refreshes monthly.
ContractMarketMethod.CAM_OPS.text=Campaign Ops (Under Development)
ContractMarketMethod.CAM_OPS.toolTipText=This is the standard Campaign Operations Contract Market, which refreshes monthly. This feature is currently under development and may not work properly.

# UnitMarketMethod Enum
UnitMarketMethod.NONE.text=Disabled
Expand Down
74 changes: 50 additions & 24 deletions MekHQ/src/mekhq/campaign/Campaign.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,9 @@
import mekhq.campaign.log.HistoricalLogEntry;
import mekhq.campaign.log.LogEntry;
import mekhq.campaign.log.ServiceLogger;
import mekhq.campaign.market.ContractMarket;
import mekhq.campaign.market.PartsStore;
import mekhq.campaign.market.PersonnelMarket;
import mekhq.campaign.market.ShoppingList;
import mekhq.campaign.market.*;
import mekhq.campaign.market.contractMarket.AbstractContractMarket;
import mekhq.campaign.market.contractMarket.AtbMonthlyContractMarket;
import mekhq.campaign.market.unitMarket.AbstractUnitMarket;
import mekhq.campaign.market.unitMarket.DisabledUnitMarket;
import mekhq.campaign.mission.*;
Expand Down Expand Up @@ -210,8 +209,7 @@ public class Campaign implements ITechManager {

private Boolean fieldKitchenWithinCapacity;

// this is updated and used per gaming session, it is enabled/disabled via the
// Campaign options
// this is updated and used per gaming session, it is enabled/disabled via the Campaign options
// we're re-using the LogEntry class that is used to store Personnel entries
public LinkedList<LogEntry> inMemoryLogHistory = new LinkedList<>();

Expand Down Expand Up @@ -240,7 +238,7 @@ public class Campaign implements ITechManager {
private ShoppingList shoppingList;

private PersonnelMarket personnelMarket;
private ContractMarket contractMarket; // AtB
private AbstractContractMarket contractMarket;
private AbstractUnitMarket unitMarket;

private transient AbstractDeath death;
Expand Down Expand Up @@ -319,7 +317,7 @@ public Campaign() {
shoppingList = new ShoppingList();
news = new News(getGameYear(), id.getLeastSignificantBits());
setPersonnelMarket(new PersonnelMarket());
setContractMarket(new ContractMarket());
setContractMarket(new AtbMonthlyContractMarket());
setUnitMarket(new DisabledUnitMarket());
setDeath(new DisabledRandomDeath(getCampaignOptions(), false));
setDivorce(new DisabledRandomDivorce(getCampaignOptions()));
Expand Down Expand Up @@ -465,13 +463,11 @@ public void setPersonnelMarket(final PersonnelMarket personnelMarket) {
this.personnelMarket = personnelMarket;
}

// TODO : AbstractContractMarket : Swap to AbstractContractMarket
public ContractMarket getContractMarket() {
public AbstractContractMarket getContractMarket() {
return contractMarket;
}

// TODO : AbstractContractMarket : Swap to AbstractContractMarket
public void setContractMarket(final ContractMarket contractMarket) {
public void setContractMarket(final AbstractContractMarket contractMarket) {
this.contractMarket = contractMarket;
}

Expand Down Expand Up @@ -1662,17 +1658,15 @@ public boolean recruitPerson(Person p, PrisonerStatus prisonerStatus, boolean gm
* appropriate to the person's phenotype and the player's faction.
*
* @param person The Bloodname candidate
* @param ignoreDice If true, skips the random roll and assigns a Bloodname
* automatically
* @param ignoreDice If true, skips the random roll and assigns a Bloodname automatically
*/
public void checkBloodnameAdd(Person person, boolean ignoreDice) {
// if person is non-clan or does not have a phenotype
if (!person.isClanPersonnel() || person.getPhenotype().isNone()) {
return;
}

// Person already has a bloodname, we open up the dialog to ask if they want to
// keep the
// Person already has a bloodname, we open up the dialog to ask if they want to keep the
// current bloodname or assign a new one
if (!person.getBloodname().isEmpty()) {
int result = JOptionPane.showConfirmDialog(null,
Expand Down Expand Up @@ -2221,6 +2215,18 @@ public Person findBestInRole(PersonnelRole role, String skill) {
return findBestInRole(role, skill, null);
}

public @Nullable Person findBestAtSkill(String skill) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a heads up, we're moving towards having everything JavaDoc'd, obviously not necessary while this is a WIP but something you'll likely need to address before it gets merged. We're aware the majority of our stuff isn't currently JavaDoc'd, so that's something we're trying to address. So if you create a new Class, Method, or edit an existing Class or Method please add JavaDoc's*

*This is going to be added to the automated tests at some point

Person person = null;
int highest = 0;
for (Person p : getActivePersonnel()) {
if (p.getSkill(skill) != null && p.getSkill(skill).getLevel() > highest) {
highest = p.getSkill(skill).getLevel();
person = p;
}
}
return person;
}

/**
* @return The list of all active {@link Person}s who qualify as technicians
* ({@link Person#isTech()}));
Expand Down Expand Up @@ -3512,7 +3518,7 @@ && getLocation().getJumpPath().getLastSystem().getId().equals(contract.getSystem
}

private void processNewDayATB() {
contractMarket.generateContractOffers(this); // TODO : AbstractContractMarket : Remove
contractMarket.generateContractOffers(this);

if ((getShipSearchExpiration() != null) && !getShipSearchExpiration().isAfter(getLocalDate())) {
setShipSearchExpiration(null);
Expand Down Expand Up @@ -6501,6 +6507,28 @@ public int getAtBUnitRatingMod() {
: reputation.getAtbModifier();
}

public int getReputationFactor() {
Fixed Show fixed Hide fixed
return switch (campaignOptions.getUnitRatingMethod()) {
case NONE -> 5;
case FLD_MAN_MERCS_REV -> getAtBUnitRatingMod() * 2;
case CAMPAIGN_OPS -> (int) ((getReputation().getReputationRating() * 0.2) + 0.5);
};
}

/**
* Returns the Strategy skill of the designated commander in the campaign.
*
* @return The value of the commander's strategy skill if a commander exists, otherwise 0.
*/
public int getCommanderStrategy() {
int cmdrStrategy = 0;
if (getFlaggedCommander() != null &&
getFlaggedCommander().getSkill(SkillType.S_STRATEGY) != null) {
cmdrStrategy = getFlaggedCommander().getSkill(SkillType.S_STRATEGY).getLevel();
}
return cmdrStrategy;
}

@Deprecated
public int getUnitRatingAsInteger() {
return getAtBUnitRatingMod();
Expand Down Expand Up @@ -7560,8 +7588,7 @@ public void initTimeInRank() {
LocalDate join = null;
for (LogEntry e : p.getPersonnelLog()) {
if (join == null) {
// If by some nightmare there is no date from the below, just use the first
// entry.
// If by some nightmare there is no date from the below, just use the first entry.
join = e.getDate();
}

Expand All @@ -7571,8 +7598,7 @@ public void initTimeInRank() {
}
}

// For that one in a billion chance the log is empty. Clone today's date and
// subtract a year
// For that one in a billion chance the log is empty. Clone today's date and subtract a year
p.setLastRankChangeDate((join != null) ? join : getLocalDate().minusYears(1));
}
}
Expand Down Expand Up @@ -7684,8 +7710,7 @@ public boolean checkOverDueLoans() {
}

/**
* Checks if a turnover prompt should be displayed based on campaign options and
* current date.
* Checks if a turnover prompt should be displayed based on campaign options and current date.
*
* @return An integer representing the user's choice:
* -1 if turnover prompt should not be displayed.
Expand Down Expand Up @@ -7747,7 +7772,8 @@ public int checkTurnoverPrompt() {
JOptionPane.INFORMATION_MESSAGE,
null,
options,
options[0]);
options[0]
);
}

/**
Expand Down
Loading