MaaXYZ / MBA

BA 小助手
GNU Affero General Public License v3.0
144 stars 7 forks source link

Mission/Commissions/Event idea & GUI #10

Open RedDeadDepresso opened 8 months ago

RedDeadDepresso commented 8 months ago

Hi there,

I've developed a Python script with a GUI for Blue Archive called BAAuto, but I must admit that I'm an inexperienced programmer and currently quite busy, so I won't work on it for long. However, I believe there are some valuable ideas within the script, in particularly Missions/Commissions/Event. These ideas could be challenging to manage without a GUI, but I hope you can consider them for future development.

You are welcome to reuse any part of the code. The code related to Missions/Commissions/Event is in BAAuto/modules/mission.py.

Mission/Commissions/Event

Description

This feature allows users to create templates, which are essentially lists of stages for the script to execute. Each stage is defined by a mode (Mission Normal, Hard, Event Quest, Base Defense, or Item Retrieval), a stage name (e.g., 1-1, 01), and the number of sweeps. Users can create multiple templates, but only the preferred template will be loaded into the queue and executed by the script.

Modifiers

GUI

I believe you could make good use of the GUI I've implemented. It's a simple interface for modifying config.json and the output of script.py. It was made using a python library called customtkinter, an enhanced and modern version of the standard tkinter library. While it may not have advanced features, I've included the essentials for a Blue Archive script. The code related to the GUI is in BAAuto/BAAuto.py.

Here's a brief overview of how it works:

  1. It loads the config.json file into a variable called config_data and creates a copy of it with all values set to None, storing them in a variable called widgets.
  2. Customtkinter widgets are defined with a command that calls the save_to_json function, and as they are created, they are added to the widgets variable.
  3. It loads config_data into widgets by accessing the same key in both dictionaries and setting the customtkinter widget to the respective value in config_data.
  4. It saves user input by doing the reverse of the previous step: extracting the value from the customtkinter widget, changing the respective value in config_data, and then saving config.json.

As for displaying script output, it uses a specific widget called CTkTextbox stored in a variable called self.log_textbox. You can define tags to set the color of the text. When you click the start button in the sidebar, it runs script.py as a separate process and starts another thread to analyze its standard output. If it finds specific words using a dictionary called self.log_level_colors (associating words with tags), it will display the line with the specified color; otherwise, it will ignore it.

To help you better understand, I've attached an image that illustrates the GUI with the Mission/Commissions/Event section.

I hope you find this script and GUI useful. While I lack knowledge in C# and Chinese, I'm open to answering any questions you may have regarding the script. If you have any inquiries, please feel free to reach out through this issue. Otherwise, you can close it.

P.S. Could you consider adding the "blue-archive" and "bluearchive" topics to the about section of your repository? I had some difficulty finding it initially, and adding these topics could improve visibility for others on GitHub.

Best regards, RedDeadDepresso example

RedDeadDepresso commented 8 months ago

test I've been able to successfully run your program within my GUI, and I was wondering if I were to fully adapt my GUI to yours, would you be able to implement Mission/Commissions/Event?

Modifying the GUI should be relatively straightforward. Mainly, I need to adjust to which keys in config_data the widgets are bound. As I mentioned before, the GUI is just an interface to modify config.json, run your program as a separate process, and display the output in the logger. It won't interact much other than starting it and stopping it.

Now, let me outline the algorithm for handling Mission/Commissions/Event:

Assume that you have a function like this:

def should_reset():
    if CurrentDate != LastRunDate and CurrentTime >= ResetTime:
        LastRunDate = CurrentDate
        return True
    else:
        return False

Here's the process:

  1. Check if AP is less than 10. If not, proceed...
  2. Check if the queue is empty or (if the daily reset is enabled and should_reset() is True). If it is, clear the queue and import the list of stages into the queue from the preferred template in the templates dictionary.
  3. Process each stage one by one until the queue is empty or you run out of AP.
  4. Attempt to sweep the stage, which can result in three outcomes: success, failure, or incomplete. Success if you swept the specified number of sweeps, failure because of not finding the stage, stage not unlocked..., and incomplete if you found the stage but did not sweep the specified number of times.
  5. Remove the stage from the queue if it's a success or failure.
  6. In the case of incomplete, check if the AP is less than 20. This is because it might be a hard stage, and the user may have already swept it before running the script. In this case, remove it from the queue and proceed. Otherwise, subtract the number of sweeps made from the specified number. This means you ran out of AP.
  7. If AP recharge is enabled, recharge AP through the cafe, tasks, club, and mailbox. Then, check if the AP is less than 10. If it's not, continue until you run out of AP.

Let me know if you're willing to collaborate on this implementation. Thanks!

Dissectum commented 8 months ago

Hi RedDeadDepresso,

Thanks for your message, I found some pretty good ideas in BAAuto and I'll reuse them in MBA, but I'm busy at the moment, so the development of MBA is slowing down.

Does config have all the configurable fields in it? Or a template of config with all the configurable fields would be appreciated.

About GUI

The core of MBA is a development language-independent task resource driven by the MaaFramework.

Because of this, there are plans to use MaaY as a GUI in the near future, and the MBA will retain only Cli until MaaY is archived or until such time as a feature emerges that requires strong coupling with Blue Archive.

The original goal was to develop a modernized UI using C#, but then I realized that my personal skills and time were not enough to accomplish that goal in the short term. If, in the future, there are no features that are strongly coupled with Blue Archive, the Cli will be refactored using Python.

About Topics

For some reason, I won't be adding "blue-archive" and "bluearchive" topics to the about section for a while until the initial completion of the v1.0 program.

In addition, there's a auto script project named baas, which written in Python with a GUI for Blue Archive.

RedDeadDepresso commented 8 months ago

Hi, I would like to express my gratitude for considering my ideas. Regarding the configuration file, it indeed contains all the necessary fields. If you're wondering why it doesn't have a 'club' section, it's because that functionality is included within the 'mailbox' section. I thought it would be redundant since, in the end, you claim the 10 AP from the mailbox.

As for the GUI, I forgot to mention that it was supposed to be temporary. My intention was to adapt it for MBA, making it feasible and worthwhile for you to implement Missions/Commissions/Events and update it as you introduce new features, until you decide to create your own GUI. I didn't intend for it to be used in the long-term, as the GUI can be a bit buggy at times, and customtkinter has its limitations. However, thinking back, I mistakenly excluded the possibility that you may not want to implement all the features of BAAuto and since you mentioned that you already have some plans in mind, you should proceed as you see fit.

Also, thanks for informing me about baas. I attempted to use it, but the GUI is currently available only in Chinese, making it challenging for me to navigate. Additionally, it seems to support only the CN server from the templates I checked. Therefore, I've decided to stick with BAAuto until MBA is at a decent point in development.

Finally, I want to remind you again that if you have other inquiries about BAAuto, please don't hesitate to reach out.

RedDeadDepresso commented 8 months ago

Hi,

I apologise for reaching out once more. I've made some modifications to my config file to implement some of my favorite features from MAA. I thought it would be beneficial to inform you about this, since you were interested in my config file. Here's a brief summary of the new additions:

Also, you can import stages from pre-existing templates when creating a new one. I've attached an image.

I want to emphasise that I completely understand that you are busy, and I'm not trying to impose any pressure. However, it would be great if you could consider implementing some of these features in MBA as well.

image