Skip to content

Commit

Permalink
Format code [skip actions]
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Nov 5, 2023
1 parent d224178 commit 1fac319
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 29 deletions.
29 changes: 15 additions & 14 deletions src/main/java/emu/grasscutter/game/ability/Ability.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,22 @@ public Ability(AbilityData data, GameEntity owner, Player playerOwner) {
//
avatarSkillStartIds = new HashSet<>();
if (data.onAbilityStart != null) {
avatarSkillStartIds.addAll(Arrays.stream(data.onAbilityStart)
.filter(action ->
action.type == AbilityModifierAction.Type.AvatarSkillStart)
.map(action -> action.skillID)
.toList());
avatarSkillStartIds.addAll(
Arrays.stream(data.onAbilityStart)
.filter(action -> action.type == AbilityModifierAction.Type.AvatarSkillStart)
.map(action -> action.skillID)
.toList());
}
avatarSkillStartIds.addAll(data.modifiers.values()
.stream()
.map(m -> (List<AbilityModifierAction>)(m.onAdded == null ?
Collections.emptyList() :
Arrays.asList(m.onAdded)))
.flatMap(List::stream)
.filter(action -> action.type == AbilityModifierAction.Type.AvatarSkillStart)
.map(action -> action.skillID)
.toList());
avatarSkillStartIds.addAll(
data.modifiers.values().stream()
.map(
m ->
(List<AbilityModifierAction>)
(m.onAdded == null ? Collections.emptyList() : Arrays.asList(m.onAdded)))
.flatMap(List::stream)
.filter(action -> action.type == AbilityModifierAction.Type.AvatarSkillStart)
.map(action -> action.skillID)
.toList());
}

public static String getAbilityName(AbilityString abString) {
Expand Down
36 changes: 23 additions & 13 deletions src/main/java/emu/grasscutter/game/ability/AbilityManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,24 @@ private void onPossibleElementalBurst(Ability ability, AbilityModifier modifier,

boolean skillInvincibility = modifier.state == AbilityModifier.State.Invincible;
if (modifier.onAdded != null) {
skillInvincibility |= Arrays.stream(modifier.onAdded)
.filter(action ->
action.type == AbilityModifierAction.Type.AttachAbilityStateResistance &&
action.resistanceListID == 11002)
.toList().size() > 0;
}

if (this.clearBurstEnergy != null && this.burstCasterId == entityId &&
(ability.getAvatarSkillStartIds().contains(this.burstSkillId) || skillInvincibility)) {
Grasscutter.getLogger().trace("Caster ID's {} burst successful, clearing energy and setting invulnerability", entityId);
skillInvincibility |=
Arrays.stream(modifier.onAdded)
.filter(
action ->
action.type == AbilityModifierAction.Type.AttachAbilityStateResistance
&& action.resistanceListID == 11002)
.toList()
.size()
> 0;
}

if (this.clearBurstEnergy != null
&& this.burstCasterId == entityId
&& (ability.getAvatarSkillStartIds().contains(this.burstSkillId) || skillInvincibility)) {
Grasscutter.getLogger()
.trace(
"Caster ID's {} burst successful, clearing energy and setting invulnerability",
entityId);
this.abilityInvulnerable = true;
this.clearBurstEnergy.accept(entityId);
this.removePendingEnergyClear();
Expand Down Expand Up @@ -329,9 +337,11 @@ public void onSkillStart(Player player, int skillId, int casterId) {
}

// Track this elemental burst to possibly clear avatar energy later.
this.clearBurstEnergy = (ignored) ->
player.getEnergyManager().handleEvtDoSkillSuccNotify(
player.getSession(), skillId, casterId);
this.clearBurstEnergy =
(ignored) ->
player
.getEnergyManager()
.handleEvtDoSkillSuccNotify(player.getSession(), skillId, casterId);
this.burstCasterId = casterId;
this.burstSkillId = skillId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ private void handleBurstCast(Avatar avatar, int skillId) {
var skillData = GameData.getAvatarSkillDataMap().get(skillId);

// If the cast skill was a burst, consume energy.
if ((avatar.getSkillDepot() != null && skillId == avatar.getSkillDepot().getEnergySkill()) ||
(skillData != null && skillData.getCostElemVal() > 0)) {
if ((avatar.getSkillDepot() != null && skillId == avatar.getSkillDepot().getEnergySkill())
|| (skillData != null && skillData.getCostElemVal() > 0)) {
avatar.getAsEntity().clearEnergy(ChangeEnergyReason.CHANGE_ENERGY_REASON_SKILL_START);
}
}
Expand Down

0 comments on commit 1fac319

Please sign in to comment.