Beispiel #1
0
    public QuestObj getQuestFromDB(string id)
    {
        IDataReader reader = getDataByString(id);
        QuestObj    quest  = null;

        while (reader.Read())
        {
            QuestObj entity = new QuestObj(reader[0].ToString(),
                                           reader[1].ToString(),
                                           reader[2].ToString(),
                                           reader[3].ToString(),
                                           reader[4].ToString(),
                                           reader[5].ToString(),
                                           reader[6].ToString(),
                                           reader[7].ToString(),
                                           reader[8].ToString(),
                                           reader[9].ToString());
            quest = entity;
        }
        if (quest == null)
        {
            return(null);
        }
        reader.Close();

        reader = getRewards(quest._id);
        while (reader.Read())
        {
            quest._Rewards.Add(reader[0].ToString());
        }
        reader.Close();

        reader = getPreReqs(quest._id);
        while (reader.Read())
        {
            quest._PreReqIds.Add(reader[0].ToString());
        }
        reader.Close();

        return(quest);
    }
Beispiel #2
0
    public void addData(QuestObj quest)
    {
        IDbCommand dbcmd = getDbCommand();

        dbcmd.CommandText =
            "INSERT INTO " + TABLE_NAME
            + " ( "
            + KEY_ID + ", "
            + KEY_TITLE + ", "
            + KEY_DESCRIPTION + ", "
            + KEY_NPCID + ", "
            + KEY_XP + ", "
            + KEY_MONEY + ", "
            + KEY_COMPLETED + ", "
            + KEY_TIMESCOMPLETED + ", "
            + KEY_ISREPEATABLE + ", "
            + KEY_INPROGRESS + " ) "

            + "VALUES (@id, @title, @description, @giver, @xp, @money, @completed, @timesCompleted, @isRepeatable, @inProgress)";

        dbcmd.Parameters.Add(new SqliteParameter {
            ParameterName = "id",
            Value         = quest._id
        });
        dbcmd.Parameters.Add(new SqliteParameter {
            ParameterName = "title",
            Value         = quest._QuestTitle
        });
        dbcmd.Parameters.Add(new SqliteParameter {
            ParameterName = "description",
            Value         = quest._Description
        });
        dbcmd.Parameters.Add(new SqliteParameter {
            ParameterName = "giver",
            Value         = quest._QuestGiver
        });
        dbcmd.Parameters.Add(new SqliteParameter {
            ParameterName = "xp",
            Value         = quest._xp
        });
        dbcmd.Parameters.Add(new SqliteParameter {
            ParameterName = "money",
            Value         = quest._Money
        });
        dbcmd.Parameters.Add(new SqliteParameter {
            ParameterName = "completed",
            Value         = quest._Completed
        });
        dbcmd.Parameters.Add(new SqliteParameter {
            ParameterName = "timesCompleted",
            Value         = quest._TimesCompleted
        });
        dbcmd.Parameters.Add(new SqliteParameter {
            ParameterName = "isRepeatable",
            Value         = quest._IsRepeatable
        });
        dbcmd.Parameters.Add(new SqliteParameter {
            ParameterName = "inProgress",
            Value         = quest._InProgress
        });

        dbcmd.ExecuteNonQuery();
    }