File: mon-iter.h

package info (click to toggle)
crawl 2%3A0.7.1-3
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 30,420 kB
  • ctags: 23,018
  • sloc: cpp: 244,317; ansic: 16,144; perl: 2,214; makefile: 984; python: 488; objc: 250; ruby: 200; sh: 140
file content (49 lines) | stat: -rw-r--r-- 871 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
 * Provide a way to iterator over all monsters,
 * subject to a few common restrictions.
 *
 * TODO:
 *  - Iterate over actors?
 */

#ifndef MON_ITER_H
#define MON_ITER_H

enum restr_type
{
    R_NONE,
    R_CIRC,
    R_LOS,
    R_ACT,
};

class circle_def;
class los_base;
class actor;

class monster_iterator
{
public:
    monster_iterator();
    monster_iterator(const circle_def* circle_);
    monster_iterator(const los_base* los_);
    explicit monster_iterator(const actor* act_);

    operator bool() const;
    monsters* operator*() const;
    monsters* operator->() const;
    monster_iterator& operator++();
    monster_iterator operator++(int);

protected:
    restr_type restr;
    int curr_mid;
    const circle_def* circle;
    const los_base* los;
    const actor* act;

    bool valid(int mid) const;
    void advance(bool may_stay=false);
};

#endif