summaryrefslogtreecommitdiff
path: root/src/map/mapflag.py
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2014-02-19 23:22:10 -0800
committerBen Longbons <b.r.longbons@gmail.com>2014-02-22 18:12:08 -0800
commitf4063c0d58d1a1812e24269efa1ebb8f9a7a2f2e (patch)
tree6abe09a93f96e475c2714c10dfaef4df412bcf0c /src/map/mapflag.py
parent8508f94daeeb49b6ccf3ee1a346f1dc9f9c56802 (diff)
downloadtmwa-f4063c0d58d1a1812e24269efa1ebb8f9a7a2f2e.tar.gz
tmwa-f4063c0d58d1a1812e24269efa1ebb8f9a7a2f2e.tar.bz2
tmwa-f4063c0d58d1a1812e24269efa1ebb8f9a7a2f2e.tar.xz
tmwa-f4063c0d58d1a1812e24269efa1ebb8f9a7a2f2e.zip
Make mapflags bitmask instead of bitfield
Diffstat (limited to 'src/map/mapflag.py')
-rw-r--r--src/map/mapflag.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/map/mapflag.py b/src/map/mapflag.py
new file mode 100644
index 0000000..181476c
--- /dev/null
+++ b/src/map/mapflag.py
@@ -0,0 +1,51 @@
+class MapFlags(object):
+ ''' print a set of map flags
+ '''
+ __slots__ = ('_value')
+ name = 'MapFlags'
+ enabled = True
+
+ def __init__(self, value):
+ self._value = value['flags']
+
+ def to_string(self):
+ i = int(self._value)
+ s = []
+ for n, v in [
+ ('ALIAS', 21),
+ ('NOMEMO', 0),
+ ('NOTELEPORT', 1),
+ ('NORETURN', 22),
+ ('MONSTER_NOTELEPORT', 23),
+ ('NOSAVE', 2),
+ ('NOBRANCH', 3),
+ ('NOPENALTY', 4),
+ ('PVP', 6),
+ ('PVP_NOPARTY', 7),
+ ('PVP_NOGUILD', 8),
+ ('PVP_NIGHTMAREDROP', 24),
+ ('PVP_NOCALCRANK', 25),
+ ('GVG', 9),
+ ('GVG_NOPARTY', 10),
+ ('NOZENYPENALTY', 5),
+ ('NOTRADE', 11),
+ ('NOSKILL', 12),
+ ('NOWARP', 13),
+ ('NOWARPTO', 26),
+ ('NOPVP', 14),
+ ('NOICEWALL', 15),
+ ('SNOW', 16),
+ ('FOG', 17),
+ ('SAKURA', 18),
+ ('LEAVES', 19),
+ ('RAIN', 20),
+ ('NO_PLAYER_DROPS', 27),
+ ('TOWN', 28),
+ ]:
+ v = 1 << v
+ if i & v:
+ i -= v
+ s.append(n)
+ if i or not s:
+ s.append('%#08x' % i)
+ return 'MapFlags(%s)' % (' | '.join(s))