Exemple #1
0
def get_object(name):
    for index in range(nethack.NUM_OBJECTS):
        obj = nethack.objclass(index)
        if nethack.OBJ_NAME(obj) == name:
            return obj
    else:
        raise ValueError("'%s' not found!" % name)
Exemple #2
0
    def test_objclass(self):
        obj = nethack.objclass(0)
        assert nethack.OBJ_NAME(obj) == "strange object"

        food_ration = get_object("food ration")
        assert food_ration.oc_weight == 20

        elven_dagger = get_object("elven dagger")
        assert nethack.OBJ_DESCR(elven_dagger) == "runed dagger"
Exemple #3
0
    def test_permonst_and_class_sym(self):
        glyph = 155  # Lichen.

        mon = nethack.permonst(nethack.glyph_to_mon(glyph))

        assert mon.mname == "lichen"

        cs = nethack.class_sym.from_mlet(mon.mlet)

        assert cs.sym == "F"
        assert cs.explain == "fungus or mold"

        assert nethack.NHW_MESSAGE == 1
        assert hasattr(nethack, "MAXWIN")

        # Slightly irritating to need `chr` here.
        cs = nethack.class_sym.from_oc_class(chr(nethack.WAND_CLASS))
        assert cs.sym == "/"
        assert cs.explain == "wand"

        obj = nethack.objclass(0)
        cs = nethack.class_sym.from_oc_class(obj.oc_class)
        assert cs.sym == "]"
        assert cs.explain == "strange object"