TextWorldAdventure.py
def save(self, fname):
        '''
        returns none and takes in fname(Str) other than self as an argument. 
        Function writes the complete current state of the World in the textfile fname.
        Effects: current state of the World is written in the 
                 text file fname
        
        save: World Str -> None
        '''
        f = open(fname, "w")
        for items in self.player.inventory:
            f.write("thing #{0} {1}\n".format(items.id, items.name))
            f.write("{0}\n".format(items.description))
        for items in self.rooms:
            for t in items.contents:
                f.write("thing #{0} {1}\n".format(t.id, t.name))
                f.write("{0}\n".format(t.description))        
        for items in self.rooms:
            f.write("room #{0} {1}\n".format(items.id, items.name))
            f.write("{0}\n".format(items.description))
            a = list(map(lambda x: "#" + str(x.id), items.contents))
            b = " ".join(a)
            f.write("contents" + " {0}\n".format(b))
        f.write("player #{0} {1}\n".format(self.player.id, self.player.name))
        f.write("{0}\n".format(self.player.description))
        c = list(map(lambda x: "#" + str(x.id), self.player.inventory))
        d = " ".join(c)
        f.write("inventory" + " {0}\n".format(d))
        f.write("location #{0}\n".format(self.player.location.id))
        for items in self.rooms:
            for ex in items.exits:
                if ex.key == None:    
                    f.write("exit #{0} #{1} {2}\n".format(items.id, ex.destination.id, ex.name))
                else:
                    f.write("keyexit #{0} #{1} {2}\n".format(items.id, ex.destination.id, ex.name))
                    f.write("#{0} {1}\n".format(ex.key.id, ex.message))       
        f.close()

        returns none and takes in fname(Str) other than self as an argument. 
        Function writes the complete current state of the World in the textfile fname.
        Effects: current state of the World is written in the 
                 text file fname
        
        save: World Str -> None
        
returns none and takes in fname(Str) other than self as an argument.
Function writes the complete current state of the World in the textfile fname.
Effects: current state of the World is written in the
text file fname

World Str -> None
returns none and takes in fname ( Str ) other than self as an argument . Function writes the complete current state of the World in the textfile fname . Effects : current state of the World is written in the text file fname World Str - > None
def save(self, fname):
        f = open(fname, "w")
        for items in self.player.inventory:
            f.write("thing #{0} {1}\n".format(items.id, items.name))
            f.write("{0}\n".format(items.description))
        for items in self.rooms:
            for t in items.contents:
                f.write("thing #{0} {1}\n".format(t.id, t.name))
                f.write("{0}\n".format(t.description))        
        for items in self.rooms:
            f.write("room #{0} {1}\n".format(items.id, items.name))
            f.write("{0}\n".format(items.description))
            a = list(map(lambda x: "#" + str(x.id), items.contents))
            b = " ".join(a)
            f.write("contents" + " {0}\n".format(b))
        f.write("player #{0} {1}\n".format(self.player.id, self.player.name))
        f.write("{0}\n".format(self.player.description))
        c = list(map(lambda x: "#" + str(x.id), self.player.inventory))
        d = " ".join(c)
        f.write("inventory" + " {0}\n".format(d))
        f.write("location #{0}\n".format(self.player.location.id))
        for items in self.rooms:
            for ex in items.exits:
                if ex.key == None:    
                    f.write("exit #{0} #{1} {2}\n".format(items.id, ex.destination.id, ex.name))
                else:
                    f.write("keyexit #{0} #{1} {2}\n".format(items.id, ex.destination.id, ex.name))
                    f.write("#{0} {1}\n".format(ex.key.id, ex.message))       
        f.close()
def save ( self , fname ) : f = open ( fname , "w" ) for items in self . player . inventory : f . write ( "thing #{0} {1}\n" . format ( items . id , items . name ) ) f . write ( "{0}\n" . format ( items . description ) ) for items in self . rooms : for t in items . contents : f . write ( "thing #{0} {1}\n" . format ( t . id , t . name ) ) f . write ( "{0}\n" . format ( t . description ) ) for items in self . rooms : f . write ( "room #{0} {1}\n" . format ( items . id , items . name ) ) f . write ( "{0}\n" . format ( items . description ) ) a = list ( map ( lambda x : "#" + str ( x . id ) , items . contents ) ) b = " " . join ( a ) f . write ( "contents" + " {0}\n" . format ( b ) ) f . write ( "player #{0} {1}\n" . format ( self . player . id , self . player . name ) ) f . write ( "{0}\n" . format ( self . player . description ) ) c = list ( map ( lambda x : "#" + str ( x . id ) , self . player . inventory ) ) d = " " . join ( c ) f . write ( "inventory" + " {0}\n" . format ( d ) ) f . write ( "location #{0}\n" . format ( self . player . location . id ) ) for items in self . rooms : for ex in items . exits : if ex . key == None : f . write ( "exit #{0} #{1} {2}\n" . format ( items . id , ex . destination . id , ex . name ) ) else : f . write ( "keyexit #{0} #{1} {2}\n" . format ( items . id , ex . destination . id , ex . name ) ) f . write ( "#{0} {1}\n" . format ( ex . key . id , ex . message ) ) f . close ( )
returns none and takes in fname(Str) other than self as an argument.
returns none and takes in fname ( Str ) other than self as an argument .
'''
        returns none and takes in fname(Str) other than self as an argument. 
        Function writes the complete current state of the World in the textfile fname.
        Effects: current state of the World is written in the 
                 text file fname
        
        save: World Str -> None
        '''
self
fname