Skip to content

Commit

Permalink
Merge pull request #1 from starsector-forks/master
Browse files Browse the repository at this point in the history
Enable AddSubmarket and add RemoveSubmarket commands
  • Loading branch information
LazyWizard committed Aug 25, 2020
2 parents b844d49 + 881d05a commit bef8325
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/org/lazywizard/console/commands/List_.java
Expand Up @@ -334,6 +334,10 @@ public CommandResult runCommand(String args, CommandContext context)
ids.add(spec.getId() + " (" + spec.getName() + ")");
}
break;
case "submarkets":
newLinePerItem = true;
ids = getSubmarketIds();
break;
case "officers":
newLinePerItem = true;
param = "officers in fleet";
Expand Down
45 changes: 45 additions & 0 deletions src/main/java/org/lazywizard/console/commands/RemoveSubmarket.java
@@ -0,0 +1,45 @@
package org.lazywizard.console.commands;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import com.fs.starfarer.api.campaign.econ.MarketAPI;
import com.fs.starfarer.api.campaign.econ.SubmarketAPI;

import org.lazywizard.console.BaseCommand;
import org.lazywizard.console.CommonStrings;
import org.lazywizard.console.Console;
import org.lazywizard.lazylib.CollectionUtils;

public class RemoveSubmarket implements BaseCommand {
@Override
public CommandResult runCommand(String args, CommandContext context) {
if (!context.isInMarket()) {
Console.showMessage(CommonStrings.ERROR_MARKET_ONLY);
return CommandResult.WRONG_CONTEXT;
}

final MarketAPI market = context.getMarket();
if (args.isEmpty()) {
final List<String> submarkets = new ArrayList<>();
for (SubmarketAPI submarket : market.getSubmarketsCopy()) {
submarkets.add(submarket.getSpecId());
}

Collections.sort(submarkets, String.CASE_INSENSITIVE_ORDER);
Console.showMessage("Existing submarkets of current market: " + CollectionUtils.implode(submarkets) + ".");
return CommandResult.SUCCESS;
}

final String id = args;
if (!market.hasSubmarket(id)) {
Console.showMessage("Market '" + market.getName() + "' does not have submarket '" + id + "'!");
return CommandResult.ERROR;
}

market.removeSubmarket(id);
Console.showMessage("Removed submarket '" + id + "' from market '" + market.getName() + "'.");
return CommandResult.SUCCESS;
}
}
2 changes: 2 additions & 0 deletions src/main/mod/data/console/commands.csv
Expand Up @@ -13,6 +13,7 @@ AddOrdnancePoints,org.lazywizard.console.commands.AddOrdnancePoints,"core,campai
AddShip,org.lazywizard.console.commands.AddShip,"core,campaign",addship <variantID> [optionalAmount],"Tries to create a ship with the supplied variant ID and adds it to your fleet. This command is case-sensitive, but it will try with different capitalization if it fails. If an amount is given, it will spawn that many ships of that ID in your fleet. Ensure you have the required supplies!\nA ship name with no variant attached will generate an empty hull (the same result as 'addship <shipname>_Hull').\nSupports reversed arguments."
AddSkillPoints,org.lazywizard.console.commands.AddSkillPoints,"core,campaign",addskillpoints <amount>,"Adds the specified amount of skill points to your character."
AddSpecial,org.lazywizard.console.commands.AddSpecial,"core,campaign",addspecial <specialId> [optionalData],"Adds a special item to your fleet's cargo with the given data, or null data if no dara argument is passed in.\nNote that this will cause a game crash if no or invalid data is passed into an object that requires it!"
AddSubmarket,org.lazywizard.console.commands.AddSubmarket,"core,market",addsubmarket <submarketId>,"Adds a submarket to a market.\nUse 'list submarkets' to list all valid submarkets."
AddSupplies,org.lazywizard.console.commands.AddSupplies,"core,campaign",addsupplies [optionalAmount],"Adds the specified amount of supplies to your fleet's cargo, or up to 50% of your current cargo capacity if no amount is entered."
AddWeapon,org.lazywizard.console.commands.AddWeapon,"core,campaign",addweapon <weaponID> [optionalAmount],"Adds a weapon to your fleet's cargo.\nIf an amount is specified, a stack of that size will be given.\nSupports reversed arguments."
AddWing,org.lazywizard.console.commands.AddWing,"core,campaign",addwing <variantID> [optionalAmount],"Tries to create a wing LPC with the supplied variant ID and adds it to your fleet's cargo.\nIf an amount is given, it will spawn that many LPCs in your cargo.\nSupports reversed arguments."
Expand Down Expand Up @@ -66,6 +67,7 @@ Reload,org.lazywizard.console.commands.ReloadConsole,"core,console",reload (no a
RemoveCondition,org.lazywizard.console.commands.RemoveCondition,"core,market",removecondition <conditionId>,"Removes a condition from a market.\nUse without arguments to list all existing conditions of the current market."
RemoveHulks,org.lazywizard.console.commands.RemoveHulks,"core,combat",removehulks (no arguments),"Destroys all hulks on the battle map. This will affect loot and ship recovery after the battle is over!"
RemoveIndustry,org.lazywizard.console.commands.RemoveIndustry,"core,market",removeindustry <industryId>,"Removes an industry from a market.\nUse without arguments to list all existing industries of the current market."
RemoveSubmarket,org.lazywizard.console.commands.RemoveSubmarket,"core,market",removesubmarket <submarketId>,"Removes a submarket from a market.\nUse without arguments to list all existing submarkets of the current market."
Repair,org.lazywizard.console.commands.Repair,"core,campaign,combat",repair (no arguments),"Repairs all friendly ships on the battle map if used in combat, or all ships in your fleet on the campaign map."
Respec,org.lazywizard.console.commands.Respec,"core,campaign",respec [optionalOfficerNameOrNumber],"Resets skills and attributes to zero and refunds all spent points. If an argument is entered, respecs that officer. Use 'list officers' for a list of respeccable officers in your fleet."
Reveal,org.lazywizard.console.commands.Reveal,"core,campaign,combat",reveal (no arguments),"Toggles fog of war on the battle map, or gives infinite sensor range on the campaign map."
Expand Down

0 comments on commit bef8325

Please sign in to comment.