Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor AvatarState constructor #2780

Merged
merged 1 commit into from
Sep 4, 2024

Conversation

moreal
Copy link
Contributor

@moreal moreal commented Aug 27, 2024

Description

This pull request only adjusts the constructor of AvatarState and introduces a new static factory method, AvatarState.Create. With some huge changes (almost from test code) by replacing the AvatarState constructor with the factory method.

Before this pull request, it was hard to create an AvatarState instance because its constructor was heavily dependent on AvatarSheets. Even if I want to create a simple custom AvatarState instance, it requires AvatarSheets (CSV data).

So it will become to provide a simple constructor (just setting properties and fields) and handle something more with the factory method.

Reviewers

I requested reviews for @ipdae, @sonohoshi, @eugene-doobu who are actively working on Lib9c. If you know someone else who would be good for this pull request, please nominate them.

Future work plan

If this pull request is accepted, I'll refactor WorldInformation and QuestList too if I need. These works will be helpful for #2685 and planetarium/NineChronicles.Headless#2540.

@moreal moreal self-assigned this Aug 27, 2024
@moreal moreal force-pushed the avatar-state branch 2 times, most recently from cef3a16 to 3330248 Compare August 28, 2024 07:54
@moreal moreal enabled auto-merge August 29, 2024 03:59
Copy link
Member

@ipdae ipdae left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the scope of the update changes for relate repositories(NineChronicles, etc) that use AvatarState?

address, agentAddress, blockIndex, questListVar, worldInformationVar, rankingMapAddress, name);
}

public AvatarState(Address address,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we take the constructor private and depend only on "AvatarState.Create"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The purpose of this pull request was to easily create an AvatarState instance without using AvatarSheets. We can change the constructor's access modifier to internal and allow to access to internal elements to the Lib9c.Tests project (it already opened), but it cannot open to NIneChronicles.Headless.Tests and other external test projects.

@moreal
Copy link
Contributor Author

moreal commented Sep 4, 2024

What is the scope of the update changes for relate repositories(NineChronicles, etc) that use AvatarState?

When I searched planetarium/NineChronicles (tool, tests), planetarium/www.nine-chronicles.dev (docs), planetarium/NineChronicles.DataProvider (tests)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants