IProjectVCharacterPresenter interface
The Character presenter. Pages should use IProjectVCharacterScreen instead; use the presenter only for what the screen contract does not cover, such as equipment, backpack, skins and two-step confirmations. Commands run one at a time; a command never throws for a server failure, it returns a failed ProjectVCharacterCommandResult.
Namespace: SilverTiger.ProjectV.Unity.Presentation.Character
public interface IProjectVCharacterPresenter
Properties
| Property | Type | Description |
|---|---|---|
Current | ProjectVCharacterSnapshot | The latest snapshot; never null. |
Transactions | ProjectVTransactionConfirmationCoordinator | The confirmation dialog state for PrepareSkillUpgrade and PrepareEquipmentUpgrade; bind your confirm dialog to it. |
PendingProgression | ProjectVCharacterProgressionPending? | A level-up or level reset whose answer was lost, or null. While it is set, offer only RetryPendingProgressionAsync; new level-ups are refused until it finishes. |
Methods
GetXpUpgradePreview(ProjectVCharacterId characterId, IReadOnlyList<ProjectVCharacterXpItemSelection> items)
Shows what leveling a character with these EXP items would do, without sending anything.
ProjectVCharacterXpUpgradePreview GetXpUpgradePreview(ProjectVCharacterId characterId, IReadOnlyList<ProjectVCharacterXpItemSelection> items);
Parameters
| Name | Type | Description |
|---|---|---|
characterId | ProjectVCharacterId | The character to level. |
items | IReadOnlyList<ProjectVCharacterXpItemSelection> | The EXP items and quantities to spend; may be empty to use only the EXP the character already has. |
Returns
ProjectVCharacterXpUpgradePreview: The preview; never null. ProjectVCharacterXpUpgradePreview.CanSubmit says whether the level-up can be sent, and ProjectVCharacterXpUpgradePreview.Message says why not. It is false while data is loading, needs a sync, or a level-up is pending, and for invalid or null items.
UseCharacterXpItemsAsync(ProjectVCharacterId characterId, IReadOnlyList<ProjectVCharacterXpItemSelection> items, CancellationToken cancellationToken)
Spends EXP items on a character without taking any level.
Task<ProjectVCharacterCommandResult> UseCharacterXpItemsAsync(ProjectVCharacterId characterId, IReadOnlyList<ProjectVCharacterXpItemSelection> items, CancellationToken cancellationToken);
Parameters
| Name | Type | Description |
|---|---|---|
characterId | ProjectVCharacterId | The character to give EXP to. |
items | IReadOnlyList<ProjectVCharacterXpItemSelection> | The EXP items and quantities to spend; at most 16 lines, each item once, not empty. |
cancellationToken | CancellationToken | Stops waiting; it does not undo EXP the server already applied. |
Returns
Task<ProjectVCharacterCommandResult>: The resulting snapshot. ProjectVCharacterCommandResult.IsSuccess is true when the server confirmed the EXP; otherwise Snapshot.Error.SafeMessage says why.
Exceptions
| Exception | When |
|---|---|
ArgumentNullException | items is null. |
ArgumentException | items has a null line, more than 16 lines or the same item twice. |
OperationCanceledException | cancellationToken was already cancelled. |
UpgradeCharacterWithXpItemsAsync(ProjectVCharacterId characterId, IReadOnlyList<ProjectVCharacterXpItemSelection> items, CancellationToken cancellationToken)
Spends EXP items on a character and takes every level the EXP and the wallet cover, in one step. Check GetXpUpgradePreview first.
Task<ProjectVCharacterCommandResult> UpgradeCharacterWithXpItemsAsync(ProjectVCharacterId characterId, IReadOnlyList<ProjectVCharacterXpItemSelection> items, CancellationToken cancellationToken);
Parameters
| Name | Type | Description |
|---|---|---|
characterId | ProjectVCharacterId | The character to level. |
items | IReadOnlyList<ProjectVCharacterXpItemSelection> | The EXP items and quantities to spend; at most 16 lines, each item once. May be empty to level with the EXP the character already has. |
cancellationToken | CancellationToken | Stops waiting; it does not undo a level-up the server already applied. |
Returns
Task<ProjectVCharacterCommandResult>: The resulting snapshot. ProjectVCharacterCommandResult.IsSuccess is true when the server confirmed it, and Snapshot.Recovery.Message says how many levels were gained. On failure, Snapshot.Error.SafeMessage says why; if the answer was lost, PendingProgression is set.
Exceptions
| Exception | When |
|---|---|
ArgumentNullException | items is null. |
ArgumentException | items has a null line, more than 16 lines or the same item twice. |
OperationCanceledException | cancellationToken was already cancelled. |
RetryPendingProgressionAsync(CancellationToken cancellationToken)
Sends PendingProgression again so the lost level-up or level reset finishes.
Task<ProjectVCharacterCommandResult> RetryPendingProgressionAsync(CancellationToken cancellationToken);
Parameters
| Name | Type | Description |
|---|---|---|
cancellationToken | CancellationToken | Stops waiting; the pending action stays pending if no answer arrives. |
Returns
Task<ProjectVCharacterCommandResult>: The resulting snapshot. ProjectVCharacterCommandResult.IsSuccess is true when the server confirmed it. Fails with a message when nothing is pending.
Exceptions
| Exception | When |
|---|---|
OperationCanceledException | cancellationToken was already cancelled. |
SubscribeAsync(Action<ProjectVCharacterSnapshot> listener)
Calls listener at once with the current snapshot, then with every change. The listener may run off the Unity main thread; IProjectVCharacterScreen.Observe renders on it for you.
Task<IDisposable> SubscribeAsync(Action<ProjectVCharacterSnapshot> listener);
Parameters
| Name | Type | Description |
|---|---|---|
listener | Action<ProjectVCharacterSnapshot> | Called with each snapshot. |
Returns
Task<IDisposable>: A subscription; dispose it when the page closes.
Exceptions
| Exception | When |
|---|---|
ArgumentNullException | listener is null. |
RefreshAsync(CancellationToken cancellationToken)
Loads the Character data. Saved data that is still fresh answers at once, without a request.
Task<ProjectVCharacterCommandResult> RefreshAsync(CancellationToken cancellationToken);
Parameters
| Name | Type | Description |
|---|---|---|
cancellationToken | CancellationToken | Stops waiting; tie it to the page. |
Returns
Task<ProjectVCharacterCommandResult>: The resulting snapshot and whether it succeeded.
Exceptions
| Exception | When |
|---|---|
OperationCanceledException | cancellationToken was cancelled while a pending level-up was being restored. |
SynchronizeAsync(CancellationToken cancellationToken)
Fetches current data from the server. Use it when ProjectVCharacterSnapshot.RequiresUpgradeSync is true or the player taps Sync.
Task<ProjectVCharacterCommandResult> SynchronizeAsync(CancellationToken cancellationToken);
Parameters
| Name | Type | Description |
|---|---|---|
cancellationToken | CancellationToken | Stops waiting; tie it to the page. |
Returns
Task<ProjectVCharacterCommandResult>: The resulting snapshot. ProjectVCharacterCommandResult.IsSuccess is false when the server could not be reached, even if saved data is shown.
Exceptions
| Exception | When |
|---|---|
OperationCanceledException | cancellationToken was cancelled while a pending level-up was being restored. |
SelectCharacterAsync(ProjectVLoadoutSlotId slotId, ProjectVCharacterId characterId, CancellationToken cancellationToken)
Puts a character in a loadout slot.
Task<ProjectVCharacterCommandResult> SelectCharacterAsync(ProjectVLoadoutSlotId slotId, ProjectVCharacterId characterId, CancellationToken cancellationToken);
Parameters
| Name | Type | Description |
|---|---|---|
slotId | ProjectVLoadoutSlotId | The loadout slot, from ProjectVCharacterData.Loadout. |
characterId | ProjectVCharacterId | An owned character. |
cancellationToken | CancellationToken | Stops waiting; it does not undo a change the server already applied. |
Returns
Task<ProjectVCharacterCommandResult>: The resulting snapshot and whether the server confirmed the change.
UpgradeCharacterAsync(ProjectVCharacterId characterId, CancellationToken cancellationToken)
Levels a character with the EXP it already has. Check ProjectVCharacterSnapshot.GetUpgradeState first. A second call while a level-up runs is refused instead of queued.
Task<ProjectVCharacterCommandResult> UpgradeCharacterAsync(ProjectVCharacterId characterId, CancellationToken cancellationToken);
Parameters
| Name | Type | Description |
|---|---|---|
characterId | ProjectVCharacterId | The character to level. |
cancellationToken | CancellationToken | Stops waiting; it does not undo a level-up the server already applied. |
Returns
Task<ProjectVCharacterCommandResult>: The resulting snapshot. ProjectVCharacterCommandResult.IsSuccess is true when the server confirmed it; otherwise Snapshot.Error.SafeMessage says why, for example not enough EXP.
Exceptions
| Exception | When |
|---|---|
OperationCanceledException | cancellationToken was already cancelled. |
UpgradeSkillAsync(ProjectVCharacterId characterId, ProjectVCharacterSkillId skillId, CancellationToken cancellationToken)
Buys the next rank of a skill straight away. To show a price confirmation first, use PrepareSkillUpgrade and ConfirmPreparedUpgradeAsync.
Task<ProjectVCharacterCommandResult> UpgradeSkillAsync(ProjectVCharacterId characterId, ProjectVCharacterSkillId skillId, CancellationToken cancellationToken);
Parameters
| Name | Type | Description |
|---|---|---|
characterId | ProjectVCharacterId | The character that owns the skill. |
skillId | ProjectVCharacterSkillId | The skill to rank up. |
cancellationToken | CancellationToken | Stops waiting; it does not undo a rank the server already applied. |
Returns
Task<ProjectVCharacterCommandResult>: The resulting snapshot and whether the server confirmed the rank.
UpgradeCastSkillAsync(ProjectVCharacterId characterId, ProjectVCharacterCastSkillSlot slot, CancellationToken cancellationToken)
Upgrades a cast skill one level. Check ProjectVCharacterData.GetCastSkillUpgradeDetails first; the command is refused when the details say it cannot be upgraded or the data needs a sync.
Task<ProjectVCharacterCommandResult> UpgradeCastSkillAsync(ProjectVCharacterId characterId, ProjectVCharacterCastSkillSlot slot, CancellationToken cancellationToken);
Parameters
| Name | Type | Description |
|---|---|---|
characterId | ProjectVCharacterId | The character that owns the cast skill. |
slot | ProjectVCharacterCastSkillSlot | The cast skill slot; not ProjectVCharacterCastSkillSlot.Unknown. |
cancellationToken | CancellationToken | Stops waiting; it does not undo an upgrade the server already applied. |
Returns
Task<ProjectVCharacterCommandResult>: The resulting snapshot. ProjectVCharacterCommandResult.IsSuccess is true when the server confirmed it; otherwise Snapshot.Error.SafeMessage says why.
ResetSkillsAsync(ProjectVCharacterId characterId, CancellationToken cancellationToken)
Resets a character's skill tree, removing every rank. What is given back is up to the server.
Task<ProjectVCharacterCommandResult> ResetSkillsAsync(ProjectVCharacterId characterId, CancellationToken cancellationToken);
Parameters
| Name | Type | Description |
|---|---|---|
characterId | ProjectVCharacterId | The character whose skill tree to reset. |
cancellationToken | CancellationToken | Stops waiting; it does not undo a reset the server already applied. |
Returns
Task<ProjectVCharacterCommandResult>: The resulting snapshot and whether the server confirmed the reset.
EquipEquipmentAsync(ProjectVEquipmentId equipmentId, CancellationToken cancellationToken)
Equips an owned piece of equipment in its slot.
Task<ProjectVCharacterCommandResult> EquipEquipmentAsync(ProjectVEquipmentId equipmentId, CancellationToken cancellationToken);
Parameters
| Name | Type | Description |
|---|---|---|
equipmentId | ProjectVEquipmentId | An owned item from ProjectVCharacterData.Equipment. |
cancellationToken | CancellationToken | Stops waiting; it does not undo a change the server already applied. |
Returns
Task<ProjectVCharacterCommandResult>: The resulting snapshot and whether the server confirmed the change.