Skip to content

Commit

Permalink
Add tax rates for Tuliyollal (#1238)
Browse files Browse the repository at this point in the history
  • Loading branch information
karashiiro committed Jun 29, 2024
1 parent baa6f15 commit 397ed49
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public void Behavior_DoesNotRun_WithoutUploaderId()
Ishgard = 3,
Kugane = 0,
Crystarium = 0,
Tuliyollal = 0,
},
};
Assert.False(behavior.ShouldExecute(upload));
Expand All @@ -63,6 +64,7 @@ public void Behavior_DoesNotRun_WithoutWorldId()
Ishgard = 3,
Kugane = 0,
Crystarium = 0,
Tuliyollal = 0,
},
UploaderId = "5627384655756342554",
};
Expand Down Expand Up @@ -91,6 +93,7 @@ public async Task Behavior_Succeeds()
Ishgard = 3,
Kugane = 0,
Crystarium = 0,
Tuliyollal = 0,
},
UploaderId = "5627384655756342554",
};
Expand All @@ -111,6 +114,7 @@ public async Task Behavior_Succeeds()
Assert.Equal(upload.TaxRates.Ishgard, data.Ishgard);
Assert.Equal(upload.TaxRates.Kugane, data.Kugane);
Assert.Equal(upload.TaxRates.Crystarium, data.Crystarium);
Assert.Equal(upload.TaxRates.Tuliyollal, data.Tuliyollal);
Assert.Equal(source.Name, data.UploadApplicationName);
}
}
4 changes: 4 additions & 0 deletions src/Universalis.Application/Uploads/Schema/MarketTaxRates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@ public class MarketTaxRates
[JsonPropertyName("sharlayan")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? OldSharlayan { get; set; }

[JsonPropertyName("tuliyollal")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? Tuliyollal { get; set; }
}
7 changes: 5 additions & 2 deletions src/Universalis.DbAccess/MarketBoard/TaxRatesStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ private async Task StoreTaxRates(IDatabase db, TaxRates taxRates, int worldId)
new HashEntry("Kugane", taxRates.Kugane),
new HashEntry("Crystarium", taxRates.Crystarium),
new HashEntry("Old Sharlayan", taxRates.OldSharlayan),
new HashEntry("Tuliyollal", taxRates.Tuliyollal),
new HashEntry("source", taxRates.UploadApplicationName),
}, CommandFlags.FireAndForget);
}
Expand Down Expand Up @@ -108,7 +109,8 @@ private async Task<TaxRates> FetchTaxRates(IDatabase db, int worldId)
try
{
var tasks = new[]
{ "Limsa Lominsa", "Gridania", "Ul'dah", "Ishgard", "Kugane", "Crystarium", "Old Sharlayan", "source" }
{ "Limsa Lominsa", "Gridania", "Ul'dah", "Ishgard", "Kugane", "Crystarium", "Old Sharlayan",
"Tuliyollal", "source" }
.Select(k => db.HashGetAsync(key, k, CommandFlags.PreferReplica));
var values = await Task.WhenAll(tasks);
return new TaxRates
Expand All @@ -120,7 +122,8 @@ private async Task<TaxRates> FetchTaxRates(IDatabase db, int worldId)
Kugane = (int)values[4],
Crystarium = (int)values[5],
OldSharlayan = (int)values[6],
UploadApplicationName = values[7],
Tuliyollal = (int)values[7],
UploadApplicationName = values[8],
};
}
catch (Exception e)
Expand Down
10 changes: 7 additions & 3 deletions src/Universalis.Entities/MarketBoard/TaxRates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public class TaxRates : IEquatable<TaxRates>, ICopyable

public int OldSharlayan { get; init; }

public int Tuliyollal { get; init; }

public string UploadApplicationName { get; init; }

public ICopyable Clone()
Expand All @@ -32,7 +34,8 @@ public bool Equals(TaxRates other)
if (ReferenceEquals(this, other)) return true;
return LimsaLominsa == other.LimsaLominsa && Gridania == other.Gridania && Uldah == other.Uldah &&
Ishgard == other.Ishgard && Kugane == other.Kugane && Crystarium == other.Crystarium &&
OldSharlayan == other.OldSharlayan && UploadApplicationName == other.UploadApplicationName;
OldSharlayan == other.OldSharlayan && Tuliyollal == other.Tuliyollal &&
UploadApplicationName == other.UploadApplicationName;
}

public override bool Equals(object obj)
Expand All @@ -44,8 +47,9 @@ public override bool Equals(object obj)

public override int GetHashCode()
{
return HashCode.Combine(LimsaLominsa, Gridania, Uldah, Ishgard, Kugane, Crystarium, OldSharlayan,
UploadApplicationName);
var taxHash = HashCode.Combine(LimsaLominsa, Gridania, Uldah, Ishgard, Kugane, Crystarium, OldSharlayan,
Tuliyollal);
return HashCode.Combine(taxHash, UploadApplicationName);
}

public static bool operator ==(TaxRates left, TaxRates right)
Expand Down

0 comments on commit 397ed49

Please sign in to comment.