Skip to content

Commit

Permalink
add ResultType to SummonSheet
Browse files Browse the repository at this point in the history
  • Loading branch information
sonohoshi committed Oct 22, 2024
1 parent 231d8d1 commit b1c152f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 22 deletions.
13 changes: 7 additions & 6 deletions .Lib9c.Tests/TableData/Summon/SummonSheetTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@ public SummonSheetTest()
public void SetToSheet()
{
const string content =
@"groupID,cost_material,cost_material_count,cost_ncg,recipe1ID,recipe1ratio,recipe1ID,recipe2ratio
10001,800201,10,0,171,70,172,30";
@"groupID,result_type,cost_material,cost_material_count,cost_ncg,recipe1ID,recipe1ratio,recipe1ID,recipe2ratio
10001,Aura,800201,10,0,171,70,172,30";
var sheet = new SummonSheet();
sheet.Set(content);

Assert.Single(sheet.Values);
Assert.NotNull(sheet.Values.First());
var row = sheet.Values.First();
Assert.Equal(10001, row.GroupId);
Assert.Equal(SummonSheet.ResultType.Aura, row.SummonResultType);
Assert.Equal(800201, row.CostMaterial);
Assert.Equal(10, row.CostMaterialCount);
Assert.Equal(0, row.CostNcg);
Expand All @@ -57,8 +58,8 @@ public void RecipeLimit(int recipeCount, Type exc = null)
{
var sbHeader = new StringBuilder();
var sbContent = new StringBuilder();
sbHeader.Append("groupID,cost_material,cost_material_count,cost_ncg");
sbContent.Append("10001,800201,10,0");
sbHeader.Append("groupID,result_type,cost_material,cost_material_count,cost_ncg");
sbContent.Append("10001,Aura,800201,10,0");
for (var i = 1; i <= recipeCount; i++)
{
sbHeader.Append($",recipe{i}ID,recipe{i}ratio");
Expand All @@ -83,8 +84,8 @@ public void RecipeLimit(int recipeCount, Type exc = null)
public void Total_Cumulative_Ratio()
{
const string content =
@"groupID,cost_material,cost_material_count,cost_ncg,recipe1ID,recipe1ratio,recipe1ID,recipe2ratio
10001,800201,10,0,171,70,172,30";
@"groupID,result_type,cost_material,cost_material_count,cost_ncg,recipe1ID,recipe1ratio,recipe1ID,recipe2ratio
10001,Aura,800201,10,0,171,70,172,30";
var sheet = new SummonSheet();
sheet.Set(content);
var row = sheet.Values.First();
Expand Down
18 changes: 9 additions & 9 deletions Lib9c/TableCSV/Summon/SummonSheet.csv
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
groupID,cost_material,cost_material_count,cost_ncg,recipe1ID,recipe1ratio,recipe2ID,recipe2ratio,recipe3ID,recipe3ratio,recipe4ID,recipe4ratio,recipe5ID,recipe5ratio,recipe6ID,recipe6ratio,recipe7ID,recipe7ratio,recipe8ID,recipe8ratio,recipe9ID,recipe9ratio,recipe10ID,recipe10ratio,recipe11ID,recipe11ratio,recipe12ID,recipe12ratio,recipe13ID,recipe13ratio,recipe14ID,recipe14ratio,recipe15ID,recipe15ratio,recipe16ID,recipe16ratio,recipe17ID,recipe17ratio,recipe18ID,recipe18ratio,recipe19ID,recipe19ratio,recipe20ID,recipe20ratio,recipe21ID,recipe21ratio,recipe22ID,recipe22ratio,recipe23ID,recipe23ratio,recipe24ID,recipe24ratio,recipe25ID,recipe25ratio,recipe26ID,recipe26ratio,recipe27ID,recipe27ratio,recipe28ID,recipe28ratio,recipe29ID,recipe29ratio,recipe30ID,recipe30ratio,recipe31ID,recipe31ratio,recipe32ID,recipe32ratio,recipe33ID,recipe33ratio,recipe34ID,recipe34ratio,recipe35ID,recipe35ratio,recipe36ID,recipe36ratio
10001,800201,10,0,173,100,172,3500,171,6000,176,3,181,3,186,3,175,30,180,30,185,30,174,100,179,100,184,100,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
10002,600201,20,0,216,150,215,1100,214,12750,178,150,183,150,188,150,177,1100,182,1100,187,1100,176,12750,181,12750,186,12750,175,98000,180,98000,185,98000,174,216667,179,216667,184,216667,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
20001,600201,20,0,10031,75,10032,75,10029,75,10030,75,10023,200,10024,200,10021,200,10022,200,10027,400,10028,400,10025,400,10026,400,10003,800,10013,800,10002,1000,10012,1000,10001,1850,10011,1850,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
30001,600202,20,0,216,5,215,37,214,370,177,36,182,36,187,36,176,360,181,360,186,360,175,2800,180,2800,185,2800,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
30002,600202,20,0,10027,15,10028,15,10025,15,10026,15,10023,8,10024,8,10021,8,10022,8,10029,2,10030,2,10031,2,10032,2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
40001,600203,20,0,217,60,218,60,219,60,220,60,221,60,222,60,223,60,224,60,225,60,226,30,227,30,228,30,229,30,230,30,231,30,232,30,233,30,234,30,235,9,236,9,237,9,238,9,239,9,240,9,241,9,242,9,243,9,244,1,245,1,246,1,247,1,248,1,249,1,250,1,251,1,252,1
50001,600202,20,0,40100004,10,40100005,10,40100018,10,40100025,10,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
50002,600202,20,0,49900001,10,49900002,10,49900003,10,49900004,10,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
groupID,cost_material,cost_material_count,cost_ncg,recipe1ID,recipe1ratio,recipe2ID,recipe2ratio,recipe3ID,recipe3ratio,recipe4ID,recipe4ratio,recipe5ID,recipe5ratio,recipe6ID,recipe6ratio,recipe7ID,recipe7ratio,recipe8ID,recipe8ratio,recipe9ID,recipe9ratio,recipe10ID,recipe10ratio,recipe11ID,recipe11ratio,recipe12ID,recipe12ratio,recipe13ID,recipe13ratio,recipe14ID,recipe14ratio,recipe15ID,recipe15ratio,recipe16ID,recipe16ratio,recipe17ID,recipe17ratio,recipe18ID,recipe18ratio,recipe19ID,recipe19ratio,recipe20ID,recipe20ratio,recipe21ID,recipe21ratio,recipe22ID,recipe22ratio,recipe23ID,recipe23ratio,recipe24ID,recipe24ratio,recipe25ID,recipe25ratio,recipe26ID,recipe26ratio,recipe27ID,recipe27ratio,recipe28ID,recipe28ratio,recipe29ID,recipe29ratio,recipe30ID,recipe30ratio,recipe31ID,recipe31ratio,recipe32ID,recipe32ratio,recipe33ID,recipe33ratio,recipe34ID,recipe34ratio,recipe35ID,recipe35ratio,recipe36ID,recipe36ratio,result_type
10001,800201,10,0,173,100,172,3500,171,6000,176,3,181,3,186,3,175,30,180,30,185,30,174,100,179,100,184,100,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Aura
10002,600201,20,0,216,150,215,1100,214,12750,178,150,183,150,188,150,177,1100,182,1100,187,1100,176,12750,181,12750,186,12750,175,98000,180,98000,185,98000,174,216667,179,216667,184,216667,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Aura
20001,600201,20,0,10031,75,10032,75,10029,75,10030,75,10023,200,10024,200,10021,200,10022,200,10027,400,10028,400,10025,400,10026,400,10003,800,10013,800,10002,1000,10012,1000,10001,1850,10011,1850,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,RuneStone
30001,600202,20,0,216,5,215,37,214,370,177,36,182,36,187,36,176,360,181,360,186,360,175,2800,180,2800,185,2800,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Aura
30002,600202,20,0,10027,15,10028,15,10025,15,10026,15,10023,8,10024,8,10021,8,10022,8,10029,2,10030,2,10031,2,10032,2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,RuneStone
40001,600203,20,0,217,60,218,60,219,60,220,60,221,60,222,60,223,60,224,60,225,60,226,30,227,30,228,30,229,30,230,30,231,30,232,30,233,30,234,30,235,9,236,9,237,9,238,9,239,9,240,9,241,9,242,9,243,9,244,1,245,1,246,1,247,1,248,1,249,1,250,1,251,1,252,1,Grimoire
50001,600202,20,0,40100004,10,40100005,10,40100018,10,40100025,10,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,FullCostume
50002,600202,20,0,49900001,10,49900002,10,49900003,10,49900004,10,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Title
26 changes: 19 additions & 7 deletions Lib9c/TableData/Summon/SummonSheet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,23 @@ namespace Nekoyume.TableData.Summon
{
public class SummonSheet : Sheet<int, SummonSheet.Row>
{
[Serializable]
public enum ResultType
{
Aura,
RuneStone,
Grimoire,
FullCostume,
Title,
}

public class Row : SheetRow<int>
{
public const int MaxRecipeCount = 100;
public override int Key => GroupId;

public int GroupId { get; private set; }
public ResultType SummonResultType { get; private set; }
public int CostMaterial { get; private set; }
public int CostMaterialCount { get; private set; }
public int CostNcg { get; private set; }
Expand Down Expand Up @@ -46,15 +57,16 @@ public int CumulativeRatio(int index)
public override void Set(IReadOnlyList<string> fields)
{
GroupId = ParseInt(fields[0]);
CostMaterial = ParseInt(fields[1]);
CostMaterialCount = ParseInt(fields[2]);
CostNcg = ParseInt(fields[3]);
SummonResultType = (ResultType)Enum.Parse(typeof(ResultType), fields[1]);
CostMaterial = ParseInt(fields[2]);
CostMaterialCount = ParseInt(fields[3]);
CostNcg = ParseInt(fields[4]);
// Min. Two recipes are necessary
Recipes.Add((ParseInt(fields[4]), ParseInt(fields[5])));
Recipes.Add((ParseInt(fields[6]), ParseInt(fields[7])));
Recipes.Add((ParseInt(fields[5]), ParseInt(fields[6])));
Recipes.Add((ParseInt(fields[7]), ParseInt(fields[8])));

// Recipe3 ~ 30 are optional
if (fields.Count > 2 * MaxRecipeCount + 4)
if (fields.Count > 2 * MaxRecipeCount + 5)
{
throw new IndexOutOfRangeException(
$"Provided recipe count {(fields.Count - 4) / 2} exceeds {MaxRecipeCount}."
Expand All @@ -63,7 +75,7 @@ public override void Set(IReadOnlyList<string> fields)

for (var i = 3; i <= MaxRecipeCount; i++)
{
var idx = 2 * i + 2;
var idx = 2 * i + 3;
if (fields.Count >= idx + 2 &&
TryParseInt(fields[idx], out _) &&
TryParseInt(fields[idx + 1], out _))
Expand Down

0 comments on commit b1c152f

Please sign in to comment.