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 {
@Override
public boolean execute(GameQuest quest, QuestData.QuestContentCondition condition, String paramStr, int... params) {
var bargain = quest.getOwner()
.getPlayerProgress()
.getBargains()
.get(condition.getParam()[0]);
if (bargain == null) return false;
return bargain.getResult() == BargainResultType.BARGAIN_COMPLETE_FAIL;
return condition.getParam()[0] == params[0] &&
condition.getParam()[1] == params[1];
}
}

View File

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

View File

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

View File

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