コード例 #1
0
ファイル: GameController.cs プロジェクト: k0dep/Bonus
 public GameController(IBonusController bonusController,
                       IFieldController fieldController,
                       IMessageBinder messageBinder,
                       IFieldBoundsApplyService fluidFiledApplyService,
                       GameConfigModel gameConfigModel)
 {
     BonusController        = bonusController;
     FieldController        = fieldController;
     FluidFiledApplyService = fluidFiledApplyService;
     GameConfigModel        = gameConfigModel;
     MessageBinder          = messageBinder;
 }
コード例 #2
0
 public FieldController(GameConfigModel configModel,
                        GameFieldModel fieldModel,
                        IFieldDimensionModel fieldDimensionModel,
                        IGameObjectFactory gameObjectFactory,
                        IMessageSender messageSender,
                        EntityMapperService entityMapperService)
 {
     ConfigModel         = configModel;
     FieldModel          = fieldModel;
     FieldDimensionModel = fieldDimensionModel;
     GameObjectFactory   = gameObjectFactory;
     MessageSender       = messageSender;
     EntityMapperService = entityMapperService;
 }
コード例 #3
0
ファイル: BonusController.cs プロジェクト: k0dep/Bonus
 public BonusController(GameFieldModel fieldModel,
                        GameConfigModel configModel,
                        IMessageSender messageSender,
                        IFieldDimensionModel fieldDimensionModel,
                        IFieldController fieldController,
                        EntityMapperService mapperService)
 {
     FieldModel          = fieldModel;
     ConfigModel         = configModel;
     MessageSender       = messageSender;
     FieldDimensionModel = fieldDimensionModel;
     FieldController     = fieldController;
     MapperService       = mapperService;
 }
コード例 #4
0
        public IActionResult StartGame(GameStartModel model)
        {
            if (HybridSupport.IsElectronActive && !_isInitialized)
            {
                ElectronNET.API.Electron.IpcMain.OnSync("get-next-move", (args) =>
                {
                    var move = JsonConvert.DeserializeObject <NextMoveModel>(args.ToString());

                    var nextMove = _uciConnector.GetNextMoveByFen(move.Fen, move.Depth);

                    var from       = nextMove.Substring(0, 2);
                    var to         = nextMove.Substring(2, 2);
                    char?promotion = null;

                    if (nextMove.Length == 5)
                    {
                        promotion = nextMove.Last();
                    }

                    var response = new
                    {
                        engineMove = new {
                            from,
                            to,
                            promotion
                        }
                    };

                    return(JsonConvert.SerializeObject(response));
                });

                _isInitialized = true;
            }

            var gameModel = new GameConfigModel();

            gameModel.Depth = model.SetDepth ? model.Depth : model.SelectedLevel;
            if (model.StartColor == "random")
            {
                gameModel.StartColor = (new Random().Next() & 1) == 0 ? "w" : "b";
            }
            else
            {
                gameModel.StartColor = model.StartColor;
            }

            return(View(gameModel));
        }
コード例 #5
0
        /// <summary>
        /// Проверяет правильность данных содержащихся в полях Caption и Config
        /// </summary>
        public bool VerifyData(out List <string> errors)
        {
            List <string>   errs;
            GameSetting     gs  = null;
            GameConfigModel gcm = null;

            errors = new List <string>();

            try
            {
                gs = JsonConvert.DeserializeObject <GameSetting>(Setting);
                gs.Verify(out errs);
                errors.AddRange(errs);
            }
            catch
            {
                errors.Add("Setting не соответствует модели");
            }

            try
            {
                gcm = JsonConvert.DeserializeObject <GameConfigModel>(Config);
                gcm.Verify(out errs);
                errors.AddRange(errs);
            }
            catch
            {
                errors.Add("Config не соответствует модели");
            }

            if (gcm != null && gs != null && gcm.TaskGrid?.Count < gs.TeamIds?.Count)
            {
                errors.Add("Количество участвующих команд больше, чем указано в сетке");
            }

            return(errors.Count == 0);
        }
コード例 #6
0
 public SceneNavigator(IEnumerable <Scene> scenes, GameConfigModel config)
 {
     Scenes = scenes;
     Config = config;
 }