public void init(int quest)
        {
            this.btnOK.Text  = SK.Text("GENERIC_OK", "OK");
            this.label1.Text = SK.Text("QuestRewardPopup_Reward", "Reward") + " : ";
            this.Text        = base.Title = SK.Text("QuestRewardPopup_Quest_Reward", "Quest Reward");
            bool flag = false;
            List <Quests.QuestReward> list = Quests.getQuestRewards(quest, true, GameEngine.NFI);
            string str   = "";
            bool   flag2 = true;

            foreach (Quests.QuestReward reward in list)
            {
                if (!flag2)
                {
                    str = str + ", ";
                }
                else
                {
                    flag2 = false;
                }
                str = str + reward.explanation;
                if ((reward.type == 0x4e24) || (reward.type == 0x4e26))
                {
                    flag = true;
                }
            }
            this.lblReward.Text = str;
            int tutorialID = Tutorials.getQuestsTutorialStage(quest);

            if (tutorialID == -1)
            {
                this.lblInfo.Text = "";
            }
            else
            {
                this.lblInfo.Text = Tutorials.getTutorialRewardText(tutorialID);
            }
            if (flag)
            {
                PlayCardsWindow.resetRewardCardTimer();
            }
        }
Ejemplo n.º 2
0
        public void CompleteQuestCallback(CompleteQuest_ReturnType returnData)
        {
            if (returnData.Success)
            {
                GameEngine.Instance.World.setTutorialInfo(returnData.m_tutorialInfo);
                this.completedActiveQuests = returnData.m_preCompletedQuests;
                if (GameEngine.Instance.GameDisplayMode == GameEngine.GameDisplays.DISPLAY_QUESTS)
                {
                    this.rebuild();
                }
                if (returnData.questCompleted >= 0)
                {
                    List <Quests.QuestReward> list = Quests.getQuestRewards(returnData.questCompleted, false, null);
                    foreach (Quests.QuestReward reward in list)
                    {
                        List <int>             list2;
                        CardTypes.PremiumToken token;
                        switch (reward.type)
                        {
                        case 0x4e20:
                        {
                            list2 = GameEngine.Instance.World.getUserVillageIDList();
                            if (list2.Count == 1)
                            {
                                break;
                            }
                            GameEngine.Instance.flushVillages();
                            if (GameEngine.Instance.GameDisplayMode == GameEngine.GameDisplays.DISPLAY_VILLAGE)
                            {
                                GameEngine.Instance.downloadCurrentVillage();
                            }
                            continue;
                        }

                        case 0x4e21:
                        {
                            GameEngine.Instance.World.addGold((double)reward.amount);
                            continue;
                        }

                        case 0x4e22:
                        {
                            GameEngine.Instance.World.addHonour((double)reward.amount);
                            continue;
                        }

                        case 0x4e23:
                        {
                            GameEngine.Instance.World.addResearchPoints(reward.amount);
                            continue;
                        }

                        case 0x4e24:
                        {
                            if (returnData.cardAdded >= 0)
                            {
                                if (reward.data == 0x1011)
                                {
                                    goto Label_01D0;
                                }
                                GameEngine.Instance.World.addProfileCard(returnData.cardAdded, CardTypes.getStringFromCard(reward.data));
                            }
                            continue;
                        }

                        case 0x4e25:
                        {
                            continue;
                        }

                        case 0x4e26:
                        {
                            WorldMap world = GameEngine.Instance.World;
                            world.FakeCardPoints += reward.amount;
                            continue;
                        }

                        default:
                        {
                            continue;
                        }
                        }
                        if (list2.Count == 1)
                        {
                            VillageMap map = GameEngine.Instance.getVillage(list2[0]);
                            if (map != null)
                            {
                                map.addResources(reward.data, reward.amount);
                            }
                        }
                        continue;
Label_01D0:
                        token                    = new CardTypes.PremiumToken();
                        token.Reward             = 1;
                        token.UserPremiumTokenID = returnData.cardAdded;
                        token.WorldID            = RemoteServices.Instance.ProfileWorldID;
                        token.Type               = 0x1011;
                        bool flag = false;
                        if (GameEngine.Instance.World.UserCardData.premiumCard <= 0)
                        {
                            XmlRpcCardsProvider provider = XmlRpcCardsProvider.CreateForEndpoint(URLs.ProfileProtocol, URLs.ProfileServerAddressCards, URLs.ProfileServerPort, URLs.ProfileCardPath);
                            XmlRpcCardsRequest  req      = new XmlRpcCardsRequest(RemoteServices.Instance.UserGuid.ToString().Replace("-", ""))
                            {
                                WorldID    = RemoteServices.Instance.ProfileWorldID.ToString(),
                                UserCardID = returnData.cardAdded.ToString()
                            };
                            if (token.Type == 0x1010)
                            {
                                req.CardString = "CARDTYPE_PREMIUM";
                            }
                            if (token.Type == 0x1011)
                            {
                                req.CardString = "CARDTYPE_PREMIUM2";
                            }
                            if (token.Type == 0x1012)
                            {
                                req.CardString = "CARDTYPE_PREMIUM30";
                            }
                            XmlRpcCardsResponse response = provider.playPremium(req, 0x1770);
                            if (response.SuccessCode != 1)
                            {
                                flag = true;
                                MyMessageBox.Show(response.Message, "Error playing premium");
                            }
                            else
                            {
                                GameEngine.Instance.World.CardPlayed(-1, token.Type, -1);
                            }
                        }
                        else
                        {
                            flag = true;
                        }
                        if (flag)
                        {
                            GameEngine.Instance.World.ProfilePremiumTokens.Add(returnData.cardAdded, token);
                        }
                    }
                    bool flag2 = false;
                    foreach (Quests.QuestReward reward2 in list)
                    {
                        if ((reward2.type == 0x4e24) || (reward2.type == 0x4e26))
                        {
                            flag2 = true;
                        }
                    }
                    if (flag2)
                    {
                        PlayCardsWindow.resetRewardCardTimer();
                    }
                }
            }
            this.inCompleteQuest = false;
        }