private void buildBoard(Player.PublicInfo info, int focus, StringBuilder[] builders) { if (info.board.Count == 0) { return; } int firstIdx = (focus == 0) ? 0 : 2; builders[0].Append(focusFrame[firstIdx * 3]); builders[1].Append(focusFrame[firstIdx * 3 + 1]); builders[2].Append(" "); builders[3].Append(" "); builders[4].Append(" "); builders[5].Append(" "); builders[6].Append(focusFrame[firstIdx * 3 + 1]); builders[7].Append(focusFrame[firstIdx * 3 + 2]); for (int i = 0; i < info.board.Count; ++i) { BoardObject obj = info.board[i]; string[] toks = info.board[i].GetDescription().Split(new char[] { ',' }, 2); string[] valueToks = toks[0].Split('/'); string[] nameToks = getNameToksForBoard(toks[1]); int focusIdx = 1 + i - focus; if (focusIdx < 0 || focusIdx > 1) { focusIdx = 2; } if (obj is Monster && (obj as Monster).CanAttack()) { builders[0].AppendFormat("{0,2}┌───╮{1}", valueToks[0], focusFrame[focusIdx * 3]); builders[1].AppendFormat("┌╯ │{0}", focusFrame[focusIdx * 3 + 1]); builders[2].AppendFormat("│{0,8}│ ", nameToks[0]); builders[3].AppendFormat("│{0,8}│ ", nameToks.Length > 1 ? nameToks[1] : ""); builders[4].Append("├─╮╭─┤ "); builders[5].AppendFormat("│{0,2}├┤{1,2}│ ", valueToks[1], valueToks[2]); builders[6].AppendFormat("╰─╯╰─╯{0}", focusFrame[focusIdx * 3 + 1]); builders[7].AppendFormat(" ︾︾︾︾︾ {0}", focusFrame[focusIdx * 3 + 2]); } else { builders[0].AppendFormat(" {0}", focusFrame[focusIdx * 3]); builders[1].AppendFormat("{0,2}┌───╮{1}", valueToks[0], focusFrame[focusIdx * 3 + 1]); builders[2].AppendFormat("┌╯ │ "); builders[3].AppendFormat("│{0,8}│ ", nameToks[0]); builders[4].AppendFormat("│{0,8}│ ", nameToks.Length > 1 ? nameToks[1] : ""); if (valueToks.Length > 1) { builders[5].Append("├─╮╭─┤ "); builders[6].AppendFormat("│{0,2}├┤{1,2}│{2}", valueToks[1], valueToks[2], focusFrame[focusIdx * 3 + 1]); builders[7].AppendFormat("╰─╯╰─╯{0}", focusFrame[focusIdx * 3 + 2]); } else { builders[5].Append("│ │ "); builders[6].AppendFormat("└────┘{0}", focusFrame[focusIdx * 3 + 1]); builders[7].AppendFormat(" {0}", focusFrame[focusIdx * 3 + 2]); } } } }
public void UpdateBoard(int idx, BoardObject obj) { if (obj.IsDestroyed()) { cemetery.Add(board[idx].GetCard()); board.RemoveAt(idx); } else { board[idx] = obj; } }
public void UpdateAllTargetObject(int playerID, TargetFilter filter, TargetFixer updater) { Player.PublicInfo[] info = new Player.PublicInfo[] { player[0].GetPublicInfo(), player[1].GetPublicInfo() }; int[] playerPattern; if (player[0].ID == playerID) { playerPattern = new int[] { Action.SELF, Action.OPP } } ; else { playerPattern = new int[] { Action.OPP, Action.SELF } }; for (int i = 0; i < 2; ++i) { int facePattern = playerPattern[i] | Action.FACE; Player.Face face = info[i].face; if (filter(facePattern, face)) { updater(face); player[i].UpdateFace(face); } List <int> indices = new List <int>(); List <BoardObject> objs = new List <BoardObject>(); for (int j = 0; j < info[i].board.Count; ++j) { int boardPattern = playerPattern[i] | Action.BOARD | (j & Action.INDEX_MASK); BoardObject obj = info[i].board[j]; if (filter(boardPattern, obj)) { updater(obj); indices.Add(j); objs.Add(obj); } } if (indices.Count > 0) { player[i].UpdateBoard(indices, objs); } } } }