Skip to content

coc.Client.get_current_war should look for a CWL war if the war state is warEnded #285

@farinaanthony96

Description

@farinaanthony96

As the title suggests, I believe the coc.Client's get_current_war() function should look for the current CWL war if the clan's current normal clan war state is "warEnded". The current implementation only takes CWL into consideration if the clan's current normal clan war state is "notInWar". However, I think it should look for both states: "notInWar" and "warEnded".

My argument for this logic change is because of the way wars and CWL intermingle, especially during the beginning of the month during the CWL signup period. This logic would also naturally affect the @coc.WarEvents.new_war() decorator since the get_current_war() function is used to track WarEvents. Currently, this decorator fails to trigger if a CWL group is found which I believe is a logistic issue as well. This is the main reason that I'm making this issue.

For clans that have normal clan wars that end during the CWL signup period, the clan's war state will be "warEnded" for a few days after the war ends, even if the clan finds a CWL group. This is the behavior of the official CoC API, but it doesn't accurately reflect the clan's true current state of war in regards to CWL. If a clan's normal clan war ends, then they search for (and find) a CWL group the current state of the clan's war should be a CWL war in preparation day. This makes sense because if a player opens the app and opens the war menu the CWL preparation day is loaded and visible (even though the normal clan war that just ended is still in the background with its state still as "warEnded").

My proposed solution is as follows: keep the same logic if the clan's current normal clan war is "notInWar". However, if the clan's current clan war state is "warEnded", it should check if the clan is currently in CWL. If it is not, return the normal clan war in the "warEnded" state. If CWL is detected, then it should return the clan's current CWL war.

This would mean that the new_war() function would be triggered when the clan finds a CWL group. This is logistically accurate since the backbone of the new_war() function is if the preparation_time changes, which is does when a CWL group is found.

I'm open to critiques or if this logic doesn't make sense in the context of the rest of the library. Maybe I'm just using the API incorrectly or there's another way of accomplishing this logic using the library that I've missed. I understand that this change would seriously change the way this function behaves and may break legacy code, so I understand if this change is met with hesitation.

Please let me know if you need more details or have questions about this. I'm open to discussion!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions