public Pack(string id, int n, Node loc, bool gameplay, Dungeon dungeon) { this.id = id; this.location = loc; this.dungeon = dungeon; if (!gameplay) { zone = dungeon.CurrentLevel(loc); for (int i = 0; i < n; i++) { Monster m = new Monster("" + id + "_" + i); m.location = location; members.Add(m); startingHP += m.GetHP(); m.SetPack(this); } } }
/* Move the pack to an adjacent node. */ public void Move(Node u) { Zone z = new Zone(dungeon, members[0]); RNode rnode = new RNode(z); RZone rzone = new RZone(z); if (!rnode.validMove(this, u) || !rzone.validMove(u)) { return; } if (!location.neighbors.Contains(u)) { throw new ArgumentException(); } int capacity = dungeon.multiplier * (dungeon.CurrentLevel(u) + 1); // count monsters already in the node: foreach (Pack Q in location.packs) { capacity = capacity - Q.members.Count; } // 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; } foreach (Monster m in members) { m.location = u; } location.packs.Remove(this); location = u; u.packs.Add(this); Logger.log("Pack " + id + " moves to an already full node " + u.id + ". Rejected."); }