Skip to content

Commit

Permalink
Adventure - Editor fix, minor quest updates
Browse files Browse the repository at this point in the history
Editor is not feature complete, but is now closer to it for quests than it was before.
  • Loading branch information
jjayers99 committed Feb 3, 2024
1 parent 4c69738 commit 1dfde9b
Show file tree
Hide file tree
Showing 8 changed files with 11,420 additions and 11,419 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@


import com.badlogic.gdx.tools.particleeditor.ParticleEditor;
import com.google.common.base.Function;
import forge.localinstance.properties.ForgeConstants;
import forge.localinstance.properties.ForgePreferences;
import forge.model.FModel;
import forge.util.Lang;
import forge.util.Localizer;

import javax.swing.*;
import java.awt.*;
Expand All @@ -17,6 +23,15 @@ public class EditorMainWindow extends JFrame {
public EditorMainWindow()
{
UIManager.LookAndFeelInfo[] var1 = UIManager.getInstalledLookAndFeels();
FModel.initialize(null, new Function<ForgePreferences, Void>() {
@Override
public Void apply(ForgePreferences preferences) {
preferences.setPref(ForgePreferences.FPref.LOAD_CARD_SCRIPTS_LAZILY, true);
return null;
}
});
Lang.createInstance(FModel.getPreferences().getPref(ForgePreferences.FPref.UI_LANGUAGE));
Localizer.getInstance().initialize(FModel.getPreferences().getPref(ForgePreferences.FPref.UI_LANGUAGE), ForgeConstants.LANG_DIR);
int var2 = var1.length;

for(int var3 = 0; var3 < var2; ++var3) {
Expand Down
210 changes: 178 additions & 32 deletions forge-adventure/src/main/java/forge/adventure/editor/QuestStageEdit.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ private void replaceTokens(DialogData data){
private EnemySprite generateTargetEnemySprite(AdventureQuestStage stage){
if (stage.objective == AdventureQuestController.ObjectiveTypes.Hunt){
EnemyData toUse = generateTargetEnemyData(stage);
toUse.lifetime = stage.count1;
toUse.lifetime = stage.count3;
EnemySprite toReturn = new EnemySprite(toUse);
toReturn.questStageID = stage.stageID.toString();
return toReturn;
Expand Down
47 changes: 26 additions & 21 deletions forge-gui-mobile/src/forge/adventure/data/AdventureQuestStage.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ public class AdventureQuestStage implements Serializable {
public int count1; //use defined by objective type, this can be enemies to defeat, minimum PoI distance, etc
public int count2; //use defined by objective type, this can be enemies to defeat, minimum PoI distance, etc
public int count3; //use defined by objective type, this can be enemies to defeat, minimum PoI distance, etc
public int count4; //use defined by objective type, this can be enemies to defeat, minimum PoI distance, etc
private int progress1; //Progress toward count1
private int progress2; //Progress toward count2
private int progress3; //Progress toward count3
private int progress4; //Progress toward count3
public boolean mixedEnemies; //false: Pick one enemy type. True: Combine all potential types
public boolean here; //Default PoI selection to current location
private PointOfInterest targetPOI; //Destination. Expand to array to cover "anyPOI?"
Expand All @@ -55,7 +57,7 @@ public class AdventureQuestStage implements Serializable {
public String deliveryItem = ""; //Imaginary item to get/fetch/deliver. Could be a general purpose field.
public String POIToken; //If defined, ignore tags input and use the target POI from a different stage's objective instead.
private transient List<Integer> _parsedPrerequisiteNames;
private transient List<PointOfInterest> validPOIs = Current.world().getAllPointOfInterest();
private transient List<PointOfInterest> validPOIs;
public boolean allowInactivePOI = false;

public UUID stageID;
Expand All @@ -64,6 +66,7 @@ public void initialize() {
if (stageID == null) {
stageID = UUID.randomUUID();
}
validPOIs = Current.world().getAllPointOfInterest();
}

public void checkPrerequisites(List<Integer> completedStages) {
Expand Down Expand Up @@ -215,6 +218,7 @@ public AdventureQuestStage(AdventureQuestStage other) {
this.count1 = other.count1;
this.count2 = other.count2;
this.count3 = other.count3;
this.count4 = other.count4;
this.enemyTags = other.enemyTags;
this.enemyExcludeTags = other.enemyExcludeTags;
this.anyPOI = other.anyPOI;
Expand Down Expand Up @@ -271,12 +275,12 @@ public AdventureQuestController.QuestStatus handleEvent(AdventureQuestEvent even
switch (objective) {
case CharacterFlag:
if (event.type == AdventureQuestEventType.CHARACTERFLAG)
status = event.flagName != null && event.flagName.equals(this.mapFlag) && event.flagValue >= this.mapFlagValue ? COMPLETE : status;
status = event.flagName != null && event.flagName.equals(this.mapFlag) && event.flagValue >= this.mapFlagValue ? COMPLETE : status;
break;
case CompleteQuest:
status = event.type == AdventureQuestEventType.QUESTCOMPLETE
&& (anyPOI || event.otherQuest != null && event.otherQuest.sourceID.equals(targetPOI.getID()))
&& ++progress1 >= count1 ? COMPLETE : status;
&& ++progress3 >= count3 ? COMPLETE : status;
break;
case Clear:
if (event.clear && event.winner) {
Expand All @@ -287,35 +291,36 @@ public AdventureQuestController.QuestStatus handleEvent(AdventureQuestEvent even
if (event.type != AdventureQuestEventType.MATCHCOMPLETE)
break;
if (event.winner) {
status = ++progress1 >= count1 ? COMPLETE : status;
status = ++progress3 >= count3 ? COMPLETE : status;
} else {
status = ++progress2 >= count2 ? FAILED : status;
status = ++progress4 >= count4 && count4 > 0 ? FAILED : status;
}
case Arena:
status = event.type == AdventureQuestEventType.ARENACOMPLETE
&& event.winner //if event won & not conceded
&& ++progress1 >= count1 ? COMPLETE : status;
&& ++progress3 >= count3 ? COMPLETE : status;
break;
case EventFinish:
if (event.type != AdventureQuestEventType.EVENTCOMPLETE)
break;
status = ++progress3 >= count3 ? COMPLETE : status;
break;
case EventWin:
if (event.type != AdventureQuestEventType.EVENTCOMPLETE)
break;
if (event.winner)
event.count1++; //number of wins
else
event.count2++; //number of losses
if (++progress2 >= count2 && count2 > 0) {
status = FAILED;
} else if (++progress1 >= count1) {
status = COMPLETE;
if (event.winner) {
status = ++progress3 >= count3 ? COMPLETE : status;
} else {
status = ++progress4 >= count4 && count4 > 0 ? FAILED : status;
}
break;
case EventWinMatches:
if (event.type != AdventureQuestEventType.EVENTMATCHCOMPLETE)
break;
if (event.winner) {
status = ++progress1 >=count1 ? COMPLETE : status;
status = ++progress3 >= count3 ? COMPLETE : status;
} else {
status = ++progress2 >= count2 && count2 > 0 ? FAILED : status;
status = ++progress4 >= count4 && count4 > 0 ? FAILED : status;
}
break;
case Fetch:
Expand All @@ -330,13 +335,13 @@ public AdventureQuestController.QuestStatus handleEvent(AdventureQuestEvent even
if (event.winner) {
status = event.enemy.equals(targetSprite) ? COMPLETE : status;
} else {
status = ++progress2 >= count2 && count2 > 0 ? FAILED : status;
status = ++progress4 >= count4 && count4 > 0 ? FAILED : status;
}
}
break;
case Leave:
if (event.type == AdventureQuestEventType.LEAVEPOI)
status = ++progress1 >= count1 ? COMPLETE : status;
status = ++progress3 >= count3 ? COMPLETE : status;
break;
case MapFlag:
if (event.type == AdventureQuestEventType.MAPFLAG)
Expand All @@ -349,11 +354,11 @@ public AdventureQuestController.QuestStatus handleEvent(AdventureQuestEvent even
case HaveReputation:
//presumed that WorldMapOK will be set on this type, as reputation will occasionally be updated remotely by quests
if (event.type == AdventureQuestEventType.REPUTATION)
status = checkIfTargetLocation(event.poi) && event.count1 >= count1 ? COMPLETE : status;
status = checkIfTargetLocation(event.poi) && event.count3 >= count3 ? COMPLETE : status;
break;
case HaveReputationInCurrentLocation:
if (event.type == AdventureQuestEventType.ENTERPOI || event.type == AdventureQuestEventType.REPUTATION)
status = event.count1 >= count1 ? COMPLETE : status;
status = event.count3 >= count3 ? COMPLETE : status;
break;
case Delivery:
//will eventually differentiate from Travel
Expand All @@ -363,7 +368,7 @@ public AdventureQuestController.QuestStatus handleEvent(AdventureQuestEvent even
case Use:
status = event.type == AdventureQuestEventType.USEITEM
&& (itemNames.isEmpty()) || itemNames.contains(event.item.name)
&& ++progress1 >= count1 ? COMPLETE : status;
&& ++progress3 >= count3 ? COMPLETE : status;
break;
}
return status;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private void triggerUse() {
done();
if (data.commandOnUse != null && !data.commandOnUse.isEmpty())
ConsoleCommandInterpreter.getInstance().command(data.commandOnUse);
if (data.dialogOnUse.text != null && !data.dialogOnUse.text.isEmpty()) {
if (data.dialogOnUse != null && data.dialogOnUse.text != null && !data.dialogOnUse.text.isEmpty()) {
MapDialog dialog = new MapDialog(data.dialogOnUse, MapStage.getInstance(),0,null);
MapStage.instance.showDialog();
dialog.activate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import forge.adventure.pointofintrest.PointOfInterestChanges;
import forge.adventure.stage.GameStage;
import forge.adventure.stage.MapStage;
import forge.adventure.world.WorldSave;
import forge.util.Aggregates;

import java.io.Serializable;
Expand Down Expand Up @@ -332,6 +333,7 @@ public void updateEnteredPOI(PointOfInterest arrivedAt)
AdventureQuestEvent event = new AdventureQuestEvent();
event.type = AdventureQuestEventType.ENTERPOI;
event.poi = arrivedAt;
event.count3 = WorldSave.getCurrentSave().getPointOfInterestChanges(arrivedAt.getID()).getMapReputation();
for(AdventureQuestData currentQuest : Current.player().getQuests()) {
currentQuest.updateStages(event);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public class AdventureQuestEvent {
public int flagValue;
public int count1;
public int count2;
public int count3;
public int count4;
public AdventureQuestData otherQuest;
}

Loading

0 comments on commit 1dfde9b

Please sign in to comment.