public static bool IsKomabukuro(Kh185 haiyaku) { bool result = false; switch (haiyaku) { case Kh185.n172_駒袋歩: case Kh185.n173_駒袋香: case Kh185.n174_駒袋桂: case Kh185.n175_駒袋銀: case Kh185.n176_駒袋金: case Kh185.n177_駒袋王: case Kh185.n178_駒袋飛: case Kh185.n179_駒袋角: case Kh185.n180_駒袋竜: case Kh185.n181_駒袋馬: case Kh185.n182_駒袋と金: case Kh185.n183_駒袋杏: case Kh185.n184_駒袋圭: case Kh185.n185_駒袋全: result = true; break; } return(result); }
private void PaintText(Graphics g, RO_Star_Koma komaKs, Point location) { if (null == komaKs) { goto gt_EndMethod; } Kh185 haiyaku = komaKs.Haiyaku; if (haiyaku == Kh185.n000_未設定) { // 配役未設定時は、普通に駒を描画します。 g.DrawString(komaKs.Text_Label, new Font(FontFamily.GenericSerif, 20.0f), Brushes.Black, location); } else { // 配役設定時は、絵修飾字を描画します。 string text = Haiyaku184Array.Name2[(int)haiyaku]; string text1; string text2; string text3; if (4 < text.Length) { text1 = text.Substring(0, 2); text2 = text.Substring(2, 2); text3 = text.Substring(4, text.Length - 4); } else if (2 < text.Length) { text1 = text.Substring(0, 2); text2 = text.Substring(2, text.Length - 2); text3 = ""; } else { text1 = text; text2 = ""; text3 = ""; } // 1行目 g.DrawString(text1, new Font(FontFamily.GenericSerif, 10.0f), Brushes.Black, location); // 2行目 g.DrawString(text2, new Font(FontFamily.GenericSerif, 10.0f), Brushes.Black, new Point(location.X, location.Y + 11)); // 3行目 g.DrawString(text3, new Font(FontFamily.GenericSerif, 10.0f), Brushes.Black, new Point(location.X, location.Y + 22)); } gt_EndMethod: ; }
public static bool IsKomadai(Kh185 haiyaku) { bool result = false; switch (haiyaku) { case Kh185.n164_歩打: case Kh185.n165_香打: case Kh185.n166_桂打: case Kh185.n167_銀打: case Kh185.n168_金打: case Kh185.n169_王打: case Kh185.n170_飛打: case Kh185.n171_角打: result = true; break; } return(result); }
/// <summary> /// 配役と、升から、次の強制転成配役を求めます。 /// /// /// </summary> /// <param name="currentHaiyaku"></param> /// <param name="masuHandle"></param> /// <returns>転生しないなら 未設定 を返します。</returns> public static Kh185 MasuHandleTo_ForcePromotionHaiyaku(Kh185 currentHaiyaku, int masuHandle, string hint) { Kh185 result; Dictionary <int, Kh185> map2 = ForcePromotionArray.HaiyakuMap[currentHaiyaku]; if ( null == map2 || !map2.ContainsKey(masuHandle) ) { result = Kh185.n000_未設定; goto gt_EndMethod; } result = map2[masuHandle];//null非許容型 { StringBuilder sbLog = new StringBuilder(); if (File.Exists("#強制転成デバッグ.txt")) { sbLog.Append(File.ReadAllText("#強制転成デバッグ.txt")); } sbLog.AppendLine(); sbLog.AppendLine(hint); sbLog.AppendLine(" 現在の配役=[" + currentHaiyaku + "]"); sbLog.AppendLine(" masuHandle=[" + masuHandle + "]"); sbLog.AppendLine(" 強制転成後の配役=[" + result + "]"); File.WriteAllText("#強制転成デバッグ.txt", sbLog.ToString()); } gt_EndMethod: return(result); }
/// <summary> /// /// </summary> /// <returns>マス番号</returns> public static int Move_RandomChoice(Kh185 haiyaku) { int result; if (Haiyaku184Array.KukanMasus[haiyaku].Count <= 0) { result = -1; goto gt_EndMethod; } SySet <SyElement> michi187 = Haiyaku184Array.KukanMasus[haiyaku][LarabeRandom.Random.Next(Haiyaku184Array.KukanMasus[haiyaku].Count)]; List <int> elements = new List <int>(); foreach (Basho element in michi187.Elements) { elements.Add(element.MasuNumber); } result = elements[LarabeRandom.Random.Next(elements.Count)]; gt_EndMethod: return(result); }
/// <summary> /// ロードした内容を確認するときに使います。 /// </summary> /// <returns></returns> public static string LogHtml() { StringBuilder sb = new StringBuilder(); sb.AppendLine("<html>"); sb.AppendLine("<head>"); sb.AppendLine(" <title>強制転成表</title>"); sb.AppendLine(" <style type=\"text/css\">"); sb.AppendLine(" /* 将棋盤 */"); sb.AppendLine(" table{"); sb.AppendLine(" border-collapse:collapse;"); sb.AppendLine(" border:2px #2b2b2b solid;"); sb.AppendLine(" }"); sb.AppendLine(" td{"); sb.AppendLine(" border:1px #2b2b2b solid;"); sb.AppendLine(" background-color:#ffcc55;"); sb.AppendLine(" width:48px; height:48px;"); sb.AppendLine(" }"); sb.AppendLine(" </style>"); sb.AppendLine("</head>"); sb.AppendLine("<body>"); foreach (KeyValuePair <Kh185, Dictionary <int, Kh185> > entry1 in ForcePromotionArray.HaiyakuMap) { sb.Append("<h1>"); sb.Append(entry1.Key); sb.AppendLine("</h1>"); sb.Append("<table>"); // 9一~1一、9二~1二、…9九~1九の順だぜ☆ for (int dan = 1; dan <= 9; dan++) { sb.AppendLine("<tr>"); sb.Append(" "); for (int suji = 9; suji >= 1; suji--) { SyElement masu = Util_Masu.OkibaSujiDanToMasu(Okiba.ShogiBan, suji, dan); sb.Append("<td>"); if (entry1.Value.ContainsKey(Util_Masu.AsMasuNumber(masu))) { // 強制転成が起こるマスなら、画像を出します。 Kh185 kh184 = entry1.Value[Util_Masu.AsMasuNumber(masu)]; int haiyakuHandle = (int)kh184; sb.Append("<img src=\"../Profile/Data/img/train"); if (haiyakuHandle < 10) { sb.Append("00"); } else if (haiyakuHandle < 100) { sb.Append("0"); } sb.Append(haiyakuHandle); sb.Append(".png\" />"); } sb.Append("</td>"); } sb.AppendLine(); sb.AppendLine("</tr>"); } sb.AppendLine("</table>"); } sb.AppendLine("</body>"); sb.AppendLine("</html>"); return(sb.ToString()); }
/// <summary> /// ************************************************************************************************************************ /// 駒ボタンの描画はここに書きます。 /// ************************************************************************************************************************ /// </summary> /// <param name="g1"></param> public void Paint(Graphics g1, NarabeRoomViewModel shogiGui) { if (!this.Visible) { goto gt_EndMethod; } //---------- // 背景 //---------- if (shogiGui.Shape_PnlTaikyoku.FigTumandeiruKoma == this.Finger) //>>>>> 駒をつまんでいる時 { g1.FillRectangle(Brushes.Brown, this.Bounds); // 駒の背景は茶色。 } else if (shogiGui.Shape_PnlTaikyoku.MovedKoma == this.Finger) //>>>>> 駒を移動した時 { g1.FillRectangle(Brushes.DarkKhaki, this.Bounds); // 駒の背景はカーキ。 } else if (this.Light) //>>>>> マウスカーソルが当たっている時 { } // この駒について。 RO_Star_Koma koma = Util_Koma.AsKoma(shogiGui.GameViewModel.GuiSkyConst.StarlightIndexOf(this.Finger).Now); //---------- // 配役画像 //---------- { Kh185 mobility = koma.Haiyaku; StringBuilder sb = new StringBuilder(); sb.Append("../../Profile/Data/img/mobility/"); sb.Append((int)mobility); sb.Append(".png"); Image img = Image.FromFile(sb.ToString()); if (koma.Pside == Playerside.P2) { // 画像を180度回転させたい☆ img.RotateFlip(RotateFlipType.Rotate180FlipNone); } else { } g1.DrawImage(img, this.Bounds); } //---------- // 枠線 //---------- { Pen pen; if (this.Light) { pen = Pens.Yellow; } else { pen = Pens.Black; } g1.DrawRectangle(pen, this.Bounds); } //---------- // 文字 //---------- if (koma.Pside == Playerside.P1) { //---------- // 先手 //---------- // // ただ描画するだけ☆ // this.PaintText(g1, koma, this.Bounds.Location); } else { //---------- // 後手 //---------- // // 180度回転させて描画するために、大掛かりになっています。 // //string moji = siteiSk.KomaDoors[this.KomaHandle].Text_Label; //---------- // 使用するフォント //---------- //Font fnt = new Font(FontFamily.GenericSerif, 20.0f); //---------- // 文字の大きさにあった白紙(b) //---------- Graphics bG; Bitmap bImg; { int w; int h; { //---------- // 文字の大きさを調べるための白紙(a) //---------- Bitmap aImg = new Bitmap(1, 1); //imgのGraphicsオブジェクトを取得 Graphics aG = Graphics.FromImage(aImg); //文字列を描画したときの大きさを計算する w = 48; h = 48; //w = (int)aG.MeasureString(moji, fnt).Width; //h = (int)fnt.GetHeight(aG); //if (w == 0 || h == 0) //{ // System.C onsole.WriteLine("moji=["+moji+"]"); //} //if (w < 1) //{ // w = 1; //} //if (h < 1) //{ // h = 1; //} aG.Dispose(); aImg.Dispose(); } bImg = new Bitmap(w, h); } // 文字描画 bG = Graphics.FromImage(bImg); this.PaintText(bG, koma, new Point(0, 0)); //bG.DrawString(moji, fnt, Brushes.Black, 0, 0); //---------- // 回転軸座標 //---------- float x = (float)this.Bounds.X + (float)this.Bounds.Width / 2; float y = (float)this.Bounds.Y + (float)this.Bounds.Height / 2; //---------- // 回転 //---------- // 180度で回転するための座標を計算 //ラジアン単位に変換 double d = 180 / (180 / Math.PI); //新しい座標位置を計算する float x1 = x + bImg.Width * (float)Math.Cos(d); float y1 = y + bImg.Width * (float)Math.Sin(d); float x2 = x - bImg.Height * (float)Math.Sin(d); float y2 = y + bImg.Height * (float)Math.Cos(d); //PointF配列を作成 PointF[] destinationPoints = { new PointF(x + (float)this.Bounds.Width / 2, y + (float)this.Bounds.Height / 2), new PointF(x1 + (float)this.Bounds.Width / 2, y1 + (float)this.Bounds.Height / 2), new PointF(x2 + (float)this.Bounds.Width / 2, y2 + (float)this.Bounds.Height / 2) }; //画像を描画 g1.DrawImage(bImg, destinationPoints); //リソースを解放する bImg.Dispose(); bG.Dispose(); //fnt.Dispose(); } // フィンガー g1.DrawString(this.Finger.ToString(), new Font(FontFamily.GenericSerif, 10.0f), Brushes.Black, this.Bounds.Location); ////---------- //// デバッグ用 ////---------- //if (true) //{ // string moji = siteiSk.KomaDoors[this.Handle].SrcOkiba.ToString(); // g1.DrawString(moji, new Font(FontFamily.GenericSerif, 12.0f), Brushes.Red, this.Bounds.Location); //} gt_EndMethod: ; }
public static List <List <string> > Load(string path, Encoding encoding) { StringBuilder sbLog = new StringBuilder(); List <List <string> > rows = new List <List <string> >(); foreach (string line in File.ReadAllLines(path, encoding)) { rows.Add(CsvLineParserImpl.UnescapeLineToFieldList(line, ',')); } // 最初の2行は削除。 rows.RemoveRange(0, 2); // 各行の先頭3列は削除。 foreach (List <string> row in rows) { row.RemoveRange(0, 3); } //------------------------------ // データ部だけが残っています。 //------------------------------ // コメント行、データ行が交互に出てきます。 // コメント行を削除します。 List <List <string> > rows2; { rows2 = new List <List <string> >(); int rowCount1 = 0; foreach (List <string> row in rows) { // 奇数行がデータです。 if (rowCount1 % 2 == 1) { rows2.Add(row); } rowCount1++; } } // デバッグ出力 { StringBuilder sb = new StringBuilder(); foreach (List <string> row2 in rows2) { foreach (string field in row2) { sb.Append(field); sb.Append(","); } sb.AppendLine(); } File.WriteAllText("配役転換表Load(1)_データ行のみ.txt", sb.ToString()); } Data_HaiyakuTransition.map = new Dictionary <PieceType, Kh185[]>(); int rowCount2 = 0; Kh185[] table81 = null; foreach (List <string> row2 in rows2) { if (rowCount2 % 9 == 0) { table81 = new Kh185[81]; int syuruiNumber = rowCount2 / 9 + 1; if (15 <= syuruiNumber) { goto gt_EndMethod; } Data_HaiyakuTransition.map.Add(Ks14Array.Items_All[syuruiNumber], table81); } //---------- // テーブル作り //---------- int columnCount = 0; foreach (string column in row2) { // 空っぽの列は無視します。 if ("" == column) { goto gt_NextColumn; } // 空っぽでない列の値を覚えます。 // 数値型のはずです。 int cellValue; if (!int.TryParse(column, out cellValue)) { throw new Exception($@"エラー。 path=[{path}] 「配役転換表」に、int型数値でないものが指定されていました。 rowCount=[{rowCount2}] columnCount=[{columnCount}]"); } int masuHandle = (8 - columnCount) * 9 + (rowCount2 % 9);//0~80 sbLog.AppendLine("(" + rowCount2 + "," + columnCount + ")[" + masuHandle + "]" + cellValue); table81[masuHandle] = Kh185Array.Items[cellValue]; gt_NextColumn: columnCount++; } rowCount2++; } gt_EndMethod: File.WriteAllText("../../Logs/_log_配役転換表Load(2).txt", sbLog.ToString()); return(rows); }
/// <summary> /// 種類。 /// </summary> public static PieceType Syurui(Kh185 haiyaku) { return(Haiyaku184Array.syurui[(int)haiyaku]); }
public RO_Star_Koma(Playerside pside, SyElement masu, Kh185 haiyaku) { this.pside = pside; this.masu = masu; this.syurui = Haiyaku184Array.Syurui(haiyaku); }