use of main.entity.type.ObjType in project Eidolons by IDemiurge.
the class ScenarioPartyManager method initPlayerParty.
@Override
public Party initPlayerParty() {
if (!getMaster().getMetaGame().isPartyRespawn()) {
party = Eidolons.getParty();
return party;
}
// preset
// choice
// already as Unit?
ObjType type = getMetaGame().getScenario().getPartyType();
randomOneHero = OptionsMaster.getGameplayOptions().getBooleanValue(GAMEPLAY_OPTION.RANDOM_HERO);
chooseOneHero = !randomOneHero;
if (type == null) {
String string = getMetaGame().getScenario().getProperty(PROPS.SCENARIO_PARTY);
type = new ObjType("dummy", DC_TYPE.PARTY);
type.setProperty(PROPS.MEMBERS, string);
} else
type = new ObjType(type);
if (getGame().getMetaMaster().getPartyManager().isRandomOneHero() || getGame().getMetaMaster().getPartyManager().isChooseOneHero()) {
List<String> members = StringMaster.openContainer(type.getProperty(PROPS.MEMBERS));
if (getGame().getMetaMaster().getPartyManager().isRandomOneHero() || members.size() == 1) {
String hero = new RandomWizard<String>().getRandomListItem(members);
type.setProperty(PROPS.MEMBERS, hero);
} else {
// for restart
String hero = selectedHero;
if (hero == null)
hero = chooseHero(members);
if (hero == null) {
// aborted
return null;
}
type.setProperty(PROPS.MEMBERS, hero);
}
}
party = new Party(type);
// if (party.getNextMission().isEmpty()) {
// String missions = StringMaster.joinList(getMetaGame().getScenario().getAvailableMissions());
// party.setProperty(PROPS.PARTY_MISSIONS_NEXT,
// missions
// StringMaster.openContainer(getMetaGame().getScenario().
// getProperty(PROPS.SCENARIO_MISSIONS)).get(0)
// , true);
// }
getGame().getState().addObject(party);
getGame().getDataKeeper().addUnitData(new UnitData(party));
party.setProperty(PROPS.PARTY_MISSION, StringMaster.openContainer(getMetaGame().getScenario().getProperty(PROPS.SCENARIO_MISSIONS)).get(0), true);
return party;
}
use of main.entity.type.ObjType in project Eidolons by IDemiurge.
the class ScenarioPrecombatMaster method newScenario.
public static void newScenario() {
final ScenarioChoiceView scv = new ScenarioChoiceView();
final ChoiceSequence choiceSequence = new ChoiceSequence(scv);
final ScenarioModeChoiceView smcv = new ScenarioModeChoiceView(choiceSequence, SCENARIO_MODES.class);
// TODO only if there are choices!
choiceSequence.addView(smcv);
choiceSequence.start();
choiceSequence.setManager(new SequenceManager() {
@Override
public void doneSelection() {
ObjType type = scv.getSelectedItem();
scenario = new Scenario(type);
SCENARIO_MODES mode = smcv.getSelectedItem();
if (mode == SCENARIO_MODES.STORY_MODE) {
String prop = scenario.getProperty(MACRO_PROPS.MISSION_PARTY);
List<Unit> heroes;
if (!DataManager.isTypeName(prop, DC_TYPE.PARTY)) {
prop = scenario.getProperty(MACRO_PROPS.MISSION_CUSTOM_PARTY);
heroes = new ArrayList<>();
String leaderName = prop.split(";")[0];
Unit leader = Launcher.getMainManager().initSelectedHero(leaderName);
// prop = prop.replace(leaderName, "");
// for (String s : StringMaster.open(prop)) {
// }
heroes.add(leader);
PartyHelper.newParty(leader);
Launcher.getMainManager().launchHC();
return;
} else {
heroes = PartyHelper.loadParty(prop);
}
Launcher.getMainManager().launchHC(heroes);
return;
}
Launcher.resetView(VIEWS.MENU);
}
@Override
public void cancelSelection() {
Launcher.getMainManager().exitToMainMenu();
}
});
}
use of main.entity.type.ObjType in project Eidolons by IDemiurge.
the class PartyHelper method savePartyAs.
/**
* @param arcade true for New Branch in arcade mode, false for Export Party
* from anywhere
*/
public static void savePartyAs(boolean arcade, boolean auto) {
String newName = party.getName();
if (!arcade) {
newName = DialogMaster.inputText(PARTY_NAME_TIP, party.getName());
}
if (newName == null) {
return;
}
if (auto) {
if (!newName.contains(StringMaster.ARCADE)) {
newName = newName + " " + StringMaster.ARCADE;
}
}
if (!auto) {
if (DataManager.isTypeName(newName) && !party.getName().equals(newName)) {
if (!newName.contains(StringMaster.ARCADE)) {
newName = newName + " " + StringMaster.ARCADE;
}
Loop.startLoop(97);
int i = 2;
while (!Loop.loopEnded()) {
if (DataManager.isTypeName(newName + "-" + i)) {
continue;
}
newName = newName + "-" + i;
break;
}
if (!checkPartyName(newName)) {
DialogMaster.error("Invalid name!");
return;
}
}
}
// save old party
saveParty();
ObjType newType = new ObjType(party.getType());
Simulation.getGame().initType(newType);
if (arcade) {
party.setType(newType);
party.setProperty(G_PROPS.GROUP, StringMaster.ARCADE, true);
getParty().setName(newName);
saveParty();
} else {
Party exportedParty = newParty(newType);
exportedParty.setProperty(G_PROPS.GROUP, StringMaster.PRESET, true);
exportedParty.setName(newName);
saveParty(exportedParty, true);
}
}
use of main.entity.type.ObjType in project Eidolons by IDemiurge.
the class PartyHelper method addCreepParty.
public static void addCreepParty(Wave wave) {
DC_Game game = wave.getGame();
Unit leader = wave.getLeader();
String name = wave.getName();
List<Unit> units = wave.getUnits();
ObjType newType = new ObjType(game);
wave.setParty(addCreepParty(leader, name, units, newType));
}
use of main.entity.type.ObjType in project Eidolons by IDemiurge.
the class PartyHelper method loadParty.
public static List<Unit> loadParty(String typeName, DC_Game game, boolean readTypes) {
// invoke before obj init, to getOrCreate full obj string
if (readTypes) {
File file = getPartyFile(typeName);
String xml = FileManager.readFile(file);
if (xml.contains(XML_Converter.openXmlFormatted(typeName))) {
String partyTypeData = StringMaster.getXmlNode(xml, typeName);
xml = xml.replace(partyTypeData, "");
XML_Reader.createCustomTypeList(partyTypeData, DC_TYPE.PARTY, game, true);
}
XML_Reader.readCustomTypeFile(file, DC_TYPE.CHARS, game);
}
ObjType partyType = DataManager.getType(typeName, DC_TYPE.PARTY);
setParty(newParty(partyType));
party.toBase();
return party.getMembers();
}
Aggregations