Esempio n. 1
0
        public override IValue Serialize()
        {
#pragma warning disable LAA1002
            return(new Dictionary(new Dictionary <IKey, IValue>
            {
                [(Text)LevelKey] = Level.Serialize(),
                [(Text)ExpiredBlockIndexKey] = ExpiredBlockIndex.Serialize(),
                [(Text)StartedBlockIndexKey] = StartedBlockIndex.Serialize(),
                [(Text)ReceivedBlockIndexKey] = ReceivedBlockIndex.Serialize(),
                [(Text)RewardLevelKey] = RewardLevel.Serialize(),
                [(Text)RewardMapKey] = new Dictionary(
                    RewardMap.Select(
                        kv => new KeyValuePair <IKey, IValue>(
                            (IKey)kv.Key.Serialize(),
                            kv.Value.Serialize()
                            )
                        )
                    ),
                [(Text)EndKey] = End.Serialize(),
                [(Text)RewardLevelMapKey] = new Dictionary(
                    RewardLevelMap.Select(
                        kv => new KeyValuePair <IKey, IValue>(
                            (IKey)kv.Key.Serialize(),
                            new List(kv.Value.Select(v => v.Serialize())).Serialize()
                            )
                        )
                    ),
            }.Union((Dictionary)base.Serialize())));

#pragma warning restore LAA1002
        }
Esempio n. 2
0
        protected bool Equals(MonsterCollectionState0 other)
        {
#pragma warning disable LAA1002
            return(Level == other.Level && ExpiredBlockIndex == other.ExpiredBlockIndex &&
                   StartedBlockIndex == other.StartedBlockIndex && ReceivedBlockIndex == other.ReceivedBlockIndex &&
                   RewardLevel == other.RewardLevel && RewardMap.SequenceEqual(other.RewardMap) && End == other.End &&
                   RewardLevelMap.SequenceEqual(other.RewardLevelMap));

#pragma warning restore LAA1002
        }
Esempio n. 3
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Level;
         hashCode = (hashCode * 397) ^ ExpiredBlockIndex.GetHashCode();
         hashCode = (hashCode * 397) ^ StartedBlockIndex.GetHashCode();
         hashCode = (hashCode * 397) ^ ReceivedBlockIndex.GetHashCode();
         hashCode = (hashCode * 397) ^ RewardLevel.GetHashCode();
         hashCode = (hashCode * 397) ^ (RewardMap != null ? RewardMap.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ End.GetHashCode();
         hashCode = (hashCode * 397) ^ (RewardLevelMap != null ? RewardLevelMap.GetHashCode() : 0);
         return(hashCode);
     }
 }
Esempio n. 4
0
        public void UpdateRewardMap(long rewardLevel, MonsterCollectionResult avatarAddress, long blockIndex)
        {
            if (rewardLevel < 0 || rewardLevel > RewardCapacity)
            {
                throw new ArgumentOutOfRangeException(nameof(rewardLevel),
                                                      $"reward level must be greater than 0 and less than {RewardCapacity}.");
            }

            if (RewardMap.ContainsKey(rewardLevel))
            {
                throw new AlreadyReceivedException("");
            }

            RewardMap[rewardLevel] = avatarAddress;
            RewardLevel            = rewardLevel;
            ReceivedBlockIndex     = blockIndex;
            End = rewardLevel == 4;
        }