Another attempt at multiple battle systems

● ARCHIVED · READ-ONLY
Started by Tsukihime 1 posts View original ↗
  1. Didn't like my first one. It changed too many things.

    Here's my new design.

    Looks something like this: http://dl.dropbox.com/u/23043573/RPG%20Maker/RMVXA%20Scripts/PluginBattleSystem.txt

    The idea is to abstract away the BattleManager and let it decide which battle manager to actually use.

    Because you should *always* setup the battle manager before you actually use it, I decided to put it there



    Code:
    module BattleManager
    
      def self.setup_battle_manager
        bs = Tsuki::PBS::Battle_Managers[$game_system.battle_system]
        @battleManager = Object.const_get(bs).new
      end
    
      def self.setup(troop_id, can_escape = true, can_lose = false)
        setup_battle_manager
        @battleManager.setup(troop_id, can_escape, can_lose)
      end
    end
    Now I will introduce a battle manager interface. It's more like an abstract class



    Code:
    class IBattleManager
    
      def setup(...)
        # the actual setup
      end
    end
    This class will define all of the default BattleManager methods, and will be treated as your default battle system.

    You can inherit from this class to define your own battle managers,



    Code:
    class MyBattleManager < IBattleManager
    
      def setup(...)
        super
        #now do some more things
      end
    end
    Then, everytime you say



    Code:
    BattleManager.do_something(arg1, arg2, ...)
    It will in theory take your method call and your arguments, and pass them down to the appropriate battle manager. But I'm not sure how that would work.

    Scene_Battle will still be the same thing, except you can define new battle scenes that inherit from Scene_Battle if needed.



    Code:
    class My_Scene_Battle < Scene_Battle
    end
    Each battle system will come with their own scene and their own set of windows, all inheriting from the default windows. There will be no aliasing or overriding.

    Rather than saying



    Code:
    SceneManager.call(Scene_Battle)
    I decided to change it to



    Code:
    SceneManager.call_battle_scene
    Which would choose the actual scene battle to use, and then let the engine do the rest of the work.

    Any thoughts on the design?

    Note that this should in theory support any battle system, because all the battle manager does is determine which battle system to use. If you're using an ABS system, well, it just has to initialize the ABS battle manager and then off it goes.

    Sprites and windows are handled by the battle scene, so that is isolated to their own systems.

    You shouldn't really have any conflicting attributes in the Game_ objects because your system shouldn't depend on the actors' values; instead, they should be deciding what to do based on the values.

    The only real problem I see is that most people prefer to alias and override, which does not work with this plugin battle system. All battle systems will need to be re-written to use subclassing, so if you need your own Spriteset_Battle, just inherit from the default, if you need a new window, just inherit it. If you need a new scene, just make one.

    There are only two calls required to make the system work properly



    Code:
    BattleManager.setup(...)
    SceneManager.call_battle_scene
    And the first one is already provided.