示例#1
0
 protected override void PerformOfflineAction(OfflineDatabase offlineDatabase, IOfflineDefinitionLoader offlineDefinitions)
 {
     ResponseBody = new SignedResponse <QuestStateCollection>
     {
         Data = SetProgressOperation.GetQuestStateCollection(offlineDatabase.Read <QuestStates>(), offlineDefinitions, includeComplete: false)
     };
 }
示例#2
0
    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)
        {
            ResponseBody        = new LocalPlayerData();
            ResponseBody.member = true;
            ResponseBody.membershipExpireDate       = DateTime.UtcNow.AddMonths(1).GetTimeInMilliseconds();
            ResponseBody.trialAvailable             = false;
            ResponseBody.subscriptionPaymentPending = false;
            ResponseBody.id = new PlayerId
            {
                id   = offlineDatabase.AccessToken,
                type = PlayerId.PlayerIdType.SWID
            };
            ClubPenguin.Net.Offline.Profile profile = offlineDatabase.Read <ClubPenguin.Net.Offline.Profile>();
            ResponseBody.profile = new ClubPenguin.Net.Domain.Profile
            {
                colour  = profile.Colour,
                daysOld = profile.DaysOld
            };
            ResponseBody.outfit           = offlineDatabase.Read <ClubPenguin.Net.Offline.PlayerOutfitDetails>().Parts;
            ResponseBody.mascotXP         = offlineDatabase.Read <ClubPenguin.Net.Offline.PlayerAssets>().Assets.mascotXP;
            ResponseBody.minigameProgress = new List <MinigameProgress>();
            ResponseBody.quests           = SetProgressOperation.GetQuestStateCollection(offlineDatabase.Read <QuestStates>(), offlineDefinitions, includeComplete: true);
            ResponseBody.tutorialData     = new List <sbyte>(offlineDatabase.Read <TutorialData>().Bytes);
            List <Breadcrumb> list = new List <Breadcrumb>();

            foreach (Breadcrumb breadcrumb in offlineDatabase.Read <BreadcrumbCollection>().breadcrumbs)
            {
                list.Add(new Breadcrumb
                {
                    id             = breadcrumb.id,
                    breadcrumbType = breadcrumb.breadcrumbType
                });
            }
            ResponseBody.breadcrumbs = new BreadcrumbsResponse
            {
                breadcrumbs = list
            };
            RegistrationProfile registrationProfile = offlineDatabase.Read <RegistrationProfile>();

            ResponseBody.name = registrationProfile.displayName;
            if (string.IsNullOrEmpty(ResponseBody.name))
            {
                ResponseBody.name = registrationProfile.userName;
            }
            ResponseBody.claimedRewardIds = offlineDatabase.Read <ClaimableRewardData>().ClimedRewards;
            ZoneId zoneId = new ZoneId();

            zoneId.name       = "DefaultIgloo";
            zoneId.instanceId = registrationProfile.Id();
            ZoneId      zoneId2     = zoneId;
            IglooEntity iglooEntity = offlineDatabase.Read <IglooEntity>();

            if (iglooEntity.Data.activeLayout != null)
            {
                string zoneId3 = iglooEntity.Data.activeLayout.zoneId;
                if (!string.IsNullOrEmpty(zoneId3))
                {
                    zoneId2.name = zoneId3;
                }
            }
            ResponseBody.zoneId = zoneId2;
            List <SavedIglooLayoutSummary> list2 = new List <SavedIglooLayoutSummary>();

            foreach (SavedSceneLayout layout in offlineDatabase.Read <SceneLayoutEntity>().Layouts)
            {
                list2.Add(new SavedIglooLayoutSummary
                {
                    createdDate     = layout.createdDate.GetValueOrDefault(0L),
                    lastUpdatedDate = layout.lastModifiedDate.GetValueOrDefault(0L),
                    layoutId        = layout.layoutId,
                    lot             = layout.zoneId,
                    memberOnly      = layout.memberOnly,
                    name            = layout.name
                });
            }
            ResponseBody.iglooLayouts = new SavedIglooLayoutsSummary
            {
                activeLayoutId = iglooEntity.Data.activeLayoutId,
                activeLayoutServerChangeNotification = ActiveLayoutServerChangeNotification.NoServerChange,
                visibility = iglooEntity.Data.visibility.GetValueOrDefault(IglooVisibility.PRIVATE),
                layouts    = list2
            };
            ClubPenguin.Net.Offline.DailySpinData dailySpinData = offlineDatabase.Read <ClubPenguin.Net.Offline.DailySpinData>();
            ResponseBody.dailySpinData = new ClubPenguin.Net.Domain.DailySpinData
            {
                currentChestId = dailySpinData.CurrentChestId,
                numChestsReceivedOfCurrentChestId = dailySpinData.NumChestsReceivedOfCurrentChestId,
                numPunchesOnCurrentChest          = dailySpinData.NumPunchesOnCurrentChest,
                timeOfLastSpinInMilliseconds      = dailySpinData.TimeOfLastSpinInMilliseconds
            };
            ClubPenguin.Net.Offline.SessionData sessionData = offlineDatabase.Read <ClubPenguin.Net.Offline.SessionData>();
            if (sessionData.Data.sessionId != 0)
            {
                ResponseBody.onlineLocation = sessionData.CurrentRoom;
            }
        }
示例#4
0
    public static SignedResponse <JoinRoomData> JoinRoom(string world, string language, ZoneId zoneId, OfflineDatabase offlineDatabase, IOfflineDefinitionLoader offlineDefinitions)
    {
        Dictionary <string, long> earnedRewards = new Dictionary <string, long>();

        foreach (ClubPenguin.Net.Offline.InRoomRewards.InRoomReward item in offlineDatabase.Read <ClubPenguin.Net.Offline.InRoomRewards>().Collected)
        {
            ClubPenguin.Net.Offline.InRoomRewards.InRoomReward current = item;
            if (current.Room == zoneId.name)
            {
                earnedRewards = current.Collected;
                break;
            }
        }
        ClubPenguin.Net.Offline.Profile profile = offlineDatabase.Read <ClubPenguin.Net.Offline.Profile>();
        PlayerRoomData playerRoomData           = default(PlayerRoomData);

        playerRoomData.assets = offlineDatabase.Read <ClubPenguin.Net.Offline.PlayerAssets>().Assets;
        playerRoomData.consumableInventory = new ClubPenguin.Net.Domain.ConsumableInventory
        {
            inventoryMap = offlineDatabase.Read <ClubPenguin.Net.Offline.ConsumableInventory>().Inventory
        };
        playerRoomData.dailyTaskProgress = new TaskProgressList();
        playerRoomData.member            = true;
        playerRoomData.outfit            = new ClubPenguin.Net.Domain.PlayerOutfitDetails
        {
            parts = offlineDatabase.Read <ClubPenguin.Net.Offline.PlayerOutfitDetails>().Parts.ToArray()
        };
        playerRoomData.profile = new ClubPenguin.Net.Domain.Profile
        {
            colour  = profile.Colour,
            daysOld = profile.DaysOld
        };
        playerRoomData.quests = SetProgressOperation.GetQuestStateCollection(offlineDatabase.Read <QuestStates>(), offlineDefinitions, includeComplete: true);
        PlayerRoomData playerRoomData2 = playerRoomData;
        RoomIdentifier roomIdentifier  = new RoomIdentifier(world, LocalizationLanguage.GetLanguageFromLanguageString(language), zoneId, new ContentIdentifier("1.13.0", "offline", DateTime.UtcNow.ToString("yyyy-MM-dd"), "NONE").ToString());
        int            equippedTubeId  = offlineDatabase.Read <TubeData>().EquippedTubeId;
        Random         random          = new Random();

        byte[] array = new byte[8];
        random.NextBytes(array);
        SignedResponse <JoinRoomData> signedResponse = new SignedResponse <JoinRoomData>();

        signedResponse.Data = new JoinRoomData
        {
            earnedRewards    = earnedRewards,
            membershipRights = new MembershipRights
            {
                member = true
            },
            playerRoomData = playerRoomData2,
            room           = roomIdentifier.ToString(),
            selectedTubeId = equippedTubeId,
            sessionId      = Math.Abs(BitConverter.ToInt64(array, 0)),
            host           = Service.Get <ICommonGameSettings>().GameServerHost,
            tcpPort        = 9933,
            userName       = offlineDatabase.Read <RegistrationProfile>().userName,
            swid           = offlineDatabase.AccessToken
        };
        signedResponse.swid = offlineDatabase.AccessToken;
        return(signedResponse);
    }
示例#5
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);
    }