コード例 #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));
 }
コード例 #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);
        }
コード例 #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)));
        }
コード例 #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);
        }
コード例 #5
0
 private void UnregisterArtefact(int ownerId, Artefact artefact)
 {
     _knownArtefacts.Remove(artefact);
     GetData(ownerId).RemoveArtefact(artefact.Id);
 }
コード例 #6
0
 private void RegisterArtefact(int claimerId, Artefact artefact)
 {
     _knownArtefacts.AddUnique(artefact);
     GetData(claimerId).AddArtefact(artefact.Id, new ArtefactData(artefact));
 }
コード例 #7
0
 public void RemoveArtefact(Artefact artefact)
 {
     artefact.OwnerId = null;
     _myArtefacts.Remove(artefact);
     InformPeers(CreateTransaction(new LostArtefact(Id, artefact)));
 }
コード例 #8
0
 public void AddArtefact(Artefact artefact)
 {
     artefact.OwnerId = Id;
     _myArtefacts.Add(artefact);
     InformPeers(CreateTransaction(new GotArtefact(Id, artefact)));
 }