From: "Sebastjan H." Date: 2012-09-21T14:08:38+09:00 Subject: Re: still learning by doing - connecting rooms in a game Henry Maddocks wrote in post #1076876: > On 21/09/2012, at 5:11 AM, "Sebastjan H." wrote: > >> >> I am doing this as a task in the book learning ruby the hard way by Zed. > > This book is considered harmful. Why exactly? >> Maybe I've made a mistake for trying to put everything in the room >> classes and not just the room descriptions. >> >> Anyway, I maintain the code here: >> https://code.launchpad.net/~sebastjan-hribar/zombies/trunk >> >> I would appreciate any pointers. I am stuck. I still have a lot of work >> to do with various descriptions and particular activities in rooms, but >> the main problem is this room connection. > > I wouldn't have written the code this way, but I don't know if you are > following the book or not. The book suggests a class per room. > To start with I would have > > One Room class that takes a name and description and a visited > attribute. Not a class for each room as you have done. > > Create a Map structure that defines the room layout. Something like > > [ > {:room => :kitchen, :next_rooms => {:north => :living_room, > :south => :basement}}, > {:room => : living_room, :next_rooms => {:north => :bathroom, :south > => :kitchen}}, > ... > ] Thank you for the idea of mapping the rooms in this way. I'll try it. regards, seba > > Henry -- Posted via http://www.ruby-forum.com/.