Siarl / sd-project-2020-VU

Project for Software Design (XB_40007), Computer Science @ VU Amsterdam, 2019/2020. TextAdventureGame Group 7: Koen van den Burg, Bogdan Cercel, Claudia Grigoras, Sofia Konovalova, Wilkin van Roosmalen.
https://studiegids.vu.nl/en/2019-2020/courses/XB_40007
GNU General Public License v3.0
1 stars 0 forks source link

Multiple Effects mapped to one Command #5

Open Siarl opened 4 years ago

Siarl commented 4 years ago

Current implementation?

When a command is entered, the Actions object handles it in onCommand(Command command, Callback callback):

    @Override
    public boolean onCommand(Command command, Callback callback) {
        if (hasCommand(command.getAction())) {
            Effect effect = getEffect(command.getAction());
            if (effect != null) {
                effect.apply(command.getGame());

                callback.onMessage("Effect applied... " + effect.toString());
            }
            return true;
        }

        return false;
    }

The Effect object mapped to the specific command string is retrieved and applied. What exactly happens when an Effect is applied depends on the Effect.Type.

What needs to change?

One command should be able to apply multiple effect types.

How is this implemented?

New class Effects should be added. The Effects should contain a collection of Effect objects. Effects should also contain an apply() method that simply applies all the Effect objects at once.

Instead of mapping the command string to an Effect object, it should be mapped to an Effects object.

TODO

please tick off when you are done and also comment

Branch: Assignment3

Siarl commented 4 years ago

I pushed the implementation changes