Skip to content

Commit

Permalink
Test rune level bonus
Browse files Browse the repository at this point in the history
  • Loading branch information
U-lis committed Apr 9, 2024
1 parent 7de243e commit 823e7aa
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 23 deletions.
39 changes: 32 additions & 7 deletions .Lib9c.Tests/Action/RuneEnhancementTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -633,14 +633,14 @@ public void Execute_FailedLoadStateException()
[InlineData(new[] { 4, 4 }, 2, false)]
[InlineData(new[] { 4, 5 }, 1, false)]
// Crete new rune
[InlineData(new int[] { }, 1, true)]
[InlineData(new int[] { }, 1, true, 100)]
[InlineData(new int[] { }, 10, true)]
[InlineData(new[] { 1 }, 9, true)]
[InlineData(new[] { 9 }, 1, true)]
[InlineData(new[] { 7 }, 3, true)]
[InlineData(new[] { 4, 4 }, 2, true)]
[InlineData(new[] { 4, 5 }, 1, true)]
public void TotalLevel(int[] prevRuneLevels, int tryCount, bool createNewRune)
public void RuneBonus(int[] prevRuneLevels, int tryCount, bool createNewRune, int expectedRuneLevelBonus = 1000)
{
// Data
const int testRuneId = 30001;
Expand Down Expand Up @@ -697,6 +697,18 @@ public void TotalLevel(int[] prevRuneLevels, int tryCount, bool createNewRune)

state = state.SetRuneState(avatarAddress, allRuneState);
var runeListSheet = tableSheets.RuneListSheet;
var runeLevelBonusSheet = tableSheets.RuneLevelBonusSheet;
var prevRuneLevelBonus = prevRuneLevels.Length == 0
? 0
: runeLevelBonusSheet.Values.First(row => row.RuneLevel == 1).Bonus;
Assert.Equal(
prevRuneLevelBonus,
RuneHelper.CalculateRuneLevelBonus(
allRuneState,
runeListSheet,
runeLevelBonusSheet
)
);

// RuneEnhancement
var ncgCurrency = state.GetGoldCurrency();
Expand All @@ -722,13 +734,26 @@ public void TotalLevel(int[] prevRuneLevels, int tryCount, bool createNewRune)
};

// Check bonus
var expectedRuneBonus = tableSheets.RuneLevelBonusSheet.Values
.OrderByDescending(row => row.RuneLevel).First(
row => row.RuneLevel <= allRuneState.TotalLevel() + tryCount
).Bonus;
var nextState = action.Execute(ctx);
var nextAllRuneState = nextState.GetRuneState(avatarAddress);
Assert.Equal(allRuneState.TotalLevel() + tryCount, nextAllRuneState.TotalLevel());
var expectedBonusLevel = 0;
foreach (var rune in nextAllRuneState.Runes.Values)
{
var runeRow = runeListSheet.Values.FirstOrDefault(row => row.Id == rune.RuneId);
if (runeRow is not null)
{
expectedBonusLevel += runeRow.BonusCoef * rune.Level;
}
}

Assert.Equal(
expectedRuneLevelBonus,
RuneHelper.CalculateRuneLevelBonus(
nextAllRuneState,
runeListSheet,
runeLevelBonusSheet
)
);
}
}
}
32 changes: 16 additions & 16 deletions Lib9c/TableCSV/Rune/RuneListSheet.csv
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
id,_name,grade,rune_type,required_level,use_place,bonus_coef
30001,Adventurer's Rune,1,1,1,7,10000
10001,Fenrir HP Rune,2,1,1,4,10000
10002,Fenrir ATK Rune,3,1,1,5,10000
10003,Fenrir Bleeding Rune,5,2,1,7,10000
10011,Saehrimnir HIT Rune,2,1,1,7,10000
10012,Saehrimnir DEF Rune,3,1,1,3,10000
10013,Saehrimnir Skill Rune,5,2,1,7,10000
20001,Golden leaf Rune,5,2,1,7,10000
10021,Adventure Stun Rune,5,2,1,1,10000
10022,Arena Stun Rune,5,2,1,2,10000
10023,Adventure Vampiric Rune,5,2,1,1,10000
10024,WorldBoss Vampiric Rune,5,2,1,4,10000
10025,Adventure Stamina Rune,4,1,1,1,10000
10026,Arena Stamina Rune,4,1,1,2,10000
10027,Arena Quick Rune,4,1,1,2,10000
10028,WorldBoss Quick Rune,4,1,1,4,10000
30001,Adventurer's Rune,1,1,1,7,1
10001,Fenrir HP Rune,2,1,1,4,1
10002,Fenrir ATK Rune,3,1,1,5,1
10003,Fenrir Bleeding Rune,5,2,1,7,1
10011,Saehrimnir HIT Rune,2,1,1,7,1
10012,Saehrimnir DEF Rune,3,1,1,3,1
10013,Saehrimnir Skill Rune,5,2,1,7,1
20001,Golden leaf Rune,5,2,1,7,1
10021,Adventure Stun Rune,5,2,1,1,1
10022,Arena Stun Rune,5,2,1,2,1
10023,Adventure Vampiric Rune,5,2,1,1,1
10024,WorldBoss Vampiric Rune,5,2,1,4,1
10025,Adventure Stamina Rune,4,1,1,1,1
10026,Arena Stamina Rune,4,1,1,2,1
10027,Arena Quick Rune,4,1,1,2,1
10028,WorldBoss Quick Rune,4,1,1,4,1

0 comments on commit 823e7aa

Please sign in to comment.