コード例 #1
0
 public void DataAdd()
 {
     var data = new BattleData();
     try
     {
         data.Weapon = this.weapon.SelectedValue.ToString();
         data.Stage = (this.stg1.IsChecked.Value ? this.stage1.SelectedValue : this.stg2.IsChecked.Value ? this.stage2.SelectedValue : this.stage3.SelectedValue).ToString();
         data.BattleType = (BattleType)this.battleType.SelectedIndex;
         data.IsTag = data.BattleType != BattleType.ナワバリ && this.isTag.IsChecked.Value;
         data.IsWin = this.resultWin.IsChecked.Value;
         data.Result = this.resultKO.IsChecked.Value ? Result.ノックアウト : this.resultBehind.IsChecked.Value ? Result.延長逆転 : Result.タイムアップ;
         data.KaisenMikata = this.kaisenMikata.IsChecked.Value;
         data.KaisenTeki = this.kaisenTeki.IsChecked.Value;
         data.Nuri = (short)(data.BattleType == BattleType.ナワバリ ? this.nawabariNuri.Value.Value : -1);
         data.Kill = (sbyte)(this.kill.Value.HasValue ? this.kill.Value.Value : -1);
         data.Death = (sbyte)(this.death.Value.HasValue ? this.death.Value.Value : -1);
         data.Udemae = data.BattleType != BattleType.ナワバリ && data.BattleType != BattleType.フェス ? this.udemae.SelectedValue.ToString() : "";
         data.UdemaePoint = (sbyte)(data.BattleType != BattleType.ナワバリ && data.BattleType != BattleType.フェス ? this.udemaePoint.Value.Value : -1);
     }
     catch (Exception)
     {
         return;
     }
     DataWrite(data);
 }
コード例 #2
0
 public void DataWrite(BattleData data)
 {
     var dataFileName = this.name.Text + ".csv";
     if (!File.Exists(dataFileName))
     {
         using (var sw = new StreamWriter(dataFileName, true,Encoding.UTF8))
         {
             sw.WriteLine(BattleData.DataLabel);
         }
     }
     using (var sw = new StreamWriter(dataFileName, true, Encoding.UTF8))
     {
         sw.WriteLine(data.ToString());
     }
     if (!Names.Contains(this.name.Text))
     {
         Names.Insert(0, this.name.Text);
         using (var sw = new StreamWriter(NamesFileName, false, Encoding.UTF8))
         {
             sw.WriteLine(string.Join(",",Names));
         }
     }
     
 }
コード例 #3
0
 public static bool TryReadString(string str, out BattleData data)
 {
     var d = str.Split(',');
     data = new BattleData() { Weapon = d[0], Stage = d[1] };
     BattleType type;
     if (Enum.TryParse<BattleType>(d[2], out type))
     {
         data.BattleType = type;
     }
     else
     {
         return false;
     }
     bool b;
     if (bool.TryParse(d[3], out b))
     {
         data.IsTag = b;
     }
     else
     {
         return false;
     }
     if (bool.TryParse(d[4], out b))
     {
         data.IsWin = b;
     }
     else
     {
         return false;
     }
     Result result;
     if (Enum.TryParse<Result>(d[5], out result))
     {
         data.Result = result;
     }
     else
     {
         return false;
     }
     if (bool.TryParse(d[6], out b))
     {
         data.KaisenMikata = b;
     }
     else
     {
         return false;
     }
     if (bool.TryParse(d[7], out b))
     {
         data.KaisenTeki = b;
     }
     else
     {
         return false;
     }
     short s;
     if (short.TryParse(d[8], out s)|| data.BattleType != BattleType.ナワバリ)
     {
         data.Nuri = data.BattleType == BattleType.ナワバリ?s:(short)-1;
     }
     else
     {
         return false;
     }
     sbyte sb;
     if (sbyte.TryParse(d[9], out sb)||d[9]=="")
     {
         data.Kill = d[9] != "" ? sb : (sbyte)-1;
     }
     else
     {
         return false;
     }
     if (sbyte.TryParse(d[10], out sb) || d[10] == "")
     {
         data.Death = d[10] != "" ? sb : (sbyte)-1;
     }
     else
     {
         return false;
     }
     if (data.BattleType == SplatoonRecorder.BattleType.ナワバリ || data.BattleType == SplatoonRecorder.BattleType.フェス)
     {
         data.Udemae = "";
         data.UdemaePoint = (sbyte)-1;
     }
     else
     {
         data.Udemae = d[11];
         if (sbyte.TryParse(d[12], out sb))
         {
             data.UdemaePoint =  sb;
         }
         else
         {
             return false;
         }
     }
     return true;
 }