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); }
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); }
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); }
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); }