Esempio n. 1
0
        public void Load(string fname, Stream stream)
        {
            using (var reader = new SrcDataReader(fname, stream))
            {
                string line_buf = "";
                while (reader.HasMore)
                {
                    line_buf = reader.GetLine();
                    if (string.IsNullOrEmpty(line_buf))
                    {
                        continue;
                    }
                    if (Strings.InStr(line_buf, ",") > 0)
                    {
                        throw reader.InvalidDataException("名称の設定が抜けています。", line_buf);
                    }

                    var data_name = line_buf;
                    if (Strings.InStr(data_name, " ") > 0)
                    {
                        throw reader.InvalidDataException("名称に半角スペースは使用出来ません。", data_name);
                    }

                    if (Strings.InStr(data_name, "(") > 0 || Strings.InStr(data_name, ")") > 0)
                    {
                        throw reader.InvalidDataException("名称に全角括弧は使用出来ません。", data_name);
                    }

                    if (Strings.InStr(data_name, "\"") > 0)
                    {
                        throw reader.InvalidDataException("名称に\"は使用出来ません。", data_name);
                    }

                    if (IsDefined(data_name))
                    {
                        // すでに定義されているエリアスのデータであれば置き換える
                        Delete(data_name);
                    }

                    var ad = Add(data_name);
                    while (reader.HasMore)
                    {
                        line_buf = reader.GetLine();
                        if (Strings.Len(line_buf) == 0)
                        {
                            break;
                        }

                        ad.AddAlias(line_buf);
                    }

                    if (ad.Count == 0)
                    {
                        throw reader.InvalidDataException("エリアス対象のデータが定義されていません。", data_name);
                    }
                }
            }
        }
Esempio n. 2
0
 public void Load(string fname, Stream stream)
 {
     using (var reader = new SrcDataReader(fname, stream))
     {
         PilotData lastPd = null;
         while (reader.HasMore)
         {
             lastPd = LoadPilot(reader, lastPd);
         }
         Raw = reader.Raw;
     }
 }
Esempio n. 3
0
 public void Load(string fname, Stream stream)
 {
     //try
     //{
     using (var reader = new SrcDataReader(fname, stream))
     {
         UnitData lastUd = null;
         while (reader.HasMore)
         {
             lastUd = LoadUnit(reader, lastUd);
         }
         Raw = reader.Raw;
     }
     //}
     //catch (InvalidSrcDataException)
     //{
     //    throw;
     //}
 }
Esempio n. 4
0
        public void Load(string fname, Stream stream)
        {
            using (var reader = new SrcDataReader(fname, stream))
            {
                while (reader.HasMore)
                {
                    string buf, buf2;
                    string data_name = "";
                    string line_buf  = "";
                    // 空行をスキップ
                    while (reader.HasMore && string.IsNullOrEmpty(line_buf))
                    {
                        line_buf = reader.GetLine();
                    }
                    if (string.IsNullOrEmpty(line_buf))
                    {
                        break;
                    }
                    data_name = line_buf;
                    if (IsDefined(data_name))
                    {
                        // すでに定義されているエリアスのデータであれば置き換える
                        Delete(data_name);
                    }

                    // XXX これでいいんか? nullになったり上書きされそう。
                    var cd = Add(data_name);
                    while (reader.HasMore)
                    {
                        line_buf = reader.GetLine();
                        if (string.IsNullOrEmpty(line_buf))
                        {
                            break;
                        }

                        cd.ConfigCalc = line_buf;
                    }
                }
            }
        }
Esempio n. 5
0
        public void Load(string fname, Stream stream)
        {
            using (var reader = new SrcDataReader(fname, stream))
            {
                bool   in_quote;
                string line_buf;
                while (reader.HasMore)
                {
                    line_buf = reader.GetLine();
                    if (string.IsNullOrEmpty(line_buf))
                    {
                        continue;
                    }

                    // 番号
                    int data_id;
                    if (Information.IsNumeric(line_buf))
                    {
                        data_id = Conversions.ToInteger(line_buf);
                    }
                    else
                    {
                        throw reader.InvalidDataException("番号の設定が間違っています。", line_buf);
                    }

                    if (data_id < 0 || data_id >= Map.MAX_TERRAIN_DATA_NUM)
                    {
                        throw reader.InvalidDataException("番号の設定が間違っています。", line_buf);
                    }

                    TerrainData td = new TerrainData
                    {
                        ID = data_id,
                    };

                    // 名称, 画像ファイル名
                    line_buf = reader.GetLine();

                    // 名称
                    var ret = Strings.InStr(line_buf, ",");
                    if (ret == 0)
                    {
                        throw reader.InvalidDataException("画像ファイル名が抜けています。", line_buf);
                    }

                    var data_name = Strings.Trim(Strings.Left(line_buf, ret - 1));
                    td.Name = data_name;
                    var buf = Strings.Mid(line_buf, ret + 1);

                    // 画像ファイル名
                    td.Bitmap = Strings.Trim(buf);
                    if (Strings.Len(td.Bitmap) == 0)
                    {
                        throw reader.InvalidDataException("画像ファイル名が指定されていません。", data_name);
                    }

                    // 地形タイプ, 移動コスト, 命中修正, ダメージ修正
                    line_buf = reader.GetLine();

                    // 地形タイプ
                    ret = Strings.InStr(line_buf, ",");
                    if (ret == 0)
                    {
                        throw reader.InvalidDataException("移動コストが抜けています。", data_name);
                    }

                    var buf2 = Strings.Trim(Strings.Left(line_buf, ret - 1));
                    buf      = Strings.Mid(line_buf, ret + 1);
                    td.Class = buf2;

                    // 移動コスト
                    ret = Strings.InStr(buf, ",");
                    if (ret == 0)
                    {
                        throw reader.InvalidDataException("命中修正が抜けています。", data_name);
                    }

                    buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                    buf  = Strings.Mid(buf, ret + 1);
                    if (buf2 == "-")
                    {
                        td.MoveCost = 1000;
                    }
                    else if (Information.IsNumeric(buf2))
                    {
                        // 0.5刻みの移動コストを使えるようにするため、実際の2倍の値で記録する
                        td.MoveCost = (int)(2d * Conversions.ToDouble(buf2));
                    }

                    if (td.MoveCost <= 0)
                    {
                        SRC.AddDataError(reader.InvalidData("移動コストの設定が間違っています。", data_name));
                    }

                    // 命中修正
                    ret = Strings.InStr(buf, ",");
                    if (ret == 0)
                    {
                        throw reader.InvalidDataException("ダメージ修正が抜けています。", data_name);
                    }

                    buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                    buf  = Strings.Mid(buf, ret + 1);
                    if (Information.IsNumeric(buf2))
                    {
                        td.HitMod = Conversions.ToInteger(buf2);
                    }
                    else
                    {
                        SRC.AddDataError(reader.InvalidData("命中修正の設定が間違っています。", data_name));
                    }

                    // ダメージ修正
                    ret = Strings.InStr(buf, ",");
                    if (ret > 0)
                    {
                        throw reader.InvalidDataException("余分な「,」が指定されています。", data_name);
                    }

                    buf2 = Strings.Trim(buf);
                    if (Information.IsNumeric(buf2))
                    {
                        td.DamageMod = Conversions.ToInteger(buf2);
                    }
                    else
                    {
                        SRC.AddDataError(reader.InvalidData("ダメージ修正の設定が間違っています。", data_name));
                    }

                    // 地形効果
                    line_buf = reader.GetLine();
                    while (Strings.Len(line_buf) > 0)
                    {
                        buf = line_buf;
                        var i = 0;
                        while (Strings.Len(buf) > 0)
                        {
                            i        = (i + 1);
                            ret      = 0;
                            in_quote = false;
                            var loopTo = Strings.Len(buf);
                            for (var j = 1; j <= loopTo; j++)
                            {
                                switch (Strings.Mid(buf, j, 1) ?? "")
                                {
                                case ",":
                                {
                                    if (!in_quote)
                                    {
                                        ret = j;
                                        break;
                                    }

                                    break;
                                }

                                case "\"":
                                {
                                    in_quote = !in_quote;
                                    break;
                                }
                                }
                            }

                            if (ret > 0)
                            {
                                buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                                buf  = Strings.Trim(Strings.Mid(buf, ret + 1));
                            }
                            else
                            {
                                buf2 = buf;
                                buf  = "";
                            }

                            if (!string.IsNullOrEmpty(buf2))
                            {
                                td.AddFeature(buf2);
                            }
                            else
                            {
                                SRC.AddDataError(reader.InvalidData("行頭から" + SrcFormatter.Format((object)i) + "番目の地形効果の設定が間違っています。", data_name));
                            }
                        }
                        if (reader.HasMore)
                        {
                            line_buf = reader.GetLine();
                        }
                        else
                        {
                            break;
                        }
                    }
                    TerrainList[data_id] = td;
                }
            }
        }
Esempio n. 6
0
        /// <param name="fname"></param>
        /// <param name="isEffect">特殊効果データor戦闘アニメデータか?</param>
        /// <param name="stream"></param>
        public void Load(string fname, bool isEffect, Stream stream)
        {
            using (var reader = new SrcDataReader(fname, stream))
            {
                string line_buf = "";
                while (reader.HasMore)
                {
                    line_buf = reader.GetLine();
                    while (reader.HasMore && string.IsNullOrEmpty(line_buf))
                    {
                        line_buf = reader.GetLine();
                    }
                    var data_name = line_buf;

                    if (Strings.InStr(line_buf, ",") > 0)
                    {
                        throw reader.InvalidDataException("名称の設定が抜けています。", data_name);
                    }
                    if (Strings.InStr(data_name, " ") > 0)
                    {
                        throw reader.InvalidDataException("名称に半角スペースは使用出来ません。", data_name);
                    }

                    if (Strings.InStr(data_name, "(") > 0 || Strings.InStr(data_name, ")") > 0)
                    {
                        throw reader.InvalidDataException("名称に全角括弧は使用出来ません。", data_name);
                    }

                    if (Strings.InStr(data_name, "\"") > 0)
                    {
                        throw reader.InvalidDataException("名称に\"は使用出来ません。", data_name);
                    }

                    // 重複して定義されたデータの場合
                    MessageData md;
                    if (IsDefined(data_name))
                    {
                        if (!isEffect)
                        {
                            // パイロットメッセージの場合は後から定義されたものを優先
                            Delete(data_name);
                            md = Add(data_name);
                        }
                        else
                        {
                            // 特殊効果データの場合は既存のものに追加
                            md = Item(data_name);
                        }
                    }
                    else
                    {
                        md = Add(data_name);
                    }

                    line_buf = reader.GetLine();
                    while (Strings.Len(line_buf) > 0)
                    {
                        var ret = Strings.InStr(line_buf, ",");
                        if (ret < 2)
                        {
                            throw reader.InvalidDataException("「,」区切りが見つかりません。", data_name);
                        }

                        var sname = Strings.Left(line_buf, (int)ret - 1);
                        var msg   = Strings.Trim(Strings.Mid(line_buf, (int)ret + 1));
                        if (Strings.Len(sname) == 0)
                        {
                            throw reader.InvalidDataException("シチュエーションの指定が抜けています。", data_name);
                        }

                        md.AddMessage(sname, msg);

                        if (!reader.HasMore)
                        {
                            break;
                        }
                        line_buf = reader.GetLine();
                    }
                }
            }
        }
Esempio n. 7
0
        public void Load(string fname, Stream stream)
        {
            using (var reader = new SrcDataReader(fname, stream))
            {
                while (reader.HasMore)
                {
                    string buf, buf2;
                    string data_name = "";
                    string line_buf  = "";
                    // 空行をスキップ
                    while (reader.HasMore && string.IsNullOrEmpty(line_buf))
                    {
                        line_buf = reader.GetLine();
                    }
                    if (string.IsNullOrEmpty(line_buf))
                    {
                        break;
                    }

                    // 名称
                    var ret = Strings.InStr(line_buf, ",");
                    if (ret > 0)
                    {
                        data_name = Strings.Trim(Strings.Left(line_buf, ret - 1));
                        buf       = Strings.Mid(line_buf, ret + 1);
                    }
                    else
                    {
                        data_name = line_buf;
                        buf       = "";
                    }

                    if (Strings.InStr(data_name, " ") > 0)
                    {
                        throw reader.InvalidDataException("名称に半角スペースは使用出来ません。", line_buf);
                    }

                    if (Strings.InStr(data_name, "(") > 0 || Strings.InStr(data_name, ")") > 0)
                    {
                        throw reader.InvalidDataException("名称に全角括弧は使用出来ません。", line_buf);
                    }

                    if (Strings.InStr(data_name, "\"") > 0)
                    {
                        throw reader.InvalidDataException("名称に\"は使用出来ません。", line_buf);
                    }

                    if (IsDefined(data_name))
                    {
                        Delete(data_name);
                    }

                    var sd = Add(data_name);
                    // 読み仮名
                    ret = Strings.InStr(buf, ",");
                    if (ret > 0)
                    {
                        throw reader.InvalidDataException("読み仮名の後に余分なデータが指定されています。", line_buf);
                    }

                    sd.KanaName = Strings.Trim(buf);
                    if (string.IsNullOrEmpty(sd.KanaName))
                    {
                        sd.KanaName = GeneralLib.StrToHiragana(data_name);
                    }

                    // 短縮形, 消費SP, 対象, 効果時間, 適用条件, 使用条件, アニメ
                    line_buf = reader.GetLine();

                    // 短縮形
                    ret = Strings.InStr(line_buf, ",");
                    if (ret == 0)
                    {
                        throw reader.InvalidDataException("消費SPが抜けています。", line_buf);
                    }

                    buf2         = Strings.Trim(Strings.Left(line_buf, ret - 1));
                    buf          = Strings.Mid(line_buf, ret + 1);
                    sd.ShortName = buf2;

                    // 消費SP
                    ret = Strings.InStr(buf, ",");
                    if (ret == 0)
                    {
                        throw reader.InvalidDataException("対象が抜けています。", line_buf);
                    }

                    buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                    buf  = Strings.Mid(buf, ret + 1);
                    if (Information.IsNumeric(buf2))
                    {
                        sd.SPConsumption = Conversions.ToInteger(buf2);
                    }
                    else
                    {
                        SRC.AddDataError(reader.InvalidData("消費SPの設定が間違っています。", data_name));
                    }

                    // 対象
                    ret = Strings.InStr(buf, ",");
                    if (ret == 0)
                    {
                        throw reader.InvalidDataException("効果時間が抜けています。", line_buf);
                    }

                    buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                    buf  = Strings.Mid(buf, ret + 1);
                    if (Information.IsNumeric(buf2))
                    {
                        throw reader.InvalidDataException("対象が間違っています。", line_buf);
                    }

                    sd.TargetType = buf2;

                    // 効果時間
                    ret = Strings.InStr(buf, ",");
                    if (ret == 0)
                    {
                        throw reader.InvalidDataException("効果時間が抜けています。", line_buf);
                    }

                    buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                    buf  = Strings.Mid(buf, ret + 1);
                    if (Information.IsNumeric(buf2))
                    {
                        throw reader.InvalidDataException("効果時間が間違っています。", line_buf);
                    }

                    sd.Duration = buf2;

                    // 適用条件
                    ret = Strings.InStr(buf, ",");
                    if (ret == 0)
                    {
                        throw reader.InvalidDataException("使用条件が抜けています。", line_buf);
                    }

                    buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                    buf  = Strings.Mid(buf, ret + 1);
                    if (Information.IsNumeric(buf2))
                    {
                        throw reader.InvalidDataException("適用条件が間違っています。", line_buf);
                    }

                    sd.NecessaryCondition = buf2;

                    // 使用条件, アニメ
                    ret = Strings.InStr(buf, ",");
                    if (ret > 0)
                    {
                        sd.Animation = Strings.Trim(Strings.Mid(buf, Strings.InStr(buf, ",") + 1));
                    }
                    else
                    {
                        sd.Animation = sd.Name;
                    }

                    // 効果
                    line_buf = reader.GetLine();
                    if (Strings.Len(line_buf) == 0)
                    {
                        throw reader.InvalidDataException("効果が指定されていません。", line_buf);
                    }

                    sd.SetEffect(line_buf);

                    // 解説
                    line_buf = reader.GetLine();
                    if (Strings.Len(line_buf) == 0)
                    {
                        throw reader.InvalidDataException("解説が指定されていません。", line_buf);
                    }

                    sd.Comment = line_buf;
                }
            }
        }
Esempio n. 8
0
        public PilotData LoadPilot(SrcDataReader reader, PilotData lastPd)
        {
            PilotData pd = null;

            try
            {
                string buf, buf2;

                string data_name = "";
                string line_buf  = "";
                // 空行をスキップ
                while (reader.HasMore && string.IsNullOrEmpty(line_buf))
                {
                    line_buf = reader.GetLine();
                }
                if (lastPd != null)
                {
                    lastPd.DataComment = reader.RawComment.Trim();
                }
                else
                {
                    DataComment = string.Join(Environment.NewLine + Environment.NewLine,
                                              new string[] {
                        DataComment,
                        reader.RawComment.Trim(),
                    }.Where(x => !string.IsNullOrEmpty(x)));
                }
                reader.ClearRawComment();
                if (reader.EOT)
                {
                    return(null);
                }

                if (Strings.InStr(line_buf, ",") > 0)
                {
                    throw reader.InvalidDataException(@"名称の設定が抜けています。", data_name);
                }

                // 名称
                data_name = line_buf;
                if (Strings.InStr(data_name, " ") > 0)
                {
                    throw reader.InvalidDataException(@"名称に半角スペースは使用出来ません。", data_name);
                }

                if (Strings.InStr(data_name, "(") > 0 || Strings.InStr(data_name, ")") > 0)
                {
                    throw reader.InvalidDataException(@"名称に全角括弧は使用出来ません", data_name);
                }

                if (Strings.InStr(data_name, "\"") > 0)
                {
                    throw reader.InvalidDataException("名称に\"は使用出来ません。", data_name);
                }

                if (IsDefined2(data_name))
                {
                    // すでに定義済みのパイロットの場合はデータを置き換え
                    pd = Item(data_name);
                    pd.Clear();
                }
                else
                {
                    pd = Add(data_name);
                }

                // 愛称, 読み仮名, 性別, クラス, 地形適応, 経験値
                line_buf = reader.GetLine();

                // 書式チェックのため、コンマの数を数えておく
                int comma_num = 0;
                var loopTo    = Strings.Len(line_buf);
                for (int i = 1; i <= loopTo; i++)
                {
                    if (Strings.Mid(line_buf, i, 1) == ",")
                    {
                        comma_num = (comma_num + 1);
                    }
                }

                if (comma_num < 3)
                {
                    throw reader.InvalidDataException(@"設定に抜けがあります。", data_name);
                }
                else if (comma_num > 5)
                {
                    throw reader.InvalidDataException(@"余分な「,」があります。", data_name);
                }

                // 愛称
                int ret = Strings.InStr(line_buf, ",");
                buf2 = Strings.Trim(Strings.Left(line_buf, ret - 1));
                buf  = Strings.Mid(line_buf, ret + 1);
                if (Strings.Len(buf2) == 0)
                {
                    throw reader.InvalidDataException(@"愛称の設定が抜けています。", data_name);
                }

                pd.Nickname = buf2;
                switch (comma_num)
                {
                case 4:
                {
                    // 読み仮名 or 性別
                    ret  = Strings.InStr(buf, ",");
                    buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                    buf  = Strings.Mid(buf, ret + 1);
                    switch (buf2 ?? "")
                    {
                    case "男性":
                    case "女性":
                    case "-":
                    {
                        pd.KanaName = GeneralLib.StrToHiragana(pd.Nickname);
                        pd.Sex      = buf2;
                        break;
                    }

                    default:
                    {
                        pd.KanaName = buf2;
                        break;
                    }
                    }

                    break;
                }

                case 5:
                {
                    // 読み仮名
                    ret  = Strings.InStr(buf, ",");
                    buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                    buf  = Strings.Mid(buf, ret + 1);
                    switch (buf2 ?? "")
                    {
                    case "男性":
                    case "女性":
                    case "-":
                    {
                        SRC.AddDataError(reader.InvalidData(@"読み仮名の設定が抜けています。", data_name));
                        pd.KanaName = GeneralLib.StrToHiragana(pd.Nickname);
                        break;
                    }

                    default:
                    {
                        pd.KanaName = buf2;
                        break;
                    }
                    }

                    // 性別
                    ret  = Strings.InStr(buf, ",");
                    buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                    buf  = Strings.Mid(buf, ret + 1);
                    switch (buf2 ?? "")
                    {
                    case "男性":
                    case "女性":
                    case "-":
                    {
                        pd.Sex = buf2;
                        break;
                    }

                    default:
                    {
                        SRC.AddDataError(reader.InvalidData(@"性別の設定が間違っています。", data_name));
                        break;
                    }
                    }

                    break;
                }

                default:
                {
                    pd.KanaName = GeneralLib.StrToHiragana(pd.Nickname);
                    break;
                }
                }

                // クラス
                ret  = Strings.InStr(buf, ",");
                buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                buf  = Strings.Mid(buf, ret + 1);
                if (!Information.IsNumeric(buf2))
                {
                    pd.Class = buf2;
                }
                else
                {
                    SRC.AddDataError(reader.InvalidData(@"クラスの設定が間違っています。", data_name));
                }

                // 地形適応
                ret  = Strings.InStr(buf, ",");
                buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                buf  = Strings.Mid(buf, ret + 1);
                if (Strings.Len(buf2) == 4)
                {
                    pd.Adaption = buf2;
                }
                else
                {
                    SRC.AddDataError(reader.InvalidData(@"地形適応の設定が間違っています。", data_name));
                    pd.Adaption = "AAAA";
                }

                // 経験値
                buf2 = Strings.Trim(buf);
                if (Information.IsNumeric(buf2))
                {
                    pd.ExpValue = GeneralLib.MinLng(Conversions.ToInteger(buf2), 9999);
                }
                else
                {
                    SRC.AddDataError(reader.InvalidData(@"経験値の設定が間違っています。", data_name));
                }

                // 特殊能力データ
                line_buf = reader.GetLine();
                if (line_buf == "特殊能力なし")
                {
                    line_buf = reader.GetLine();
                }
                else if (line_buf == "特殊能力")
                {
                    // 新形式による特殊能力表記
                    line_buf = reader.GetLine();
                    buf      = line_buf;
                    int    i      = 0;
                    string aname  = "";
                    string adata  = "";
                    double alevel = Constants.DEFAULT_LEVEL;
                    while (true)
                    {
                        i = (i + 1);

                        // コンマの位置を検索
                        ret = Strings.InStr(buf, ",");
                        // 「"」が使われているか検索
                        int ret2 = Strings.InStr(buf, "\"");
                        if (ret2 < ret && ret2 > 0)
                        {
                            // 「"」が見つかった場合、次の「"」後のコンマを検索
                            bool in_quote = true;
                            int  j        = (ret2 + 1);
                            while (j <= Strings.Len(buf))
                            {
                                switch (Strings.Mid(buf, j, 1) ?? "")
                                {
                                case "\"":
                                {
                                    in_quote = !in_quote;
                                    break;
                                }

                                case ",":
                                {
                                    if (!in_quote)
                                    {
                                        buf2 = Strings.Left(buf, j - 1);
                                        buf  = Strings.Mid(buf, j + 1);
                                    }

                                    break;
                                }
                                }

                                j = (j + 1);
                            }

                            if (j == Strings.Len(buf))
                            {
                                buf2 = buf;
                                buf  = "";
                            }

                            in_quote = false;
                        }
                        else if (ret > 0)
                        {
                            // コンマが見つかったらコンマまでの文字列を切り出す
                            buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                            buf  = Strings.Trim(Strings.Mid(buf, ret + 1));

                            // コンマの後ろの文字列が空白の場合
                            if (string.IsNullOrEmpty(buf))
                            {
                                if (i % 2 == 1)
                                {
                                    throw reader.InvalidDataException(@"行末の「,」の後に特殊能力指定が抜けています。", data_name);
                                }
                                else
                                {
                                    throw reader.InvalidDataException(@"行末の「,」の後に特殊能力レベル指定が抜けています。", data_name);
                                };
                            }
                        }
                        else
                        {
                            // 行末の文字列
                            buf2 = buf;
                            buf  = "";
                        }

                        if (i % 2 == 1)
                        {
                            // 特殊能力名&レベル

                            if (Information.IsNumeric(buf2))
                            {
                                if (i == 1)
                                {
                                    // 特殊能力の指定は終り。能力値の指定へ
                                    buf = buf2 + ", " + buf;
                                    break;
                                }
                                else
                                {
                                    SRC.AddDataError(reader.InvalidData(@"行頭から" + SrcFormatter.Format((object)((i + 1) / 2)) + "番目の特殊能力名の設定が間違っています。", data_name));
                                }
                            }

                            if (Strings.InStr(buf2, " ") > 0)
                            {
                                if (Strings.Left(buf2, 4) != "先手必勝" && Strings.Left(buf2, 6) != "SP消費減少" && Strings.Left(buf2, 12) != "スペシャルパワー自動発動" && Strings.Left(buf2, 4) != "ハンター" && Strings.InStr(buf2, "=解説 ") == 0)
                                {
                                    if (string.IsNullOrEmpty(aname))
                                    {
                                        throw reader.InvalidDataException(@"行頭から" + SrcFormatter.Format((object)((i + 1) / 2)) + "番目の特殊能力「" + Strings.Trim(Strings.Left(buf2, Strings.InStr(buf2, " "))) + "」の指定の後に「,」が抜けています。", data_name);
                                    }
                                    else
                                    {
                                        throw reader.InvalidDataException(@"特殊能力「" + aname + "」のレベル指定の後に「,」が抜けています。", data_name);
                                    };
                                }
                            }

                            // 特殊能力の別名指定がある?
                            int j = Strings.InStr(buf2, "=");
                            if (j > 0)
                            {
                                adata = Strings.Mid(buf2, j + 1);
                                buf2  = Strings.Left(buf2, j - 1);
                            }
                            else
                            {
                                adata = "";
                            }

                            // 特殊能力のレベル指定を切り出す
                            j = Strings.InStr(buf2, "Lv");
                            switch (j)
                            {
                            case 0:
                            {
                                // 指定なし
                                aname  = buf2;
                                alevel = Constants.DEFAULT_LEVEL;
                                break;
                            }

                            case 1:
                            {
                                // レベル指定のみあり
                                if (!Information.IsNumeric(Strings.Mid(buf2, j + 2)))
                                {
                                    SRC.AddDataError(reader.InvalidData(@"特殊能力「" + aname + "」のレベル指定が不正です。", data_name));
                                }

                                alevel = Conversions.ToDouble(Strings.Mid(buf2, j + 2));
                                if (string.IsNullOrEmpty(aname))
                                {
                                    SRC.AddDataError(reader.InvalidData(@"行頭から" + SrcFormatter.Format((object)((i + 1) / 2)) + "番目の特殊能力名の設定が間違っています。", data_name));
                                }

                                break;
                            }

                            default:
                            {
                                // 特殊能力名とレベルの両方が指定されている
                                aname  = Strings.Left(buf2, j - 1);
                                alevel = Conversions.ToDouble(Strings.Mid(buf2, j + 2));
                                break;
                            }
                            }
                        }
                        // 特殊能力修得レベル
                        else if (Information.IsNumeric(buf2))
                        {
                            pd.AddSkill(aname, alevel, adata, Conversions.ToInteger(buf2));
                        }
                        else
                        {
                            if (alevel > 0d)
                            {
                                SRC.AddDataError(reader.InvalidData(@"特殊能力「" + aname + "Lv" + SrcFormatter.Format((object)alevel) + "」の修得レベルが間違っています。", data_name));
                            }
                            else
                            {
                                SRC.AddDataError(reader.InvalidData(@"特殊能力「" + aname + "」の修得レベルが間違っています。", data_name));
                            }

                            pd.AddSkill(aname, alevel, adata, 1);
                        }

                        if (string.IsNullOrEmpty(buf))
                        {
                            // ここでこの行は終り

                            // iが奇数の場合は修得レベルが抜けている
                            if (i % 2 == 1)
                            {
                                if (alevel > 0d)
                                {
                                    SRC.AddDataError(reader.InvalidData(@"特殊能力「" + aname + "Lv" + SrcFormatter.Format((object)alevel) + "」の修得レベルが間違っています。", data_name));
                                }
                                else
                                {
                                    SRC.AddDataError(reader.InvalidData(@"特殊能力「" + aname + "」の修得レベルが間違っています。", data_name));
                                }
                            }

                            line_buf = reader.GetLine();
                            buf      = line_buf;
                            i        = 0;
                            aname    = "";
                        }
                    }
                }
                else if (Strings.InStr(line_buf, "特殊能力,") == 1)
                {
                    // 旧形式による特殊能力表記
                    buf = Strings.Mid(line_buf, 6);
                    int    i      = 0;
                    string aname  = "";
                    string adata  = "";
                    double alevel = Constants.DEFAULT_LEVEL;
                    do
                    {
                        i = (i + 1);

                        // コンマの位置を検索
                        ret = Strings.InStr(buf, ",");
                        // 「"」が使われているか検索
                        int ret2 = Strings.InStr(buf, "\"");
                        if (ret2 < ret && ret2 > 0)
                        {
                            // 「"」が見つかった場合、次の「"」後のコンマを検索
                            bool in_quote = true;
                            int  j        = (ret2 + 1);
                            while (j <= Strings.Len(buf))
                            {
                                switch (Strings.Mid(buf, j, 1) ?? "")
                                {
                                case "\"":
                                {
                                    in_quote = !in_quote;
                                    break;
                                }

                                case ",":
                                {
                                    if (!in_quote)
                                    {
                                        buf2 = Strings.Left(buf, j - 1);
                                        buf  = Strings.Mid(buf, j + 1);
                                    }

                                    break;
                                }
                                }

                                j = (j + 1);
                            }

                            if (j == Strings.Len(buf))
                            {
                                buf2 = buf;
                                buf  = "";
                            }

                            in_quote = false;
                        }
                        else if (ret > 0)
                        {
                            // コンマが見つかったらコンマまでの文字列を切り出す
                            buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                            buf  = Strings.Mid(buf, ret + 1);

                            // コンマの後ろの文字列が空白の場合
                            if (string.IsNullOrEmpty(buf))
                            {
                                if (i % 2 == 1)
                                {
                                    throw reader.InvalidDataException(@"行末の「,」の後に特殊能力指定が抜けています。", data_name);
                                }
                                else
                                {
                                    throw reader.InvalidDataException(@"行末の「,」の後に特殊能力レベル指定が抜けています。", data_name);
                                };
                            }
                        }
                        else
                        {
                            // 行末の文字列
                            buf2 = buf;
                            buf  = "";
                        }

                        if (i % 2 == 1)
                        {
                            // 特殊能力名&レベル

                            if (Strings.InStr(buf2, " ") > 0)
                            {
                                if (string.IsNullOrEmpty(aname))
                                {
                                    throw reader.InvalidDataException(@"行頭から" + SrcFormatter.Format((object)((i + 1) / 2)) + "番目の特殊能力の指定の後に「,」が抜けています。", data_name);
                                }
                                else
                                {
                                    throw reader.InvalidDataException(@"特殊能力「" + aname + "」のレベル指定の後に「,」が抜けています。", data_name);
                                };
                            }

                            // 特殊能力の別名指定がある?
                            int j = Strings.InStr(buf2, "=");
                            if (j > 0)
                            {
                                adata = Strings.Mid(buf2, j + 1);
                                buf2  = Strings.Left(buf2, j - 1);
                            }
                            else
                            {
                                adata = "";
                            }

                            // 特殊能力のレベル指定を切り出す
                            j = Strings.InStr(buf2, "Lv");
                            switch (j)
                            {
                            case 0:
                            {
                                // 指定なし
                                aname  = buf2;
                                alevel = Constants.DEFAULT_LEVEL;
                                break;
                            }

                            case 1:
                            {
                                // レベル指定のみあり
                                if (!Information.IsNumeric(Strings.Mid(buf2, j + 2)))
                                {
                                    throw reader.InvalidDataException(@"特殊能力「" + aname + "」のレベル指定が不正です", data_name);
                                }

                                alevel = Conversions.ToDouble(Strings.Mid(buf2, j + 2));
                                if (string.IsNullOrEmpty(aname))
                                {
                                    throw reader.InvalidDataException(@"行頭から" + SrcFormatter.Format((object)((i + 1) / 2)) + "番目の特殊能力の名前「" + buf2 + "」が不正です", data_name);
                                }

                                break;
                            }

                            default:
                            {
                                // 特殊能力名とレベルの両方が指定されている
                                aname  = Strings.Left(buf2, j - 1);
                                alevel = Conversions.ToDouble(Strings.Mid(buf2, j + 2));
                                break;
                            }
                            }
                        }
                        // 特殊能力修得レベル
                        else if (Information.IsNumeric(buf2))
                        {
                            pd.AddSkill(aname, alevel, adata, Conversions.ToInteger(buf2));
                        }
                        else
                        {
                            if (alevel > 0d)
                            {
                                SRC.AddDataError(reader.InvalidData(@"特殊能力「" + aname + "Lv" + SrcFormatter.Format((object)alevel) + "」の修得レベルが間違っています。", data_name));
                            }
                            else
                            {
                                SRC.AddDataError(reader.InvalidData(@"特殊能力「" + aname + "」の修得レベルが間違っています。", data_name));
                            }

                            pd.AddSkill(aname, alevel, adata, 1);
                        }
                    }while (ret > 0);

                    // iが奇数の場合は修得レベルが抜けている
                    if (i % 2 == 1)
                    {
                        if (alevel > 0d)
                        {
                            SRC.AddDataError(reader.InvalidData(@"特殊能力「" + aname + "Lv" + SrcFormatter.Format((object)alevel) + "」の修得レベルが間違っています。", data_name));
                        }
                        else
                        {
                            SRC.AddDataError(reader.InvalidData(@"特殊能力「" + aname + "」の修得レベルが間違っています。", data_name));
                        }
                    }

                    line_buf = reader.GetLine();
                }
                else
                {
                    throw reader.InvalidDataException(@"特殊能力の設定が抜けています。", data_name);
                }

                // 格闘
                if (Strings.Len(line_buf) == 0)
                {
                    throw reader.InvalidDataException(@"格闘攻撃力の設定が抜けています。", data_name);
                }

                ret = Strings.InStr(line_buf, ",");
                if (ret == 0)
                {
                    throw reader.InvalidDataException(@"射撃攻撃力の設定が抜けています。", data_name);
                }

                buf2 = Strings.Trim(Strings.Left(line_buf, ret - 1));
                buf  = Strings.Mid(line_buf, ret + 1);
                if (Information.IsNumeric(buf2))
                {
                    pd.Infight = GeneralLib.MinLng(Conversions.ToInteger(buf2), 9999);
                }
                else
                {
                    SRC.AddDataError(reader.InvalidData(@"格闘攻撃力の設定が間違っています。", data_name));
                }

                // 射撃
                ret = Strings.InStr(buf, ",");
                if (ret == 0)
                {
                    throw reader.InvalidDataException(@"命中の設定が抜けています。", data_name);
                }

                buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                buf  = Strings.Mid(buf, ret + 1);
                if (Information.IsNumeric(buf2))
                {
                    pd.Shooting = GeneralLib.MinLng(Conversions.ToInteger(buf2), 9999);
                }
                else
                {
                    SRC.AddDataError(reader.InvalidData(@"射撃攻撃力の設定が間違っています。", data_name));
                }

                // 命中
                ret = Strings.InStr(buf, ",");
                if (ret == 0)
                {
                    throw reader.InvalidDataException(@"回避の設定が抜けています。", data_name);
                }

                buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                buf  = Strings.Mid(buf, ret + 1);
                if (Information.IsNumeric(buf2))
                {
                    pd.Hit = GeneralLib.MinLng(Conversions.ToInteger(buf2), 9999);
                }
                else
                {
                    SRC.AddDataError(reader.InvalidData(@"命中の設定が間違っています。", data_name));
                }

                // 回避
                ret = Strings.InStr(buf, ",");
                if (ret == 0)
                {
                    throw reader.InvalidDataException(@"技量の設定が抜けています。", data_name);
                }

                buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                buf  = Strings.Mid(buf, ret + 1);
                if (Information.IsNumeric(buf2))
                {
                    pd.Dodge = GeneralLib.MinLng(Conversions.ToInteger(buf2), 9999);
                }
                else
                {
                    SRC.AddDataError(reader.InvalidData(@"回避の設定が間違っています。", data_name));
                }

                // 技量
                ret = Strings.InStr(buf, ",");
                if (ret == 0)
                {
                    throw reader.InvalidDataException(@"反応の設定が抜けています。", data_name);
                }

                buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                buf  = Strings.Mid(buf, ret + 1);
                if (Information.IsNumeric(buf2))
                {
                    pd.Technique = GeneralLib.MinLng(Conversions.ToInteger(buf2), 9999);
                }
                else
                {
                    SRC.AddDataError(reader.InvalidData(@"技量の設定が間違っています。", data_name));
                }

                // 反応
                ret = Strings.InStr(buf, ",");
                if (ret == 0)
                {
                    throw reader.InvalidDataException(@"性格の設定が抜けています。", data_name);
                }

                buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                buf  = Strings.Mid(buf, ret + 1);
                if (Information.IsNumeric(buf2))
                {
                    pd.Intuition = GeneralLib.MinLng(Conversions.ToInteger(buf2), 9999);
                }
                else
                {
                    SRC.AddDataError(reader.InvalidData(@"反応の設定が間違っています。", data_name));
                }

                // 性格
                buf2 = Strings.Trim(buf);
                if (Strings.Len(buf2) == 0)
                {
                    throw reader.InvalidDataException(@"性格の設定が抜けています。", data_name);
                }

                if (Strings.InStr(buf2, ",") > 0)
                {
                    SRC.AddDataError(reader.InvalidData(@"行末に余分なコンマが付けられています。", data_name));
                    buf2 = Strings.Trim(Strings.Left(buf2, Strings.InStr(buf2, ",") - 1));
                }

                if (!Information.IsNumeric(buf2))
                {
                    pd.Personality = buf2;
                }
                else
                {
                    SRC.AddDataError(reader.InvalidData(@"性格の設定が間違っています。", data_name));
                }

                // スペシャルパワー
                line_buf = reader.GetLine();
                switch (line_buf ?? "")
                {
                // スペシャルパワーを持っていない
                case "SPなし":
                case "精神なし":
                {
                    break;
                }

                case var @case when @case == "":
                {
                    throw reader.InvalidDataException(@"スペシャルパワーの設定が抜けています。", data_name);
                }

                default:
                {
                    ret = Strings.InStr(line_buf, ",");
                    if (ret == 0)
                    {
                        throw reader.InvalidDataException(@"SP値の設定が抜けています。", data_name);
                    }

                    buf2 = Strings.Trim(Strings.Left(line_buf, ret - 1));
                    buf  = Strings.Mid(line_buf, ret + 1);
                    if (buf2 != "SP" && buf2 != "精神")
                    {
                        throw reader.InvalidDataException(@"スペシャルパワーの設定が抜けています。", data_name);
                    }

                    // SP値
                    ret = Strings.InStr(buf, ",");
                    if (ret > 0)
                    {
                        buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                        buf  = Strings.Mid(buf, ret + 1);
                    }
                    else
                    {
                        buf2 = Strings.Trim(buf);
                        buf  = "";
                    }

                    if (Information.IsNumeric(buf2))
                    {
                        pd.SP = GeneralLib.MinLng(Conversions.ToInteger(buf2), 9999);
                    }
                    else
                    {
                        SRC.AddDataError(reader.InvalidData(@"SPの設定が間違っています。", data_name));
                        pd.SP = 1;
                    }

                    // スペシャルパワーと獲得レベル
                    ret = Strings.InStr(buf, ",");
                    string sname = "";
                    while (ret > 0)
                    {
                        sname = Strings.Trim(Strings.Left(buf, ret - 1));
                        int sp_cost = 0;
                        buf = Strings.Mid(buf, ret + 1);

                        // SP消費量
                        if (Strings.InStr(sname, "=") > 0)
                        {
                            sp_cost = GeneralLib.StrToLng(Strings.Mid(sname, Strings.InStr(sname, "=") + 1));
                            sname   = Strings.Left(sname, Strings.InStr(sname, "=") - 1);
                        }
                        else
                        {
                            sp_cost = 0;
                        }

                        ret = Strings.InStr(buf, ",");
                        if (ret == 0)
                        {
                            buf2 = Strings.Trim(buf);
                            buf  = "";
                        }
                        else
                        {
                            buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                            buf  = Strings.Mid(buf, ret + 1);
                        }

                        if (string.IsNullOrEmpty(sname))
                        {
                            SRC.AddDataError(reader.InvalidData(@"スペシャルパワーの指定が抜けています。", data_name));
                        }
                        // TODO ビューワでSP設定しとく
                        //else if (!SRC.SPDList.IsDefined(sname))
                        //{
                        //    SRC.AddDataError(reader.InvalidData(@sname + "というスペシャルパワーは存在しません。", data_name));
                        //}
                        else if (!Information.IsNumeric(buf2))
                        {
                            SRC.AddDataError(reader.InvalidData(@"スペシャルパワー「" + sname + "」の獲得レベルが間違っています。", data_name));
                            pd.AddSpecialPower(sname, 1, sp_cost);
                        }
                        else
                        {
                            pd.AddSpecialPower(sname, Conversions.ToInteger(buf2), sp_cost);
                        }

                        ret = Strings.InStr(buf, ",");
                    }

                    if (!string.IsNullOrEmpty(buf))
                    {
                        SRC.AddDataError(reader.InvalidData(@"スペシャルパワー「" + Strings.Trim(sname) + "」の獲得レベル指定が抜けています。", data_name));
                    }

                    break;
                }
                }

                // ビットマップ, MIDI
                line_buf = reader.GetLine();

                // ビットマップ
                if (Strings.Len(line_buf) == 0)
                {
                    throw reader.InvalidDataException(@"ビットマップの設定が抜けています。", data_name);
                }

                ret = Strings.InStr(line_buf, ",");
                if (ret == 0)
                {
                    throw reader.InvalidDataException(@"MIDIの設定が抜けています。", data_name);
                }

                buf2 = Strings.Trim(Strings.Left(line_buf, ret - 1));
                buf  = Strings.Mid(line_buf, ret + 1);
                if (Strings.LCase(Strings.Right(buf2, 4)) == ".bmp")
                {
                    pd.Bitmap = buf2;
                }
                else
                {
                    SRC.AddDataError(reader.InvalidData(@"ビットマップの設定が間違っています。", data_name));
                    pd.IsBitmapMissing = true;
                }

                // MIDI
                buf  = Strings.Trim(buf);
                buf2 = buf;
                while (Strings.Right(buf2, 1) == ")")
                {
                    buf2 = Strings.Left(buf2, Strings.Len(buf2) - 1);
                }
                switch (Strings.LCase(Strings.Right(buf2, 4)) ?? "")
                {
                case ".mid":
                case ".mp3":
                case ".wav":
                case "-":
                {
                    pd.BGM = buf;
                    break;
                }

                case var case1 when case1 == "":
                {
                    SRC.AddDataError(reader.InvalidData(@"MIDIの設定が抜けています。", data_name));
                    pd.Bitmap = "-.mid";
                    break;
                }

                default:
                {
                    SRC.AddDataError(reader.InvalidData(@"MIDIの設定が間違っています。", data_name));
                    pd.Bitmap = "-.mid";
                    break;
                }
                }

                if (reader.EOT)
                {
                    return(pd);
                }

                line_buf = reader.GetLine();
                if (line_buf != "===")
                {
                    return(pd);
                }

                // 特殊能力データ
                line_buf = UnitDataList.LoadFeature(data_name, pd, reader, SRC);


                if (line_buf != "===")
                {
                    return(pd);
                }

                // 武器データ
                line_buf = UnitDataList.LoadWepon(data_name, pd, reader, SRC);

                if (line_buf != "===")
                {
                    return(pd);
                }

                // アビリティデータ
                line_buf = UnitDataList.LoadAbility(data_name, pd, reader, SRC);
            }
            finally
            {
                if (pd != null)
                {
                    pd.Raw = reader.RawData;
                    reader.ClearRawData();
                }
            }
            return(pd);
        }
Esempio n. 9
0
        public void Load(string fname, Stream stream)
        {
            using (var reader = new SrcDataReader(fname, stream))
            {
                string line_buf = "";
                while (reader.HasMore)
                {
                    line_buf = reader.GetLine();
                    if (string.IsNullOrEmpty(line_buf))
                    {
                        continue;
                    }

                    // 名称
                    var data_name = line_buf;
                    if (Strings.InStr(line_buf, ",") > 0)
                    {
                        throw reader.InvalidDataException("名称の設定が抜けています。", data_name);
                    }
                    if (Strings.InStr(data_name, " ") > 0)
                    {
                        throw reader.InvalidDataException("名称に半角スペースは使用出来ません。", data_name);
                    }

                    if (Strings.InStr(data_name, "(") > 0 || Strings.InStr(data_name, ")") > 0)
                    {
                        throw reader.InvalidDataException("名称に全角括弧は使用出来ません。", data_name);
                    }

                    if (Strings.InStr(data_name, "\"") > 0)
                    {
                        throw reader.InvalidDataException("名称に\"は使用出来ません。", data_name);
                    }

                    NonPilotData pd;
                    if (IsDefined(data_name))
                    {
                        // すでに定義されているノンパイロットのデータであれば置き換える
                        if ((Item(data_name).Name ?? "") == (data_name ?? ""))
                        {
                            pd = Item(data_name);
                        }
                        else
                        {
                            pd = Add(data_name);
                        }
                    }
                    else
                    {
                        pd = Add(data_name);
                    }
                    // 愛称、ビットマップ
                    line_buf = reader.GetLine();

                    // 愛称
                    var ret = Strings.InStr(line_buf, ",");
                    if (ret == 0)
                    {
                        throw reader.InvalidDataException("ビットマップの設定が抜けています。", data_name);
                    }

                    var buf2 = Strings.Trim(Strings.Left(line_buf, ret - 1));
                    var buf  = Strings.Mid(line_buf, ret + 1);
                    if (!string.IsNullOrEmpty(buf2))
                    {
                        pd.Nickname = buf2;
                    }
                    else
                    {
                        throw reader.InvalidDataException("愛称の設定が間違っています。", data_name);
                    }

                    // ビットマップ
                    buf2 = Strings.Trim(buf);
                    if (Strings.LCase(Strings.Right(buf2, 4)) == ".bmp")
                    {
                        pd.Bitmap = buf2;
                    }
                    else
                    {
                        SRC.AddDataError(reader.InvalidData("ビットマップの設定が間違っています。", data_name));
                    }
                }
            }
        }
Esempio n. 10
0
        private ItemData LoadItem(SrcDataReader reader, ItemData lastId)
        {
            ItemData nd = null;

            try
            {
                string buf, buf2;

                string data_name = "";
                string line_buf  = "";
                // 空行をスキップ
                while (reader.HasMore && string.IsNullOrEmpty(line_buf))
                {
                    line_buf = reader.GetLine();
                }
                if (lastId != null)
                {
                    lastId.DataComment = reader.RawComment.Trim();
                }
                else
                {
                    DataComment = string.Join(Environment.NewLine + Environment.NewLine,
                                              new string[] {
                        DataComment,
                        reader.RawComment.Trim(),
                    }.Where(x => !string.IsNullOrEmpty(x)));
                }
                reader.ClearRawComment();
                if (reader.EOT)
                {
                    return(null);
                }

                if (Strings.InStr(line_buf, ",") > 0)
                {
                    throw reader.InvalidDataException(@"名称の設定が抜けています。", data_name);
                }

                // 名称
                data_name = line_buf;
                if (Strings.InStr(data_name, " ") > 0)
                {
                    throw reader.InvalidDataException("名称に半角スペースは使用出来ません。", data_name);
                }

                if (Strings.InStr(data_name, "(") > 0 || Strings.InStr(data_name, ")") > 0)
                {
                    throw reader.InvalidDataException("名称に全角括弧は使用出来ません。", data_name);
                }

                if (Strings.InStr(data_name, "\"") > 0)
                {
                    throw reader.InvalidDataException("名称に\"は使用出来ません。", data_name);
                }

                if (IsDefined(data_name))
                {
                    Delete(data_name);
                }

                nd = Add(data_name);
                // 愛称、読み仮名、アイテムクラス、装備個所
                line_buf = reader.GetLine();

                // 書式チェックのため、コンマの数を数えておく
                var comma_num = 0;
                var loopTo    = Strings.Len(line_buf);
                for (var i = 1; i <= loopTo; i++)
                {
                    if (Strings.Mid(line_buf, i, 1) == ",")
                    {
                        comma_num = (comma_num + 1);
                    }
                }

                if (comma_num < 2)
                {
                    throw reader.InvalidDataException("設定に抜けがあります。", data_name);
                }
                else if (comma_num > 3)
                {
                    throw reader.InvalidDataException("余分な「,」があります。", data_name);
                }

                // 愛称
                if (Strings.Len(line_buf) == 0)
                {
                    throw reader.InvalidDataException("愛称の設定が抜けています。", data_name);
                }

                var ret = Strings.InStr(line_buf, ",");
                buf2        = Strings.Trim(Strings.Left(line_buf, ret - 1));
                buf         = Strings.Mid(line_buf, ret + 1);
                nd.Nickname = buf2;

                // 読み仮名
                if (comma_num == 3)
                {
                    ret         = Strings.InStr(buf, ",");
                    buf2        = Strings.Trim(Strings.Left(buf, ret - 1));
                    buf         = Strings.Mid(buf, ret + 1);
                    nd.KanaName = buf2;
                }
                else
                {
                    nd.KanaName = GeneralLib.StrToHiragana(nd.Nickname);
                }

                // アイテムクラス
                ret      = Strings.InStr(buf, ",");
                buf2     = Strings.Trim(Strings.Left(buf, ret - 1));
                buf      = Strings.Mid(buf, ret + 1);
                nd.Class = buf2;

                // 装備個所
                buf2 = Strings.Trim(buf);
                if (Strings.Len(buf2) == 0)
                {
                    throw reader.InvalidDataException("装備個所の設定が抜けています。", data_name);
                }

                nd.Part = buf2;

                // 特殊能力データ
                line_buf = UnitDataList.LoadFeatureOuter(data_name, nd, reader, SRC);

                // 最大HP修正値, 最大EN修正値, 装甲修正値, 運動性修正値, 移動力修正値

                // 最大HP修正値
                ret = Strings.InStr(line_buf, ",");
                if (ret == 0)
                {
                    throw reader.InvalidDataException("最大EN修正値の設定が抜けています。", data_name);
                }

                buf2 = Strings.Trim(Strings.Left(line_buf, ret - 1));
                buf  = Strings.Mid(line_buf, ret + 1);
                if (Information.IsNumeric(buf2))
                {
                    nd.HP = Conversions.ToInteger(buf2);
                }
                else
                {
                    SRC.AddDataError(reader.InvalidData("最大HP修正値の設定が間違っています。", data_name));
                }

                // 最大EN修正値
                ret = Strings.InStr(buf, ",");
                if (ret == 0)
                {
                    throw reader.InvalidDataException("装甲修正値の設定が抜けています。", data_name);
                }

                buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                buf  = Strings.Mid(buf, ret + 1);
                if (Information.IsNumeric(buf2))
                {
                    nd.EN = Conversions.ToInteger(buf2);
                }
                else
                {
                    SRC.AddDataError(reader.InvalidData("最大EN修正値の設定が間違っています。", data_name));
                }

                // 装甲修正値
                ret = Strings.InStr(buf, ",");
                if (ret == 0)
                {
                    throw reader.InvalidDataException("運動性修正値の設定が抜けています。", data_name);
                }

                buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                buf  = Strings.Mid(buf, ret + 1);
                if (Information.IsNumeric(buf2))
                {
                    nd.Armor = Conversions.ToInteger(buf2);
                }
                else
                {
                    SRC.AddDataError(reader.InvalidData("装甲修正値の設定が間違っています。", data_name));
                }

                // 運動性修正値
                ret = Strings.InStr(buf, ",");
                if (ret == 0)
                {
                    throw reader.InvalidDataException("移動力修正値の設定が抜けています。", data_name);
                }

                buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                buf  = Strings.Mid(buf, ret + 1);
                if (Information.IsNumeric(buf2))
                {
                    nd.Mobility = Conversions.ToInteger(buf2);
                }
                else
                {
                    SRC.AddDataError(reader.InvalidData("運動性修正値の設定が間違っています。", data_name));
                }

                // 移動力修正値
                buf2 = Strings.Trim(buf);
                if (Strings.Len(buf2) == 0)
                {
                    throw reader.InvalidDataException("移動力修正値の設定が抜けています。", data_name);
                }

                if (Information.IsNumeric(buf2))
                {
                    nd.Speed = Conversions.ToInteger(buf2);
                }
                else
                {
                    SRC.AddDataError(reader.InvalidData("移動力修正値の設定が間違っています。", data_name));
                }

                if (reader.EOT)
                {
                    return(nd);
                }

                // 武器データ
                line_buf = UnitDataList.LoadWepon(data_name, nd, reader, SRC);

                if (line_buf == "===")
                {
                    // アビリティデータ
                    line_buf = UnitDataList.LoadAbility(data_name, nd, reader, SRC);
                }

                // 解説
                while (Strings.Left(line_buf, 1) == "*")
                {
                    if (Strings.Len(nd.Comment) > 0)
                    {
                        nd.Comment = nd.Comment + Environment.NewLine;
                    }

                    nd.Comment = nd.Comment + Strings.Mid(line_buf, 2);
                    if (reader.EOT)
                    {
                        break;
                    }

                    line_buf = reader.GetLine();
                }
            }
            finally
            {
                if (nd != null)
                {
                    nd.Raw = reader.RawData;
                    reader.ClearRawData();
                }
            }
            return(nd);
        }
Esempio n. 11
0
        public void Load(string fname, Stream stream)
        {
            using (var reader = new SrcDataReader(fname, stream))
            {
                string line_buf = "";
                while (reader.HasMore)
                {
                    line_buf = reader.GetLine();
                    while (reader.HasMore && string.IsNullOrEmpty(line_buf))
                    {
                        line_buf = reader.GetLine();
                    }

                    // パイロット名一覧
                    var pilot_list = GeneralLib.LNormalize(line_buf);
                    if (IsDefined(pilot_list))
                    {
                        Delete(pilot_list);
                    }


                    DialogData dd = Add(pilot_list);
                    line_buf = reader.GetLine();
                    while (reader.HasMore && Strings.Len(line_buf) > 0)
                    {
                        // シチューション
                        var d = dd.AddDialog(line_buf);
                        while (reader.HasMore)
                        {
                            line_buf = reader.GetLine();

                            // 話者
                            var ret = Strings.InStr(line_buf, ",");
                            if (ret == 0)
                            {
                                // 次のシチュエーションないしダイアログ
                                break;
                            }

                            var pname = Strings.Left(line_buf, ret - 1);

                            // 指定した話者のデータが存在するかチェック。
                            // ただし合体技のパートナーは場合は他の作品のパイロットであることも
                            // あるので話者チェックを行わない。
                            if (Strings.Left(pname, 1) != "@")
                            {
                                if (!SRC.PDList.IsDefined(pname) && !SRC.NPDList.IsDefined(pname) && pname != "システム")
                                {
                                    throw reader.InvalidDataException("パイロット「" + pname + "」が定義されていません。", pilot_list);
                                }
                            }

                            // メッセージ
                            if (Strings.Len(line_buf) == ret)
                            {
                                throw reader.InvalidDataException("メッセージが定義されていません。", pilot_list);
                            }

                            var msg = Strings.Trim(Strings.Mid(line_buf, ret + 1));
                            d.AddMessage(pname, msg);
                        }
                    }
                }
            }
        }
Esempio n. 12
0
        public static string LoadWepon(string data_name, IUnitDataElements ud, SrcDataReader reader, SRC SRC)
        {
            int    ret;
            string buf;
            string buf2;
            string line_buf = reader.GetLine();

            // アビリティとの区切り文字かアイテムの解説行で終了
            while (Strings.Len(line_buf) > 0 &&
                   line_buf != "===" &&
                   !line_buf.StartsWith("*"))
            {
                // 武器名
                ret = Strings.InStr(line_buf, ",");
                if (ret == 0)
                {
                    throw reader.InvalidDataException(@"武器データの終りには空行を置いてください。", data_name);
                }

                string wname = Strings.Trim(Strings.Left(line_buf, ret - 1));
                buf = Strings.Mid(line_buf, ret + 1);
                if (string.IsNullOrEmpty(wname))
                {
                    throw reader.InvalidDataException(@"武器名の設定が間違っています。", data_name);
                }

                // 武器を登録
                WeaponData wd = ud.AddWeapon(wname);

                // 攻撃力
                ret = Strings.InStr(buf, ",");
                if (ret == 0)
                {
                    throw reader.InvalidDataException(@wname + "の最小射程が抜けています。", data_name);
                }

                buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                buf  = Strings.Mid(buf, ret + 1);
                if (Information.IsNumeric(buf2))
                {
                    wd.Power = GeneralLib.MinLng(Conversions.ToInteger(buf2), 99999);
                }
                else if (buf == "-")
                {
                    wd.Power = 0;
                }
                else
                {
                    SRC.AddDataError(reader.InvalidData(@wname + "の攻撃力の設定が間違っています。", data_name));
                    if (GeneralLib.LLength(buf2) > 1)
                    {
                        buf      = GeneralLib.LIndex(buf2, 2) + "," + buf;
                        wd.Power = GeneralLib.StrToLng(GeneralLib.LIndex(buf2, 1));
                    }
                }

                // 最小射程
                ret = Strings.InStr(buf, ",");
                if (ret == 0)
                {
                    throw reader.InvalidDataException(@wname + "の最大射程の設定が抜けています。", data_name);
                }

                buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                buf  = Strings.Mid(buf, ret + 1);
                if (Information.IsNumeric(buf2))
                {
                    wd.MinRange = Conversions.ToInteger(buf2);
                }
                else
                {
                    SRC.AddDataError(reader.InvalidData(@wname + "の最小射程の設定が間違っています。", data_name));
                    wd.MinRange = 1;
                    if (GeneralLib.LLength(buf2) > 1)
                    {
                        buf         = GeneralLib.LIndex(buf2, 2) + "," + buf;
                        wd.MinRange = GeneralLib.StrToLng(GeneralLib.LIndex(buf2, 1));
                    }
                }

                // 最大射程
                ret = Strings.InStr(buf, ",");
                if (ret == 0)
                {
                    throw reader.InvalidDataException(@wname + "の命中率の設定が抜けています。", data_name);
                }

                buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                buf  = Strings.Mid(buf, ret + 1);
                if (Information.IsNumeric(buf2))
                {
                    wd.MaxRange = GeneralLib.MinLng(Conversions.ToInteger(buf2), 99);
                }
                else
                {
                    SRC.AddDataError(reader.InvalidData(@wname + "の最大射程の設定が間違っています。", data_name));
                    wd.MaxRange = 1;
                    if (GeneralLib.LLength(buf2) > 1)
                    {
                        buf         = GeneralLib.LIndex(buf2, 2) + "," + buf;
                        wd.MaxRange = GeneralLib.StrToLng(GeneralLib.LIndex(buf2, 1));
                    }
                }

                // 命中率
                ret = Strings.InStr(buf, ",");
                if (ret == 0)
                {
                    throw reader.InvalidDataException(@wname + "の弾数の設定が抜けています。", data_name);
                }

                buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                buf  = Strings.Mid(buf, ret + 1);
                if (Information.IsNumeric(buf2))
                {
                    int n = Conversions.ToInteger(buf2);
                    if (n > 999)
                    {
                        n = 999;
                    }
                    else if (n < -999)
                    {
                        n = -999;
                    }

                    wd.Precision = n;
                }
                else
                {
                    SRC.AddDataError(reader.InvalidData(@wname + "の命中率の設定が間違っています。", data_name));
                    if (GeneralLib.LLength(buf2) > 1)
                    {
                        buf          = GeneralLib.LIndex(buf2, 2) + "," + buf;
                        wd.Precision = GeneralLib.StrToLng(GeneralLib.LIndex(buf2, 1));
                    }
                }

                // 弾数
                ret = Strings.InStr(buf, ",");
                if (ret == 0)
                {
                    throw reader.InvalidDataException(@wname + "の消費ENの設定が抜けています。", data_name);
                }

                buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                buf  = Strings.Mid(buf, ret + 1);
                if (buf2 != "-")
                {
                    if (Information.IsNumeric(buf2))
                    {
                        wd.Bullet = GeneralLib.MinLng(Conversions.ToInteger(buf2), 99);
                    }
                    else
                    {
                        SRC.AddDataError(reader.InvalidData(@wname + "の弾数の設定が間違っています。", data_name));
                        if (GeneralLib.LLength(buf2) > 1)
                        {
                            buf       = GeneralLib.LIndex(buf2, 2) + "," + buf;
                            wd.Bullet = GeneralLib.StrToLng(GeneralLib.LIndex(buf2, 1));
                        }
                    }
                }

                // 消費EN
                ret = Strings.InStr(buf, ",");
                if (ret == 0)
                {
                    throw reader.InvalidDataException(@wname + "の必要気力が抜けています。", data_name);
                }

                buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                buf  = Strings.Mid(buf, ret + 1);
                if (buf2 != "-")
                {
                    if (Information.IsNumeric(buf2))
                    {
                        wd.ENConsumption = GeneralLib.MinLng(Conversions.ToInteger(buf2), 999);
                    }
                    else
                    {
                        SRC.AddDataError(reader.InvalidData(@wname + "の消費ENの設定が間違っています。", data_name));
                        {
                            buf = GeneralLib.LIndex(buf2, 2) + "," + buf;
                            wd.ENConsumption = GeneralLib.StrToLng(GeneralLib.LIndex(buf2, 1));
                        }
                    }
                }

                // 必要気力
                ret = Strings.InStr(buf, ",");
                if (ret == 0)
                {
                    throw reader.InvalidDataException(@wname + "の地形適応が抜けています。", data_name);
                }

                buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                buf  = Strings.Mid(buf, ret + 1);
                if (buf2 != "-")
                {
                    if (Information.IsNumeric(buf2))
                    {
                        int n = Conversions.ToInteger(buf2);
                        if (n > 1000)
                        {
                            n = 1000;
                        }
                        else if (n < 0)
                        {
                            n = 0;
                        }

                        wd.NecessaryMorale = n;
                    }
                    else
                    {
                        SRC.AddDataError(reader.InvalidData(@wname + "の必要気力の設定が間違っています。", data_name));
                        if (GeneralLib.LLength(buf2) > 1)
                        {
                            buf = GeneralLib.LIndex(buf2, 2) + "," + buf;
                            wd.NecessaryMorale = GeneralLib.StrToLng(GeneralLib.LIndex(buf2, 1));
                        }
                    }
                }

                // 地形適応
                ret = Strings.InStr(buf, ",");
                if (ret == 0)
                {
                    throw reader.InvalidDataException(@wname + "のクリティカル率が抜けています。", data_name);
                }

                buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                buf  = Strings.Mid(buf, ret + 1);
                if (Strings.Len(buf2) == 4)
                {
                    wd.Adaption = buf2;
                }
                else
                {
                    SRC.AddDataError(reader.InvalidData(@wname + "の地形適応の設定が間違っています。", data_name));
                    wd.Adaption = "----";
                    if (GeneralLib.LLength(buf2) > 1)
                    {
                        buf         = GeneralLib.LIndex(buf2, 2) + "," + buf;
                        wd.Adaption = GeneralLib.LIndex(buf2, 1);
                    }
                }

                // クリティカル率
                ret = Strings.InStr(buf, ",");
                if (ret == 0)
                {
                    throw reader.InvalidDataException(@wname + "の武器属性が抜けています。", data_name);
                }

                buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                buf  = Strings.Mid(buf, ret + 1);
                if (Information.IsNumeric(buf2))
                {
                    int n = Conversions.ToInteger(buf2);
                    if (n > 999)
                    {
                        n = 999;
                    }
                    else if (n < -999)
                    {
                        n = -999;
                    }

                    wd.Critical = n;
                }
                else
                {
                    SRC.AddDataError(reader.InvalidData(@wname + "のクリティカル率の設定が間違っています。", data_name));
                    if (GeneralLib.LLength(buf2) > 1)
                    {
                        buf         = GeneralLib.LIndex(buf2, 2) + "," + buf;
                        wd.Critical = GeneralLib.StrToLng(GeneralLib.LIndex(buf2, 1));
                    }
                }

                // 武器属性
                buf = Strings.Trim(buf);
                if (Strings.Len(buf) == 0)
                {
                    SRC.AddDataError(reader.InvalidData(@wname + "の武器属性の設定が間違っています。", data_name));
                }

                if (Strings.Right(buf, 1) == ")")
                {
                    // 必要技能
                    ret = Strings.InStr(buf, "> ");
                    if (ret > 0)
                    {
                        if (ret > 0)
                        {
                            wd.NecessarySkill = Strings.Mid(buf, ret + 2);
                            buf = Strings.Trim(Strings.Left(buf, ret + 1));
                            ret = Strings.InStr(wd.NecessarySkill, "(");
                            wd.NecessarySkill = Strings.Mid(wd.NecessarySkill, ret + 1, Strings.Len(wd.NecessarySkill) - ret - 1);
                        }
                    }
                    else
                    {
                        ret = Strings.InStr(buf, "(");
                        if (ret > 0)
                        {
                            wd.NecessarySkill = Strings.Trim(Strings.Mid(buf, ret + 1, Strings.Len(buf) - ret - 1));
                            buf = Strings.Trim(Strings.Left(buf, ret - 1));
                        }
                    }
                }

                if (Strings.Right(buf, 1) == ">")
                {
                    // 必要条件
                    ret = Strings.InStr(buf, "<");
                    if (ret > 0)
                    {
                        wd.NecessaryCondition = Strings.Trim(Strings.Mid(buf, ret + 1, Strings.Len(buf) - ret - 1));
                        buf = Strings.Trim(Strings.Left(buf, ret - 1));
                    }
                }

                wd.Class = buf;
                if (wd.Class == "-")
                {
                    wd.Class = "";
                }

                if (Strings.InStr(wd.Class, "Lv") > 0)
                {
                    SRC.AddDataError(reader.InvalidData(@wname + "の属性のレベル指定が間違っています。", data_name));
                }

                if (reader.EOT)
                {
                    return("");
                }

                line_buf = reader.GetLine();
            }
            return(line_buf);
        }
Esempio n. 13
0
        public static string LoadFeature(string data_name, IUnitDataElements ud, SrcDataReader reader, SRC SRC)
        {
            string line_buf = reader.GetLine();
            string buf      = line_buf;
            string buf2;
            int    i = 0;

            while (true)
            {
                // パイロットデータ時には空行やデータ区切りでブレークする。
                if (string.IsNullOrEmpty(line_buf) || line_buf == "===")
                {
                    break;
                }

                i = i + 1;
                int  ret      = 0;
                bool in_quote = false;
                var  loopTo1  = Strings.Len(buf);
                int  j;
                for (j = 1; j <= loopTo1; j++)
                {
                    switch (Strings.Mid(buf, j, 1) ?? "")
                    {
                    case ",":
                    {
                        if (!in_quote)
                        {
                            ret = j;
                            break;
                        }
                        break;
                    }

                    case "\"":
                    {
                        in_quote = !in_quote;
                        break;
                    }
                    }
                }

                if (ret > 0)
                {
                    buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                    if (j == 1)
                    {
                        if (Information.IsNumeric(buf2))
                        {
                            break;
                        }
                    }
                    buf = Strings.Trim(Strings.Mid(buf, ret + 1));
                }
                else
                {
                    buf2 = buf;
                    buf  = "";
                }

                // ユニットとアイテムは特殊能力に続いて数値のみの行が続く。
                if (Information.IsNumeric(buf2.Replace("+", "").Replace("-", "")))
                {
                    break;
                }
                else if (string.IsNullOrEmpty(buf2) || Information.IsNumeric(buf2))
                {
                    SRC.AddDataError(reader.InvalidData("行頭から" + i + "番目の特殊能力の設定が間違っています。", data_name));
                }
                else
                {
                    ud.AddFeature(buf2);
                }

                if (string.IsNullOrEmpty(buf))
                {
                    line_buf = reader.GetLine();
                    buf      = line_buf;
                    i        = 0;
                }
            }
            return(line_buf);
        }
Esempio n. 14
0
        public static string LoadFeatureOuter(string data_name, IUnitDataElements ud, SrcDataReader reader, SRC SRC)
        {
            int    ret;
            string buf;
            string buf2;
            string line_buf = reader.GetLine();

            if (line_buf == "特殊能力なし")
            {
                line_buf = reader.GetLine();
            }
            else if (line_buf == "特殊能力")
            {
                // 新形式による特殊能力表記
                line_buf = LoadFeature(data_name, ud, reader, SRC);
            }
            else if (Strings.InStr(line_buf, "特殊能力,") == 1)
            {
                // 旧形式による特殊能力表記
                buf = Strings.Mid(line_buf, 6);
                ret = 0;
                bool in_quote = false;
                var  loopTo2  = Strings.Len(buf);
                int  k;
                for (k = 1; k <= loopTo2; k++)
                {
                    switch (Strings.Mid(buf, k, 1) ?? "")
                    {
                    case ",":
                    {
                        if (!in_quote)
                        {
                            ret = k;
                            break;
                        }

                        break;
                    }

                    case "\"":
                    {
                        in_quote = !in_quote;
                        break;
                    }
                    }
                }

                int i = 0;
                while (ret > 0)
                {
                    i    = (i + 1);
                    buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                    buf  = Strings.Mid(buf, ret + 1);
                    ret  = Strings.InStr(buf, ",");
                    if (!string.IsNullOrEmpty(buf2))
                    {
                        ud.AddFeature(buf2);
                    }
                    else
                    {
                        SRC.AddDataError(reader.InvalidData(SrcFormatter.Format(i + "番目の特殊能力の設定が間違っています。"), data_name));
                    }
                }

                i    = (i + 1);
                buf2 = Strings.Trim(buf);
                if (!string.IsNullOrEmpty(buf2))
                {
                    ud.AddFeature(buf2);
                }
                else
                {
                    SRC.AddDataError(reader.InvalidData(SrcFormatter.Format(i + "番目の特殊能力の設定が間違っています。"), data_name));
                }

                line_buf = reader.GetLine();
            }
            else
            {
                throw reader.InvalidDataException(@"特殊能力の設定が抜けています。", data_name);
            }

            return(line_buf);
        }
Esempio n. 15
0
        // reader から1つユニットを読み込む。
        // 返却したUnitDataはリストに追加されている状態。
        private UnitData LoadUnit(SrcDataReader reader, UnitData lastUd)
        {
            UnitData ud = null;

            try
            {
                int    ret;
                string buf, buf2;
                var    line_buf = "";

                // 空行をスキップ
                while (reader.HasMore && string.IsNullOrEmpty(line_buf))
                {
                    line_buf = reader.GetLine();
                }
                if (lastUd != null)
                {
                    lastUd.DataComment = reader.RawComment.Trim();
                }
                else
                {
                    DataComment = string.Join(Environment.NewLine + Environment.NewLine,
                                              new string[] {
                        DataComment,
                        reader.RawComment.Trim(),
                    }.Where(x => !string.IsNullOrEmpty(x)));
                }
                reader.ClearRawComment();
                if (reader.EOT)
                {
                    return(null);
                }

                // 名称
                string data_name;
                ret = Strings.InStr(line_buf, ",");
                if (ret > 0)
                {
                    data_name = Strings.Trim(Strings.Left(line_buf, ret - 1));
                    buf       = Strings.Mid(line_buf, ret + 1);
                }
                else
                {
                    data_name = line_buf;
                    buf       = "";
                }

                if (Strings.InStr(data_name, " ") > 0)
                {
                    throw reader.InvalidDataException(@"名称に半角スペースは使用出来ません。", data_name);
                }

                if (Strings.InStr(data_name, "(") > 0 || Strings.InStr(data_name, ")") > 0)
                {
                    throw reader.InvalidDataException(@"名称に全角括弧は使用出来ません。", data_name);
                }

                if (Strings.InStr(data_name, "\"") > 0)
                {
                    throw reader.InvalidDataException(@"名称に\は使用出来ません。", data_name);
                }

                if (IsDefined(data_name))
                {
                    ud = Item(data_name);
                    ud.Clear();
                }
                else
                {
                    ud = Add(data_name);
                }
                // 読み仮名
                ret = Strings.InStr(buf, ",");
                if (ret > 0)
                {
                    throw reader.InvalidDataException(@"読み仮名の後に余分なデータが指定されています。", data_name);
                }
                ud.KanaName = buf;

                // 愛称, 読み仮名, ユニットクラス, パイロット数, アイテム数
                line_buf = reader.GetLine();
                // 書式チェックのため、コンマの数を数えておく
                int comma_num = 0;
                var loopTo    = Strings.Len(line_buf);
                for (int i = 1; i <= loopTo; i++)
                {
                    if (Strings.Mid(line_buf, i, 1) == ",")
                    {
                        comma_num = (comma_num + 1);
                    }
                }

                if (comma_num < 3)
                {
                    throw reader.InvalidDataException(@"設定に抜けがあります。", data_name);
                }
                else if (comma_num > 4)
                {
                    throw reader.InvalidDataException(@"余分な「,」があります。", data_name);
                }

                // 愛称
                if (Strings.Len(line_buf) == 0)
                {
                    throw reader.InvalidDataException(@"愛称の設定が抜けています。", data_name);
                }

                ret         = Strings.InStr(line_buf, ",");
                buf2        = Strings.Trim(Strings.Left(line_buf, ret - 1));
                buf         = Strings.Mid(line_buf, ret + 1);
                ud.Nickname = buf2;

                // 読み仮名
                if (comma_num == 4)
                {
                    ret         = Strings.InStr(buf, ",");
                    buf2        = Strings.Trim(Strings.Left(buf, ret - 1));
                    buf         = Strings.Mid(buf, ret + 1);
                    ud.KanaName = buf2;
                }
                else
                {
                    ud.KanaName = GeneralLib.StrToHiragana(ud.Nickname);
                }

                // ユニットクラス
                ret  = Strings.InStr(buf, ",");
                buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                buf  = Strings.Mid(buf, ret + 1);
                if (!Information.IsNumeric(buf2))
                {
                    ud.Class = buf2;
                }
                else
                {
                    SRC.AddDataError(reader.InvalidData(@"ユニットクラスの設定が間違っています。", data_name));
                    ud.Class = "汎用";
                }

                // パイロット数
                ret  = Strings.InStr(buf, ",");
                buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                buf  = Strings.Mid(buf, ret + 1);
                if (Strings.Left(buf2, 1) != "(")
                {
                    if (Information.IsNumeric(buf2))
                    {
                        ud.PilotNum = GeneralLib.MinLng(Conversions.ToInteger(buf2), 99);
                    }
                    else
                    {
                        SRC.AddDataError(reader.InvalidData(@"パイロット数の設定が間違っています。", data_name));
                        ud.PilotNum = 1;
                    }
                    if (ud.PilotNum < 1)
                    {
                        SRC.AddDataError(reader.InvalidData(@"パイロット数の設定が間違っています。", data_name));
                        ud.PilotNum = 1;
                    }
                }
                else
                {
                    if (Strings.Right(buf2, 1) != ")")
                    {
                        throw reader.InvalidDataException(@"パイロット数の設定が間違っています。", data_name);
                    }

                    buf2 = Strings.Mid(buf2, 2, Strings.Len(buf2) - 2);
                    if (Information.IsNumeric(buf2))
                    {
                        ud.PilotNum = GeneralLib.MinLng(Conversions.ToInteger(buf2), 99);
                    }
                    else
                    {
                        SRC.AddDataError(reader.InvalidData(@"パイロット数の設定が間違っています。", data_name));
                        ud.PilotNum = 1;
                    }

                    if (ud.PilotNum < 1)
                    {
                        SRC.AddDataError(reader.InvalidData(@"パイロット数の設定が間違っています。", data_name));
                        ud.PilotNum = 1;
                    }

                    // XXX 何で負数にしてるの?
                    ud.PilotNum = -ud.PilotNum;
                }

                // アイテム数
                buf = Strings.Trim(buf);
                if (Strings.Len(buf) == 0)
                {
                    throw reader.InvalidDataException(@"アイテム数の設定が抜けています。", data_name);
                }

                if (Information.IsNumeric(buf))
                {
                    ud.ItemNum = GeneralLib.MinLng(Conversions.ToInteger(buf), 99);
                }
                else
                {
                    SRC.AddDataError(reader.InvalidData(@"アイテム数の設定が間違っています。", data_name));
                    ud.ItemNum = 4;
                }

                // 移動可能地形, 移動力, サイズ, 修理費, 経験値
                line_buf = reader.GetLine();

                // 移動可能地形
                ret = Strings.InStr(line_buf, ",");
                if (ret == 0)
                {
                    throw reader.InvalidDataException(@"移動力の設定が抜けています。", data_name);
                }

                buf2 = Strings.Trim(Strings.Left(line_buf, ret - 1));
                buf  = Strings.Mid(line_buf, ret + 1);
                if (!Information.IsNumeric(buf2))
                {
                    ud.Transportation = buf2;
                }
                else
                {
                    SRC.AddDataError(reader.InvalidData(@"移動可能地形の設定が間違っています。", data_name));
                    ud.Transportation = "陸";
                }

                // 移動力
                ret = Strings.InStr(buf, ",");
                if (ret == 0)
                {
                    throw reader.InvalidDataException(@"サイズの設定が抜けています。", data_name);
                }

                buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                buf  = Strings.Mid(buf, ret + 1);
                if (Information.IsNumeric(buf2))
                {
                    ud.Speed = GeneralLib.MinLng(Conversions.ToInteger(buf2), 99);
                }
                else
                {
                    SRC.AddDataError(reader.InvalidData(@"移動力の設定が間違っています。", data_name));
                }

                // サイズ
                ret = Strings.InStr(buf, ",");
                if (ret == 0)
                {
                    throw reader.InvalidDataException(@"経験値の設定が抜けています。", data_name);
                }

                buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                buf  = Strings.Mid(buf, ret + 1);
                switch (buf2 ?? "")
                {
                case "XL":
                case "LL":
                case "L":
                case "M":
                case "S":
                case "SS":
                {
                    ud.Size = buf2;
                    break;
                }

                default:
                {
                    SRC.AddDataError(reader.InvalidData(@"サイズの設定が間違っています。", data_name));
                    ud.Size = "M";
                    break;
                }
                }

                // 修理費
                ret = Strings.InStr(buf, ",");
                if (ret == 0)
                {
                    throw reader.InvalidDataException(@"経験値の設定が抜けています。", data_name);
                }

                buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                buf  = Strings.Mid(buf, ret + 1);
                if (Information.IsNumeric(buf2))
                {
                    ud.Value = GeneralLib.MinLng(Conversions.ToInteger(buf2), 9999999);
                }
                else
                {
                    SRC.AddDataError(reader.InvalidData(@"修理費の設定が間違っています。", data_name));
                }

                // 経験値
                buf = Strings.Trim(buf);
                if (Strings.Len(buf) == 0)
                {
                    throw reader.InvalidDataException(@"経験値の設定が抜けています。", data_name);
                }

                if (Information.IsNumeric(buf))
                {
                    ud.ExpValue = GeneralLib.MinLng(Conversions.ToInteger(buf), 9999);
                }
                else
                {
                    SRC.AddDataError(reader.InvalidData(@"経験値の設定が間違っています。", data_name));
                }

                // 特殊能力データ
                line_buf = LoadFeatureOuter(data_name, ud, reader, SRC);

                // 最大HP
                ret = Strings.InStr(line_buf, ",");
                if (ret == 0)
                {
                    throw reader.InvalidDataException(@"最大ENの設定が抜けています。", data_name);
                }

                buf2 = Strings.Trim(Strings.Left(line_buf, ret - 1));
                buf  = Strings.Mid(line_buf, ret + 1);
                if (Information.IsNumeric(buf2))
                {
                    ud.HP = GeneralLib.MinLng(Conversions.ToInteger(buf2), 9999999);
                }
                else
                {
                    SRC.AddDataError(reader.InvalidData(@"最大HPの設定が間違っています。", data_name));
                    ud.HP = 1000;
                }

                // 最大EN
                ret = Strings.InStr(buf, ",");
                if (ret == 0)
                {
                    throw reader.InvalidDataException(@"装甲の設定が抜けています。", data_name);
                }

                buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                buf  = Strings.Mid(buf, ret + 1);
                if (Information.IsNumeric(buf2))
                {
                    ud.EN = GeneralLib.MinLng(Conversions.ToInteger(buf2), 9999);
                }
                else
                {
                    SRC.AddDataError(reader.InvalidData(@"最大ENの設定が間違っています。", data_name));
                    ud.EN = 100;
                }

                // 装甲
                ret = Strings.InStr(buf, ",");
                if (ret == 0)
                {
                    throw reader.InvalidDataException(@"運動性の設定が抜けています。", data_name);
                }

                buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                buf  = Strings.Mid(buf, ret + 1);
                if (Information.IsNumeric(buf2))
                {
                    ud.Armor = GeneralLib.MinLng(Conversions.ToInteger(buf2), 99999);
                }
                else
                {
                    SRC.AddDataError(reader.InvalidData(@"装甲の設定が間違っています。", data_name));
                }

                // 運動性
                buf2 = Strings.Trim(buf);
                if (Strings.Len(buf2) == 0)
                {
                    throw reader.InvalidDataException(@"運動性の設定が抜けています。", data_name);
                }

                if (Information.IsNumeric(buf2))
                {
                    ud.Mobility = GeneralLib.MinLng(Conversions.ToInteger(buf2), 9999);
                }
                else
                {
                    SRC.AddDataError(reader.InvalidData(@"運動性の設定が間違っています。", data_name));
                }

                // 地形適応, ビットマップ
                line_buf = reader.GetLine();

                // 地形適応
                ret = Strings.InStr(line_buf, ",");
                if (ret == 0)
                {
                    throw reader.InvalidDataException(@"ビットマップの設定が抜けています。", data_name);
                }

                buf2 = Strings.Trim(Strings.Left(line_buf, ret - 1));
                buf  = Strings.Mid(line_buf, ret + 1);
                if (Strings.Len(buf2) == 4)
                {
                    ud.Adaption = buf2;
                }
                else
                {
                    SRC.AddDataError(reader.InvalidData(@"地形適応の設定が間違っています。", data_name));
                    ud.Adaption = "AAAA";
                }

                // ビットマップ
                buf = Strings.Trim(buf);
                if (Strings.Len(buf) == 0)
                {
                    throw reader.InvalidDataException(@"ビットマップの設定が抜けています。", data_name);
                }

                if (Strings.LCase(Strings.Right(buf, 4)) == ".bmp")
                {
                    ud.Bitmap = buf;
                }
                else
                {
                    SRC.AddDataError(reader.InvalidData(@"ビットマップの設定が間違っています。", data_name));
                    ud.IsBitmapMissing = true;
                }

                if (reader.EOT)
                {
                    return(ud);
                }

                // 武器データ
                line_buf = LoadWepon(data_name, ud, reader, SRC);

                if (line_buf != "===")
                {
                    return(ud);
                }

                // アビリティデータ
                line_buf = LoadAbility(data_name, ud, reader, SRC);
            }
            finally
            {
                if (ud != null)
                {
                    ud.Raw = reader.RawData;
                    reader.ClearRawData();
                }
            }
            return(ud);
        }
Esempio n. 16
0
        public static string LoadAbility(string data_name, IUnitDataElements ud, SrcDataReader reader, SRC SRC)
        {
            int    ret;
            string buf;
            string buf2;
            string line_buf = reader.GetLine();

            // アイテムの解説行で終了
            while (Strings.Len(line_buf) > 0 &&
                   !line_buf.StartsWith("*"))
            {
                // アビリティ名
                ret = Strings.InStr(line_buf, ",");
                if (ret == 0)
                {
                    throw reader.InvalidDataException(@"アビリティデータの終りに空行を置いてください。", data_name);
                }

                string sname = Strings.Trim(Strings.Left(line_buf, ret - 1));
                buf = Strings.Mid(line_buf, ret + 1);
                if (string.IsNullOrEmpty(sname))
                {
                    throw reader.InvalidDataException(@"アビリティ名の設定が間違っています。", data_name);
                }

                // アビリティを登録
                AbilityData sd = ud.AddAbility(sname);

                // 効果
                ret = Strings.InStr(buf, ",");
                if (ret == 0)
                {
                    throw reader.InvalidDataException(@sname + "の射程の設定が抜けています。", data_name);
                }

                buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                buf  = Strings.Mid(buf, ret + 1);
                sd.SetEffect(buf2);

                // 射程
                sd.MinRange = 0;
                ret         = Strings.InStr(buf, ",");
                if (ret == 0)
                {
                    throw reader.InvalidDataException(@sname + "の回数の設定が抜けています。", data_name);
                }

                buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                buf  = Strings.Mid(buf, ret + 1);
                if (Information.IsNumeric(buf2))
                {
                    sd.MaxRange = GeneralLib.MinLng(Conversions.ToInteger(buf2), 99);
                }
                else if (buf2 == "-")
                {
                    sd.MaxRange = 0;
                }
                else
                {
                    SRC.AddDataError(reader.InvalidData(@sname + "の射程の設定が間違っています。", data_name));
                    if (GeneralLib.LLength(buf2) > 1)
                    {
                        buf         = GeneralLib.LIndex(buf2, 2) + "," + buf;
                        sd.MaxRange = GeneralLib.StrToLng(GeneralLib.LIndex(buf2, 1));
                    }
                }

                // 回数
                ret = Strings.InStr(buf, ",");
                if (ret == 0)
                {
                    throw reader.InvalidDataException(@sname + "の消費ENの設定が抜けています。", data_name);
                }

                buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                buf  = Strings.Mid(buf, ret + 1);
                if (buf2 != "-")
                {
                    if (Information.IsNumeric(buf2))
                    {
                        sd.Stock = GeneralLib.MinLng(Conversions.ToInteger(buf2), 99);
                    }
                    else
                    {
                        SRC.AddDataError(reader.InvalidData(@sname + "の回数の設定が間違っています。", data_name));
                        if (GeneralLib.LLength(buf2) > 1)
                        {
                            buf      = GeneralLib.LIndex(buf2, 2) + "," + buf;
                            sd.Stock = GeneralLib.StrToLng(GeneralLib.LIndex(buf2, 1));
                        }
                    }
                }

                // 消費EN
                ret = Strings.InStr(buf, ",");
                if (ret == 0)
                {
                    throw reader.InvalidDataException(@sname + "の必要気力の設定が抜けています。", data_name);
                }

                buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                buf  = Strings.Mid(buf, ret + 1);
                if (buf2 != "-")
                {
                    if (Information.IsNumeric(buf2))
                    {
                        sd.ENConsumption = GeneralLib.MinLng(Conversions.ToInteger(buf2), 999);
                    }
                    else
                    {
                        SRC.AddDataError(reader.InvalidData(@sname + "の消費ENの設定が間違っています。", data_name));
                        if (GeneralLib.LLength(buf2) > 1)
                        {
                            buf = GeneralLib.LIndex(buf2, 2) + "," + buf;
                            sd.ENConsumption = GeneralLib.StrToLng(GeneralLib.LIndex(buf2, 1));
                        }
                    }
                }

                // 必要気力
                ret = Strings.InStr(buf, ",");
                if (ret == 0)
                {
                    throw reader.InvalidDataException(@sname + "のアビリティ属性の設定が抜けています。", data_name);
                }

                buf2 = Strings.Trim(Strings.Left(buf, ret - 1));
                buf  = Strings.Mid(buf, ret + 1);
                if (buf2 != "-")
                {
                    if (Information.IsNumeric(buf2))
                    {
                        int n = Conversions.ToInteger(buf2);
                        if (n > 1000)
                        {
                            n = 1000;
                        }
                        else if (n < 0)
                        {
                            n = 0;
                        }

                        sd.NecessaryMorale = n;
                    }
                    else
                    {
                        SRC.AddDataError(reader.InvalidData(@sname + "の必要気力の設定が間違っています。", data_name));
                        if (GeneralLib.LLength(buf2) > 1)
                        {
                            buf = GeneralLib.LIndex(buf2, 2) + "," + buf;
                            sd.NecessaryMorale = GeneralLib.StrToLng(GeneralLib.LIndex(buf2, 1));
                        }
                    }
                }

                // アビリティ属性
                buf = Strings.Trim(buf);
                if (Strings.Len(buf) == 0)
                {
                    SRC.AddDataError(reader.InvalidData(@sname + "のアビリティ属性の設定が間違っています。", data_name));
                }

                if (Strings.Right(buf, 1) == ")")
                {
                    // 必要技能
                    ret = Strings.InStr(buf, "> ");
                    if (ret > 0)
                    {
                        if (ret > 0)
                        {
                            sd.NecessarySkill = Strings.Mid(buf, ret + 2);
                            buf = Strings.Trim(Strings.Left(buf, ret + 1));
                            ret = Strings.InStr(sd.NecessarySkill, "(");
                            sd.NecessarySkill = Strings.Mid(sd.NecessarySkill, ret + 1, Strings.Len(sd.NecessarySkill) - ret - 1);
                        }
                    }
                    else
                    {
                        ret = Strings.InStr(buf, "(");
                        if (ret > 0)
                        {
                            sd.NecessarySkill = Strings.Trim(Strings.Mid(buf, ret + 1, Strings.Len(buf) - ret - 1));
                            buf = Strings.Trim(Strings.Left(buf, ret - 1));
                        }
                    }
                }

                if (Strings.Right(buf, 1) == ">")
                {
                    // 必要条件
                    ret = Strings.InStr(buf, "<");
                    if (ret > 0)
                    {
                        sd.NecessaryCondition = Strings.Trim(Strings.Mid(buf, ret + 1, Strings.Len(buf) - ret - 1));
                        buf = Strings.Trim(Strings.Left(buf, ret - 1));
                    }
                }

                sd.Class = buf;
                if (sd.Class == "-")
                {
                    sd.Class = "";
                }

                if (Strings.InStr(sd.Class, "Lv") > 0)
                {
                    SRC.AddDataError(reader.InvalidData(@sname + "の属性のレベル指定が間違っています。", data_name));
                }
                line_buf = reader.GetLine();
            }

            return(line_buf);
        }