예제 #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)
예제 #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"