protected override void PerformOfflineAction(OfflineDatabase offlineDatabase, IOfflineDefinitionLoader offlineDefinitions) { ResponseBody = new SignedResponse <QuestStateCollection> { Data = SetProgressOperation.GetQuestStateCollection(offlineDatabase.Read <QuestStates>(), offlineDefinitions, includeComplete: false) }; }
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) { if (item.Room == zoneId.name) { earnedRewards = item.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); }
protected override void SetOfflineData(OfflineDatabase offlineDatabase, IOfflineDefinitionLoader offlineDefinitions) { QuestChangeResponse responseBody = new QuestChangeResponse(); if (ResponseBody.reward != null) { offlineDefinitions.AddReward(ResponseBody.reward.ToReward(), responseBody); } SetProgressOperation.SetOfflineQuestStateCollection(offlineDatabase, ResponseBody.questStateCollection.Data); }
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 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); }
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); }
protected override void SetOfflineData(OfflineDatabase offlineDatabase, IOfflineDefinitionLoader offlineDefinitions) { SetProgressOperation.SetOfflineQuestStateCollection(offlineDatabase, ResponseBody.Data); }
protected override void PerformOfflineAction(OfflineDatabase offlineDatabase, IOfflineDefinitionLoader offlineDefinitions) { ResponseBody = SetProgressOperation.SetProgress(RequestBody, offlineDatabase, offlineDefinitions); }
public APICall <SetProgressOperation> SetProgress(SignedResponse <QuestObjectives> objectives) { SetProgressOperation operation = new SetProgressOperation(objectives); return(new APICall <SetProgressOperation>(clubPenguinClient, operation)); }