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

Armored Motive System #292

Merged
merged 18 commits into from
Mar 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion Data/Equipment/equipment.json
Original file line number Diff line number Diff line change
Expand Up @@ -4257,7 +4257,7 @@
"alloc_sides": true,
"alloc_rear": true,
"alloc_turret": true,
"alloc_body": false,
"alloc_body": true,
"CanSplit": false,
"CanMountRear": true,
"Explosive": false,
Expand Down
80 changes: 63 additions & 17 deletions saw/src/main/java/saw/gui/frmVeeWide.java
Original file line number Diff line number Diff line change
Expand Up @@ -1128,6 +1128,7 @@ private void initComponents() {
pnlAdditionalFluff = new javax.swing.JPanel();
JPanel pnlManufacturers = new JPanel();
JLabel lblManuInfo = new JLabel();
txtLog = new javax.swing.JTextArea();
txtManufacturer = new javax.swing.JTextField();
txtEngineManufacturer = new javax.swing.JTextField();
txtArmorModel = new javax.swing.JTextField();
Expand Down Expand Up @@ -1693,8 +1694,15 @@ public void inputMethodTextChanged(java.awt.event.InputMethodEvent evt) {
pnlExperimental.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Experimental Equipment"));

chkArmoredMotive.setEnabled(false);
chkCommandConsole.setEnabled(false);
chkArmoredMotive.addActionListener(this::chkArmoredMotiveActionPerformed);

chkEscapePod.setText("Combat Vehicle Escape Pod");
chkEscapePod.setEnabled(false);

chkCommandConsole.setText("Command Console");
chkCommandConsole.setEnabled(false);

chkMinesweeper.setText("Minesweeper");
chkMinesweeper.setEnabled(false);
chkJetBooster.setEnabled(false);
chkJetBooster.addActionListener(this::chkJetBoosterActionPerformed);
Expand Down Expand Up @@ -2243,6 +2251,12 @@ public void mouseClicked( MouseEvent e ) {
tbpWeaponChooser.addTab("Artillery", EquipmentLocation(lstChooseArtillery, this::lstChooseArtilleryValueChanged, mlAddEquip, placeholder));
tbpWeaponChooser.addTab("Ammunition", EquipmentLocation(lstChooseAmmunition, this::lstChooseAmmunitionValueChanged, mlAddEquip, placeholder));

//region Log Output
JPanel pnlLog = new JPanel();
pnlLog.setLayout(new BoxLayout(pnlLog, BoxLayout.Y_AXIS));
//pnlLog.add(txtLog); //Uncomment this when you want to see entries in the Log
//endregion

GroupLayout pnlEquipmentLayout = new GroupLayout(pnlEquipment);
pnlEquipment.setLayout(pnlEquipmentLayout);
pnlEquipmentLayout.setHorizontalGroup(
Expand All @@ -2253,7 +2267,9 @@ public void mouseClicked( MouseEvent e ) {
.addComponent(pnlControls, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(pnlSpecials, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
.addComponent(pnlSelected, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE)
.addComponent(pnlEquipInfo, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
.addGroup(pnlEquipmentLayout.createParallelGroup(GroupLayout.Alignment.LEADING, true)
.addComponent(pnlEquipInfo, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(pnlLog, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE)))
);
pnlEquipmentLayout.setVerticalGroup(
pnlEquipmentLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
Expand All @@ -2266,7 +2282,8 @@ public void mouseClicked( MouseEvent e ) {
.addComponent(pnlSpecials, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
.addGroup(pnlEquipmentLayout.createSequentialGroup()
.addComponent(pnlEquipInfo, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
.addComponent(pnlEquipInfo, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(pnlLog, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE))
);

tbpMainTabPane.addTab("Equipment", pnlEquipment);
Expand Down Expand Up @@ -3138,11 +3155,8 @@ private void BuildChassisSelector() {
}

private void BuildExpEquipmentSelector() {
JCheckBox[] ExpEquipmentCheckboxes = { chkArmoredMotive,
chkSupercharger,
chkCommandConsole,
JCheckBox[] ExpEquipmentCheckboxes = { chkCommandConsole,
chkMinesweeper,
chkJetBooster,
chkEscapePod,
chkSponsonTurret };
if (cmbRulesLevel.getSelectedIndex() > 1) {
Expand Down Expand Up @@ -3915,25 +3929,26 @@ private void RefreshEquipment() {
// refreshes the equipment selectors
//fix the CASE control
CASE Case = new CASE();
setCheckbox(chkCASE, ( CommonTools.IsAllowed( Case.GetAvailability(), CurVee) || CurVee.GetTechBase() == AvailableCode.TECH_CLAN ), CurVee.GetLoadout().HasCase());
setCheckbox(chkCASE, ( CommonTools.IsAllowed( Case.GetAvailability(), CurVee) || CurVee.GetTechBase() == AvailableCode.TECH_CLAN ), CurVee.GetLoadout().HasCase(), CurVee.isOmni());

// fix Artemis IV controls
ifMissileGuidance ArtCheck = new ArtemisIVFCS( null );
setCheckbox(chkFCSAIV, ( CommonTools.IsAllowed( ArtCheck.GetAvailability(), CurVee ) ), CurVee.UsingArtemisIV());
setCheckbox(chkFCSAIV, ( CommonTools.IsAllowed( ArtCheck.GetAvailability(), CurVee ) ), CurVee.UsingArtemisIV(), CurVee.isOmni());

// fix Artemis V controls
ArtCheck = new ArtemisVFCS( null );
setCheckbox(chkFCSAV, ( CommonTools.IsAllowed( ArtCheck.GetAvailability(), CurVee ) ), CurVee.UsingArtemisV());
setCheckbox(chkFCSAV, ( CommonTools.IsAllowed( ArtCheck.GetAvailability(), CurVee ) ), CurVee.UsingArtemisV(), CurVee.isOmni());

// fix ApolloFCS controls
ArtCheck = new ApolloFCS( null );
setCheckbox(chkFCSApollo, ( CommonTools.IsAllowed( ArtCheck.GetAvailability(), CurVee ) ), CurVee.UsingApollo());
setCheckbox(chkFCSApollo, ( CommonTools.IsAllowed( ArtCheck.GetAvailability(), CurVee ) ), CurVee.UsingApollo(), CurVee.isOmni());

// fix the targeting computer display
setCheckbox(chkUseTC, ( CommonTools.IsAllowed( CurVee.GetTC().GetAvailability(), CurVee ) ), CurVee.UsingTC());
setCheckbox(chkUseTC, ( CommonTools.IsAllowed( CurVee.GetTC().GetAvailability(), CurVee ) ), CurVee.UsingTC(), CurVee.isOmni());

setCheckbox(chkSupercharger, ( CommonTools.IsAllowed( CurVee.GetLoadout().GetSupercharger().GetAvailability(), CurVee ) && !CurVee.IsVTOL() ), CurVee.GetLoadout().HasSupercharger());
setCheckbox(chkJetBooster, ( CommonTools.IsAllowed( CurVee.GetLoadout().GetVTOLBooster().GetAvailability(), CurVee ) && CurVee.IsVTOL() && !CurVee.IsOmni() ), CurVee.GetLoadout().HasVTOLBooster());
setCheckbox(chkSupercharger, ( CommonTools.IsAllowed( CurVee.GetLoadout().GetSupercharger().GetAvailability(), CurVee ) && !CurVee.IsVTOL() ), CurVee.GetLoadout().HasSupercharger(), CurVee.isOmni());
setCheckbox(chkJetBooster, ( CommonTools.IsAllowed( CurVee.GetLoadout().GetVTOLBooster().GetAvailability(), CurVee ) && CurVee.IsVTOL() && !CurVee.IsOmni() ), CurVee.GetLoadout().HasVTOLBooster(), CurVee.isOmni());
setCheckbox(chkArmoredMotive, ( CommonTools.IsAllowed( CurVee.GetLoadout().GetArmoredMotiveSystem().GetAvailability(), CurVee ) && !CurVee.IsVTOL() ), CurVee.GetLoadout().HasArmoredMotiveSystem(), CurVee.isOmni());

if( ! chkUseTC.isEnabled() ) { CurVee.UseTC( false, false ); }

Expand Down Expand Up @@ -3965,10 +3980,14 @@ private void RefreshEquipment() {
}
}

private void setCheckbox(JCheckBox element, Boolean isEnabled, Boolean isSelected) {
private void Log(String message) {
txtLog.append(message + "\n");
}

private void setCheckbox(JCheckBox element, Boolean isEnabled, Boolean isSelected, Boolean allowSelection) {
element.setEnabled(isEnabled);
element.setSelected(false);
if (isEnabled) {
if (isEnabled || allowSelection) {
element.setSelected(isSelected);
}
}
Expand Down Expand Up @@ -6381,7 +6400,33 @@ private void chkJetBoosterActionPerformed(java.awt.event.ActionEvent evt) {
RefreshSummary();
RefreshInfoPane();
}

private void chkArmoredMotiveActionPerformed(ActionEvent evt) {
if (CurVee.GetLoadout().HasArmoredMotiveSystem() == chkArmoredMotive.isSelected()) {
return;
}
try {
switch (CurVee.GetTechBase()) {
case AvailableCode.TECH_INNER_SPHERE:
CurVee.GetLoadout().SetArmoredMotiveSystem(chkArmoredMotive.isSelected(), false);
break;
case AvailableCode.TECH_CLAN:
CurVee.GetLoadout().SetArmoredMotiveSystem(chkArmoredMotive.isSelected(), true);
break;
case AvailableCode.TECH_BOTH:
dlgTechBaseChooser tech = new dlgTechBaseChooser(this, true);
tech.setLocationRelativeTo(this);
tech.setVisible(true);
CurVee.GetLoadout().SetArmoredMotiveSystem(chkArmoredMotive.isSelected(), tech.IsClan());
break;
}
} catch( Exception e ) {
Media.Messager( this, e.getMessage() );
chkArmoredMotive.setSelected( false );
}
RefreshSelectedEquipment();
RefreshSummary();
RefreshInfoPane();
}
private void chkSuperchargerActionPerformed(java.awt.event.ActionEvent evt) {
if( CurVee.GetLoadout().HasSupercharger() == chkSupercharger.isSelected() ) {
return;
Expand Down Expand Up @@ -7452,6 +7497,7 @@ private void FixJJSpinnerModel() {
private javax.swing.JTextField txtInfoFreeTons;
private javax.swing.JTextField txtInfoTonnage;
private javax.swing.JTextField txtJJModel;
private javax.swing.JTextArea txtLog;
private javax.swing.JTextField txtManufacturer;
private javax.swing.JTextField txtManufacturerLocation;
private javax.swing.JTextField txtModel;
Expand Down
11 changes: 11 additions & 0 deletions sswlib/src/main/java/common/CommonTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,17 @@ public static String GetTechbaseString( int tech ) {
}
}

public static int GetTechbaseValue( String tech ) {
switch( tech ) {
case "Clan":
return AvailableCode.TECH_CLAN;
case "Mixed":
return AvailableCode.TECH_BOTH;
default:
return AvailableCode.TECH_INNER_SPHERE;
}
}

public static String GetAggregateReportBV( abPlaceable p ) {
// since an item may have both offensive and defensive BV, this gives us
// an aggregate battle value string for reporting
Expand Down
3 changes: 3 additions & 0 deletions sswlib/src/main/java/common/EquipmentFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ public EquipmentFactory( ArrayList rweapons, ArrayList pweapons, ArrayList equip
}
if ( m instanceof CombatVehicle ) {
Equipment.add( new Hitch() );
Equipment.add( new ArmoredMotiveSystem(((CombatVehicle) m).GetLoadout()));
}
BuildMGArrays();
}
Expand All @@ -144,6 +145,8 @@ public abPlaceable GetCopy( abPlaceable p, ifUnit m ) {
retval = new DroneOperatingSystem( (Mech) m );
} else if (p instanceof LiftHoist) {
retval = new LiftHoist(m);
} else if (p instanceof ArmoredMotiveSystem) {
retval = new ArmoredMotiveSystem(((CombatVehicle)m).GetLoadout());
} else if( p instanceof Equipment ) {
retval = ((Equipment) p).Clone();
} else if( p instanceof ModularArmor ) {
Expand Down
110 changes: 110 additions & 0 deletions sswlib/src/main/java/components/ArmoredMotiveSystem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
package components;

import common.CommonTools;
import common.EquipmentFactory;

public class ArmoredMotiveSystem extends Equipment {
private ifCVLoadout Owner;
private AvailableCode AC = new AvailableCode( AvailableCode.TECH_BOTH );
public ArmoredMotiveSystem(ifCVLoadout l) {
AC.SetISCodes('E', 'X', 'X', 'F', 'E');
AC.SetISDates( 3069, 3071, true, 0, 0, 0, false, false );
AC.SetISFactions( "FWL", "FWL", "", "" );
AC.SetCLCodes( 'F', 'X', 'X', 'F', 'E' );
AC.SetCLDates( 3054, 3057, true, 0, 0, 0, false, false );
AC.SetCLFactions( "CHH", "CHH", "", "" );
AC.SetPBMAllowed( false );
AC.SetPIMAllowed( false );
AC.SetRulesLevels( AvailableCode.RULES_UNALLOWED, AvailableCode.RULES_UNALLOWED, AvailableCode.RULES_EXPERIMENTAL, AvailableCode.RULES_UNALLOWED, AvailableCode.RULES_UNALLOWED );

Owner = l;
}
@Override
public String ActualName() {
return "Armored Motive System";
}

@Override
public String LookupName() {
return "Armored Motive System";
}

@Override
public String CritName() {
return "Armored Motive System";
}

@Override
public String ChatName() {
return "ArmMotSys";
}

@Override
public String MegaMekName(boolean UseRear) {
return (IsClan() ? "CL" : "IS") + "ArmoredMotiveSystem";
}

@Override
public String BookReference() {
return "Tactical Operations";
}

@Override
public int NumCrits() {
return 0;
}

@Override
public int NumCVSpaces() {
return 0;
}

@Override
public double GetTonnage() {
return CommonTools.RoundHalfUp(Owner.GetOwner().GetTonnage() * (IsClan() ? .1 : .15));
}

@Override
public double GetCost() {
return 100000 * GetTonnage();
}

@Override
public double GetOffensiveBV() {
return 0;
}

@Override
public double GetCurOffensiveBV(boolean UseRear, boolean UseTC, boolean UseAES) {
return 0;
}

@Override
public double GetCurOffensiveBV(boolean UseRear, boolean UseTC, boolean UseAES, boolean UseRobotic) {
return 0;
}

@Override
public double GetDefensiveBV() {
return 0;
}

@Override
public AvailableCode GetAvailability() {
return AC;
}

public void SetClan(boolean b ) { super.SetCurrentTech(b ? AvailableCode.TECH_CLAN : AvailableCode.TECH_INNER_SPHERE); }

public boolean IsClan() { return (super.GetCurrentTech() == AvailableCode.TECH_CLAN); }

@Override
public boolean CoreComponent() {
return true;
}

@Override
public String GetEquipmentType() {
return "Armored Motive System";
}
}
8 changes: 4 additions & 4 deletions sswlib/src/main/java/components/AvailableCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ public void SetCodes( char istech, char isSL, char isSW, char isCI, char isDA, c
IS_SW = isSW;
IS_CI = isCI;
IS_DA = isDA;
CL_TechRating = istech;
CL_SL = isSL;
CL_SW = isSW;
CL_CI = isCI;
CL_TechRating = cltech;
CL_SL = clSL;
CL_SW = clSW;
CL_CI = clCI;
CL_DA = clDA;
}

Expand Down
23 changes: 12 additions & 11 deletions sswlib/src/main/java/components/CASE.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@

package components;

public class CASE extends abPlaceable {
public class CASE extends Equipment {
// A simple class for Inner Sphere CASE.
private AvailableCode AC = new AvailableCode( AvailableCode.TECH_INNER_SPHERE );
private boolean IsClan = false;

public CASE() {
AC.SetISCodes( 'E', 'C', 'F', 'D', 'C' );
Expand Down Expand Up @@ -72,9 +71,7 @@ public String ChatName() {
return "CASE";
}

public String MegaMekName( boolean UseRear ) {
return "ISCASE";
}
public String MegaMekName( boolean UseRear ) { return (IsClan() ? "CL" : "IS") + "CASE"; }

public String BookReference() {
return "Tech Manual";
Expand All @@ -86,12 +83,12 @@ public int NumCrits() {

@Override
public int NumCVSpaces() {
if ( IsClan ) return 0;
if ( IsClan() ) return 0;
return 1;
}

public double GetTonnage() {
if ( IsClan ) return 0;
if ( IsClan() ) return 0;
return 0.5;
}

Expand Down Expand Up @@ -135,10 +132,14 @@ public AvailableCode GetAvailability() {
public String toString() {
return "CASE";
}

public void SetClan(boolean b ) {
IsClan = b;

public void SetClan(boolean b ) { super.SetCurrentTech(b ? AvailableCode.TECH_CLAN : AvailableCode.TECH_INNER_SPHERE); }

public boolean IsClan() { return (super.GetCurrentTech() == AvailableCode.TECH_CLAN); }

@Override
public String GetEquipmentType() {
return "CASE";
}

public boolean IsClan() { return IsClan; }
}
Loading