Jump to content

Advise code architecture


Hannes7337

Recommended Posts

I'm currently working on a Varrock Museum script for the 1k hunter and slayer xp :) However, I have a few problems regarding my code architecture.  

My idea is to solve the questions based on configs. For example, when config 1014 equals 2 the script should solve the Lizard questions. I think a switch statement is the best option to decide which animal to solve. 

I'm using an abstract Quiz class where most of my functions are defined, like walking to the right display position. I want to create subclasses for every animal that holds the questions, answers and the display position. So far my subclasses looks redundant, because I'm only using a constructor to pass the questions, answers and display position. Is it better to use, for example, a Enum that holds all the data?

Can someone help me out here?

Link to comment
Share on other sites

It's an interesting question, naturally there's no correct answer.

I can't remeber exactly how the museum works, but I think it would be sufficient to store all the data in one big DisplayCase enum (position, config val, questions etc). Perhaps also create classes encapsulating questions and answers, and other intricacies. I'd do it this way because 1: all display cases are the same, thus there's really no need for inheritance, and 2: All the data is in one place so it's easier to manipulate when needed.

You can then, as you suggested, switch through the current config value to determine the corresponding display case, and act on the data respectively.

Good luck!

Apa

  • Like 2
Link to comment
Share on other sites

7 minutes ago, Apaec said:

It's an interesting question, naturally there's no correct answer.

I can't remeber exactly how the museum works, but I think it would be sufficient to store all the data in one big DisplayCase enum (position, config val, questions etc). Perhaps also create classes encapsulating questions and answers, and other intricacies. I'd do it this way because 1: all display cases are the same, thus there's really no need for inheritance, and 2: All the data is in one place so it's easier to manipulate when needed.

You can then, as you suggested, switch through the current config value to determine the corresponding display case, and act on the data respectively.

Good luck!

Apa

Was thinking on the exact same lines.

Put each display case data into an enum value (config, position, answers) and etc) and just grab the appropriate "enum record" in your onLoop based on the config value present.

As Apa mentioned, no real need for inheritance here.

Can also just use if/switch statements and you'll end up with one class.

Link to comment
Share on other sites

3 hours ago, liverare said:
  • Enum for the data.
  • Custom API for everything relating to the Museum (and only the museum - which will also include the enum).
  • Task/Node or plain code for macro logic.

This is what I did for mine in my AIO Hunter script. Also if you are wanting a free script that has been made already, there is one on the SDN. Good luck though :)

Link to comment
Share on other sites

2 hours ago, ProjectPact said:

This is what I did for mine in my AIO Hunter script. Also if you are wanting a free script that has been made already, there is one on the SDN. Good luck though :)

Thank you! I'll take a look on the SDN then :)

Edited by Hannes7337
I tried the museum script on the SDN recently. It's not working at the moment that's why I'm making one
Link to comment
Share on other sites

23 hours ago, killercrak said:

I just tried to use it on a new pure a few days ago. It did not even load at all.

Anyways, I'm finishing up my Museum script code and after that I need to test it on a few accounts. Too bad I need to use bonds to make them member ; p

When it's done I'll release it as a free script :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...