Optimize content handlers

This commit is contained in:
KingRainbow44 2023-08-13 12:48:04 -04:00
parent 597574ddda
commit 948dd5df59
No known key found for this signature in database
GPG Key ID: FC2CB64B00D257BE
4 changed files with 8 additions and 27 deletions

View File

@ -9,12 +9,7 @@ import emu.grasscutter.net.proto.BargainResultTypeOuterClass.BargainResultType;
public final class ContentBargainFail extends BaseContent { public final class ContentBargainFail extends BaseContent {
@Override @Override
public boolean execute(GameQuest quest, QuestData.QuestContentCondition condition, String paramStr, int... params) { public boolean execute(GameQuest quest, QuestData.QuestContentCondition condition, String paramStr, int... params) {
var bargain = quest.getOwner() return condition.getParam()[0] == params[0] &&
.getPlayerProgress() condition.getParam()[1] == params[1];
.getBargains()
.get(condition.getParam()[0]);
if (bargain == null) return false;
return bargain.getResult() == BargainResultType.BARGAIN_COMPLETE_FAIL;
} }
} }

View File

@ -9,12 +9,7 @@ import emu.grasscutter.net.proto.BargainResultTypeOuterClass.BargainResultType;
public final class ContentBargainLessThan extends BaseContent { public final class ContentBargainLessThan extends BaseContent {
@Override @Override
public boolean execute(GameQuest quest, QuestData.QuestContentCondition condition, String paramStr, int... params) { public boolean execute(GameQuest quest, QuestData.QuestContentCondition condition, String paramStr, int... params) {
var bargain = quest.getOwner() return condition.getParam()[0] == params[0] &&
.getPlayerProgress() condition.getParam()[1] == params[1];
.getBargains()
.get(condition.getParam()[0]);
if (bargain == null) return false;
return bargain.getResult() == BargainResultType.BARGAIN_SINGLE_FAIL;
} }
} }

View File

@ -3,18 +3,12 @@ package emu.grasscutter.game.quest.content;
import emu.grasscutter.data.excels.quest.QuestData; import emu.grasscutter.data.excels.quest.QuestData;
import emu.grasscutter.game.quest.*; import emu.grasscutter.game.quest.*;
import emu.grasscutter.game.quest.enums.QuestContent; import emu.grasscutter.game.quest.enums.QuestContent;
import emu.grasscutter.net.proto.BargainResultTypeOuterClass.BargainResultType;
@QuestValueContent(QuestContent.QUEST_CONTENT_BARGAIN_SUCC) @QuestValueContent(QuestContent.QUEST_CONTENT_BARGAIN_SUCC)
public final class ContentBargainSuccess extends BaseContent { public final class ContentBargainSuccess extends BaseContent {
@Override @Override
public boolean execute(GameQuest quest, QuestData.QuestContentCondition condition, String paramStr, int... params) { public boolean execute(GameQuest quest, QuestData.QuestContentCondition condition, String paramStr, int... params) {
var bargain = quest.getOwner() return condition.getParam()[0] == params[0] &&
.getPlayerProgress() condition.getParam()[1] == params[1];
.getBargains()
.get(condition.getParam()[0]);
if (bargain == null) return false;
return bargain.getResult() == BargainResultType.BARGAIN_COMPLETE_SUCC;
} }
} }

View File

@ -8,10 +8,7 @@ import emu.grasscutter.game.quest.enums.QuestContent;
public final class ContentFinishGivingItem extends BaseContent { public final class ContentFinishGivingItem extends BaseContent {
@Override @Override
public boolean execute(GameQuest quest, QuestData.QuestContentCondition condition, String paramStr, int... params) { public boolean execute(GameQuest quest, QuestData.QuestContentCondition condition, String paramStr, int... params) {
var giveAction = quest.getOwner() return condition.getParam()[0] == params[0] &&
.getPlayerProgress() condition.getParam()[1] == params[1];
.getItemGivings()
.get(condition.getParam()[0]);
return giveAction != null && giveAction.isFinished();
} }
} }