[Rem] Upper sum Text & upper bonus text | previewText & recordedScoreText (move to scoreText)
This commit is contained in:
@@ -10,8 +10,7 @@ namespace YachtDice.UI
|
||||
{
|
||||
[Header("UI Elements")]
|
||||
[SerializeField] private TMP_Text categoryNameText;
|
||||
[SerializeField] private TMP_Text previewText;
|
||||
[SerializeField] private TMP_Text recordedScoreText;
|
||||
[SerializeField] private TMP_Text scoreText;
|
||||
[SerializeField] private Button selectButton;
|
||||
[SerializeField] private Image background;
|
||||
|
||||
@@ -31,8 +30,7 @@ namespace YachtDice.UI
|
||||
_category = categoryDef;
|
||||
_isUsed = false;
|
||||
categoryNameText.text = categoryDef.DisplayName;
|
||||
previewText.text = "";
|
||||
recordedScoreText.text = "-";
|
||||
scoreText.text = "-";
|
||||
selectButton.onClick.AddListener(HandleClick);
|
||||
SetInteractable(false);
|
||||
background.color = normalColor;
|
||||
@@ -41,22 +39,21 @@ namespace YachtDice.UI
|
||||
public void ShowPreview(int previewScore)
|
||||
{
|
||||
if (_isUsed) return;
|
||||
previewText.text = previewScore.ToString();
|
||||
scoreText.text = previewScore.ToString();
|
||||
background.color = previewScore > 0 ? previewPositiveColor : previewZeroColor;
|
||||
}
|
||||
|
||||
public void HidePreview()
|
||||
{
|
||||
if (_isUsed) return;
|
||||
previewText.text = "";
|
||||
scoreText.text = "-";
|
||||
background.color = normalColor;
|
||||
}
|
||||
|
||||
public void SetRecordedScore(int score)
|
||||
{
|
||||
_isUsed = true;
|
||||
recordedScoreText.text = score.ToString();
|
||||
previewText.text = "";
|
||||
scoreText.text = score.ToString();
|
||||
SetInteractable(false);
|
||||
background.color = usedColor;
|
||||
}
|
||||
@@ -74,8 +71,7 @@ namespace YachtDice.UI
|
||||
public void ResetRow()
|
||||
{
|
||||
_isUsed = false;
|
||||
previewText.text = "";
|
||||
recordedScoreText.text = "-";
|
||||
scoreText.text = "-";
|
||||
SetInteractable(false);
|
||||
background.color = normalColor;
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace YachtDice.UI.Presentation
|
||||
|
||||
public void UpdateTotalDisplay(ScoreSummary summary)
|
||||
{
|
||||
_view.UpdateTotalDisplay(summary.DisplayTotal, summary.UpperSum, summary.HasUpperBonus);
|
||||
_view.UpdateTotalDisplay(summary.DisplayTotal);
|
||||
}
|
||||
|
||||
public void ResetAll()
|
||||
|
||||
@@ -3,14 +3,10 @@ namespace YachtDice.UI.Presentation
|
||||
public readonly struct ScoreSummary
|
||||
{
|
||||
public int DisplayTotal { get; }
|
||||
public int UpperSum { get; }
|
||||
public bool HasUpperBonus { get; }
|
||||
|
||||
public ScoreSummary(int displayTotal, int upperSum, bool hasUpperBonus)
|
||||
public ScoreSummary(int displayTotal)
|
||||
{
|
||||
DisplayTotal = displayTotal;
|
||||
UpperSum = upperSum;
|
||||
HasUpperBonus = hasUpperBonus;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using YachtDice.Categories;
|
||||
using YachtDice.Scoring;
|
||||
|
||||
namespace YachtDice.UI.Presentation
|
||||
@@ -6,43 +5,15 @@ namespace YachtDice.UI.Presentation
|
||||
public sealed class ScoreSummaryService : IScoreSummaryService
|
||||
{
|
||||
private readonly ScoringSystem _scoringSystem;
|
||||
private readonly CategoryCatalog _categoryCatalog;
|
||||
|
||||
public ScoreSummaryService(ScoringSystem scoringSystem, CategoryCatalog categoryCatalog)
|
||||
public ScoreSummaryService(ScoringSystem scoringSystem)
|
||||
{
|
||||
_scoringSystem = scoringSystem;
|
||||
_categoryCatalog = categoryCatalog;
|
||||
}
|
||||
|
||||
public ScoreSummary Calculate()
|
||||
{
|
||||
var upperSum = CalculateUpperSum();
|
||||
var hasUpperBonus = upperSum >= _categoryCatalog.UpperBonusThreshold;
|
||||
|
||||
var total = _scoringSystem.TotalScore;
|
||||
if (hasUpperBonus)
|
||||
total += _categoryCatalog.UpperBonusValue;
|
||||
|
||||
return new ScoreSummary(total, upperSum, hasUpperBonus);
|
||||
}
|
||||
|
||||
private int CalculateUpperSum()
|
||||
{
|
||||
var upperSum = 0;
|
||||
var allCategories = _categoryCatalog.All;
|
||||
|
||||
for (var i = 0; i < allCategories.Count; i++)
|
||||
{
|
||||
var category = allCategories[i];
|
||||
if (!category.IsUpperSection)
|
||||
continue;
|
||||
|
||||
var categoryScore = _scoringSystem.GetCategoryScore(category);
|
||||
if (categoryScore >= 0)
|
||||
upperSum += categoryScore;
|
||||
}
|
||||
|
||||
return upperSum;
|
||||
return new ScoreSummary(_scoringSystem.TotalScore);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,6 @@ namespace YachtDice.UI
|
||||
[SerializeField] private List<CategoryRowView> categoryRows = new();
|
||||
|
||||
[Header("Summary")]
|
||||
[SerializeField] private TMP_Text upperSumText;
|
||||
[SerializeField] private TMP_Text upperBonusText;
|
||||
[SerializeField] private TMP_Text totalScoreText;
|
||||
|
||||
public event Action<CategoryDefinition> OnCategorySelected;
|
||||
@@ -40,7 +38,7 @@ namespace YachtDice.UI
|
||||
_categoryToRowIndex[all[i]] = i;
|
||||
}
|
||||
|
||||
UpdateTotalDisplay(0, 0, false);
|
||||
UpdateTotalDisplay(0);
|
||||
}
|
||||
|
||||
public void UpdatePreviews(Dictionary<CategoryDefinition, int> previews)
|
||||
@@ -76,14 +74,9 @@ namespace YachtDice.UI
|
||||
t.SetInteractable(interactable);
|
||||
}
|
||||
|
||||
public void UpdateTotalDisplay(int totalScore, int upperSum, bool hasUpperBonus)
|
||||
public void UpdateTotalDisplay(int totalScore)
|
||||
{
|
||||
var threshold = _catalog != null ? _catalog.UpperBonusThreshold : 63;
|
||||
var bonusValue = _catalog != null ? _catalog.UpperBonusValue : 35;
|
||||
|
||||
totalScoreText.text = totalScore.ToString();
|
||||
upperSumText.text = $"{upperSum} / {threshold}";
|
||||
upperBonusText.text = hasUpperBonus ? $"+{bonusValue}" : "---";
|
||||
}
|
||||
|
||||
public void ResetAll()
|
||||
@@ -91,7 +84,7 @@ namespace YachtDice.UI
|
||||
foreach (var t in categoryRows)
|
||||
t.ResetRow();
|
||||
|
||||
UpdateTotalDisplay(0, 0, false);
|
||||
UpdateTotalDisplay(0);
|
||||
}
|
||||
|
||||
private void HandleCategorySelected(CategoryDefinition category)
|
||||
|
||||
Reference in New Issue
Block a user