Exemplo n.º 1
0
        public CollectionMap UpdateCompletedQuest(CollectionMap eventMap)
        {
            const QuestEventType type = QuestEventType.Complete;

            eventMap[(int)type] = _quests.Count(i => i.Complete);
            return(UpdateGeneralQuest(new[] { type }, eventMap));
        }
Exemplo n.º 2
0
        public override void Execute(CollectionMap map)
        {
            if (this._type == ePathType.Relative)
            {
                this._path = Path.Combine(map.Directory, this._path);

                if (File.Exists(this._path) && this._import == eImportType.negate)
                {
                    return;
                }

                var directory = Path.GetDirectoryName(this._path);
                Directory.CreateDirectory(directory);
                File.Create(this._path);
            }
            else
            {
                this._path = Path.Combine(map.Profile.Directory, this._path);

                if (File.Exists(this._path) && this._import == eImportType.negate)
                {
                    return;
                }

                var directory = Path.GetDirectoryName(this._path);
                Directory.CreateDirectory(directory);
                File.Create(this._path);
            }
        }
Exemplo n.º 3
0
        public AvatarState(Address address,
                           Address agentAddress,
                           long blockIndex,
                           TableSheets sheets,
                           GameConfigState gameConfigState,
                           string name = null) : base(address)
        {
            if (address == null)
            {
                throw new ArgumentNullException(nameof(address));
            }

            this.name         = name ?? string.Empty;
            characterId       = GameConfig.DefaultAvatarCharacterId;
            level             = 1;
            exp               = 0;
            inventory         = new Inventory();
            worldInformation  = new WorldInformation(blockIndex, sheets.WorldSheet, GameConfig.IsEditor);
            updatedAt         = DateTimeOffset.UtcNow;
            this.agentAddress = agentAddress;
            questList         = new QuestList(
                sheets.QuestSheet,
                sheets.QuestRewardSheet,
                sheets.QuestItemRewardSheet,
                sheets.EquipmentItemRecipeSheet,
                sheets.EquipmentItemSubRecipeSheet
                );
            mailBox         = new MailBox();
            this.blockIndex = blockIndex;
            actionPoint     = gameConfigState.ActionPointMax;
            stageMap        = new CollectionMap();
            monsterMap      = new CollectionMap();
            itemMap         = new CollectionMap();
            const QuestEventType createEvent = QuestEventType.Create;
            const QuestEventType levelEvent  = QuestEventType.Level;

            eventMap = new CollectionMap
            {
                new KeyValuePair <int, int>((int)createEvent, 1),
                new KeyValuePair <int, int>((int)levelEvent, level),
            };
            combinationSlotAddresses = new List <Address>(CombinationSlotCapacity);
            for (var i = 0; i < CombinationSlotCapacity; i++)
            {
                var slotAddress = address.Derive(
                    string.Format(
                        CultureInfo.InvariantCulture,
                        CombinationSlotState.DeriveFormat,
                        i
                        )
                    );
                combinationSlotAddresses.Add(slotAddress);
            }
            UpdateGeneralQuest(new[] { createEvent, levelEvent });
            UpdateCompletedQuest();

            PostConstructor();
        }
Exemplo n.º 4
0
        public void UpdateMonsterQuest(CollectionMap monsterMap)
        {
            var monsterQuests = _quests.OfType <MonsterQuest>();

            foreach (var quest in monsterQuests)
            {
                quest.Update(monsterMap);
            }
        }
Exemplo n.º 5
0
        public void UpdateCollectQuest(CollectionMap itemMap)
        {
            var collectQuests = _quests.OfType <CollectQuest>();

            foreach (var quest in collectQuests)
            {
                quest.Update(itemMap);
            }
        }
Exemplo n.º 6
0
        public void UpdateStageQuest(CollectionMap stageMap)
        {
            var stageQuests = _quests.OfType <WorldQuest>();

            foreach (var quest in stageQuests)
            {
                quest.Update(stageMap);
            }
        }
Exemplo n.º 7
0
        public void Update(CollectionMap stageMap)
        {
            if (Complete)
            {
                return;
            }

            Complete = stageMap.TryGetValue(Goal, out _);
        }
Exemplo n.º 8
0
        public void Update(CollectionMap itemMap)
        {
            if (Complete)
            {
                return;
            }

            itemMap.TryGetValue(ItemId, out _current);
            Check();
        }
Exemplo n.º 9
0
        public void Update(CollectionMap monsterMap)
        {
            if (Complete)
            {
                return;
            }

            monsterMap.TryGetValue(MonsterId, out _current);
            Check();
        }
        public IPropertyMappingProvider Visit(CollectionMap collectionMap)
        {
            var result = new CollectionMappingProvider(CreatePropertyMapping(collectionMap), collectionMap.StorageStrategy);
            if (collectionMap.ElementConverterType != null)
            {
                result.ElementConverterType = collectionMap.ElementConverterType;
            }

            return result;
        }
Exemplo n.º 11
0
        protected ServiceAction(IEnumerable <Argument> arguments, ServiceActionExecutor executor)
        {
            if (executor == null)
            {
                throw new ArgumentNullException("executor");
            }

            this.arguments = Helper.MakeReadOnlyCopy <string, Argument> (arguments);
            this.executor  = executor;
        }
Exemplo n.º 12
0
        protected internal ServiceAction(Deserializer deserializer, ServiceController controller)
            : base(deserializer)
        {
            if (controller == null)
            {
                throw new ArgumentNullException("controller");
            }

            this.controller = controller;
            this.arguments  = new CollectionMap <string, Argument> ();
        }
        public bool Evaluate(CollectionMap map)
        {
            try
            {
                var collection = map.GetCollection(this._filename, this._manager, this._gcareer);
                var gcareer    = collection as GCareer;

                var node = gcareer.GetCollection(this._collection, this._root);
                return(!(node is null));
            }
            catch { return(false); }
        }
        public bool Evaluate(CollectionMap map)
        {
            try
            {
                this._path = this._type == ePathType.Relative
                                        ? Path.Combine(map.Directory, this._path)
                                        : Path.Combine(map.Profile.Directory, this._path);

                return(File.Exists(this._path));
            }
            catch { return(false); }
        }
Exemplo n.º 15
0
        public void Update(CollectionMap eventMap)
        {
            if (Complete)
            {
                return;
            }

            var key = (int)Event;

            eventMap.TryGetValue(key, out _current);
            Check();
        }
Exemplo n.º 16
0
        public override void Execute(CollectionMap map)
        {
            var collection = map.GetCollection(this._filename, this._manager, this._str);

            if (collection is STRBlock str)
            {
                str.AddRecord(this._key, this._label, this._text);
            }
            else
            {
                throw new Exception($"Object {this._str} is not a STRBlock");
            }
        }
Exemplo n.º 17
0
        public override void Execute(CollectionMap map)
        {
            var collection = map.GetCollection(this._filename, this._manager, this._gcareer);

            if (collection is GCareer gcareer)
            {
                gcareer.CloneCollection(this._to, this._from, this._root);
            }
            else
            {
                throw new Exception($"Object {this._gcareer} is not a GCareer");
            }
        }
Exemplo n.º 18
0
 public override void Execute(CollectionMap map)
 {
     if (this._type == ePathType.Relative)
     {
         this._path = Path.Combine(map.Directory, this._path);
         Directory.CreateDirectory(this._path);
     }
     else
     {
         this._path = Path.Combine(map.Profile.Directory, this._path);
         Directory.CreateDirectory(this._path);
     }
 }
Exemplo n.º 19
0
        public override void Execute(CollectionMap map)
        {
            var collection = map.GetCollection(this._filename, this._manager, this._tpk);

            if (collection is TPKBlock tpk)
            {
                var path = Path.Combine(map.Directory, this._path);
                tpk.AddTexture(this._cname, path);
            }
            else
            {
                throw new Exception($"Object {this._tpk} is not a TPKBlock");
            }
        }
        public bool Evaluate(CollectionMap map)
        {
            try
            {
                var key = this._texture.IsHexString()
                                        ? Convert.ToUInt32(this._texture, 16)
                                        : this._texture.BinHash();

                var collection = map.GetCollection(this._filename, this._manager, this._tpk);
                var tpk        = collection as TPKBlock;
                return(!(tpk.FindTexture(key, KeyType.BINKEY) is null));
            }
            catch { return(false); }
        }
Exemplo n.º 21
0
        public bool Evaluate(CollectionMap map)
        {
            try
            {
                var key = this._texture.IsHexString()
                                        ? Convert.ToUInt32(this._texture, 16)
                                        : this._texture.BinHash();

                var collection = map.GetCollection(this._filename, this._manager, this._tpk);
                var tpk        = collection as TPKBlock;
                var check      = tpk.FindTexture(key, KeyType.BINKEY).GetValue(this._property);
                return(String.Compare(check, this._value, StringComparison.Ordinal) == 0);
            }
            catch { return(false); }
        }
Exemplo n.º 22
0
        public bool Evaluate(CollectionMap map)
        {
            try
            {
                var collection = map.GetCollection(this._filename, this._manager, this._str);
                var str        = collection as STRBlock;

                var key = this._record.IsHexString()
                                        ? Convert.ToUInt32(this._record, 16)
                                        : this._record.BinHash();

                return(!(str.GetRecord(key) is null));
            }
            catch { return(false); }
        }
Exemplo n.º 23
0
 public override void Execute(CollectionMap map)
 {
     if (String.Compare(this._enable, "true", StringComparison.OrdinalIgnoreCase) == 0)
     {
         this.Enable = true;
     }
     else if (String.Compare(this._enable, "false", StringComparison.OrdinalIgnoreCase) == 0)
     {
         this.Enable = false;
     }
     else
     {
         throw new Exception("Invalid parameter passed to 'stop_errors' command");
     }
 }
Exemplo n.º 24
0
        public CollectionMap UpdateGeneralQuest(IEnumerable <QuestEventType> types,
                                                CollectionMap eventMap)
        {
            foreach (var type in types)
            {
                var targets = _quests
                              .OfType <GeneralQuest>()
                              .Where(i => i.Event == type && !i.Complete);
                foreach (var target in targets)
                {
                    target.Update(eventMap);
                }
            }

            return(eventMap);
        }
Exemplo n.º 25
0
        public void Serialize()
        {
            var map = new CollectionMap();

            map.Add(1, 1);
            map.Add(2, 1);

            var map2 = new CollectionMap();

            map2.Add(2, 1);
            map2.Add(1, 1);

            var deserialized = new CollectionMap((Dictionary)map2.Serialize());

            Assert.Equal(deserialized, map);
        }
        public bool Evaluate(CollectionMap map)
        {
            try
            {
                var collection = map.GetCollection(this._filename, this._manager, this._str);
                var str        = collection as STRBlock;

                var key = this._record.IsHexString()
                                        ? Convert.ToUInt32(this._record, 16)
                                        : this._record.BinHash();

                var check = str.GetRecord(key).GetValue(this._property);
                return(String.Compare(check, this._value, StringComparison.Ordinal) == 0);
            }
            catch { return(false); }
        }
Exemplo n.º 27
0
        public override void Execute(CollectionMap map)
        {
            var collection = map.GetCollection(this._filename, this._manager, this._str);

            if (collection is STRBlock str)
            {
                var key = this._record.IsHexString()
                                        ? Convert.ToUInt32(this._record, 16)
                                        : this._record.BinHash();

                str.RemoveRecord(key);
            }
            else
            {
                throw new Exception($"Object {this._str} is not a STRBlock");
            }
        }
Exemplo n.º 28
0
        public override void Execute(CollectionMap map)
        {
            var collection = map.GetCollection(this._filename, this._manager, this._tpk);

            if (collection is TPKBlock tpk)
            {
                var key = this._texture.IsHexString()
                                        ? Convert.ToUInt32(this._texture, 16)
                                        : this._texture.BinHash();

                tpk.RemoveTexture(key, KeyType.BINKEY);
            }
            else
            {
                throw new Exception($"Object {this._tpk} is not a TPKBlock");
            }
        }
Exemplo n.º 29
0
        public override void Execute(CollectionMap map)
        {
            var sdb = map.Profile[this._filename];

            if (sdb is null)
            {
                throw new LookupFailException($"File {this._filename} was never loaded");
            }

            var manager = sdb.Database.GetManager(this._manager);

            if (manager is null)
            {
                throw new LookupFailException($"Manager named {this._manager} does not exist");
            }

            manager.Add(this._collection);
            map.AddCollection(this._filename, this._manager, this._collection, manager[^ 1]);
Exemplo n.º 30
0
        public void GetEnumerator()
        {
            const int size = 10;
            var       map  = new CollectionMap();

            for (var i = 0; i < size; i++)
            {
                map.Add(size - i, i);
            }

            var idx = 1;

            foreach (var(key, _) in map)
            {
                Assert.Equal(idx, key);
                idx++;
            }
        }
Exemplo n.º 31
0
        public override void Execute(CollectionMap map)
        {
            var sdb = map.Profile[this._filename];

            if (sdb is null)
            {
                throw new LookupFailException($"File {this._filename} was never loaded");
            }

            var manager = sdb.Database.GetManager(this._manager);

            if (manager is null)
            {
                throw new LookupFailException($"Manager named {this._manager} does not exist");
            }

            manager.Static(this._property, this._value);
        }
 public TypeAssignmentCache()
 {
     _typesMap = new CollectionMap<Type, Type>();
     _typesCached = new List<Type>();
 }
 internal StorageStrategyPart(CollectionMap collectionMap)
 {
     _collectionMap = collectionMap;
 }