GS2-SkillTree
This microservice is designed to realize the skill tree functionality commonly used as a growth factor for characters and other objects. A skill tree has a tree structure like the one shown below, and the release of nodes improves the parameters of a character. Releasing a node requires a cost, and GS2-SkillTree allows you to set the “Consume Action” provided by each microservice.
Prerequisite node
Each node can have a “prerequisite node” to create a tree structure. Up to 10 nodes can be set as a precondition node, and a node cannot be released unless the node set as a precondition node is in the released state.
Note that it is not necessary to set all the nodes leading up to the node as a precondition node, but only the one immediately before it to create the tree structure.
Restore a released node to un-released
Each individual node or all nodes can be returned to the unreleased state.
Cost reimbursement
In doing so, the cost consumed to release the node can be returned based on a specified percentage.
It is important to note that there are two types of transaction consumption actions: reversible and nonreversible. A “reversible” spend action is returned, while a “non-reversible” spend action is not.
Please check each microservice reference to see if a spend action is “reversible”.
Manipulating nodes in the middle of the tree
If a node on which a node depends has already been released, the node cannot be returned to the un-released state.
Batch release of nodes
Multiple nodes can be released at once. The GS2-SkillTree does not need to specify the node while paying attention to the dependency relationship, but performs the release processing while considering the order of dependency relationships and judging whether the release is possible.
Implementation Example
Obtains the release status of a node
var domain = gs2.SkillTree.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Status(
);
var item = await domain.ModelAsync();
const auto Domain = Gs2->SkillTree->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
)->Status(
);
const auto Future = Domain.Model();
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
return false;
}
Node release
var domain = gs2.SkillTree.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Status(
);
var result = await domain.ReleaseAsync(
nodeModelNames: new string[] {
"node-0001",
}
);
const auto Domain = Gs2->SkillTree->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
)->Status(
);
const auto Future = Domain->Release(
[]
{
const auto v = MakeShared<TArray<FString>>();
v->Add("node-0001");
return v;
}()
);
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
return false;
}
Restore the released state of a node
var domain = gs2.SkillTree.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Status(
);
var result = await domain.RestrainAsync(
nodeModelNames: new string[] {
"node-0001",
}
);
const auto Domain = Gs2->SkillTree->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
)->Status(
);
const auto Future = Domain->Restrain(
[]
{
const auto v = MakeShared<TArray<FString>>();
v->Add("node-0001");
return v;
}()
);
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
return false;
}
Reset the release status of a node
var domain = gs2.SkillTree.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Status(
);
var result = await domain.ResetAsync(
);
const auto Domain = Gs2->SkillTree->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
)->Status(
);
const auto Future = Domain->Reset(
);
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
return false;
}