コード例 #1
0
ファイル: QuestDialog.cs プロジェクト: acid1789/DecoServer2
        private void cbRewardContext_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cbRewardContext.SelectedItem != null && lvRewards.SelectedItems.Count > 0)
            {
                ListViewItem lvi = lvRewards.SelectedItems[0];
                QuestReward  qr  = (QuestReward)lvi.Tag;

                switch (qr.Type)
                {
                case QuestReward.RewardType.Teleport:
                    Location loc = (Location)cbRewardContext.SelectedItem;
                    qr.Context           = loc.ID;
                    lvi.SubItems[1].Text = loc.ToString();
                    SetDirty(true);
                    break;

                case QuestReward.RewardType.Skill:
                    // TODO: Implement
                    break;

                case QuestReward.RewardType.Item:
                    NamedItemTemplate nit = (NamedItemTemplate)cbRewardContext.SelectedItem;
                    qr.Context           = nit.Template.ID;
                    lvi.SubItems[1].Text = RewardContextString(qr);
                    SetDirty(true);
                    break;
                }
            }
        }
コード例 #2
0
ファイル: QuestDialog.cs プロジェクト: acid1789/DecoServer2
        void AddRewardToDisplay(QuestReward qr)
        {
            ListViewItem rvi = lvRewards.Items.Add(qr.Type.ToString());

            rvi.SubItems.Add(RewardContextString(qr));
            rvi.Tag = qr;
        }
コード例 #3
0
 public void DeleteReward(QuestReward qr)
 {
     Rewards.Remove(qr);
     if (!qr.New)
     {
         DeletedRewards.Add(qr);
     }
 }
コード例 #4
0
ファイル: QuestDialog.cs プロジェクト: acid1789/DecoServer2
        void SetRewardContext(QuestReward qr)
        {
            switch (qr.Type)
            {
            case QuestReward.RewardType.Gold:
            case QuestReward.RewardType.Exp:
            case QuestReward.RewardType.Fame:
                cbRewardContext.Visible = false;
                tbRewardContext.Enabled = true;
                tbRewardContext.Text    = qr.Context.ToString();
                break;

            case QuestReward.RewardType.Item:
                cbRewardContext.Enabled = true;
                cbRewardContext.Visible = true;
                cbRewardContext.Items.Clear();
                foreach (NamedItemTemplate nit in _items.Values)
                {
                    cbRewardContext.Items.Add(nit);
                }
                if (_items.ContainsKey(qr.Context))
                {
                    cbRewardContext.SelectedItem = _items[qr.Context];
                }
                else
                {
                    cbRewardContext.SelectedItem = null;
                }
                break;

            case QuestReward.RewardType.Teleport:
                cbRewardContext.Enabled = true;
                cbRewardContext.Visible = true;
                cbRewardContext.Items.Clear();
                foreach (Location loc in _locations.Values)
                {
                    cbRewardContext.Items.Add(loc);
                }
                if (_locations.ContainsKey(qr.Context))
                {
                    cbRewardContext.SelectedItem = _locations[qr.Context];
                }
                else
                {
                    cbRewardContext.SelectedItem = null;
                }
                break;

            case QuestReward.RewardType.Skill:
                // TODO: Implement skill
                cbRewardContext.Visible = false;
                tbRewardContext.Enabled = true;
                tbRewardContext.Text    = qr.Context.ToString();
                break;
            }
        }
コード例 #5
0
ファイル: QuestDialog.cs プロジェクト: acid1789/DecoServer2
        private void cbRewardType_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cbRewardType.SelectedItem != null && lvRewards.SelectedItems.Count > 0)
            {
                ListViewItem lvi = lvRewards.SelectedItems[0];
                QuestReward  qr  = (QuestReward)lvi.Tag;

                qr.Type = (QuestReward.RewardType)cbRewardType.SelectedIndex;
                SetRewardContext(qr);
                lvi.SubItems[1].Text = RewardContextString(qr);
            }
        }
コード例 #6
0
ファイル: QuestDialog.cs プロジェクト: acid1789/DecoServer2
        private void btnAddReward_Click(object sender, EventArgs e)
        {
            ListViewItem lvi = lvSteps.SelectedItems[0];
            QuestStep    qs  = (QuestStep)lvi.Tag;

            // Create reward
            QuestReward qr = new QuestReward((byte)Math.Max(cbRewardType.SelectedIndex, 0), 0);

            qr.New = true;

            // Add to the step
            qs.Rewards.Add(qr);

            // Add to the display
            AddRewardToDisplay(qr);

            SetDirty(true);
        }
コード例 #7
0
ファイル: QuestDialog.cs プロジェクト: acid1789/DecoServer2
        string RewardContextString(QuestReward qr)
        {
            string str = "";

            switch (qr.Type)
            {
            case QuestReward.RewardType.Gold:
            case QuestReward.RewardType.Exp:
            case QuestReward.RewardType.Fame:
                str = qr.Context.ToString();
                break;

            case QuestReward.RewardType.Item:
                if (_items.ContainsKey(qr.Context))
                {
                    NamedItemTemplate nit = _items[qr.Context];
                    str = nit.ToString();
                }
                else
                {
                    str = qr.Context.ToString();
                }
                break;

            case QuestReward.RewardType.Teleport:
                if (_locations.ContainsKey(qr.Context))
                {
                    Location loc = _locations[qr.Context];
                    str = loc.ToString();
                }
                else
                {
                    str = qr.Context.ToString();
                }
                break;

            case QuestReward.RewardType.Skill:
                // TODO: Need to implement skills
                str = qr.Context.ToString();
                break;
            }

            return(str);
        }
コード例 #8
0
ファイル: QuestDialog.cs プロジェクト: acid1789/DecoServer2
        private void tbRewardContext_TextChanged(object sender, EventArgs e)
        {
            try
            {
                ListViewItem lvi = lvRewards.SelectedItems[0];
                QuestReward  qr  = (QuestReward)lvi.Tag;

                switch (qr.Type)
                {
                case QuestReward.RewardType.Exp:
                case QuestReward.RewardType.Fame:
                case QuestReward.RewardType.Gold:
                case QuestReward.RewardType.Skill:
                    qr.Context           = Convert.ToUInt32(tbRewardContext.Text);
                    lvi.SubItems[1].Text = RewardContextString(qr);
                    SetDirty(true);
                    break;
                }
            }
            catch (Exception) { }
        }
コード例 #9
0
ファイル: QuestDialog.cs プロジェクト: acid1789/DecoServer2
        private void lvRewards_SelectedIndexChanged(object sender, EventArgs e)
        {
            cbRewardType.Enabled    = false;
            cbRewardContext.Enabled = false;
            cbRewardContext.Visible = false;
            tbRewardContext.Enabled = false;
            tbRewardContext.Text    = "";
            btnDeleteReward.Enabled = false;

            if (lvRewards.SelectedItems.Count > 0)
            {
                _selectingQuest = true;
                ListViewItem lvi = lvRewards.SelectedItems[0];
                QuestReward  qr  = (QuestReward)lvi.Tag;

                cbRewardType.Enabled = true;
                SetRewardContext(qr);
                btnDeleteReward.Enabled = true;

                _selectingQuest = false;
            }
        }
コード例 #10
0
ファイル: QuestDialog.cs プロジェクト: acid1789/DecoServer2
        private void btnDeleteReward_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Are you sure you want to delete this reward?", "Delete Reward", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                // Get the reward
                ListViewItem lvi = lvRewards.SelectedItems[0];
                QuestReward  qr  = (QuestReward)lvi.Tag;

                // Deselect
                lvi.Selected = false;

                // Remove from the quest step
                ListViewItem lvs = lvSteps.SelectedItems[0];
                QuestStep    qs  = (QuestStep)lvs.Tag;
                qs.DeleteReward(qr);

                // Remove from the display
                lvRewards.Items.Remove(lvi);

                SetDirty(true);
            }
        }
コード例 #11
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());
        }