Пример #1
0
 protected override void PerformOfflineAction(OfflineDatabase offlineDatabase, IOfflineDefinitionLoader offlineDefinitions)
 {
     DecorationInventory       = new DecorationInventory();
     DecorationInventory.items = new List <DecorationInventoryItem>();
     foreach (KeyValuePair <string, int> item in offlineDatabase.Read <DecorationInventoryEntity>().inventory)
     {
         DecorationInventory.items.Add(new DecorationInventoryItem
         {
             decorationId = DecorationId.FromString(item.Key),
             count        = item.Value
         });
     }
 }
        protected override void SetOfflineData(OfflineDatabase offlineDatabase, IOfflineDefinitionLoader offlineDefinitions)
        {
            ClaimDailySpinRewardResponse responseBody = new ClaimDailySpinRewardResponse();

            if (ResponseBody.reward != null)
            {
                offlineDefinitions.AddReward(ResponseBody.reward.ToReward(), responseBody);
            }
            if (ResponseBody.chestReward != null)
            {
                offlineDefinitions.AddReward(ResponseBody.chestReward.ToReward(), responseBody);
            }
        }
        protected override void PerformOfflineAction(OfflineDatabase offlineDatabase, IOfflineDefinitionLoader offlineDefinitions)
        {
            int partialCount = updateInventory(offlineDatabase);

            SignedUsedConsumable = new SignedResponse <UsedConsumable>
            {
                Data = new UsedConsumable
                {
                    partialCount = partialCount,
                    type         = Type
                }
            };
        }
        protected override void PerformOfflineAction(OfflineDatabase offlineDatabase, IOfflineDefinitionLoader offlineDefinitions)
        {
            ClubPenguin.Net.Offline.PlayerAssets value = offlineDatabase.Read <ClubPenguin.Net.Offline.PlayerAssets>();
            int coinsForExchange = offlineDefinitions.GetCoinsForExchange(value.Assets.collectibleCurrencies);

            value.Assets.coins += coinsForExchange;
            value.Assets.collectibleCurrencies.Clear();
            offlineDatabase.Write(value);
            ResponseBody = new RewardGrantedResponse
            {
                assets = value.Assets
            };
        }
        protected override void SetOfflineData(OfflineDatabase offlineDatabase, IOfflineDefinitionLoader offlineDefinitions)
        {
            SceneLayoutEntity value = offlineDatabase.Read <SceneLayoutEntity>();

            if (value.Layouts.Count == 0)
            {
                IglooEntity value2 = offlineDatabase.Read <IglooEntity>();
                value2.Data.activeLayout   = ResponseBody;
                value2.Data.activeLayoutId = ResponseBody.layoutId;
                offlineDatabase.Write(value2);
            }
            value.Layouts.Add(ResponseBody);
            offlineDatabase.Write(value);
        }
        public static void AddDecoration(DecorationId decoration, int count, OfflineDatabase offlineDatabase)
        {
            DecorationInventoryEntity value = offlineDatabase.Read <DecorationInventoryEntity>();

            if (value.Inventory.ContainsKey(decoration))
            {
                value.Inventory[decoration] += count;
            }
            else
            {
                value.Inventory[decoration] = count;
            }
            offlineDatabase.Write(value);
        }
        protected override void SetOfflineData(OfflineDatabase offlineDatabase, IOfflineDefinitionLoader offlineDefinitions)
        {
            CustomEquipmentCollection value = offlineDatabase.Read <CustomEquipmentCollection>();

            foreach (CustomEquipment item in value.Equipment)
            {
                if (item.equipmentId == EquipmentId)
                {
                    value.Equipment.Remove(item);
                    break;
                }
            }
            offlineDatabase.Write(value);
        }
 protected override void PerformOfflineAction(OfflineDatabase offlineDatabase, IOfflineDefinitionLoader offlineDefinitions)
 {
     ClubPenguin.Net.Offline.DailySpinData value = offlineDatabase.Read <ClubPenguin.Net.Offline.DailySpinData>();
     value.CurrentChestId                    = requestBody.CurrentChestId;
     value.NumPunchesOnCurrentChest          = requestBody.NumPunchesOnCurrentChest;
     value.NumChestsReceivedOfCurrentChestId = requestBody.NumChestsReceivedOfCurrentChestId;
     value.TimeOfLastSpinInMilliseconds      = requestBody.TimeOfLastSpinInMilliseconds;
     if (requestBody.ResetRewards)
     {
         value.EarnedNonRepeatableRewardIds.Clear();
         value.EarnedRepeatableRewardIds.Clear();
     }
     offlineDatabase.Write(value);
 }
Пример #9
0
        protected override void PerformOfflineAction(OfflineDatabase offlineDatabase, IOfflineDefinitionLoader offlineDefinitions)
        {
            TubeData value = offlineDatabase.Read <TubeData>();

            value.EquippedTubeId = TubeId;
            offlineDatabase.Write(value);
            SignedEquipTubeResponse = new SignedResponse <EquipTubeResponse>
            {
                Data = new EquipTubeResponse
                {
                    tubeId = TubeId
                }
            };
        }
Пример #10
0
        protected override void PerformOfflineAction(OfflineDatabase offlineDatabase, IOfflineDefinitionLoader offlineDefinitions)
        {
            SceneLayoutEntity value = offlineDatabase.Read <SceneLayoutEntity>();

            for (int i = 0; i < value.Layouts.Count; i++)
            {
                if (value.Layouts[i].layoutId == SceneLayoutId)
                {
                    value.Layouts.RemoveAt(i);
                    break;
                }
            }
            offlineDatabase.Write(value);
        }
        protected override void PerformOfflineAction(OfflineDatabase offlineDatabase, IOfflineDefinitionLoader offlineDefinitions)
        {
            ResponseBody = new ClaimDailySpinRewardResponse();
            Reward reward     = new Reward();
            Reward reward2    = new Reward();
            int    spinResult = offlineDefinitions.GetSpinResult(reward, reward2);

            offlineDefinitions.AddReward(reward, ResponseBody);
            offlineDefinitions.AddReward(reward2, ResponseBody);
            JsonService jsonService = Service.Get <JsonService>();

            ResponseBody.spinOutcomeId = spinResult;
            ResponseBody.reward        = jsonService.Deserialize <RewardJsonReader>(jsonService.Serialize(RewardJsonWritter.FromReward(reward)));
            ResponseBody.chestReward   = jsonService.Deserialize <RewardJsonReader>(jsonService.Serialize(RewardJsonWritter.FromReward(reward2)));
        }
        protected override void PerformOfflineAction(OfflineDatabase offlineDatabase, IOfflineDefinitionLoader offlineDefinitions)
        {
            Random random = new Random();

            byte[] array = new byte[8];
            random.NextBytes(array);
            long equipmentId = BitConverter.ToInt64(array, 0);

            createEquipment(equipmentId, offlineDatabase, offlineDefinitions);
            CustomEquipmentResponse = new CreateEquipmentResponse
            {
                assets      = offlineDatabase.Read <ClubPenguin.Net.Offline.PlayerAssets>().Assets,
                equipmentId = equipmentId
            };
        }
        private void createEquipment(long equipmentId, OfflineDatabase offlineDatabase, IOfflineDefinitionLoader offlineDefinitions)
        {
            CustomEquipmentCollection value           = offlineDatabase.Read <CustomEquipmentCollection>();
            CustomEquipment           customEquipment = default(CustomEquipment);

            customEquipment.dateTimeCreated = DateTime.UtcNow.GetTimeInMilliseconds();
            customEquipment.definitionId    = CustomEquipmentRequest.definitionId;
            customEquipment.equipmentId     = equipmentId;
            customEquipment.parts           = CustomEquipmentRequest.parts;
            CustomEquipment item = customEquipment;

            value.Equipment.Add(item);
            offlineDefinitions.SubtractEquipmentCost(item.definitionId);
            offlineDatabase.Write(value);
        }
Пример #14
0
        protected override void SetOfflineData(OfflineDatabase offlineDatabase, IOfflineDefinitionLoader offlineDefinitions)
        {
            TutorialData value = offlineDatabase.Read <TutorialData>();

            for (int i = 0; i < value.Bytes.Length; i++)
            {
                sbyte b = 0;
                if (i < TutorialResponse.tutorialBytes.Count)
                {
                    b = TutorialResponse.tutorialBytes[i];
                }
                value.Bytes[i] = b;
            }
            offlineDatabase.Write(value);
        }
 protected override void PerformOfflineAction(OfflineDatabase offlineDatabase, IOfflineDefinitionLoader offlineDefinitions)
 {
     ClubPenguin.Net.Offline.ConsumableInventory value = offlineDatabase.Read <ClubPenguin.Net.Offline.ConsumableInventory>();
     if (!value.Inventory.ContainsKey(Partial.Data.type))
     {
         value.Inventory[Partial.Data.type] = new InventoryItemStock();
     }
     value.Inventory[Partial.Data.type].partialCount = Partial.Data.partialCount;
     offlineDatabase.Write(value);
     SignedConsumableInventory = new SignedResponse <ClubPenguin.Net.Domain.ConsumableInventory>
     {
         Data = new ClubPenguin.Net.Domain.ConsumableInventory
         {
             inventoryMap = value.Inventory
         }
     };
 }
        protected override void PerformOfflineAction(OfflineDatabase offlineDatabase, IOfflineDefinitionLoader offlineDefinitions)
        {
            QuestStates questStates = offlineDatabase.Read <QuestStates>();

            for (int i = 0; i < questStates.Quests.Count; i++)
            {
                if (questStates.Quests[i].questId == QuestId)
                {
                    questStates.Quests.RemoveAt(i);
                    break;
                }
            }
            offlineDatabase.Write(questStates);
            ResponseBody = new SignedResponse <QuestStateCollection>
            {
                Data = SetProgressOperation.GetQuestStateCollection(questStates, offlineDefinitions, includeComplete: false)
            };
        }
 protected override void PerformOfflineAction(OfflineDatabase offlineDatabase, IOfflineDefinitionLoader offlineDefinitions)
 {
     ClubPenguin.Net.Offline.ConsumableInventory value = offlineDatabase.Read <ClubPenguin.Net.Offline.ConsumableInventory>();
     if (!value.Inventory.ContainsKey(Type))
     {
         value.Inventory[Type] = new InventoryItemStock();
     }
     value.Inventory[Type].itemCount             = int.Parse(Count);
     value.Inventory[Type].lastPurchaseTimestamp = DateTime.UtcNow.GetTimeInMilliseconds();
     offlineDatabase.Write(value);
     SignedConsumableInventory = new SignedResponse <ClubPenguin.Net.Domain.ConsumableInventory>
     {
         Data = new ClubPenguin.Net.Domain.ConsumableInventory
         {
             inventoryMap = value.Inventory
         }
     };
 }
Пример #18
0
        protected override void SetOfflineData(OfflineDatabase offlineDatabase, IOfflineDefinitionLoader offlineDefinitions)
        {
            ClubPenguin.Net.Offline.PlayerAssets value = offlineDatabase.Read <ClubPenguin.Net.Offline.PlayerAssets>();
            value.Assets = Response.assets;
            offlineDatabase.Write(value);
            DecorationInventoryEntity value2     = offlineDatabase.Read <DecorationInventoryEntity>();
            Dictionary <string, int>  dictionary = new Dictionary <string, int>();

            foreach (DecorationInventoryItem item in Response.decorationInventory.Data.items)
            {
                dictionary.Add(item.decorationId.ToString(), item.count);
            }
            value2.inventory = dictionary;
            offlineDatabase.Write(value2);
            ClubPenguin.Net.Offline.ConsumableInventory value3 = offlineDatabase.Read <ClubPenguin.Net.Offline.ConsumableInventory>();
            value3.Inventory = Response.inventory.Data.inventoryMap;
            offlineDatabase.Write(value3);
        }
        protected override void PerformOfflineAction(OfflineDatabase offlineDatabase, IOfflineDefinitionLoader offlineDefinitions)
        {
            SceneLayoutEntity value = offlineDatabase.Read <SceneLayoutEntity>();
            int    count            = value.Layouts.Count;
            Random random           = new Random();

            byte[] array = new byte[8];
            random.NextBytes(array);
            SavedSceneLayout savedSceneLayout = new SavedSceneLayout();

            savedSceneLayout.createdDate       = DateTime.UtcNow.GetTimeInMilliseconds();
            savedSceneLayout.decorationsLayout = RequestBody.decorationsLayout;
            savedSceneLayout.extraInfo         = RequestBody.extraInfo;
            savedSceneLayout.lastModifiedDate  = DateTime.UtcNow.GetTimeInMilliseconds();
            savedSceneLayout.layoutId          = BitConverter.ToInt64(array, 0);
            savedSceneLayout.lightingId        = RequestBody.lightingId;
            savedSceneLayout.memberOnly        = true;
            savedSceneLayout.musicId           = RequestBody.musicId;
            savedSceneLayout.name   = RequestBody.name;
            savedSceneLayout.zoneId = RequestBody.zoneId;
            SavedSceneLayout savedSceneLayout2 = savedSceneLayout;

            if (savedSceneLayout2.decorationsLayout == null)
            {
                savedSceneLayout2.decorationsLayout = new List <DecorationLayout>();
            }
            if (savedSceneLayout2.extraInfo == null)
            {
                savedSceneLayout2.extraInfo = new Dictionary <string, string>();
            }
            if (count == 0)
            {
                IglooEntity value2 = offlineDatabase.Read <IglooEntity>();
                value2.Data.activeLayout   = savedSceneLayout2;
                value2.Data.activeLayoutId = savedSceneLayout2.layoutId;
                offlineDatabase.Write(value2);
            }
            value.Layouts.Add(savedSceneLayout2);
            offlineDatabase.Write(value);
            ResponseBody = savedSceneLayout2;
        }
        protected override void SetOfflineData(OfflineDatabase offlineDatabase, IOfflineDefinitionLoader offlineDefinitions)
        {
            TubeData value = offlineDatabase.Read <TubeData>();

            value.EquippedTubeId = SignedJoinRoomData.Data.selectedTubeId;
            offlineDatabase.Write(value);
            ClubPenguin.Net.Offline.ConsumableInventory value2 = offlineDatabase.Read <ClubPenguin.Net.Offline.ConsumableInventory>();
            value2.Inventory = SignedJoinRoomData.Data.playerRoomData.consumableInventory.inventoryMap;
            offlineDatabase.Write(value2);
            ClubPenguin.Net.Offline.PlayerAssets value3 = offlineDatabase.Read <ClubPenguin.Net.Offline.PlayerAssets>();
            value3.Assets = SignedJoinRoomData.Data.playerRoomData.assets;
            offlineDatabase.Write(value3);
            ClubPenguin.Net.Offline.PlayerOutfitDetails value4 = offlineDatabase.Read <ClubPenguin.Net.Offline.PlayerOutfitDetails>();
            value4.Parts = new List <CustomEquipment>(SignedJoinRoomData.Data.playerRoomData.outfit.parts);
            offlineDatabase.Write(value4);
            ClubPenguin.Net.Offline.Profile value5 = offlineDatabase.Read <ClubPenguin.Net.Offline.Profile>();
            value5.Colour      = SignedJoinRoomData.Data.playerRoomData.profile.colour;
            value5.DateCreated = DateTime.UtcNow.AddDays(-1 * SignedJoinRoomData.Data.playerRoomData.profile.daysOld).GetTimeInMilliseconds();
            offlineDatabase.Write(value5);
            SetProgressOperation.SetOfflineQuestStateCollection(offlineDatabase, SignedJoinRoomData.Data.playerRoomData.quests);
        }
Пример #21
0
        protected override void PerformOfflineAction(OfflineDatabase offlineDatabase, IOfflineDefinitionLoader offlineDefinitions)
        {
            TutorialData value = offlineDatabase.Read <TutorialData>();

            byte[] array = new byte[value.Bytes.Length];
            for (int i = 0; i < array.Length; i++)
            {
                array[i] = (byte)value.Bytes[i];
            }
            BitArray bitArray = new BitArray(array);

            bitArray.Set(Tutorial.tutorialID, Tutorial.isComplete);
            bitArray.CopyTo(array, 0);
            for (int i = 0; i < array.Length; i++)
            {
                value.Bytes[i] = (sbyte)array[i];
            }
            offlineDatabase.Write(value);
            TutorialResponse = new TutorialResponse
            {
                tutorialBytes = new List <sbyte>(value.Bytes)
            };
        }
        protected override void PerformOfflineAction(OfflineDatabase offlineDatabase, IOfflineDefinitionLoader offlineDefinitions)
        {
            IglooEntity value = offlineDatabase.Read <IglooEntity>();

            if (RequestBody.visibility.HasValue)
            {
                value.Data.visibility = RequestBody.visibility;
            }
            if (RequestBody.activeLayoutId.HasValue)
            {
                SceneLayoutEntity sceneLayoutEntity = offlineDatabase.Read <SceneLayoutEntity>();
                if (sceneLayoutEntity[RequestBody.activeLayoutId.Value] != null)
                {
                    value.Data.activeLayout   = sceneLayoutEntity[RequestBody.activeLayoutId.Value];
                    value.Data.activeLayoutId = RequestBody.activeLayoutId;
                }
            }
            offlineDatabase.Write(value);
            SignedResponseBody = new SignedResponse <IglooData>
            {
                Data = value.Data
            };
        }
Пример #23
0
        public static void SetOfflineQuestStateCollection(OfflineDatabase offlineDatabase, QuestStateCollection quests)
        {
            QuestStates value = offlineDatabase.Read <QuestStates>();

            foreach (QuestState quest in quests)
            {
                bool flag = false;
                foreach (QuestStates.QuestState quest2 in value.Quests)
                {
                    if (quest2.questId == quest.questId)
                    {
                        quest2.completedObjectives = quest.completedObjectives;
                        quest2.unlockTime          = quest.unlockTime;
                        quest2.status         = quest.status;
                        quest2.timesCompleted = quest.timesCompleted;
                        flag = true;
                        break;
                    }
                }
                if (!flag)
                {
                    QuestStates.QuestState questState = new QuestStates.QuestState();
                    questState.questId             = quest.questId;
                    questState.completedObjectives = quest.completedObjectives;
                    questState.timesCompleted      = quest.timesCompleted;
                    questState.status     = quest.status;
                    questState.unlockTime = quest.unlockTime;
                    QuestStates.QuestState current2 = questState;
                    if (current2.status == QuestStatus.COMPLETED)
                    {
                        current2.completedTime = DateTime.UtcNow;
                    }
                    value.Quests.Add(current2);
                }
            }
            offlineDatabase.Write(value);
        }
Пример #24
0
        protected override void PerformOfflineAction(OfflineDatabase offlineDatabase, IOfflineDefinitionLoader offlineDefinitions)
        {
            string world = "Igloo";

            switch (LocalizationLanguage.GetLanguageFromLanguageString(Language))
            {
            case DevonLocalization.Core.Language.es_LA:
                world = "Iglú";
                break;

            case DevonLocalization.Core.Language.fr_FR:
                world = "Iglou";
                break;

            case DevonLocalization.Core.Language.pt_BR:
                world = "Iglu";
                break;
            }
            SignedJoinRoomData = PostRoomPlayersOperation.JoinRoom(world, Language, IglooId, offlineDatabase, offlineDefinitions);
            SignedJoinRoomData.Data.extraLayoutData = offlineDatabase.Read <IglooEntity>().Data.activeLayout;
            if (SignedJoinRoomData.Data.extraLayoutData == null)
            {
                SignedJoinRoomData.Data.extraLayoutData = new SceneLayout
                {
                    zoneId = IglooId.name
                };
            }
            RegistrationProfile registrationProfile = offlineDatabase.Read <RegistrationProfile>();

            SignedJoinRoomData.Data.roomOwnerName = registrationProfile.displayName;
            if (string.IsNullOrEmpty(SignedJoinRoomData.Data.roomOwnerName))
            {
                SignedJoinRoomData.Data.roomOwnerName = registrationProfile.userName;
            }
            SignedJoinRoomData.Data.roomOwner = true;
        }
        private int updateInventory(OfflineDatabase offlineDatabase)
        {
            ClubPenguin.Net.Offline.ConsumableInventory value = offlineDatabase.Read <ClubPenguin.Net.Offline.ConsumableInventory>();
            if (!value.Inventory.ContainsKey(Type))
            {
                value.Inventory[Type] = new InventoryItemStock();
            }
            int partialCount = value.Inventory[Type].partialCount;

            if (partialCount > 0)
            {
                value.Inventory[Type].partialCount = 0;
            }
            else
            {
                value.Inventory[Type].itemCount--;
                if (value.Inventory[Type].itemCount <= 0)
                {
                    value.Inventory.Remove(Type);
                }
            }
            offlineDatabase.Write(value);
            return(partialCount);
        }
Пример #26
0
 protected override void PerformOfflineAction(OfflineDatabase offlineDatabase, IOfflineDefinitionLoader offlineDefinitions)
 {
     throw new NotImplementedException();
 }
Пример #27
0
 protected override void PerformOfflineAction(OfflineDatabase offlineDatabase, IOfflineDefinitionLoader offlineDefinitions)
 {
     IglooListItems = new List <IglooListItem>();
 }
Пример #28
0
        public static QuestChangeResponse SetStatus(QuestStatus status, string questId, OfflineDatabase offlineDatabase, IOfflineDefinitionLoader offlineDefinitions)
        {
            QuestChangeResponse questChangeResponse = new QuestChangeResponse();
            QuestStates         questStates         = offlineDatabase.Read <QuestStates>();

            QuestStates.QuestState questState = null;
            int num = -1;

            for (int i = 0; i < questStates.Quests.Count; i++)
            {
                if (questStates.Quests[i].questId == questId)
                {
                    questState = questStates.Quests[i];
                    num        = i;
                    break;
                }
            }
            QuestRewardsCollection questRewardsCollection = offlineDefinitions.QuestRewards(questId);
            Reward reward = null;

            if (questState == null)
            {
                reward = questRewardsCollection.StartReward;
                if (reward != null)
                {
                    if (reward.isEmpty())
                    {
                        reward = null;
                    }
                    else
                    {
                        offlineDefinitions.AddReward(reward, questChangeResponse);
                    }
                }
                questState         = new QuestStates.QuestState();
                questState.questId = questId;
            }
            if (status == QuestStatus.ACTIVE)
            {
                for (int i = 0; i < questStates.Quests.Count; i++)
                {
                    if (questStates.Quests[i].status == QuestStatus.ACTIVE)
                    {
                        questStates.Quests[i].status = QuestStatus.SUSPENDED;
                    }
                }
                if (questState.status == QuestStatus.COMPLETED)
                {
                    questState.completedObjectives.Clear();
                }
            }
            if (status == QuestStatus.COMPLETED)
            {
                int timesCompleted = questState.timesCompleted;
                if (timesCompleted == 0)
                {
                    questState.completedTime = DateTime.UtcNow;
                    reward = questRewardsCollection.CompleteReward;
                    if (reward != null)
                    {
                        if (reward.isEmpty())
                        {
                            reward = null;
                        }
                        else
                        {
                            offlineDefinitions.AddReward(reward, questChangeResponse);
                        }
                    }
                }
                questState.timesCompleted = timesCompleted + 1;
            }
            questState.status = status;
            if (num >= 0)
            {
                questStates.Quests[num] = questState;
            }
            else
            {
                questStates.Quests.Add(questState);
            }
            offlineDatabase.Write(questStates);
            JsonService jsonService = Service.Get <JsonService>();

            if (reward != null)
            {
                questChangeResponse.reward = jsonService.Deserialize <RewardJsonReader>(jsonService.Serialize(RewardJsonWritter.FromReward(reward)));
            }
            questChangeResponse.questId = questId;
            questChangeResponse.questStateCollection = new SignedResponse <QuestStateCollection>
            {
                Data = SetProgressOperation.GetQuestStateCollection(questStates, offlineDefinitions, includeComplete: false)
            };
            return(questChangeResponse);
        }
Пример #29
0
 protected override void SetOfflineData(OfflineDatabase offlineDatabase, IOfflineDefinitionLoader offlineDefinitions)
 {
     PerformOfflineAction(offlineDatabase, offlineDefinitions);
 }
Пример #30
0
        protected override void PerformOfflineAction(OfflineDatabase offlineDatabase, IOfflineDefinitionLoader offlineDefinitions)
        {
            QuestStatus status = (QuestStatus)Enum.Parse(typeof(QuestStatus), RequestBody);

            ResponseBody = SetStatus(status, QuestId, offlineDatabase, offlineDefinitions);
        }