Ejemplo n.º 1
0
    static Land FromParcel(ParcelFields parcel, LandRole role)
    {
        string id     = CoordsToId(parcel.x, parcel.y);
        Land   result = new Land()
        {
            id          = id,
            name        = parcel.data?.name ?? $"Parcel {id}",
            type        = LandType.PARCEL,
            role        = role,
            description = parcel.data?.description,
            owner       = parcel.owner.address,
            operators   = new List <string>()
        };

        if (int.TryParse(parcel.x, out int x))
        {
            result.x = x;
        }
        if (int.TryParse(parcel.y, out int y))
        {
            result.y = y;
        }

        if (!string.IsNullOrEmpty(parcel.updateOperator))
        {
            result.operators.Add(parcel.updateOperator);
        }

        return(result);
    }
Ejemplo n.º 2
0
    static Land FromEstate(EstateFields estate, LandRole role)
    {
        string id = estate.id;

        Land result = new Land()
        {
            id          = id,
            name        = estate.data?.name ?? $"Parcel {id}",
            type        = LandType.ESTATE,
            role        = role,
            description = estate.data?.description,
            size        = estate.size,
            parcels     = new List <Parcel>(),
            owner       = estate.owner.address,
            operators   = new List <string>()
        };

        for (int i = 0; i < estate.parcels.Length; i++)
        {
            if (!(int.TryParse(estate.parcels[i].x, out int x) && (int.TryParse(estate.parcels[i].y, out int y))))
            {
                continue;
            }

            result.parcels.Add(new Parcel()
            {
                x  = x,
                y  = y,
                id = CoordsToId(estate.parcels[i].x, estate.parcels[i].y)
            });
        }

        if (!string.IsNullOrEmpty(estate.updateOperator))
        {
            result.operators.Add(estate.updateOperator);
        }

        return(result);
    }