コード例 #1
0
ファイル: ship.py プロジェクト: esasiela/hc-space-haul
    def from_dict(cls, d, star_list: StarList):
        s = Ship(d["_ship_id"], d["_name"], Location.from_dict(d["_location"]))

        if d["_docked_star"] is not None:
            # find the star in the StarList by ID
            for star in star_list.stars():
                if star.star_id() == d["_docked_star"]:
                    s.set_docked_star(star)

        if d["_destination_star"] is not None:
            # find the star in the StarList by ID
            for star in star_list.stars():
                if star.star_id() == d["_destination_star"]:
                    s.set_destination_star(star)

        if d["_departure_star"] is not None:
            # find the star in the StarList by ID
            for star in star_list.stars():
                if star.star_id() == d["_departure_star"]:
                    s.set_departure_star(star)

        return s
コード例 #2
0
 def from_dict(cls, d):
     return Star(d["_star_id"], d["_name"],
                 Location.from_dict(d["_location"]))