2 Replies Latest reply on Dec 5, 2008 1:47 PM by clbeech

    Variable Storage

    Level 7
      Dear All,

      I wondering if anyone can help me with the best way to store some
      information. I am creating a version of Monopoly. In this game there are 40
      boxes of which only 30 can be either owned by "Mr Monopoly" or "Player1".
      The first colour on the monopoly board is brown, then blue then pink. There
      are 2 brown boxes b1 or b2, either could be owned by MrMonopoly or Player1.
      I would like to create a data structure that can easily be updated everytime
      a box is bought and interrogated to return whether the current player owns
      none some or all of the boxes of that colour.

      At any one time the token knows the number of the box on the board it is
      currently on, what's its colour is and whether it is owned by "Mr Monopoly"
      or "Player1". The number of box colour groups are always constant but not
      always concurrent. For example Brown would not be piece 1 and 2 on the
      board as they are separated by "Community Chest".

      I think it would be an array of 40 boxes and when the token lands on a box
      it identifies what colour of box it lands on and then checks the array to
      see if this player owns none, some or all of the boxes of that colour in the

      Owner = new Array(0,1,0,1,0,2,0,3,0,3,0,0,2) etc....

      where 0 is non - ownable box; 1 is brown pieces; 2 are ownable airports (of
      which there are 4); 3 is a blue.

      So I am some how trying to show that all the browns are owned by this player
      or all the blues, etc... and something happens after that.

      I would like to thank you staying with this long post but I would welcome
      any suggestions.

      Alastair MacFarlane

        • 1. Variable Storage
          Ned Murphy Adobe Community Professional & MVP
          I'm not really clear on the workings of the game as you have planned them, but you could use an object to store data for each box and store those in an array.

          Boxes[40] = { boxName: "Boardwalk", boxOwner: 1, relatedBoxes: [39] };

          The 1 there could be anything, but is intended to equate to an owner... a null or a zero could be a non-owned box.

          That [39] is intended to be an array, though I forget the right way to express it. You could use that to check how many of the companion boxes are owned and by whom.
          • 2. Re: Variable Storage
            clbeech Level 3
            that's right way to instantiate a new array Ned particularly within a Object prop declaration like you have there. be the same as saying:

            var relatedBoxes:Array = new Array(39, 40, 41);
            var relatedBoxes = [39,40,41];

            right on the money ;)

            OT- reached the 1k club i see LOL! :)