Ejemplo n.º 1
0
 private static void addChestReward(Reward chestReward, CellPhoneDailySpinActivityDefinition dailySpinDefinition, ClubPenguin.Net.Offline.DailySpinData dailySpinData, CellPhoneDailySpinActivityDefinition.ChestDefinition chestDefinition)
 {
     if (dailySpinData.NumChestsReceivedOfCurrentChestId == 0)
     {
         chestReward.AddReward(getRepeatableChestReward(dailySpinData, chestDefinition).Reward.ToReward());
         chestReward.AddReward(chestDefinition.FirstTimeClaimedReward.ToReward());
     }
     else
     {
         chestReward.AddReward(getRepeatableChestReward(dailySpinData, chestDefinition).Reward.ToReward());
         chestReward.AddReward(getNonRepeatableChestReward(dailySpinData, chestDefinition).Reward.ToReward());
     }
 }
Ejemplo n.º 2
0
        public Reward GetInRoomReward(List <string> newRewards)
        {
            Reward reward = new Reward();

            foreach (string newReward in newRewards)
            {
                GameObject gameObject = GameObject.Find(newReward);
                if (!(gameObject != null))
                {
                    continue;
                }
                Collectible[] array = gameObject.GetComponents <Collectible>();
                if (array.Length == 0)
                {
                    ShakeCollectible componentInParent = gameObject.GetComponentInParent <ShakeCollectible>();
                    if (componentInParent == null)
                    {
                        continue;
                    }
                    SceneryCollectible[] array2 = UnityEngine.Object.FindObjectsOfType <SceneryCollectible>();
                    List <Collectible>   list   = new List <Collectible>();
                    SceneryCollectible[] array3 = array2;
                    foreach (SceneryCollectible sceneryCollectible in array3)
                    {
                        if (sceneryCollectible.originalParent == componentInParent.transform)
                        {
                            list.Add(sceneryCollectible);
                        }
                    }
                    array = list.ToArray();
                }
                Collectible[] array4 = array;
                foreach (Collectible collectible in array4)
                {
                    RewardDefinition rewardDef = collectible.RewardDef;
                    if (rewardDef != null)
                    {
                        reward.AddReward(rewardDef.ToReward());
                    }
                }
            }
            return(reward);
        }
    private static int addWeightedRandomSpinReward(Reward spinReward, CellPhoneDailySpinActivityDefinition dailySpinDefinition, ClubPenguin.Net.Offline.DailySpinData dailySpinData, CellPhoneDailySpinActivityDefinition.ChestDefinition chestDefinition)
    {
        int num = 0;
        List <KeyValuePair <int, int> > list       = new List <KeyValuePair <int, int> >();
        Dictionary <int, Reward>        dictionary = new Dictionary <int, Reward>();
        int num2 = dailySpinDefinition.InitialRespinWeight + dailySpinDefinition.RespinWeightIncreasePerSpin * dailySpinData.NumSpinsSinceReceivedExtraSpin;

        dictionary.Add(dailySpinDefinition.RespinSpinOutcomeId, dailySpinDefinition.RespinReward.ToReward());
        list.Add(new KeyValuePair <int, int>(dailySpinDefinition.RespinSpinOutcomeId, num2));
        num += num2;
        if (isChestValidSpinReward(dailySpinData, chestDefinition))
        {
            int num3 = dailySpinDefinition.InitialChestWeight + dailySpinDefinition.ChestWeightIncreasePerSpin * dailySpinData.NumSpinsSinceReceivedChest;
            dictionary.Add(dailySpinDefinition.ChestSpinOutcomeId, new Reward());
            list.Add(new KeyValuePair <int, int>(dailySpinDefinition.ChestSpinOutcomeId, num3));
            num += num3;
        }
        foreach (CellPhoneDailySpinActivityDefinition.SpinReward spinReward2 in dailySpinDefinition.SpinRewards)
        {
            CellPhoneDailySpinActivityDefinition.SpinReward current = spinReward2;
            dictionary.Add(current.SpinOutcomeId, current.Reward.ToReward());
            list.Add(new KeyValuePair <int, int>(current.SpinOutcomeId, current.Weight));
            num += current.Weight;
        }
        int num4 = UnityEngine.Random.Range(0, num);
        int num5 = 0;

        foreach (KeyValuePair <int, int> item in list)
        {
            num5 += item.Value;
            if (num5 > num4)
            {
                spinReward.AddReward(dictionary[item.Key]);
                return(item.Key);
            }
        }
        return(-1);
    }
Ejemplo n.º 4
0
        public int GetSpinResult(Reward spinReward, Reward chestReward)
        {
            CellPhoneDailySpinActivityDefinition widgetData = ClubPenguin.Core.SceneRefs.Get <CellPhoneActivityScreenDailySpinWidget>().WidgetData;

            ClubPenguin.Net.Offline.DailySpinData dailySpinData = offlineDatabase.Read <ClubPenguin.Net.Offline.DailySpinData>();
            bool flag = dailySpinData.CurrentChestId == 0 && dailySpinData.NumPunchesOnCurrentChest == 0 && dailySpinData.NumChestsReceivedOfCurrentChestId == 0;

            CellPhoneDailySpinActivityDefinition.ChestDefinition chestDefinition = getChestDefinitionForId(dailySpinData.CurrentChestId, widgetData) ?? default(CellPhoneDailySpinActivityDefinition.ChestDefinition);
            dailySpinData.NumPunchesOnCurrentChest++;
            int num = -1;

            if (dailySpinData.NumPunchesOnCurrentChest >= chestDefinition.NumPunchesPerChest)
            {
                addChestReward(chestReward, widgetData, dailySpinData, chestDefinition);
            }
            if (flag && !widgetData.FirstTimeSpinReward.Reward.ToReward().isEmpty())
            {
                num = widgetData.FirstTimeSpinReward.SpinOutcomeId;
                spinReward.AddReward(widgetData.FirstTimeSpinReward.Reward.ToReward());
            }
            else
            {
                num = addWeightedRandomSpinReward(spinReward, widgetData, dailySpinData, chestDefinition);
            }
            if (num == widgetData.ChestSpinOutcomeId)
            {
                dailySpinData.NumSpinsSinceReceivedChest = 0;
                dailySpinData.NumSpinsSinceReceivedExtraSpin++;
                addChestReward(spinReward, widgetData, dailySpinData, chestDefinition);
            }
            else if (num == widgetData.RespinSpinOutcomeId)
            {
                dailySpinData.NumSpinsSinceReceivedExtraSpin = 0;
                if (isChestValidSpinReward(dailySpinData, chestDefinition))
                {
                    dailySpinData.NumSpinsSinceReceivedChest++;
                }
            }
            else
            {
                dailySpinData.NumSpinsSinceReceivedExtraSpin++;
                if (isChestValidSpinReward(dailySpinData, chestDefinition))
                {
                    dailySpinData.NumSpinsSinceReceivedChest++;
                }
            }
            if (num == widgetData.ChestSpinOutcomeId || !chestReward.isEmpty())
            {
                dailySpinData.NumChestsReceivedOfCurrentChestId++;
                dailySpinData.NumPunchesOnCurrentChest = 0;
                if (dailySpinData.NumChestsReceivedOfCurrentChestId >= chestDefinition.NumChestsToNextLevel)
                {
                    CellPhoneDailySpinActivityDefinition.ChestDefinition?chestDefinitionForId = getChestDefinitionForId(chestDefinition.ChestId + 1, widgetData);
                    if (chestDefinitionForId.HasValue)
                    {
                        dailySpinData.CurrentChestId = chestDefinitionForId.Value.ChestId;
                        dailySpinData.NumChestsReceivedOfCurrentChestId = 0;
                    }
                }
            }
            if (spinReward.TryGetValue <MascotXPReward>(out var rewardable))
            {
                bool flag2 = false;
                ProgressionService progressionService = Service.Get <ProgressionService>();
                foreach (KeyValuePair <string, int> item in rewardable.XP)
                {
                    if (progressionService.IsMascotMaxLevel(item.Key))
                    {
                        flag2 = true;
                        break;
                    }
                }
                if (flag2)
                {
                    rewardable.XP.Clear();
                    spinReward.AddReward(widgetData.DefaultReward.ToReward());
                }
            }
            if (num != widgetData.RespinSpinOutcomeId)
            {
                dailySpinData.TimeOfLastSpinInMilliseconds = DateTime.UtcNow.GetTimeInMilliseconds();
            }
            offlineDatabase.Write(dailySpinData);
            return(num);
        }