예제 #1
0
        string RequirmentContext(QuestRequirement qr)
        {
            string str = "";

            switch (qr.TheType)
            {
            case QuestRequirement.Type.Level:
            case QuestRequirement.Type.Fame:
            case QuestRequirement.Type.Item:
                str = qr.Context.ToString();
                break;

            case QuestRequirement.Type.Race:
                str = qr.Context == 0 ? "Millena" : "Rain";
                break;

            case QuestRequirement.Type.Gender:
                str = qr.Context == 0 ? "Male" : "Female";
                break;

            case QuestRequirement.Type.Job:
                str = Program.s_jobs.ContainsKey((int)qr.Context) ?  Program.s_jobs[(int)qr.Context].ToString() : "unknown";
                break;
            }
            return(str);
        }
예제 #2
0
 public void DeleteRequirement(QuestRequirement qr)
 {
     Requirements.Remove(qr);
     if (!qr.New)
     {
         DeletedReqs.Add(qr);
     }
 }
예제 #3
0
        private void cbRequirementType_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lvRequirements.SelectedItems.Count > 0)
            {
                ListViewItem     lvi = lvRequirements.SelectedItems[0];
                QuestRequirement qr  = (QuestRequirement)lvi.Tag;

                qr.TheType           = (QuestRequirement.Type)cbRequirementType.SelectedIndex;
                lvi.SubItems[1].Text = RequirmentContext(qr);
                lvi.Text             = qr.TheType.ToString();
                SelectContext(qr);
                SetDirty(true);
            }
        }
예제 #4
0
        void SelectContext(QuestRequirement qr)
        {
            tbRequirementParam.Enabled = false;
            cbReqParam.Visible         = false;
            switch (qr.TheType)
            {
            case QuestRequirement.Type.Level:
                tbRequirementParam.Text    = qr.Context.ToString();
                tbRequirementParam.Enabled = true;
                break;

            case QuestRequirement.Type.Race:
                cbReqParam.Visible = true;
                cbReqParam.Items.Clear();
                cbReqParam.Items.Add("Millena");
                cbReqParam.Items.Add("Rain");
                cbReqParam.SelectedIndex = (int)qr.Context;
                break;

            case QuestRequirement.Type.Gender:
                cbReqParam.Visible = true;
                cbReqParam.Items.Clear();
                cbReqParam.Items.Add("Male");
                cbReqParam.Items.Add("Female");
                cbReqParam.SelectedIndex = (int)qr.Context;
                break;

            case QuestRequirement.Type.Job:
                cbReqParam.Visible = true;
                cbReqParam.Items.Clear();
                foreach (IntStrID job in Program.s_jobs.Values)
                {
                    cbReqParam.Items.Add(job);
                }
                cbReqParam.SelectedIndex = (int)qr.Context;
                break;

            case QuestRequirement.Type.Fame:
                tbRequirementParam.Text    = qr.Context.ToString();
                tbRequirementParam.Enabled = true;
                break;

            case QuestRequirement.Type.Item:
                tbRequirementParam.Text    = qr.Context.ToString();
                tbRequirementParam.Enabled = true;
                break;
            }
        }
예제 #5
0
        private void tbRequirementParam_TextChanged(object sender, EventArgs e)
        {
            if (lvRequirements.SelectedItems.Count > 0)
            {
                ListViewItem     lvi = lvRequirements.SelectedItems[0];
                QuestRequirement qr  = (QuestRequirement)lvi.Tag;

                try
                {
                    uint param = Convert.ToUInt32(tbRequirementParam.Text);
                    qr.Context           = param;
                    lvi.SubItems[1].Text = RequirmentContext(qr);
                    SetDirty(true);
                }
                catch (Exception) { }
            }
        }
예제 #6
0
        private void btnNewRequirement_Click(object sender, EventArgs e)
        {
            if (_selectedQuest != null)
            {
                // Create the requirement
                QuestRequirement qr = new QuestRequirement(0, QuestRequirement.Type.Level, 0);
                qr.New = true;

                // Add it to the quest
                _selectedQuest.Requirements.Add(qr);

                // Add it to the display
                SelectQuest(_selectedQuest);

                // Mark dirty
                SetDirty(true);
            }
        }
예제 #7
0
        private void btnDeleteRequirement_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Are you sure you want to delete this requirement?", "Delete Requirement", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                ListViewItem     lvi = lvRequirements.SelectedItems[0];
                QuestRequirement qr  = (QuestRequirement)lvi.Tag;

                // Deselect
                lvi.Selected = false;

                // Remove from the quest
                _selectedQuest.DeleteRequirement(qr);

                // Remove from the list view
                lvRequirements.Items.Remove(lvi);

                SetDirty(true);
            }
        }
예제 #8
0
        private void lvRequirements_SelectedIndexChanged(object sender, EventArgs e)
        {
            tbRequirementParam.Enabled = false;
            cbRequirementType.Enabled  = false;
            btnDeleteQuest.Enabled     = false;
            cbReqParam.Visible         = false;

            if (lvRequirements.SelectedItems.Count > 0)
            {
                ListViewItem     lvi = lvRequirements.SelectedItems[0];
                QuestRequirement qr  = (QuestRequirement)lvi.Tag;

                cbRequirementType.SelectedIndex = (int)qr.TheType;
                cbRequirementType.Enabled       = true;
                btnDeleteQuest.Enabled          = true;

                SelectContext(qr);
            }
        }
예제 #9
0
        private void cbReqParam_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lvRequirements.SelectedItems.Count > 0)
            {
                ListViewItem     lvi = lvRequirements.SelectedItems[0];
                QuestRequirement qr  = (QuestRequirement)lvi.Tag;

                switch (qr.TheType)
                {
                case QuestRequirement.Type.Gender:
                case QuestRequirement.Type.Race:
                    qr.Context = (uint)cbReqParam.SelectedIndex;
                    break;

                case QuestRequirement.Type.Job:
                    IntStrID job = (IntStrID)cbReqParam.SelectedItem;
                    qr.Context = (uint)job.ID;
                    break;
                }
                lvi.SubItems[1].Text = RequirmentContext(qr);
                SetDirty(true);
            }
        }
예제 #10
0
        static public Quest[] FetchQuests()
        {
            List <Quest> quests = new List <Quest>();

            // Fetch Quests
            List <object[]> rows = ExecuteQuery("SELECT * FROM quest_info;");

            foreach (object[] row in rows)
            {
                Quest q = new Quest((uint)row[0], (uint)row[1], (ushort)row[2]);
                quests.Add(q);
            }

            // Go get subquest data
            foreach (Quest q in quests)
            {
                // Fetch Name
                string sql = string.Format("SELECT * FROM quest_names WHERE quest_id={0};", q.ID);
                rows = ExecuteQuery(sql);
                if (rows.Count > 0)
                {
                    q.Name = (string)rows[0][1];
                }

                // Fetch Requirements
                sql  = string.Format("SELECT * FROM quest_requirements WHERE quest_id={0};", q.ID);
                rows = ExecuteQuery(sql);
                foreach (object[] row in rows)
                {
                    uint             id   = (uint)row[0];
                    byte             type = (byte)row[2];
                    QuestRequirement qr   = new QuestRequirement(id, (QuestRequirement.Type)type, (uint)row[3]);
                    q.Requirements.Add(qr);
                }

                // Fetch Steps
                sql  = string.Format("SELECT * FROM quest_steps WHERE quest_id={0};", q.ID);
                rows = ExecuteQuery(sql);
                foreach (object[] row in rows)
                {
                    byte      type = (byte)row[2];
                    QuestStep qs   = new QuestStep((byte)row[1], (QuestStep.CompletionType)type, (uint)row[3], (uint)row[4], (uint)row[5], (uint)row[6]);
                    q.Steps.Add(qs);
                }

                // Process Steps
                foreach (QuestStep qs in q.Steps)
                {
                    // Fetch Rewards
                    sql  = string.Format("SELECT * FROM quest_rewards WHERE quest_id={0} AND step={1};", q.ID, qs.Step);
                    rows = ExecuteQuery(sql);
                    foreach (object[] row in rows)
                    {
                        // 0: quest_id	int(10) unsigned
                        // 1: step	tinyint(3) unsigned
                        // 2: type	tinyint(10) unsigned
                        // 3: context	int(10) unsigned
                        QuestReward qr = new QuestReward((byte)row[2], (uint)row[3]);
                        qs.Rewards.Add(qr);
                    }

                    // Fetch Lines
                    sql  = string.Format("SELECT * FROM quest_lines WHERE quest_id={0} AND step={1};", q.ID, qs.Step);
                    rows = ExecuteQuery(sql);
                    foreach (object[] row in rows)
                    {
                        string text = null;
                        if (row[6].GetType() != typeof(DBNull))
                        {
                            text = (string)row[6];
                        }
                        QuestLine ql = new QuestLine((byte)row[3], (ushort)row[4], (ushort)row[5], text, (uint)row[0]);
                        qs.Lines.Add(ql);
                    }

                    // Order Lines
                    qs.OrderLines();
                }

                // Order Steps
                q.OrderSteps();
            }
            return(quests.ToArray());
        }