public void DestroyArtefact(ArtefactId id) { if (!Account.KnowsArtefact(id) || Account.GetArtefact(id).OwnerId != Account.Id) { throw new ArgumentException("Tried to destroy artefact not owned"); } OnDestroyArtefact(Account.GetArtefact(id)); }
public override int GetHashCode() { unchecked { var hashCode = (GroupId != null ? GroupId.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ArtefactId != null ? ArtefactId.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Version != null ? Version.GetHashCode() : 0); return(hashCode); } }
public void ForgetArtefact(ArtefactId id) { if (!KnowsArtefact(id)) { return; } var artefact = GetArtefact(id); _knownArtefacts.Remove(id); if (artefact.OwnerId == default || !IsConnectedTo(artefact.OwnerId)) { return; } GetPeer(artefact.OwnerId).RemoveArtefact(id); }
public Artefact GetArtefact(ArtefactId id) => _artefacts.TryGetValue(id, out var artefact) ? artefact : throw new NotFound <Artefact>(nameof(id), id.ToString());
public bool HasArtefact(ArtefactId id) => _artefacts.ContainsKey(id);
public void RemoveArtefact(ArtefactId id) { _artefacts.Remove(id); }
public Artefact(ArtefactId id, string name, AgentId ownerId) { Id = id; Name = name; OwnerId = ownerId; }
public Artefact GetArtefact(ArtefactId id) => _knownArtefacts[id];
public bool KnowsArtefact(ArtefactId id) => _knownArtefacts.ContainsKey(id);