It's like Booom
It's like Booom

Reputation: 137

How to share an object between two Models in MVC?

I have two Models in my card game.

  1. HandModel - contains the list of instances of CardModel.
  2. BoardModel - contains instances of CardModel placed on the board with specific coordinates.

I want to pop a card instance from the HandModel list and place it in the BoardModel coordinates. I would like to send a Card between those two models, but I don't want to directly call BoardModel inside HandModel just for this reason. Not sure how should I do it.

Upvotes: 0

Views: 94

Answers (1)

Markus Steppberger
Markus Steppberger

Reputation: 638

You might want to design your model in a way in which the card model itself has some kind of location which can be updated by a controller which handles the cards. That way no model has to know any other model.

Upvotes: 1

Related Questions