Closed nskins closed 7 years ago
Actually, this can be solved by referring to the first map via Player.saved_maps
. For instance, the first map might contain the line:
player.move_to(Couple.new(0,0), Island.new)
Knowing that :the Player has saved the first map (say, with name "City"), the second map would have this line:
player.move_to(Couple.new(0,0), player.saved_maps["City"])
Since the circular reference problem is resolved, I'll just close this for now.
A circular reference arises if we try to place one
Event
each on twoMap
s for moving to and from one another.Since saved maps are accessible by the name of the
Map
(viaPlayer.saved_maps
), one possible solution is to create a new function where the name is specified rather than theMap
object (see#Player.move_to
). The function would be pretty similar to#move_to.
Alternatively, we could extendmove_to
to accept either aMap
orString
and to act accordingly. It might prevent duplicate code, although the documentation would be more confusing. The code might be stinky, too.