Skip to content

01 Game and Store Commands Refactor

Marc Johnston edited this page Jul 19, 2022 · 8 revisions

The ActivationHandler and CastingHandler classed were converted into the ICommand interface and all command actions were converted into class objects that implements the ICommand interface. The parameters into the handler class constructors (player and level) are passed as objects to the command execution.

Since the store also referenced these same commands, the IStoreCommand interface was also added. This IStoreCommand interface defines the Execute method, but does not pass the Level object because stores cannot interact with items outside of the store. All command objects that also serve as store commands added the IStoreCommand interface. During this process, a flaw was exposed where the store needed to pass the current Level object to the command. This flaw is apparent when the command needs the player to select an object. The GetItem method requires a Level object to allow the player to select an object from the floor.

There are two avenues to absolve this deficiency.

  1. Refactor the IStoreCommand.Execute(Player) into IStoreCommand.Execute(Player, SaveGame.Instance.Level) but that would allow the store access to items in the Town.
  2. Refactor the GetItem method. This is the avenue we will take. Once the GetItem framework objects are created, a base class should be able to implement the GetItem that is limited to the player inventory.
Clone this wiki locally