ArchipelagoMW / Archipelago.MultiClient.Net

A client library for use with .NET based prog-langs for interfacing with Archipelago hosts.
MIT License
14 stars 11 forks source link

Documentation #65

Closed toasterparty closed 2 years ago

toasterparty commented 2 years ago

The example code presented in README.MD leaves first time users with some questions:

A minimalistic example class with connection error handling, basic message handler, basic item received callback, and a "report location completion" function would go a long way to helping new devs.

Jarno458 commented 2 years ago

Thanks for reporting this, CompleteLocationChecks marks an location as "completed" or checked or marked off

CompleteLocationChecks marks an location as "completed" or checked or marked off ScoutLocationsAsync asks the server for what item is stored in that location, it can also be used to generate actual hints that are visable to players and under !hint. it does however now mark the location as collected or completed or marked off or checked

The received item helper callback should be invoked for every item again after a reconnect. Whether or not it includes the first batch of remote items depents on your ItemHandlingFlags setting during connection

We do need to improve these docs quite a bit

toasterparty commented 2 years ago

Additionally, this is important for a basic implementation:

        public static void send_completion()
        {
            var statusUpdatePacket = new StatusUpdatePacket();
            statusUpdatePacket.Status = ArchipelagoClientState.ClientGoal;
            Session.Socket.SendPacket(statusUpdatePacket);
        }
toasterparty commented 2 years ago

In this existing example code, the language keyword new is used illegally.

session.DataStorage["OnChangeHandler"].OnValueChanged += (old, new) => {
    var changed = (int)new - (int)old; //Keep track of changes made to `OnChangeHandler` by any client, and calculate the difference
};

It also doesn't demonstrate how to cast back to an object like so:

session.DataStorage["OnChangeHandler"].OnValueChanged += (_old, _new) => {
    OnChangeHandler(
        _old.ToObject<Dictionary<int, int>>(),
        _new.ToObject<Dictionary<int, int>>()
    );
};
toasterparty commented 2 years ago

Trying to set DataStorage["Key"].OnValueChanged before result is LoginSuccessful loginSuccess results in an exception being thrown. This is counterintuitive because the examples show other callback handlers such as:

session.Items.ItemReceived += (receivedItemsHelper) => { OnItemReceived(receivedItemsHelper); };

...before the TryConnectAndLogin call.

Jarno458 commented 2 years ago

Intresting comments, wy dont you just put them in pull request >.>

toasterparty commented 2 years ago

I may, but I'm still learning new things about the lib. I will when I'm done with my implementation.