0
\$\begingroup\$

Concept

I am designing turn-based boss battles and want each boss to have different behaviors and skills they perform during a battle. The boss is selected randomly and is identified by a unique string that we will call the boss_id.

Issue

If I have many different bosses, the battle logic would contain long sections of if and else if statements to account for every boss_id which would be very messy and hard to maintain.

The idea I have come up with is defining a dictionary with the boss_id as the key pointing to a function containing the unique logic for that boss. This idea sounds much cleaner and more modular, but having hundreds of functions sounds like I may be approaching this all wrong.

Question

What are other/better design approaches than the one I have described?

If the programming language matters for certain implementations; I am using Python

Edit #1

Another idea I have had is adding behavior code at every possible trigger point in the battle logic. The boss_id will point to behavior data in a dictionary which will fill parameters of the behavior code and cause different actions, even no action.

This seems to be a powerful approach since some bosses may have repeat behaviors but with slight numerical variations.

\$\endgroup\$
3
  • \$\begingroup\$ Do any of your bosses have any parts of their behaviour in common? e.g. Boss 1 and 3 both go dormant for a turn after a major attack / Bosses 2 & 7 each have a phase where they alternate moves each turn / etc.? Or are they all extremely bespoke? \$\endgroup\$ Commented Sep 9, 2023 at 14:58
  • \$\begingroup\$ @DMGregory Some bosses will have similar behavior. I shall edit the post to include another idea that your questions have sparked. \$\endgroup\$ Commented Sep 9, 2023 at 16:35
  • 1
    \$\begingroup\$ It's best not to segregate edits with "Edit #1" headings. Edit history is tracked automatically in case anyone is ever curious which bits were added when. So we recommend editing the question so it reads the way it would have if you'd included this information from the beginning. This makes it easier to follow as one coherent post, rather than a series of incremental updates. \$\endgroup\$ Commented Sep 9, 2023 at 17:04

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.