| | 1 | | using System.Collections.Generic; |
| | 2 | | using System.Linq; |
| | 3 | |
|
| | 4 | | [System.Serializable] |
| | 5 | | public class UserProfileModel |
| | 6 | | { |
| | 7 | | [System.Serializable] |
| | 8 | | public class Snapshots |
| | 9 | | { |
| | 10 | | public string face256; |
| | 11 | | public string body; |
| | 12 | |
|
| | 13 | | public bool Equals(Snapshots snapshots) |
| | 14 | | { |
| 0 | 15 | | if (snapshots == null) return false; |
| 0 | 16 | | if (snapshots.face256 != face256) return false; |
| 0 | 17 | | if (snapshots.body != body) return false; |
| 0 | 18 | | return true; |
| | 19 | | } |
| | 20 | | } |
| | 21 | |
|
| | 22 | | [System.Serializable] |
| | 23 | | public class ParcelsWithAccess |
| | 24 | | { |
| | 25 | | public int x; |
| | 26 | | public int y; |
| | 27 | | public LandRole landRole; |
| | 28 | |
|
| | 29 | | [System.Serializable] |
| | 30 | | public enum LandRole |
| | 31 | | { |
| | 32 | | OWNER = 0, |
| | 33 | | OPERATOR = 1 |
| | 34 | | } |
| | 35 | |
|
| | 36 | | public bool Equals(ParcelsWithAccess parcelsWithAccess) |
| | 37 | | { |
| 0 | 38 | | if (parcelsWithAccess == null) return false; |
| 0 | 39 | | if (parcelsWithAccess.x != x) return false; |
| 0 | 40 | | if (parcelsWithAccess.y != y) return false; |
| 0 | 41 | | if (parcelsWithAccess.landRole != landRole) return false; |
| 0 | 42 | | return true; |
| | 43 | | } |
| | 44 | | } |
| | 45 | |
|
| | 46 | | public string userId; |
| | 47 | | public string ethAddress; |
| | 48 | | public string name; |
| | 49 | | public string email; |
| | 50 | | public string description; |
| | 51 | | public string baseUrl; |
| | 52 | | public ParcelsWithAccess[] parcelsWithAccess; |
| | 53 | | public ulong created_at; |
| | 54 | | public ulong updated_at; |
| | 55 | | public int version; |
| | 56 | | public AvatarModel avatar; |
| 1309 | 57 | | public Snapshots snapshots = new Snapshots(); |
| 0 | 58 | | public UserProfileModel Clone() => (UserProfileModel)MemberwiseClone(); |
| | 59 | |
|
| 1309 | 60 | | public bool hasConnectedWeb3 = true; |
| | 61 | |
|
| | 62 | | public int tutorialFlagsMask; |
| | 63 | | public List<string> blocked; |
| | 64 | | public List<string> muted; |
| | 65 | | public int tutorialStep; |
| | 66 | | public bool hasClaimedName = false; |
| | 67 | |
|
| | 68 | | public bool Equals(UserProfileModel model) |
| | 69 | | { |
| 653 | 70 | | if (model == null) return false; |
| 1195 | 71 | | if (model.userId != userId) return false; |
| 111 | 72 | | if (model.ethAddress != ethAddress) return false; |
| 160 | 73 | | if (model.name != name) return false; |
| 63 | 74 | | if (model.email != email) return false; |
| 61 | 75 | | if (model.description != description) return false; |
| 61 | 76 | | if (model.baseUrl != baseUrl) return false; |
| 61 | 77 | | if (model.created_at != created_at) return false; |
| 61 | 78 | | if (model.updated_at != updated_at) return false; |
| 61 | 79 | | if (model.version != version) return false; |
| 101 | 80 | | if (!model.avatar.Equals(avatar)) return false; |
| | 81 | |
|
| 21 | 82 | | if (model.parcelsWithAccess != null) |
| | 83 | | { |
| 0 | 84 | | if (!model.parcelsWithAccess.Equals(parcelsWithAccess)) |
| 0 | 85 | | return false; |
| | 86 | | } |
| 21 | 87 | | else if (parcelsWithAccess != null) |
| 0 | 88 | | return false; |
| | 89 | |
|
| 21 | 90 | | if (model.hasConnectedWeb3 != hasConnectedWeb3) return false; |
| 21 | 91 | | if (model.tutorialFlagsMask != tutorialFlagsMask) return false; |
| 21 | 92 | | if (model.tutorialFlagsMask != tutorialFlagsMask) return false; |
| | 93 | |
|
| 21 | 94 | | if (model.blocked != null && blocked != null) |
| | 95 | | { |
| 0 | 96 | | if (!model.blocked.All(blocked.Contains) || model.blocked.Count != blocked.Count) |
| 0 | 97 | | return false; |
| | 98 | | } |
| 21 | 99 | | else if (model.blocked != null || blocked != null) |
| 0 | 100 | | return false; |
| | 101 | |
|
| 21 | 102 | | if (model.muted != null && muted != null) |
| | 103 | | { |
| 0 | 104 | | if (!model.muted.All(muted.Contains) || model.muted.Count != muted.Count) |
| 0 | 105 | | return false; |
| | 106 | | } |
| 21 | 107 | | else if (model.muted != null || muted != null) |
| 0 | 108 | | return false; |
| | 109 | |
|
| 21 | 110 | | if (model.tutorialStep != tutorialStep) return false; |
| 21 | 111 | | if (model.hasClaimedName != hasClaimedName) return false; |
| | 112 | |
|
| 21 | 113 | | return true; |
| | 114 | | } |
| | 115 | |
|
| | 116 | | public string ComposeCorrectUrl(string url) |
| | 117 | | { |
| 150 | 118 | | if (string.IsNullOrEmpty(url)) |
| 95 | 119 | | return url; |
| | 120 | |
|
| 55 | 121 | | if (!url.StartsWith("Qm") && !url.StartsWith("ba")) |
| 55 | 122 | | return url; |
| | 123 | |
|
| 0 | 124 | | return baseUrl + url; |
| | 125 | | } |
| | 126 | | } |