Skip to content

Commit

Permalink
Merge pull request MegaMek#4798 from MegaMek/generated_multicrew
Browse files Browse the repository at this point in the history
  • Loading branch information
NickAragua authored Sep 21, 2023
2 parents 59dee6b + 8ddf962 commit 6bcfd42
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
22 changes: 21 additions & 1 deletion megamek/src/megamek/client/ratgenerator/CrewDescriptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,26 @@ public void setPiloting(int piloting) {
}

public Crew createCrew(CrewType crewType) {
return new Crew(crewType, name, 1, gunnery, piloting, gender, null);
Crew crew = new Crew(crewType, name, crewType.getCrewSlots(), gunnery, piloting, gender, null);
// Randomize names and skills of crew, then assign the piloting and
// gunnery skills generated for the unit to the correct slot.
if (crewType.getCrewSlots() > 1) {
int oldPiloting = crew.getPiloting();
int oldGunnery = crew.getGunnery();
setSkills();
crew.setPiloting(piloting, 0);
crew.setGunnery(gunnery, 0);
for (int i = 1; i < crew.getSlotCount(); i++) {
crew.setName(generateName(Gender.RANDOMIZE), i);
setSkills();
crew.setPiloting(piloting, i);
crew.setGunnery(gunnery, i);
}
crew.setPiloting(oldPiloting, crew.getCurrentPilotIndex());
crew.setGunnery(oldGunnery, crew.getCurrentGunnerIndex());
setPiloting(oldPiloting);
setGunnery(oldGunnery);
}
return crew;
}
}
6 changes: 6 additions & 0 deletions megamek/src/megamek/common/Mech.java
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,12 @@ public int getUnitType() {
return UnitType.MEK;
}

@Override
public CrewType defaultCrewType() {
return (cockpitType == COCKPIT_COMMAND_CONSOLE) || (cockpitType == COCKPIT_SUPERHEAVY_COMMAND_CONSOLE)
|| (cockpitType == COCKPIT_SMALL_COMMAND_CONSOLE) ? CrewType.COMMAND_CONSOLE : CrewType.SINGLE;
}

/**
* @return if this mech cannot stand up from hulldown
*/
Expand Down
4 changes: 4 additions & 0 deletions megamek/src/megamek/common/QuadVee.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ public boolean hasTracks() {
return false;
}

@Override
public CrewType defaultCrewType() {
return CrewType.QUADVEE;
}

@Override
public int getWalkMP(MPCalculationSetting mpCalculationSetting) {
Expand Down
5 changes: 5 additions & 0 deletions megamek/src/megamek/common/TripodMech.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ public boolean isTripodMek() {
return true;
}

@Override
public CrewType defaultCrewType() {
return isSuperHeavy() ? CrewType.SUPERHEAVY_TRIPOD : CrewType.TRIPOD;
}

/**
* Returns true if the entity can flip its arms
*/
Expand Down

0 comments on commit 6bcfd42

Please sign in to comment.