private static void ChangeOwner( PersonData ownerData, int claimerId, PersonData claimerData, Artefact artefact) { artefact.OwnerId = claimerId; claimerData.AddArtefact(artefact.Id, ownerData.RemoveArtefact(artefact.Id)); }
public IEnumerable <Artefact> SplitArtefact(Artefact artefact, params string[] newNames) { RemoveArtefact(artefact); var newArtefacts = newNames .Select(_factory.CreateArtefact) .ToArray(); newArtefacts .ForEach(AddArtefact); return(newArtefacts); }
public void Compliment(Artefact artefact) { var receiverId = artefact.KnownOwnerId; var receiverData = GetData(receiverId); var artefactData = receiverData.GetArtefact(artefact.Id); if (artefactData.IsEndorced) { return; } artefactData.IsEndorced = true; receiverData.Grace(ArtefactEndorcementTrustFactor); InformPeers(CreateTransaction(new Compliment(Id, artefact.Id))); }
private int QuestionOwnership( int ownerId, int claimerId, Artefact artefact) { var ownerData = GetData(ownerId); var claimerData = GetData(claimerId); var leastTrustedData = new[] { claimerData, ownerData }.OrderBy(data => data.Trust).First(); if (leastTrustedData == ownerData) { ChangeOwner(ownerData, claimerId, claimerData, artefact); } leastTrustedData.Doubt(ArtefactDisputeDoubtFactor); return(artefact.KnownOwnerId); }
private void UnregisterArtefact(int ownerId, Artefact artefact) { _knownArtefacts.Remove(artefact); GetData(ownerId).RemoveArtefact(artefact.Id); }
private void RegisterArtefact(int claimerId, Artefact artefact) { _knownArtefacts.AddUnique(artefact); GetData(claimerId).AddArtefact(artefact.Id, new ArtefactData(artefact)); }
public void RemoveArtefact(Artefact artefact) { artefact.OwnerId = null; _myArtefacts.Remove(artefact); InformPeers(CreateTransaction(new LostArtefact(Id, artefact))); }
public void AddArtefact(Artefact artefact) { artefact.OwnerId = Id; _myArtefacts.Add(artefact); InformPeers(CreateTransaction(new GotArtefact(Id, artefact))); }