public static void SetDefaultSettings()
 {
     startState = new GameState();
     boardType = BoardType.square;
     skillEnabled.SetAll(true);
     rules = Rules.INVISIBLE_TOWERS;
 }
 public GameBoard(BoardType type, bool[,] matrix)
 {
     shipsMatrix = matrix;
     boardType = type;
     this.ships = new Ship[matrix.GetLength(0), matrix.GetLength(1)];
     for (int i = 0; i < this.ships.GetLength(0); i++)
         for (int j = 0; j < this.ships.GetLength(1); j++)
         {
             ships[i, j] = new Ship(i, j, type, matrix[i, j]);
             ships[i, j].Name = i + "" + j;
         }
 }
        public IHttpActionResult Post(BoardType BoardType)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            _BoardTypeService.Create(BoardType);


            return Created(BoardType);
        }
Exemple #4
0
 public Board(BoardType bt)
 {
     Type = bt;
     switch (bt)
     {
         case BoardType.Three:
             BuildBoard(3,3);
             break;
         case BoardType.Five:
             BuildBoard(5,5);
             break;
     }
     SelectedPiece = null;
 }
        /// <summary>
        /// Creates a news instance for the specific BoardType.
        /// </summary>
        /// <param name="board">Board type to retrieve its information.</param>
        public BoardInfo(BoardType board)
        {
            BoardName = board;
            switch (board)
            {
                case BoardType.UNO:
                    NumberOfDigitalPins = 14;
                    NumberOfAnalogInputPins = 6;
                    AnalogOutPins = new List<int>(new int[] { 3, 5, 6, 9, 10, 11 });
                    break;

                default:
                    throw new NotImplementedException("The selected board is not implemented yet.");
            }
        }
Exemple #6
0
        public Commander(String portname, int baudrate, BoardType boardtype)
        {
            Transport = new SerialTransport
            {
                CurrentSerialSettings =
                { 
                    PortName = portname, 
                    BaudRate = baudrate, 
                    DtrEnable = false
                }
            };

            Messenger = new CmdMessenger(Transport)
            {
                BoardType = boardtype
            };

            AttachCommandCallBacks();
            Messenger.StartListening();
        }
Exemple #7
0
        /// <summary> Initializes this object. </summary>
        /// <param name="transport">   The transport layer. </param>
        /// <param name="boardType"> Embedded Processor type. Needed to translate variables between sides. </param>
        /// <param name="fieldSeparator">   The field separator. </param>
        /// <param name="commandSeparator"> The command separator. </param>
        /// <param name="escapeCharacter">  The escape character. </param>
        /// <param name="sendBufferMaxLength"> The maximum size of the send buffer</param>
        private void Init(ITransport transport, BoardType boardType, char fieldSeparator, char commandSeparator,
                          char escapeCharacter, int sendBufferMaxLength)
        {
            ControlToInvokeOn = null;

            //Logger.Open(@"sendCommands.txt");
            Logger.DirectFlush = true;

            _receiveCommandQueue  = new ReceiveCommandQueue(HandleMessage);
            _communicationManager = new CommunicationManager(transport, _receiveCommandQueue, boardType, commandSeparator, fieldSeparator, escapeCharacter);
            _sendCommandQueue     = new SendCommandQueue(_communicationManager, sendBufferMaxLength);

            PrintLfCr = false;

            _receiveCommandQueue.NewLineReceived += (o, e) => InvokeNewLineEvent(NewLineReceived, e);
            _sendCommandQueue.NewLineSent        += (o, e) => InvokeNewLineEvent(NewLineSent, e);

            Escaping.EscapeChars(fieldSeparator, commandSeparator, escapeCharacter);
            _callbackList = new Dictionary <int, MessengerCallbackFunction>();

            _sendCommandQueue.Start();
            _receiveCommandQueue.Start();
        }
        public static void SetBitInBoard(BoardType type, int index)
        {
            switch (type)
            {
            case BoardType.Rock:
                RockBoard64 |= 1L << index;
                break;

            case BoardType.Water:
                WaterBoard64 |= 1L << index;
                break;

            case BoardType.Woods:
                WoodBoard64 |= 1L << index;
                break;

            case BoardType.Dirt:
                DirtBoard64 |= 1L << index;
                break;

            case BoardType.Desert:
                DesertBoard64 |= 1L << index;
                break;

            case BoardType.Grain:
                GrainBoard64 |= 1L << index;
                break;

            case BoardType.Pasture:
                PastureBoard64 |= 1L << index;
                break;

            case BoardType.PlayerBoard:
                PlayerBoard64 |= 1L << index;
                break;
            }
        }
        public NewBoardDialog(BoardType boardType, string serviceAddressMark, IList <ServiceAddressInfo> serviceInfos)
        {
            InitializeComponent();
            switch (boardType)
            {
            case BoardType.InputA:
                TblItemCountTitle.Text = "工业版Switch数量";
                break;

            case BoardType.OutputA:
                TblItemCountTitle.Text = "工业版Relay数量";
                break;

            default:
                throw new ArgumentOutOfRangeException("boardType", boardType, null);
            }
            for (var i = 0; i < 32; i++)
            {
                CboItemCount.Items.Add(i + 1);
            }
            CboItemCount.SelectedIndex = 31;

            CboServices.ItemsSource = serviceInfos;
            var serviceInfo = serviceInfos.FirstOrDefault(s => s.Mark == serviceAddressMark);

            if (serviceInfo != null)
            {
                CboServices.SelectedItem = serviceInfo;
            }
            else
            {
                CboServices.SelectedIndex = 0;
            }

            Loaded += NewBoardDialog_Loaded;
        }
Exemple #10
0
        private void option_ini_Creator(string name, string desc, BoardType type,
                                        string file, bool prev, bool draw,
                                        DrawNumType dnTy, string font, bool ibTy)
        {
            StreamWriter sw  = new StreamWriter("option.ini");
            string       str = "//////////////////////////////////////////////////////////////////////////////////\r\n" +
                               "//                               오호라~! Puzzle -_-?                           //\r\n" +
                               "//                                    설정 파일                                 //\r\n" +
                               "//////////////////////////////////////////////////////////////////////////////////\r\n" +
                               "//                                                                              //\r\n" +
                               "//          :::: 경고 ::::                                                      //\r\n" +
                               "//   ※함부로 수정하면 에러날 가능성 99.999999.. (하악)% 씩이나 된답니다 ^-^)b  //\r\n" +
                               "//     잘 못 건드려서 맛이가면 새로 설치해 주시는 Sense~!!                      //\r\n" +
                               "//                                                                              //\r\n" +
                               "//////////////////////////////////////////////////////////////////////////////////\r\n" +
                               "//\r\n" +
                               "//\r\n" +
                               "PuzzleImage\r\n" +
                               "{\r\n" +
                               "   name=" + name + "\r\n" +
                               "   desc=" + desc + "\r\n" +
                               "   Type=" + type + "\r\n" +
                               "   file=" + file + "\r\n" +
                               "}\r\n" +
                               "BoardOption\r\n" +
                               "{\r\n" +
                               "   prev=" + prev + "\r\n" +
                               "   draw=" + draw + "\r\n" +
                               "   dTyp=" + dnTy + "\r\n" +
                               "   font=" + font + "\r\n" +
                               "   igno=" + ibTy + "\r\n" +
                               "}";

            sw.Write(str);
            sw.Close();
        }
Exemple #11
0
    public void Show(string boardID)
    {
        playerInfoList.Clear();

        BoardElement board;

        library.boardLibrary.TryGetValue(boardID, out board);
        int i = board.players.Count;

        titleBarObject.transform.localPosition  = new Vector3(0, 40 * i, 0);
        interfaceObject.transform.localPosition = new Vector3(0, -20 * i, 0);
        foreach (PlayerImport player in board.players)
        {
            i--;
            GameConfigurationController tmp = GameObject.Instantiate(playerConfigPrefab, new Vector3(), new Quaternion(), playerConfigListObject.transform).GetComponent <GameConfigurationController>();
            tmp.Initialize(player.interfaceColor ?? default(Color));
            tmp.transform.localPosition = new Vector3(-30, 40 * i, 0);
            playerInfoList.Add(tmp);
        }

        this.boardID   = boardID;
        this.boardType = board.boardType;
        interfaceObject.SetActive(true);
    }
Exemple #12
0
        public void UploadCompleted(object sender, UploadStringCompletedEventArgs e)
        {
            BoardType list = JsonConvert.DeserializeObject <BoardType>(e.Result);

            BoardCollections.Add(list);
        }
 public void Create(BoardType boardType, int size, float cellsize)
 {
     this.HexBoardType = boardType;
     Create(size, cellsize);
 }
Exemple #14
0
 /// <summary>
 /// 駒落ちであるかを判定して返す。
 /// → この設計よくない。BoardType.Othersが駒落ちの局面である可能性がある。
 ///   position.Handicappedを用いるべき。
 /// </summary>
 /// <param name="boardType"></param>
 /// <returns></returns>
 public static bool IsHandicapped(this BoardType boardType)
 {
     return(!(boardType == BoardType.NoHandicap || boardType == BoardType.Current));
 }
        /// <summary> Initializes this object. </summary>
        /// <param name="transport">   The transport layer. </param>
        /// <param name="boardType"> Embedded Processor type. Needed to translate variables between sides. </param>
        /// <param name="fieldSeparator">   The field separator. </param>
        /// <param name="commandSeparator"> The command separator. </param>
        /// <param name="escapeCharacter">  The escape character. </param>
        /// <param name="sendBufferMaxLength"> The maximum size of the send buffer</param>
        private void Init(ITransport transport, BoardType boardType, char fieldSeparator, char commandSeparator,
                          char escapeCharacter, int sendBufferMaxLength)
        {           
            ControlToInvokeOn = null;

            //Logger.Open(@"sendCommands.txt");
            Logger.DirectFlush = true;

            _receiveCommandQueue = new ReceiveCommandQueue(HandleMessage);
            _communicationManager = new CommunicationManager(transport, _receiveCommandQueue, boardType, commandSeparator, fieldSeparator, escapeCharacter);
            _sendCommandQueue = new SendCommandQueue(_communicationManager, sendBufferMaxLength);

            PrintLfCr = false;

            _receiveCommandQueue.NewLineReceived += (o, e) => InvokeNewLineEvent(NewLineReceived, e);
            _sendCommandQueue.NewLineSent        += (o, e) => InvokeNewLineEvent(NewLineSent, e);

            Escaping.EscapeChars(fieldSeparator, commandSeparator, escapeCharacter);
            _callbackList = new Dictionary<int, MessengerCallbackFunction>();

            _sendCommandQueue.Start();
            _receiveCommandQueue.Start();
        }
        /// <summary>
        /// Converts the given array of bytes to the board storage by the following convention:
        /// From left to right, from bottom to up.
        /// First the cellTypeId goes.
        /// If it is not an id of an empty cell, it is followed by three bytes: spearmen, archers, cavalrymen
        /// in the current army respectively.
        /// The rest of the initialization process is the same as in the random filling.
        /// </summary>
        public void FillBoardStorageFromArray(byte[] array, IBoardStorage boardStorage, BoardType configurationType,
                                              BoardManager boardManager)
        {
            InitializeConfigurationParameters(configurationType, boardManager);
            CreateGlobalTables(out var currentBoardTable, out var currentBonusTable);
            FillBonusTable(currentBonusTable);

            var currentInd = 0;

            for (var col = 1; col <= blockWidth * blocksHorizontal; col++)
            {
                for (var row = 1; row <= blockHeight * blocksVertical; row++)
                {
                    var currentType = array[currentInd];
                    currentInd++;

                    if (currentType == emptyCellId)
                    {
                        continue;
                    }

                    var armyComposition = FillArmyCompositionFromArray(array, currentInd);
                    // Three bytes were read from array
                    currentInd += 3;

                    InitializeCellById(currentType, armyComposition, out var currentArmy, out var currentSprite);
                    CompleteArmyCellInitialization(currentBoardTable, col, row, currentArmy, currentSprite);
                }
            }
            boardStorage.Fill(currentBoardTable, currentBonusTable);
        }
Exemple #17
0
 public Board(int id_board, string file, BoardType board_type)
 {
     this.id_board   = id_board;
     this.file       = file;
     this.board_type = board_type;
 }
        public Battlefield()
        {
            boardPanel = new Panel();

            ships        = new List <Ship>();
            cells        = new Cell[FIELD_SIZE, FIELD_SIZE];
            rowLabels    = new Label[FIELD_SIZE];
            columnLabels = new Label[FIELD_SIZE];
            int rowLabelSize    = CELL_SIZE;
            int columnLabelSize = CELL_SIZE;

            for (int i = 0; i < FIELD_SIZE; i++)
            {
                rowLabels[i]           = new Label();
                rowLabels[i].Text      = Convert.ToString(i + 1);
                rowLabels[i].Location  = new Point(1, (i + 1) * CELL_SIZE);
                rowLabels[i].Size      = new Size(rowLabelSize, CELL_SIZE);
                rowLabels[i].TextAlign = ContentAlignment.MiddleCenter;
                boardPanel.Controls.Add(rowLabels[i]);
            }

            for (int i = 0; i < FIELD_SIZE; i++)
            {
                char columnLabelChar = (char)('A' + i);
                columnLabels[i]           = new Label();
                columnLabels[i].Text      = Convert.ToString(columnLabelChar);
                columnLabels[i].Location  = new Point((i + 1) * CELL_SIZE, 1);
                columnLabels[i].Size      = new Size(columnLabelSize, CELL_SIZE);
                columnLabels[i].TextAlign = ContentAlignment.MiddleCenter;
                boardPanel.Controls.Add(columnLabels[i]);
            }

            for (int i = 0; i < FIELD_SIZE; i++)
            {
                for (int j = 0; j < FIELD_SIZE; j++)
                {
                    cells[i, j]              = new Cell();
                    cells[i, j].RowNumber    = i;
                    cells[i, j].ColumnNumber = j;
                    cells[i, j].Location     = new Point(rowLabelSize + i * Battlefield.CELL_SIZE, columnLabelSize + j * Battlefield.CELL_SIZE);
                    cells[i, j].Battlefield  = this;
                    boardPanel.Controls.Add(cells[i, j]);
                }
            }

            boardTypeLabel           = new Label();
            boardTypeLabel.Text      = BoardType.ToString();
            boardTypeLabel.Font      = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            boardTypeLabel.Size      = new Size(CELL_SIZE * (FIELD_SIZE + 1), 24);
            boardTypeLabel.Location  = new Point(0, 0);
            boardTypeLabel.TextAlign = ContentAlignment.MiddleCenter;
            this.Controls.Add(boardTypeLabel);

            boardPanel.Size     = new Size(CELL_SIZE * (FIELD_SIZE + 1), CELL_SIZE * (FIELD_SIZE + 1));
            boardPanel.Location = new Point(0, boardTypeLabel.Size.Height + 1);
            this.Controls.Add(boardPanel);

            scoreboard             = new Scoreboard();
            scoreboard.Size        = new Size(60, 70);
            scoreboard.Location    = new Point(boardPanel.Size.Width + 10, boardTypeLabel.Size.Height + 1 + columnLabelSize + 1);
            scoreboard.Battlefield = this;
            this.Controls.Add(scoreboard);

            this.BoardType = GameLibrary.BoardType.User;
        }
        public void Valid_BoardTypes_Create()
        {
            //Arrange
            BoardType c = new BoardType() { Name = "American Board" };

            //Act
            var result =   (RedirectToRouteResult) objController.Create(c).Result ;

            //Assert 
            _BoardTypesRepositoryMock.Verify(m => m.Create(c), Times.Once);
            Assert.AreEqual("Index", result.RouteValues["action"]);

        }
 public static Field<Route> MakeBoard(BoardType type)
 {
     switch(type){
     case BoardType.square:
         return SquareBoard();
     case BoardType.circular:
         return Circular();
     case BoardType.largeSquare:
         return LargeBoard();
     case BoardType.donut:
         return Donut();
     default:
         return SquareBoard();
     }
 }
Exemple #21
0
        /// <summary>
        /// 局面識別子を実際の局面に直します。
        /// </summary>
        public static Board ToBoard(this BoardType type)
        {
            var board = new Board();

            switch (type)
            {
            case BoardType.NoHandicap:
                return(board);

            case BoardType.HandicapKyo:
                board[1, 1] = null;
                break;

            case BoardType.HandicapRightKyo:
                board[9, 1] = null;
                break;

            case BoardType.HandicapKaku:
                board[2, 2] = null;
                break;

            case BoardType.HandicapHisya:
                board[8, 2] = null;
                break;

            case BoardType.HandicapHisyaKyo:
                board[1, 1] = null;
                board[8, 2] = null;
                break;

            case BoardType.Handicap2:
                board[2, 2] = null;
                board[8, 2] = null;
                break;

            case BoardType.Handicap3:
                board[9, 1] = null;
                goto case BoardType.Handicap2;

            case BoardType.Handicap4:
                board[1, 1] = null;
                board[9, 1] = null;
                goto case BoardType.Handicap2;

            case BoardType.Handicap5:
                board[8, 1] = null;
                goto case BoardType.Handicap4;

            case BoardType.HandicapLeft5:
                board[2, 1] = null;
                goto case BoardType.Handicap4;

            case BoardType.Handicap6:
                board[2, 1] = null;
                board[8, 1] = null;
                goto case BoardType.Handicap4;

            case BoardType.Handicap8:
                board[3, 1] = null;
                board[7, 1] = null;
                goto case BoardType.Handicap6;

            case BoardType.Handicap10:
                board[4, 1] = null;
                board[6, 1] = null;
                goto case BoardType.Handicap8;

            default:
                throw new ShogiException(
                          type + ": BoardTypeの値が間違っています。");
            }

            // 駒落ちの場合、最初に指すのは上手=後手となります。
            board.Turn = BWType.White;
            return(board);
        }
Exemple #22
0
        // -- 以下、棋譜処理

        /// <summary>
        /// 盤面を特定の局面で初期化する。
        /// </summary>
        /// <param name="boardType"></param>
        public void InitBoard(BoardType boardType)
        {
            Tree.SetRootBoardType(boardType);
        }
Exemple #23
0
    public void OnChangeType()
    {
        int current = (int)Mathf.Repeat((int)boardType + 1, Enum.GetNames(typeof(BoardType)).Length);

        boardType = (BoardType)Enum.ToObject(typeof(BoardType), current);
    }
        private void txtDesc_Draw(string name, BoardType boardType, string desc)
        {
            TypeChanger btc = new TypeChanger();

            this.txtDesc.Text = ":::" + name + ":::\r\n[ " + btc.BoardTypeToDesc(boardType) + " ]\r\n" + desc;
        }
Exemple #25
0
 /// <summary>
 /// BoardType型が正当な値の範囲であるかをテストする
 /// </summary>
 /// <param name="boardType"></param>
 /// <returns></returns>
 public static bool IsOk(this BoardType boardType)
 {
     return(BoardType.ZERO <= boardType && boardType < BoardType.NB);
 }
        public void Invalid_BoardTypes_Create()
        {
            // Arrange
            BoardType c = new BoardType() { Name = "" };
            objController.ModelState.AddModelError("Error", "Something went wrong");

            //Act
            var result = (ViewResult)objController.Create(c).Result;

            //Assert
            _BoardTypesRepositoryMock.Verify(m => m.Create(c), Times.Never);
            Assert.AreEqual("", result.ViewName);
        }
Exemple #27
0
 /// <summary>
 /// BoardType型をInt32に変換する
 /// </summary>
 /// <param name="boardType"></param>
 /// <returns></returns>
 public static Int32 ToInt(this BoardType boardType)
 {
     return((Int32)boardType);
 }
 /// <summary> Constructor. </summary>
 /// <param name="transport"> The transport layer. </param>
 /// <param name="sendBufferMaxLength"> The maximum size of the send buffer</param>
 /// <param name="boardType"> Embedded Processor type. Needed to translate variables between sides. </param>
 public CmdMessenger(ITransport transport, int sendBufferMaxLength, BoardType boardType = BoardType.Bit16)
 {
     Init(transport, boardType, ',', ';', '/', sendBufferMaxLength);
 }
Exemple #29
0
        /// <summary>
        /// The control to invoke the callback on
        /// </summary>
        //public Control ControlToInvokeOn { get; set; }

        /// <summary> Constructor. </summary>
        /// <param name="transport"> The transport layer. </param>
        /// <param name="boardType"> Embedded Processor type. Needed to translate variables between sides. </param>
        public CmdMessenger(ITransport transport, BoardType boardType = BoardType.Bit16)
        {
            Init(transport, boardType, ',', ';', '/', 60);
        }
 /// <summary> Constructor. </summary>
 /// <param name="transport">   The transport layer. </param>
 /// <param name="boardType"> Embedded Processor type. Needed to translate variables between sides. </param>
 /// <param name="fieldSeparator">   The field separator. </param>
 /// <param name="commandSeparator"> The command separator. </param>
 public CmdMessenger(ITransport transport, BoardType boardType, char fieldSeparator, char commandSeparator)
 {
     Init(transport, boardType, fieldSeparator, commandSeparator, commandSeparator, 60);
 }
        /// <summary>
        /// Get seasonal stats for the provided <see cref="UbisoftAccount"/>
        /// </summary>
        /// <param name="client">The <see cref="Dragon6Client"/> to use</param>
        /// <param name="account">The <see cref="UbisoftAccount"/> to get stats for</param>
        /// <param name="seasonId">The season id. Defaults to the current season</param>
        /// <param name="board">The leaderboard to get rankings for</param>
        /// <param name="region">The region to get stats for. Seasons after ~17 do not need to set this</param>
        /// <param name="token">Optional cancellation token</param>
        public static Task <SeasonalStats> GetSeasonalStatsAsync(this Dragon6Client client, UbisoftAccount account, int seasonId = -1, BoardType board = BoardType.Ranked, Region region = Region.EMEA, CancellationToken token = default)
        {
            var request = new SeasonalStatsRequest(account.Yield(), board, seasonId, region);

            return(client.PerformAsync <SeasonalStatsResponse>(request, token).ContinueWith(t => t.Result.For(account), TaskContinuationOptions.OnlyOnRanToCompletion));
        }
    public BoardSection(int section, int ringCount, BoardType boardType, Vector3 sectionOrigin, int[] pCenter, GameObject pHexPrefab, float pHexSize, float rotation, Color emptyColor)
    {
        sectionNumber = section;
        origin = sectionOrigin;
        hexSize = pHexSize;
        center = pCenter;

        // Determine what column each row starts in, and how large the middle/max length row is
        if (boardType == BoardType.ThreePlayer) {
            firstColumns = new int[7] {3, 2, 2, 1, 1, 0, 0};
            maxRowSize = firstColumns.Length-1;
        } else if (boardType == BoardType.Hexagon) {
            //Note: This assumes a maximum ring count of 4.
            firstColumns = new int[1 + (2 * ringCount)];
            for (int i=ringCount; i >= 0; i--) {
                firstColumns[ringCount - i] = i;
            }
            //All remaining rows start all the way to the left
            for (int i=ringCount; i < firstColumns.Length; i++) {
                firstColumns[i] = 0;
            }
            maxRowSize = firstColumns.Length;
        }

        // Set up the map shape/size
        hexMap = new SystemHex[firstColumns.Length][];
        int rowLength=0;
        SystemHex[] hexRow1;
        SystemHex[] hexRow2 = new SystemHex[1];
        for (int i=0; i <= hexMap.Length / 2; i++) {
            if (boardType == BoardType.ThreePlayer) {
                if (i == 0) {
                    rowLength = i + ringCount - 1;
                } else {
                    rowLength = i + ringCount;
                }
            } else if (boardType == BoardType.Hexagon) {
                rowLength = i + ringCount + 1;
            }
            //Work in from both sides
            hexRow1 = new SystemHex[rowLength];
            if (i != hexMap.Length / 2) {
                hexRow2 = new SystemHex[rowLength];
            }
            for (int j=0; j < rowLength; j++) {
                //Create hex object and add systemHex script
                hexRow1[j] = setEmptyHexSlot(pHexPrefab, GetHexLocation (j,i), rotation, emptyColor);
                hexRow1[j].SetSection(sectionNumber);
                //Debug.Log("<><><><>: " + i + "    ,     " + j);
                hexRow1[j].SetPosition(arrayCoordsToAxial(j, i));
                if (i != hexMap.Length / 2) {
                    hexRow2[j] = setEmptyHexSlot(pHexPrefab, GetHexLocation(j,hexMap.Length - i - 1), rotation, emptyColor);
                    hexRow2[j].SetSection(sectionNumber);
                    //Debug.Log("<><><><>: " + (hexMap.Length - i - 1) + "    ,     " + j);
                    hexRow2[j].SetPosition(arrayCoordsToAxial(j, hexMap.Length - i - 1));
                }
            }

            hexMap[i] = hexRow1;
            if (i != hexMap.Length / 2) {
                hexMap[hexMap.Length - i - 1] = hexRow2;
            }
        }
    }
 /// <summary> Constructor. </summary>
 /// <param name="transport"> The transport layer. </param>
 /// <param name="boardType"> Embedded Processor type. Needed to translate variables between sides. </param>
 /// <param name="fieldSeparator"> The field separator. </param>
 /// <param name="sendBufferMaxLength"> The maximum size of the send buffer</param>
 public CmdMessenger(ITransport transport, BoardType boardType, char fieldSeparator, int sendBufferMaxLength)
 {
     Init(transport, boardType, fieldSeparator, ';', '/', sendBufferMaxLength);
 }
        /// <summary>
        /// Get seasonal stats for the provided <see cref="UbisoftAccount"/>s
        /// </summary>
        /// <param name="client">The <see cref="Dragon6Client"/> to use</param>
        /// <param name="accounts">The <see cref="UbisoftAccount"/>s to get stats for</param>
        /// <param name="seasonId">The season id. Defaults to the current season</param>
        /// <param name="board">The leaderboard to get rankings for</param>
        /// <param name="region">The region to get stats for. Seasons after ~17 do not need to set this</param>
        /// <param name="token">Optional cancellation token</param>
        public static Task <SeasonalStatsResponse> GetSeasonalStatsAsync(this Dragon6Client client, IEnumerable <UbisoftAccount> accounts, int seasonId = -1, BoardType board = BoardType.Ranked, Region region = Region.EMEA, CancellationToken token = default)
        {
            var platformRequests = accounts.GroupBy(x => x.Platform).Select(x =>
            {
                var request = new SeasonalStatsRequest(x, board, seasonId, region);
                return(client.PerformAsync <JObject>(request, token));
            });

            return(Task.WhenAll(platformRequests).ContinueWith(t =>
            {
                var json = t.Result.Aggregate((a, b) =>
                {
                    a.Merge(b);
                    return a;
                });

                return json.ToObject <SeasonalStatsResponse>();
            }, TaskContinuationOptions.OnlyOnRanToCompletion));
        }
 /// <summary> Constructor. </summary>
 /// <param name="transport">   The transport layer. </param>
 /// <param name="boardType"> Embedded Processor type. Needed to translate variables between sides. </param>
 /// <param name="fieldSeparator">   The field separator. </param>
 /// <param name="commandSeparator"> The command separator. </param>
 /// <param name="escapeCharacter">  The escape character. </param>
 /// <param name="sendBufferMaxLength"> The maximum size of the send buffer</param>
 public CmdMessenger(ITransport transport, BoardType boardType, char fieldSeparator, char commandSeparator,
                     char escapeCharacter, int sendBufferMaxLength)
 {
     Init(transport, boardType, fieldSeparator, commandSeparator, escapeCharacter, sendBufferMaxLength);
 }
Exemple #36
0
        public Board CreateBoard(
            Guid id,
            BoardType boardType,
            TileShape tileShape,
            int columnsOrSideLength,
            int?rows = null,
            double?landToWaterRatio = null
            )
        {
            // Determine shape and tile layout
            var useTileShape = tileShape;
            var useBoardType = boardType;

            // Validate column count
            if (columnsOrSideLength < 3)
            {
                throw new Exception("Not enough tile column(s) were specified");
            }

            // Validate row count
            if ((rows != null ? rows : columnsOrSideLength) < 3)
            {
                throw new Exception("Not enough row column(s) were specified");
            }

            // regular polygon boards enforce an odd number of column(s)
            if (useBoardType.CenterOrigin && ((columnsOrSideLength & 1) < 1))
            {
                throw new Exception("Board types with centered origin require an odd number of column(s)");
            }

            // Array to store rows of tiles (board)
            IList <Tile> tiles = new List <Tile>();

            // Build Rectangular board (fixed number of tiles per row)
            if (useBoardType.Equals(BoardType.Rectangle))
            {
                // Calculate width and height
                var columnCount = columnsOrSideLength;
                var rowCount    = (int)((rows != null) ? rows : columnsOrSideLength); // Default to width (length of side)
                tiles = BuildRectangle(columnCount, rowCount, useTileShape);
            }

            // Build Regular polygon / convex shape board
            if (useBoardType.Equals(BoardType.RegularPolygon))
            {
                var sideLength = columnsOrSideLength;
                if (useTileShape.Equals(TileShape.Square))
                {
                    tiles = BuildSquare(sideLength, useBoardType.CenterOrigin);
                }
                if (useTileShape.Equals(TileShape.Octagon))
                {
                    tiles = BuildRegularOctagon(sideLength, useBoardType.CenterOrigin);
                }
                if (useTileShape.Equals(TileShape.Hexagon) || useTileShape.Equals(TileShape.Circle))
                {
                    tiles = BuildRegularHexagon(sideLength, useBoardType.CenterOrigin, useTileShape);
                }
            }

            // Get a terrain type for each tile
            var impassableTerrain = Terrain.List().Where(x => !x.Passable);
            var passableTerrain   = Terrain.List().Where(x => x.Passable);

            foreach (var tile in tiles)
            {
                var terrain = GetRandomTerrain(landToWaterRatio, impassableTerrain, passableTerrain);
                tile.SetTerrain(terrain);
            }

            // Create new board
            var board = new Board(
                boardType: useBoardType,
                id: id,
                tiles: tiles,
                tileShape: useTileShape
                );

            // return the board
            return(board);
        }
 /// <summary> Constructor. </summary>
 /// <param name="transport"> The transport layer. </param>
 /// <param name="boardType"> Embedded Processor type. Needed to translate variables between sides. </param>
 public CmdMessenger(ITransport transport, BoardType boardType = BoardType.Bit16)
 {
     Init(transport, boardType, ',', ';', '/', 60);
 }
Exemple #38
0
        private static void CreateInterfaceTypes(AutomaticaContext context)
        {
            var boards = Enum.GetValues(typeof(BoardTypeEnum));

            foreach (var boardTypeEnum in boards)
            {
                var type       = boardTypeEnum.GetType();
                var memInfo    = type.GetMember(boardTypeEnum.ToString());
                var attributes = memInfo[0].GetCustomAttributes(typeof(GuidTemplateTypeAttribute), false);
                if (attributes.Length > 0 && attributes[0] is GuidTemplateTypeAttribute attribute)
                {
                    var boardType   = context.BoardTypes.SingleOrDefault(a => a.Type == attribute.Guid);
                    var isNewObject = false;
                    if (boardType == null)
                    {
                        boardType      = new BoardType();
                        boardType.Type = attribute.Guid;
                        isNewObject    = true;
                    }

                    boardType.Name        = boardType.ToString();
                    boardType.Description = boardType.ToString();

                    if (isNewObject)
                    {
                        context.BoardTypes.Add(boardType);
                    }
                    else
                    {
                        context.BoardTypes.Update(boardType);
                    }
                }
            }

            var interfaceTypes = Enum.GetValues(typeof(InterfaceTypeEnum));

            foreach (var interfaceTypeEnum in interfaceTypes)
            {
                var type       = interfaceTypeEnum.GetType();
                var memInfo    = type.GetMember(interfaceTypeEnum.ToString());
                var attributes = memInfo[0].GetCustomAttributes(typeof(GuidTemplateTypeAttribute), false);
                if (attributes.Length > 0 && attributes[0] is GuidTemplateTypeAttribute attribute)
                {
                    var interfaceType = context.InterfaceTypes.SingleOrDefault(a => a.Type == attribute.Guid);
                    var isNewObject   = false;
                    if (interfaceType == null)
                    {
                        interfaceType      = new InterfaceType();
                        interfaceType.Type = attribute.Guid;
                        isNewObject        = true;
                    }

                    interfaceType.Name              = interfaceType.ToString();
                    interfaceType.Description       = interfaceType.ToString();
                    interfaceType.IsDriverInterface = false;
                    interfaceType.MaxChilds         = attribute.MaxChilds;
                    interfaceType.MaxInstances      = 1;

                    if (isNewObject)
                    {
                        context.InterfaceTypes.Add(interfaceType);
                    }
                    else
                    {
                        context.InterfaceTypes.Update(interfaceType);
                    }
                }
            }
            context.SaveChanges();
        }
        public static OptionSetValue GetBoardType(BoardType boardType)
        {
            int value = -1;

            switch (boardType)
            {
            case BoardType.NotSpecified:
                value = 950000003;
                break;

            case BoardType.AllInclusive:
                value = 950000000;
                break;

            case BoardType.AllInclusivePlus:
                value = 950000028;
                break;

            case BoardType.AmericanBreakfast:
                value = 950000004;
                break;

            case BoardType.BedAndBreakfast:
                value = 950000005;
                break;

            case BoardType.BedEnglishBfast:
                value = 950000006;
                break;

            case BoardType.BoardAccordingToDescription:
                value = 950000007;
                break;

            case BoardType.Breakfast:
                value = 950000008;
                break;

            case BoardType.CateredChalet:
                value = 950000009;
                break;

            case BoardType.ClubBoard:
                value = 950000010;
                break;

            case BoardType.ContinentalBfast:
                value = 950000011;
                break;

            case BoardType.CruiseBoard:
                value = 950000012;
                break;

            case BoardType.DeluxeHalfBoard:
                value = 950000013;
                break;

            case BoardType.DineOut:
                value = 950000014;
                break;

            case BoardType.DrinksInclusive:
                value = 950000015;
                break;

            case BoardType.EveningMeal:
                value = 950000016;
                break;

            case BoardType.FlyDrive:
                value = 950000017;
                break;

            case BoardType.FullBoard:
                value = 950000001;
                break;

            case BoardType.FullBoardPlus:
                value = 950000018;
                break;

            case BoardType.HalfBoard:
                value = 950000002;
                break;

            case BoardType.HalfBoardUpgrade:
                value = 950000020;
                break;

            case BoardType.MealPlan:
                value = 950000021;
                break;

            case BoardType.NotApplicable:
                value = 950000022;
                break;

            case BoardType.RoomOnly:
                value = 950000023;
                break;

            case BoardType.Unknown:
                value = 950000003;
                break;

            case BoardType.ValueDiningPlan:
                value = 950000025;
                break;

            case BoardType.VariableBoard:
                value = 950000026;
                break;

            case BoardType.WithoutAny:
                value = 950000027;
                break;

            default:
                value = 950000003;
                break;
            }
            return(new OptionSetValue(value));
        }
Exemple #40
0
        private void InitModule(BoardType input, BoardType output)
        {
            int numberOfInputs;
            int numberOfOutputs;

            if (input == BoardType.Analog)
            {
                inputBoard = BoardType.Analog;
                numberOfInputs = 6;
                grpAnalogInputs.Visible = true;
                grpDigitalInputs.Visible = false;
            }
            else
            {
                inputBoard = BoardType.Digital;
                numberOfInputs = 8;
                grpDigitalInputs.Visible = true;
                grpAnalogInputs.Visible = true;
            }

            if (output == BoardType.Analog)
            {
                outputBoard = BoardType.Analog;
                numberOfOutputs = 8;
                grpAnalogOutputs.Visible = true;
                grpDigitalOutputs.Visible = false;
            }
            else
            {
                outputBoard = BoardType.Digital;
                numberOfOutputs = 8;
                grpDigitalOutputs.Visible = true;
                grpAnalogOutputs.Visible = false;
            }

            if (mdl != null)
            {
                mdl.Disconnect();
                mdl.Dispose();

                mdl = new Module(inputBoard, numberOfInputs, outputBoard, numberOfOutputs);
            }
            else
            {
                mdl = new Module(inputBoard, numberOfInputs, outputBoard, numberOfOutputs);
            }

            mdl.IpAddress = IPAddress.Parse(Properties.Settings.Default.clientIP);
            mdl.Port = Int32.Parse(Properties.Settings.Default.clientPort);

            if (Properties.Settings.Default.clientAlwaysSync)
            {
                statusSync.Enabled = true;
                mdl.AutoSync = true;
                mdl.AutoSyncInterval = (int)Properties.Settings.Default.clientSynTime;
            }
            else
            {
                statusSync.Enabled = false;
                mdl.AutoSync = false;
            }

            // SUBSCRIPTIONS TO MODULE EVENTS //
            mdl.ConnectionEvent += new ConnectionEventHandler(ConnectionEventUpdated);
            mdl.NetworkUpdatedEvent += new NetworkUpdatedEventHandler(NetworkInfoUpdated);
            mdl.RTCUpdatedEvent += new RTCUpdatedEventHandler(RTCUpdated);
            mdl.OutputDigitalPinChangedEvent += new DigitalPinChangedEventHandler(OutputDigitalPinUpdated);
            mdl.OutputAnalogPinChangedEvent += new AnalogPinChangedEventHandler(OutputAnalogPinUpdated);
            mdl.InputDigitalPinChangedEvent += new DigitalPinChangedEventHandler(InputDigitalPinUpdated);
            mdl.InputAnalogPinChangedEvent += new AnalogPinChangedEventHandler(InputAnalogPinUpdated);
        }
        /// <summary>
        /// Fetchs all pins in the board.
        /// </summary>
        /// <returns>The pins.</returns>
        /// <param name="board_id">Board identifier.</param>
        /// <param name="board_name">Board name.</param>
        /// <param name="cursor">Cursor.</param>
        /// <param name="page1st">Whether to fetch 2nd page or not.</param>
        private static async Task FetchPins(BoardType type, string board_id, string board_name, string cursor, bool page1st)
        {
            IEnumerable <string> fields = new string[] { "image" };
            PagedResponse <Pin>  pins   = null;
            var    foldername           = string.Format("{0}_{1}", board_name, board_id);
            string next_page_cursor     = null;

            // Get pins in 1st page.
            if (string.IsNullOrEmpty(cursor) == true)
            {
                pins = await client.Boards.GetPinsAsync <Pin>(board_id, fields, FETCH_PIN_LIMIT);
            }
            else
            {
                pins = await client.Boards.GetPinsAsync <Pin>(board_id, fields, cursor, FETCH_PIN_LIMIT);
            }

            foreach (var pin in pins)
            {
                if (db.IsPinExists(board_id, pin.Id) == false)
                {
                    logger.Info(pin.Image.Original.Url);

                    DownloadImage(Path.Combine(pinpath, foldername), pin.Image.Original.Url);
                    db.AddExistPin(pin.Id, board_id, board_name);
                }
            }

            if (page1st == false)
            {
                // Get pins after 1st page.
                while (string.IsNullOrEmpty(pins.NextPageCursor) == false)
                {
                    try
                    {
                        next_page_cursor = pins.NextPageCursor;

                        pins = await client.Boards.GetPinsAsync <Pin>(board_id, fields, next_page_cursor, FETCH_PIN_LIMIT);

                        foreach (var pin in pins)
                        {
                            if (db.IsPinExists(board_id, pin.Id) == false)
                            {
                                logger.Info(pin.Image.Original.Url);

                                DownloadImage(Path.Combine(pinpath, foldername), pin.Image.Original.Url);
                                db.AddExistPin(pin.Id, board_id, board_name);
                            }
                        }
                    }
                    catch (PinSharp.Api.Exceptions.PinSharpRateLimitExceededException pe)
                    {
                        logger.Trace("Exceeded Pinterest API RateLimit.");
                        logger.Error("PinSharpRateLimitExceededException");
                        logger.Error(pe.Message);

                        if (type == BoardType.Me)
                        {
                            db.SavePaginationMe(board_id, board_name, next_page_cursor);
                        }
                        else if (type == BoardType.Following)
                        {
                            db.SavePaginationFollowing(board_id, board_name, next_page_cursor);
                        }

                        throw pe;
                    }
                }
            }

            logger.Trace(string.Format("Complete downloading board {0} {1}", board_id, board_name));
            logger.Info("End fetcing a board.");
        }
Exemple #42
0
 /// <summary> Constructor. </summary>
 /// <param name="transport"> The transport layer. </param>
 /// <param name="sendBufferMaxLength"> The maximum size of the send buffer</param>
 /// <param name="boardType"> Embedded Processor type. Needed to translate variables between sides. </param>
 public CmdMessenger(ITransport transport, int sendBufferMaxLength, BoardType boardType = BoardType.Bit16)
 {
     Init(transport, boardType, ',', ';', '/', sendBufferMaxLength);
 }
 private BoardType IdentifyBoard()
 {
     lock (syncLock)
     {
         BoardType cublocBoardType = new BoardType();
         mTxData[0] = 73;
         mTxData[1] = 68;
         mTxData[2] = 69;
         mTxData[3] = 78;
         mTxData[4] = 84;
         mResponseReceived = false;
         mPort.Write(mTxData, 0, 7);
         DateTime timeStamp = DateTime.Now;
         DateTime endTime = DateTime.Now.AddSeconds(5);
         while (timeStamp < endTime && !mResponseReceived)
             timeStamp = DateTime.Now;
         if (!mResponseReceived)
             throw new Exception(mWaitErrorStr);
         if (mRxData[0] == 67 && mRxData[1] == 85 && mRxData[2] == 66 && mRxData[3] == 51 && mRxData[4] == 50 && mRxData[5] == 77)
             cublocBoardType = BoardType.CUBASE32M;
         else if (mRxData[0] == 67 && mRxData[1] == 85 && mRxData[2] == 83 && mRxData[3] == 66 && mRxData[4] == 50 && mRxData[5] == 50 && mRxData[6] == 82)
             cublocBoardType = BoardType.CUSB22R;
         return cublocBoardType;
     }
 }
Exemple #44
0
 /// <summary> Constructor. </summary>
 /// <param name="transport"> The transport layer. </param>
 /// <param name="boardType"> Embedded Processor type. Needed to translate variables between sides. </param>
 /// <param name="fieldSeparator"> The field separator. </param>
 /// <param name="sendBufferMaxLength"> The maximum size of the send buffer</param>
 public CmdMessenger(ITransport transport, BoardType boardType, char fieldSeparator, int sendBufferMaxLength)
 {
     Init(transport, boardType, fieldSeparator, ';', '/', sendBufferMaxLength);
 }
Exemple #45
0
 /// <summary>
 /// BoardType型がBoardType.ToSfen()でsfen化できる範囲にあるかをテストする。
 /// </summary>
 /// <param name="boardType"></param>
 /// <returns></returns>
 public static bool IsSfenOk(this BoardType boardType)
 {
     return(BoardType.ZERO <= boardType && boardType < BoardType.Others);
 }
Exemple #46
0
 /// <summary> Constructor. </summary>
 /// <param name="transport">   The transport layer. </param>
 /// <param name="boardType"> Embedded Processor type. Needed to translate variables between sides. </param>
 /// <param name="fieldSeparator">   The field separator. </param>
 /// <param name="commandSeparator"> The command separator. </param>
 public CmdMessenger(ITransport transport, BoardType boardType, char fieldSeparator, char commandSeparator)
 {
     Init(transport, boardType, fieldSeparator, commandSeparator, commandSeparator, 60);
 }
Exemple #47
0
 public Bus1553()
 {
     BoardType     = BoardType.A1553;
     Name          = BoardType.ToString();//此处以BoardType来作为Name,标识唯一性。
     DriverOperate = new Device1553Operator();
 }
Exemple #48
0
 /// <summary> Constructor. </summary>
 /// <param name="transport">   The transport layer. </param>
 /// <param name="boardType"> Embedded Processor type. Needed to translate variables between sides. </param>
 /// <param name="fieldSeparator">   The field separator. </param>
 /// <param name="commandSeparator"> The command separator. </param>
 /// <param name="escapeCharacter">  The escape character. </param>
 /// <param name="sendBufferMaxLength"> The maximum size of the send buffer</param>
 public CmdMessenger(ITransport transport, BoardType boardType, char fieldSeparator, char commandSeparator,
                     char escapeCharacter, int sendBufferMaxLength)
 {
     Init(transport, boardType, fieldSeparator, commandSeparator, escapeCharacter, sendBufferMaxLength);
 }