Exemplo n.º 1
0
 private static void ChangeOwner(
     PersonData ownerData,
     int claimerId,
     PersonData claimerData,
     Artefact artefact)
 {
     artefact.OwnerId = claimerId;
     claimerData.AddArtefact(artefact.Id, ownerData.RemoveArtefact(artefact.Id));
 }
Exemplo n.º 2
0
        public IEnumerable <Artefact> SplitArtefact(Artefact artefact, params string[] newNames)
        {
            RemoveArtefact(artefact);
            var newArtefacts = newNames
                               .Select(_factory.CreateArtefact)
                               .ToArray();

            newArtefacts
            .ForEach(AddArtefact);
            return(newArtefacts);
        }
Exemplo n.º 3
0
        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)));
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
 private void UnregisterArtefact(int ownerId, Artefact artefact)
 {
     _knownArtefacts.Remove(artefact);
     GetData(ownerId).RemoveArtefact(artefact.Id);
 }
Exemplo n.º 6
0
 private void RegisterArtefact(int claimerId, Artefact artefact)
 {
     _knownArtefacts.AddUnique(artefact);
     GetData(claimerId).AddArtefact(artefact.Id, new ArtefactData(artefact));
 }
Exemplo n.º 7
0
 public void RemoveArtefact(Artefact artefact)
 {
     artefact.OwnerId = null;
     _myArtefacts.Remove(artefact);
     InformPeers(CreateTransaction(new LostArtefact(Id, artefact)));
 }
Exemplo n.º 8
0
 public void AddArtefact(Artefact artefact)
 {
     artefact.OwnerId = Id;
     _myArtefacts.Add(artefact);
     InformPeers(CreateTransaction(new GotArtefact(Id, artefact)));
 }