Example #1
0
        /* Move the pack to an adjacent node. */
        public bool move(Node u)
        {
            if (!location.neighbors.Contains(u))
            {
                throw new ArgumentException();
            }
            int capacity = dungeon.capacity(u);

            // capacity now expresses how much space the node has left
            if (members.Count > capacity)
            {
                Logger.log("Pack " + id + " is trying to move to a full node " + u.id + ", but this would cause the node to exceed its capacity. Rejected.");
                return(false);
            }
            location.packs.Remove(this); // Remove pack from current node
            location = u;
            u.packs.Add(this);
            Logger.log("Pack " + id + " succesfully moves to " + u.id + " node.");
            return(true);
        }