make some small changes to merging
This commit is contained in:
@@ -24,7 +24,7 @@ namespace KernelPanic.UI
|
||||
private LanguageDeckDatabase _languageDeckDatabase;
|
||||
private CardDatabase _cardDatabase;
|
||||
private PlayerCollection _playerCollection;
|
||||
private Func<int> _getMergesBalance;
|
||||
private Func<DistroDefinition, int> _getMergesBalance;
|
||||
private Func<DistroDefinition, VersionUpgradeResult> _tryUpgradeUnit;
|
||||
private IReadOnlyList<DistroDefinition> _units = Array.Empty<DistroDefinition>();
|
||||
private IReadOnlyList<LanguageCatalogEntry> _languages = LanguageCatalog.All;
|
||||
@@ -38,7 +38,7 @@ namespace KernelPanic.UI
|
||||
|
||||
public event Action ViewChanged;
|
||||
|
||||
public void Bind(VisualElement root, FontAsset artFont, LanguageDeckDatabase deckDatabase, CardDatabase cardsDatabase, PlayerCollection collection, Func<int> getMergesBalance = null, Func<DistroDefinition, VersionUpgradeResult> tryUpgradeUnit = null)
|
||||
public void Bind(VisualElement root, FontAsset artFont, LanguageDeckDatabase deckDatabase, CardDatabase cardsDatabase, PlayerCollection collection, Func<DistroDefinition, int> getMergesBalance = null, Func<DistroDefinition, VersionUpgradeResult> tryUpgradeUnit = null)
|
||||
{
|
||||
_monospaceFont = artFont;
|
||||
_languageDeckDatabase = deckDatabase;
|
||||
@@ -296,7 +296,7 @@ namespace KernelPanic.UI
|
||||
{
|
||||
int version = _playerCollection == null ? 1 : Mathf.Clamp(_playerCollection.GetVersion(unit.Id), 1, GachaTuning.MaxVersion);
|
||||
string release = DistroVersionCatalog.GetReleaseLabel(unit.Id, version);
|
||||
int merges = _getMergesBalance?.Invoke() ?? 0;
|
||||
int merges = _getMergesBalance?.Invoke(unit) ?? 0;
|
||||
|
||||
VisualElement panel = new();
|
||||
panel.AddToClassList("version-upgrade-panel");
|
||||
@@ -308,7 +308,7 @@ namespace KernelPanic.UI
|
||||
current.AddToClassList("version-upgrade-current");
|
||||
summary.Add(current);
|
||||
|
||||
Label wallet = new(version < GachaTuning.MaxVersion ? $"merges {merges} / {GachaTuning.GetVersionUpgradeCost(version + 1)}" : $"merges {merges}");
|
||||
Label wallet = new(version < GachaTuning.MaxVersion ? $"{unit.DisplayName} merges {merges} / {GachaTuning.GetVersionUpgradeCost(version + 1)}" : $"{unit.DisplayName} merges {merges}");
|
||||
wallet.AddToClassList("version-upgrade-wallet");
|
||||
summary.Add(wallet);
|
||||
panel.Add(summary);
|
||||
|
||||
@@ -297,8 +297,8 @@ namespace KernelPanic.UI
|
||||
return value.Kind switch
|
||||
{
|
||||
PullOutcomeKind.Granted => " granted",
|
||||
PullOutcomeKind.Dupe => $" duplicate +{value.MergesAwarded} merges",
|
||||
PullOutcomeKind.DupeOverflow => $" max-version duplicate +{value.MergesAwarded} merges",
|
||||
PullOutcomeKind.Dupe => $" duplicate +{value.MergesAwarded} {value.UnitId} merges",
|
||||
PullOutcomeKind.DupeOverflow => $" max-version duplicate +{value.MergesAwarded} {value.UnitId} merges",
|
||||
_ => string.Empty
|
||||
};
|
||||
}
|
||||
|
||||
@@ -650,6 +650,16 @@ namespace KernelPanic.UI
|
||||
{
|
||||
_saveData ??= SaveData.CreateDefault();
|
||||
_saveData.EnsureLists();
|
||||
Dictionary<string, int> mergeBalances = new(StringComparer.OrdinalIgnoreCase);
|
||||
for (int i = 0; i < _saveData.ownedUnits.Count; i++)
|
||||
{
|
||||
OwnedUnitSaveEntry entry = _saveData.ownedUnits[i];
|
||||
if (entry != null && !string.IsNullOrWhiteSpace(entry.id))
|
||||
{
|
||||
mergeBalances[entry.id] = Mathf.Max(0, entry.merges);
|
||||
}
|
||||
}
|
||||
|
||||
_saveData.entropyBalance = _wallet == null ? 0 : _wallet.Balance;
|
||||
_saveData.ownedUnits.Clear();
|
||||
_saveData.ownedUnitIds.Clear();
|
||||
@@ -664,7 +674,8 @@ namespace KernelPanic.UI
|
||||
_saveData.ownedUnits.Add(new OwnedUnitSaveEntry
|
||||
{
|
||||
id = unit.Id,
|
||||
version = Mathf.Clamp(_playerCollection.GetVersion(unit.Id), 1, GachaTuning.MaxVersion)
|
||||
version = Mathf.Clamp(_playerCollection.GetVersion(unit.Id), 1, GachaTuning.MaxVersion),
|
||||
merges = mergeBalances.TryGetValue(unit.Id, out int merges) ? merges : 0
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -687,11 +698,12 @@ namespace KernelPanic.UI
|
||||
return PullResolver.Resolve(pulledDistros, context);
|
||||
}
|
||||
|
||||
private int GetMergesBalance()
|
||||
private int GetMergesBalance(DistroDefinition unit)
|
||||
{
|
||||
_saveData ??= SaveData.CreateDefault();
|
||||
_saveData.EnsureLists();
|
||||
return _saveData.merges;
|
||||
OwnedUnitSaveEntry entry = unit == null ? null : _saveData.FindOwnedUnit(unit.Id);
|
||||
return Math.Max(0, entry?.merges ?? 0);
|
||||
}
|
||||
|
||||
private VersionUpgradeResult UpgradeCollectionUnit(DistroDefinition unit)
|
||||
@@ -757,11 +769,24 @@ namespace KernelPanic.UI
|
||||
_rootCreditsToEntropyButton?.SetEnabled(true);
|
||||
bool showPullTokens = IsGachaVisible();
|
||||
_pullTokensLabel.text = showPullTokens
|
||||
? $"bandwidth={_gachaService.PullTokens} compute-credits={_gachaService.LimitedPullTokens} merges={_saveData.merges}"
|
||||
? $"bandwidth={_gachaService.PullTokens} compute-credits={_gachaService.LimitedPullTokens} distro-merges={GetTotalDistroMerges()}"
|
||||
: string.Empty;
|
||||
_pullTokensLabel.EnableInClassList(HiddenClassName, !showPullTokens);
|
||||
}
|
||||
|
||||
private int GetTotalDistroMerges()
|
||||
{
|
||||
_saveData ??= SaveData.CreateDefault();
|
||||
_saveData.EnsureLists();
|
||||
int total = 0;
|
||||
for (int i = 0; i < _saveData.ownedUnits.Count; i++)
|
||||
{
|
||||
total += Mathf.Max(0, _saveData.ownedUnits[i]?.merges ?? 0);
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
private void RefreshEventBanner()
|
||||
{
|
||||
EventBannerContent banner = _eventBannerSource?.GetBanner();
|
||||
|
||||
Reference in New Issue
Block a user