예제 #1
0
        public void RenderGameboardRow(Square[] squaresToPrint)
        {
            RowPosition _rowType = GetRowType(squaresToPrint[0]);

            switch (_rowType)
            {
            case RowPosition.TopOfBoard:     // Top Row
            {
                RenderBlankRow();
                RenderMiddleRow(squaresToPrint);
                RenderBottomRow();
                break;
            }

            case RowPosition.MiddleOfBoard:     // Middle Rows
            {
                RenderBlankRow();
                RenderMiddleRow(squaresToPrint);
                RenderBottomRow();
                break;
            }

            case RowPosition.BottomOfBoard:     // Bottom Row
            {
                RenderBlankRow();
                RenderMiddleRow(squaresToPrint);
                RenderBlankRow();
                break;
            }

            default:     // Other
                throw new ArgumentException();
            }
            ;
        }
        public static bool IsMyRow(this RowPosition row)
        {
            switch (row)
            {
            case RowPosition.MyRow1:
                return(true);

            case RowPosition.MyRow2:
                return(true);

            case RowPosition.MyRow3:
                return(true);

            case RowPosition.MyHand:
                return(true);

            case RowPosition.MyStay:
                return(true);

            case RowPosition.MyDeck:
                return(true);

            case RowPosition.MyCemetery:
                return(true);

            case RowPosition.SpecialPlace:
                return(true);

            default:
                return(false);
            }
        }
        public static bool IsOnPlace(this RowPosition row)
        {
            switch (row)
            {
            case RowPosition.MyRow1:
                return(true);

            case RowPosition.MyRow2:
                return(true);

            case RowPosition.MyRow3:
                return(true);

            case RowPosition.EnemyRow1:
                return(true);

            case RowPosition.EnemyRow2:
                return(true);

            case RowPosition.EnemyRow3:
                return(true);

            default:
                return(false);
            }
        }
        public static RowPosition Mirror(this RowPosition row)
        {
            switch (row)
            {
            case RowPosition.MyRow1:
                return(RowPosition.EnemyRow1);

            case RowPosition.MyRow2:
                return(RowPosition.EnemyRow2);

            case RowPosition.MyRow3:
                return(RowPosition.EnemyRow3);

            case RowPosition.EnemyRow1:
                return(RowPosition.MyRow1);

            case RowPosition.EnemyRow2:
                return(RowPosition.MyRow2);

            case RowPosition.EnemyRow3:
                return(RowPosition.MyRow3);

            case RowPosition.MyHand:
                return(RowPosition.EnemyHand);

            case RowPosition.EnemyHand:
                return(RowPosition.MyHand);

            case RowPosition.MyStay:
                return(RowPosition.EnemyStay);

            case RowPosition.EnemyStay:
                return(RowPosition.MyStay);

            case RowPosition.MyDeck:
                return(RowPosition.EnemyDeck);

            case RowPosition.EnemyDeck:
                return(RowPosition.MyDeck);

            case RowPosition.MyCemetery:
                return(RowPosition.EnemyCemetery);

            case RowPosition.EnemyCemetery:
                return(RowPosition.MyCemetery);

            case RowPosition.SpecialPlace:
                return(RowPosition.SpecialPlace);

            case RowPosition.MyLeader:
                return(RowPosition.EnemyLeader);

            case RowPosition.EnemyLeader:
                return(RowPosition.MyLeader);
            }
            return(RowPosition.SpecialPlace);
        }
예제 #5
0
        private void ValidateExistingTakenPositions(Player player, RowPosition row, ColumnPosition column)
        {
            //? probably advised to push this validation to the board...

            if (board.IsPositionTaken(row, column))
            {
                throw player.CannotPlayAlreadyTakenPositionException();
            }
        }
        /// <summary>
        ///   Initiliazes a new instance of the <see cref="FormGridRowInfo"/> class with all
        ///   required information.
        /// </summary>
        /// <param name="control"> The control to the inserted into the row. Must not be <see langword="null" />.</param>
        /// <param name="newRowType">
        ///   The <see cref="RowType"/> for the new <see cref="FormGridManager.FormGridRow"/>.
        /// </param>
        /// <param name="relatedRowID">
        ///   The row used as a point of reference for inserting the new <see cref="FormGridManager.FormGridRow"/>. Can be <see langword="null" />.
        /// </param>
        /// <param name="positionInFormGrid">
        ///   The <see cref="RowPosition"/> for inserting the new
        ///   <see cref="FormGridManager.FormGridRow"/>.
        /// </param>
        public FormGridRowInfo(
            Control control,
            RowType newRowType,
            string relatedRowID,
            RowPosition positionInFormGrid)
        {
            ArgumentUtility.CheckNotNull("control", control);

            _control            = control;
            _newRowType         = newRowType;
            _positionInFormGrid = positionInFormGrid;
            _releatedRowID      = relatedRowID;
        }
예제 #7
0
        internal void AcceptMove(Player player, RowPosition row, ColumnPosition column)
        {
            ValidateFirstMove(player);

            ValidateAlternatingMoves(player);

            ValidateExistingTakenPositions(player, row, column);

            player.Mark(board, row, column);

            currentPlayer = player;
            numberMoves++;
        }
        public static bool IsNone(this RowPosition row)
        {
            switch (row)
            {
            case RowPosition.Banish:
            case RowPosition.SpecialPlace:
            case RowPosition.None:
                return(true);

            default:
                return(false);
            }
        }
        public static bool IsOnStay(this RowPosition row)
        {
            switch (row)
            {
            case RowPosition.MyStay:
                return(true);

            case RowPosition.EnemyStay:
                return(true);

            default:
                return(false);
            }
        }
예제 #10
0
        //小回合结束后,记录位置,让flag为真
        public async Task HandleEvent(AfterRoundOver @event)
        {
            //小回合结束时,如果不在场上,什么都不做
            if (!Card.Status.CardRow.IsOnPlace())
            {
                return;
            }
            //在场上时,让flag为true,准备复活,记录rowposition
            _RoundoverResurrectFlag        = true;
            _RoundOverResurrectRowPosition = Game.GetCardLocation(Card).RowPosition;
            await Task.CompletedTask;

            return;
        }
        public static bool IsInHand(this RowPosition row)
        {
            switch (row)
            {
            case RowPosition.MyHand:
                return(true);

            case RowPosition.EnemyHand:
                return(true);

            default:
                return(false);
            }
        }
        public static bool IsInCemetery(this RowPosition row)
        {
            switch (row)
            {
            case RowPosition.MyCemetery:
                return(true);

            case RowPosition.EnemyCemetery:
                return(true);

            default:
                return(false);
            }
        }
예제 #13
0
        public override async Task OnWeatherApply(int playerIndex, RowPosition row, RowStatus type)
        {
            // 这个判断是否同排有没有简单的方法呀
            if (((playerIndex == Card.PlayerIndex && row == Card.Status.CardRow) ||          // 己方
                 (playerIndex != Card.PlayerIndex && row.Mirror() == Card.Status.CardRow)) &&                // 敌方
                type == RowStatus.FullMoon)                    // 满月
            {
                var left = Card.GetLocation(Card.PlayerIndex); // 左侧
                await Game.CreatCard("25007", Card.PlayerIndex, left);

                var right = Card.GetLocation(Card.PlayerIndex);                 // 右侧
                right.CardIndex += 1;
                await Game.CreatCard("25007", Card.PlayerIndex, right);
            }
        }
예제 #14
0
 /// <summary>
 /// 设置checkbox列的位置
 /// </summary>
 /// <param name="o"></param>
 /// <param name="defaultValue"></param>
 /// <returns></returns>
 /// <remarks>
 /// 设置checkbox列的位置
 /// </remarks>
 public static RowPosition ParseRowPosition(object o, RowPosition defaultValue)
 {
     if (o == null || o.ToString() == "")
     {
         return(defaultValue);
     }
     try
     {
         return((RowPosition)Enum.Parse(typeof(RowPosition), o.ToString(), true));
     }
     catch
     {
         throw new FormatException("'" + o.ToString() + "' 类型改变失败");
     }
 }
예제 #15
0
 /// <summary>
 /// 设置checkbox列的位置
 /// </summary>
 /// <param name="o"></param>
 /// <param name="defaultValue"></param>
 /// <returns></returns>
 /// <remarks>
 /// 设置checkbox列的位置 
 /// </remarks>
 public static RowPosition ParseRowPosition(object o, RowPosition defaultValue)
 {
     if (o == null || o.ToString() == "")
     {
         return defaultValue;
     }
     try
     {
         return (RowPosition)Enum.Parse(typeof(RowPosition), o.ToString(), true);
     }
     catch
     {
         throw new FormatException("'" + o.ToString() + "' 类型改变失败");
     }
 }
        private void StoreData(Image inputFace, string PersonName)
        {
            if (DbConnection.State.Equals(ConnectionState.Closed))

            {
                DbConnection.Open();
                try
                {
                    byte[] FaceAsByte = ConverImageToByte(inputFace);


                    RowPosition = LocalDataTable.Rows.Count;
                    RowPosition++;


                    MessageBox.Show("Saving Image at Index:" + RowPosition.ToString());

                    SqlCommand InsertCommand = new SqlCommand("INSERT INTO pictureData (ImageID, Image, PersonName) VALUES('" + RowPosition.ToString() + "',@MyImage,'" + PersonName + "' )", DbConnection);


                    // InsertCommand.Parameters.AddWithValue("@MyImage", inputFace);

                    SqlParameter imageParameter = InsertCommand.Parameters.AddWithValue("@MyImage", inputFace);
                    imageParameter.Value = FaceAsByte;
                    imageParameter.Size  = FaceAsByte.Length;

                    int rowAffected = InsertCommand.ExecuteNonQuery();

                    MessageBox.Show("Image Data Successfully Uploaded in " + rowAffected.ToString() + "row");

                    RowPosition++;
                }

                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString());
                    MessageBox.Show(ex.StackTrace.ToString());
                }


                finally
                {
                    refreshDBconnection();
                }
            }
        }
        public static int MyRowToIndex(this RowPosition row)
        {
            switch (row)
            {
            case RowPosition.MyRow1:
                return(0);

            case RowPosition.MyRow2:
                return(1);

            case RowPosition.MyRow3:
                return(2);

            default:
                return(-1);
            }
        }
        public static bool IsOnRow(this RowPosition row)
        {
            switch (row)
            {
            case RowPosition.MyRow1:
                return(true);

            case RowPosition.MyRow2:
                return(true);

            case RowPosition.MyRow3:
                return(true);

            case RowPosition.MyHand:
                return(true);

            case RowPosition.MyStay:
                return(true);

            case RowPosition.EnemyRow1:
                return(true);

            case RowPosition.EnemyRow2:
                return(true);

            case RowPosition.EnemyRow3:
                return(true);

            case RowPosition.EnemyHand:
                return(true);

            case RowPosition.EnemyStay:
                return(true);

            case RowPosition.MyLeader:
                return(true);

            case RowPosition.EnemyLeader:
                return(true);

            default:
                return(false);
            }
        }
예제 #19
0
 public CardLocation(RowPosition row, int index)
 {
     RowPosition = row;
     CardIndex   = index;
 }
예제 #20
0
 public void Place(Marker marker, RowPosition row, ColumnPosition column)
 {
     this.placements.Add(new Tuple <RowPosition, ColumnPosition>(row, column), marker);
 }
예제 #21
0
 public bool IsPositionTaken(RowPosition row, ColumnPosition column)
 {
     return(placements.Count(x => x.Key.Item1 == row && x.Key.Item2 == column) > 0);
 }
 public AfterWeatherApply(int playerIndex, RowPosition row, RowStatus type)
 {
     PlayerIndex = playerIndex;
     Row         = row;
     Type        = type;
 }
예제 #23
0
        public string CreateEntryDataSaveLine(string data_separator)
        {
            //we want
            //  ent-data;entry-id=geog_222;title=GEOG 222;subtitle=Introduction to Geomatics;colour=#FFFF7272;prerequisites=[];
            //      corequisites=[];avail-col-ids=[20_fa,21_wi,21_fa,22_wi,22_fa,23_wi,23_fa,24_wi];set-col-id=;list-pos=0

            Debug.WriteLine("CreateEntryDataSaveLine");

            string return_data_line;
            string data_line_start = "ent-data";


            return_data_line = data_line_start;


            foreach (string cur_data_parameter in Parameter_Names)
            {
                //should be like this
                // Parameter_Names = { "Entry_ProjectName", "EntryID", "Title", "Subtitle",
                //    "ColourHex", "PrereqEntryIDs", "CoreqEntryIDs", "AvailColIDs", "SetColID", "RowPosition" };
                // Parameter_Save_Names = { "", "entry-id", "title", "subtitle",
                //    "colour", "prerequisites", "corequisites", "avail-col-ids", "set-col-id", "list-pos" };

                //this one is skipped
                if (cur_data_parameter == "Col_ProjectName")
                {
                    continue;
                }


                string cur_data_addition = "";

                string cur_data_save_name = Parameter_Save_Names[Parameter_Names.IndexOf(cur_data_parameter)];
                string data_val           = "";

                switch (cur_data_parameter)
                {
                case "EntryID":
                    data_val = EntryID.ToString();
                    break;

                case "Title":
                    data_val = Title.ToString();
                    break;

                case "Subtitle":
                    data_val = Subtitle.ToString();
                    break;

                case "ColourHex":
                    data_val = ColourHex.ToString();
                    break;

                case "PrereqEntryIDs":
                    data_val = FormattedSaveDataFromList(PrereqEntryIDs);
                    break;

                case "CoreqEntryIDs":
                    data_val = FormattedSaveDataFromList(CoreqEntryIDs);
                    break;

                case "AvailColIDs":
                    data_val = FormattedSaveDataFromList(AvailColIDs);
                    break;

                case "SetColID":
                    data_val = SetColID.ToString();
                    break;

                case "RowPosition":
                    data_val = RowPosition.ToString();
                    break;
                }

                cur_data_addition = string.Format("{0}={1}", cur_data_save_name, data_val);

                return_data_line += data_separator + cur_data_addition;
            }

            return(return_data_line);
        }
예제 #24
0
 public void Play(RowPosition row, ColumnPosition column)
 {
     game.AcceptMove(this, row, column);
 }
예제 #25
0
 internal void Mark(IBoard board, RowPosition row, ColumnPosition column)
 {
     board.Place(this.playingMarker, row, column);
 }
예제 #26
0
        /// <summary>
        /// This method is used to move the focus to the specified fixed row position in the data source
        /// </summary>
        /// <param name="position">The position to which the focus is moved</param>
        /// <returns>True if the specified position now has the focus or false if the focus could not be set due
        /// to validation failure on the current row.</returns>
        /// <remarks>Before moving to the specified position, the <see cref="IsValid"/> property is checked to
        /// ensure that it is safe to move.  If it returns false, the focus will stay on the current row.</remarks>
        /// <exception cref="ArgumentOutOfRangeException">This is thrown if there is no data source or there are
        /// no rows.</exception>
        /// <exception cref="NotSupportedException">This is thrown if additions // are not currently allowed as
        /// defined by the current <see cref="AllowAdditions"/> property setting and an attempt is made to move
        /// the <c>NewRow</c> position.</exception>
        public bool MoveTo(RowPosition position)
        {
            int newRow;

            if(listManager == null || (listManager.Count == 0 && position != RowPosition.NewRow))
                throw new ArgumentOutOfRangeException("position", position, LR.GetString("ExInvalidRowNumber"));

            switch(position)
            {
                case RowPosition.FirstRow:
                    newRow = 0;
                    break;

                case RowPosition.LastRow:
                    newRow = listManager.Count - 1;
                    break;

                case RowPosition.NextRow:
                    newRow = listManager.Position + 1;
                    break;

                case RowPosition.PreviousRow:
                    newRow = listManager.Position - 1;
                    break;

                default:    // New row
                    return this.AddRowInternal();
            }

            // This will throw an exception if the new row number isn't valid
            return this.MoveTo(newRow);
        }
예제 #27
0
 public CardStatus(string statusId, Faction deckFaction, RowPosition position) : this(statusId)
 {
     this.DeckFaction = deckFaction;
     CardRow          = position;
 }
예제 #28
0
 //----------------------------------
 public void ShowWeatherApply(RowPosition row, RowStatus type)
 {
     _code.GetComponent <GameCode>().GameEvent.ShowWeatherApply(row, type);
 }
예제 #29
0
        public void PrintEntryDataValues()
        {
            Debug.WriteLine("\nEntryData class paramters:");



            foreach (string cur_param_name in Parameter_Names)
            {
                bool basic_formatting = false;
                bool list_formatting  = false;

                string        cur_param_val = "";
                List <string> cur_param_lst = new List <string>();

                switch (cur_param_name)
                {
                case "Entry_ProjectName":
                    cur_param_val    = Entry_ProjectName.ToString();
                    basic_formatting = true;
                    break;

                case "EntryID":
                    cur_param_val    = EntryID.ToString();
                    basic_formatting = true;
                    break;

                case "Title":
                    cur_param_val    = Title.ToString();
                    basic_formatting = true;
                    break;

                case "Subtitle":
                    cur_param_val    = Subtitle.ToString();
                    basic_formatting = true;
                    break;

                case "ColourHex":
                    cur_param_val    = ColourHex.ToString();
                    basic_formatting = true;
                    break;

                case "PrereqEntryIDs":
                    cur_param_lst   = PrereqEntryIDs;
                    list_formatting = true;
                    break;

                case "CoreqEntryIDs":
                    cur_param_lst   = CoreqEntryIDs;
                    list_formatting = true;
                    break;

                case "SetColID":
                    cur_param_val    = SetColID.ToString();
                    basic_formatting = true;
                    break;

                case "ActualColID":
                    cur_param_val    = ActualColID.ToString();
                    basic_formatting = true;
                    break;

                case "RowPosition":
                    cur_param_val    = RowPosition.ToString();
                    basic_formatting = true;
                    break;

                case "ColPosition":
                    cur_param_val    = ColPosition.ToString();
                    basic_formatting = true;
                    break;

                case "AvailColIDs":
                    cur_param_lst   = AvailColIDs;
                    list_formatting = true;
                    break;

                case "Is_Selected":
                    cur_param_val    = Is_Selected.ToString();
                    basic_formatting = true;
                    break;
                }

                if (basic_formatting)
                {
                    Debug.WriteLine(string.Format("    {0,-18} = {1}", cur_param_name, cur_param_val));
                }
                if (list_formatting)
                {
                    Debug.Write(string.Format("    {0,-18} = ", cur_param_name));

                    foreach (string cur_val in cur_param_lst)
                    {
                        Debug.Write(string.Format("{0} ", cur_val));
                    }
                    Debug.WriteLine("");
                }
            }
            Debug.WriteLine("");
        }
예제 #30
0
        private void ParseText(string t)
        {
            t = t.Trim();
            t = t.Replace("\t\t", "");
            Chunks = new List<Chunk>();
            t = t.Replace("<br xmlns=\"http://segurify.net/TR/2011\" /" + ">", "\n");
            t = t.Replace("<br xmlns=\"http://segurify.net/TR/2011\" /" + ">", "\n");

            var tagList = new List<Chunk>();
            string pattern =  @"<link(.*?)uri=[""'](?<uri>.*?)[""'](.*?)>(?<text>.*?)</link>";
            t = t.Replace(" xmlns=\"http://segurify.net/TR/2011\"", "");
             var matches = Regex.Matches(t, pattern,  RegexOptions.IgnoreCase);
            int prevIndex = 0;
            int garbageCount = 0;
            if (matches.Count > 0)
            {
                for (int i = 0; i < matches.Count; i++)
                {
                    if (i > 0)
                    {
                        ParsedText += t.Substring(prevIndex , matches[i].Index - prevIndex);

                    } else {
                        ParsedText += t.Substring(prevIndex, matches[i].Index - prevIndex);
                    }
                    Chunk chunk = new Chunk();
                    chunk.StartIndex = ParsedText.Length;
                    chunk.EndIndex = ParsedText.Length + matches[i].Groups[4].Value.Length;

                    chunk.Content = matches[i].Groups[4].Value;
                    chunk.Uri = new Uri(matches[i].Groups[3].Value);
                    Chunks.Add(chunk);
                    ParsedText += chunk.Content;
                    prevIndex = matches[i].Index + matches[i].Value.Length;
                    garbageCount += matches[i].Value.Length;

                }
                ParsedText += t.Substring(prevIndex, t.Length - prevIndex);
                ParsedText = ParsedText.Trim() + " ";

                RowPosition currentRow = new RowPosition();
                Chunk currentChunk = null;
                int row = 0;
                int x1 = 0;
                int j = 0;
                float left = 0;
                // Mark occurances
                int roww = 0;
                for (int i = 0; i < ParsedText.Length; i++)
                {

                    char c = ParsedText[i];

                    if (currentChunk != null)
                        if (i == currentChunk.EndIndex)
                        {

                            currentRow.end = left;

                            currentChunk.rowPositions.Add(currentRow);

                            currentChunk = null;
                        }
                    if (c == '\n' || left * 1f > this.Width )
                    {
                        if (c == '\n')
                        {
                        }
                        row += Block.Font.Height;
                        left = 0;
                        roww++;
                        if (currentChunk != null)
                        {
                            currentRow.end = left;

                            currentChunk.rowPositions.Add(currentRow);
                            currentRow = new RowPosition();
                            currentRow.start = 0;

                            currentRow.y = row;
                        }
                        continue;
                    }
                    foreach (Chunk chunk in Chunks)
                    {
                        if (i == chunk.StartIndex)
                        {
                            currentChunk = chunk;
                            currentRow = new RowPosition();
                            currentRow.y = row;
                            currentRow.start = left;

                        }
                    }

                    j++;
                    left += (float)(TextRenderer.MeasureText(c.ToString(), Block.Font).Width) * 0.4f;
                    Console.WriteLine(left.ToString() + " " + c.ToString());
                }
            }
            else
            {
                ParsedText = t;
            }
        }
예제 #31
0
 public void SetWeather(RowPosition row, RowStatus weather)
 {
     Row[RowIndex.Select((item, index) => (item, index)).Single(x => x.item == row).index]
예제 #32
0
        /// <summary>
        /// This method is used to move the focus to the specified fixed row position in the data source
        /// </summary>
        /// <param name="position">The position to which the focus is moved</param>
        /// <returns>True if the specified position now has the focus or false if the focus could not be set due
        /// to validation failure on the current row.</returns>
        /// <remarks>Before moving to the specified position, the <see cref="TemplateControl.IsValid"/> property
        /// is checked on the current row template to ensure that it is safe to move.  If it returns false, the
        /// focus will stay on the current row.</remarks>
        /// <exception cref="ArgumentOutOfRangeException">This is thrown if there is no data source or there are
        /// no rows.</exception>
        /// <exception cref="NotSupportedException">This is thrown if additions are not currently allowed as
        /// defined by the current <see cref="AllowAdditions"/> property setting and an attempt is made to move
        /// to the <c>NewRow</c> position.</exception>
        public bool MoveTo(RowPosition position)
        {
            int newRow;

            if(listManager == null || (listManager.Count == 0 && position != RowPosition.NewRow))
                throw new ArgumentOutOfRangeException("position", position, LR.GetString("ExInvalidRowNumber"));

            switch(position)
            {
                case RowPosition.FirstRow:
                    newRow = 0;
                    break;

                case RowPosition.LastRow:
                    newRow = listManager.Count - 1;
                    break;

                case RowPosition.NextRow:
                    newRow = listManager.Position + 1;
                    break;

                case RowPosition.PreviousRow:
                    newRow = listManager.Position - 1;
                    break;

                default:    // New row
                    if(!changePolicy.AllowAdditions)
                        throw new NotSupportedException(LR.GetString("ExAddNotAllowed"));

                    if(!this.IsValid)
                        return false;

                    newRow = pnlRows.Controls.Count - 1;

                    if(showSep)
                        newRow--;

                    if(!pnlRows.Controls[newRow].ContainsFocus)
                        pnlRows.Controls[newRow].Focus();

                    this.Select(-1, -1, -1);
                    return true;
            }

            // This will throw an exception if the new row number isn't valid
            return this.MoveTo(newRow);
        }
예제 #33
0
        private GameCard RandomChooseCard(RowPosition position)
        {
            var row = Game.RowToList(Card.PlayerIndex, position).ToList();

            return(!row.Any() ? null : row.Mess(RNG).First());
        }
 public static Task CreateCardAtEnd(this IGwentServerGame game, string cardId, int playerIndex, RowPosition row, Action <CardStatus> setting = null)
 {
     return(game.CreateCard(cardId, playerIndex, new CardLocation(row, game.RowToList(playerIndex, row).Count), setting));
 }