Prechádzať zdrojové kódy

fix(summon): Fixed summon/pet max buff count

Summons and pets were using the base MaxBuffCount as defined in character.properties instead of using the value of their owner, taking Divine Inspiration into account.
Noe Caratini 3 rokov pred
rodič
commit
fb419c3a14

+ 5 - 0
src/main/java/com/l2jserver/gameserver/model/actor/stat/SummonStat.java

@@ -29,4 +29,9 @@ public class SummonStat extends PlayableStat {
 	public L2Summon getActiveChar() {
 		return (L2Summon) super.getActiveChar();
 	}
+
+	@Override
+	public int getMaxBuffCount() {
+		return getActiveChar().getOwner().getStat().getMaxBuffCount();
+	}
 }

+ 66 - 0
src/test/java/com/l2jserver/gameserver/model/actor/stat/SummonStatTest.java

@@ -0,0 +1,66 @@
+/*
+ * Copyright © 2004-2021 L2J Server
+ *
+ * This file is part of L2J Server.
+ *
+ * L2J Server is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * L2J Server is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.l2jserver.gameserver.model.actor.stat;
+
+import com.l2jserver.gameserver.model.actor.L2Summon;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.when;
+
+/**
+ * @author Noé Caratini aka Kita
+ * @version 2.6.3.0
+ */
+@ExtendWith(MockitoExtension.class)
+public class SummonStatTest {
+
+    @Mock
+    private L2Summon summon;
+    @Mock
+    private L2PcInstance player;
+    @Mock
+    private PcStat pcStat;
+
+    private SummonStat summonStat;
+
+    @BeforeEach
+    public void setUp() {
+        summonStat = new SummonStat(summon);
+
+        when(summon.getOwner()).thenReturn(player);
+        when(player.getStat()).thenReturn(pcStat);
+    }
+
+    @Test
+    public void shouldReturnOwnersMaxBuffCount() {
+        int maxBuffs = 24;
+
+        when(pcStat.getMaxBuffCount()).thenReturn(maxBuffs);
+
+        int result = summonStat.getMaxBuffCount();
+
+        assertThat(result).isEqualTo(maxBuffs);
+    }
+}