Exemplo n.º 1
0
        private Fiber<List<UserLogicModel>> CreateFiber(DebugGameRoom room, GameObject gameObject, bool emulating, GameDataModel game, List<int> breakpoints)
        {
            return new Fiber<List<UserLogicModel>>(players =>
            {
                if (players == null || players.Count == 0) return true;
                room.Players = players;
                ServerLogger.LogDebug("game started", room);
                GameObject sev = null;

                Script.Eval("sev = new gameObject();");
                room.PlayersLeft = new List<UserLogicModel>();
                sev.CardGame=new GameCardGame();
                sev.CardGame.Emulating = emulating;
                room.Game = sev;
                sev.CardGame.DebugInfo = new DebugInfo() { Breakpoints = breakpoints ?? new List<int>() };
                sev.CardGame.SetEmulatedAnswers(room.EmulatedAnswers);
                sev.CardGame.SetPlayers(players);
                sev.CardGame.Size = new Size(game.GameLayout.Width, game.GameLayout.Height);

                foreach (var gameTextModel in game.GameLayout.Texts)
                {
                    sev.CardGame.TextAreas.Add(new GameCardGameTextArea(new GameCardGameTextAreaOptions()
                    {
                        X = gameTextModel.Left,
                        Y = gameTextModel.Top,
                        Name = gameTextModel.Name,
                        Text = gameTextModel.Text,

                    }));
                }


                foreach (var gameSpaceModel in game.GameLayout.Spaces)
                {
                    sev.CardGame.Spaces.Add(new CardGameTableSpace(new CardGameTableSpaceOptions()
                    {
                        X = gameSpaceModel.Left,
                        Y = gameSpaceModel.Top,
                        Height = gameSpaceModel.Height,
                        Width = gameSpaceModel.Width,
                        Name = gameSpaceModel.Name,
                        Vertical = gameSpaceModel.Vertical,
                        ResizeType = gameSpaceModel.ResizeType
                    }));
                }

                foreach (var gameEffect in game.Effects)
                {
                    sev.CardGame.Effects.Add(new CardGameEffect(new CardGameEffectOptions()
                    {
                        Name = gameEffect.Name,
                        Type = gameEffect.Type,
                        Properties = gameEffect.Properties.Map(a => new CardGameEffectProperty() { Name = a.Name, Value = a.Value })
                    }));
                }

                gameData.TotalGames++;
                gameData.TotalPlayers += players.Count;
                sev.CardGame.EmulatedAnswerIndex = 0;

                //todo to data
                sev.CardGame.NumberOfCards = 52;
                sev.CardGame.NumberOfJokers = 0;

                sev.CardGame.ConfigurationCompleted();
                sev.Constructor();
                sev.RunGame();
                ServerLogger.LogDebug("Doneski", gameData);

                room.Unwind(players);
                return true;
            });
        }
        public void Game_CreateGame(string userHash, string gameName, Action<GameDataModel> result)
        {

            manager.client.Collection("Games",
                (err, collection) =>
                {
                    GameDataModel gameDataModel = new GameDataModel()
                                                  {
                                                      Assets = new List<object>(),
                                                      CardImages = new List<object>(),
                                                      Effects = new List<GameEffectModel>(),
                                                      GameCode = new GameCodeModel()
                                                                 {
                                                                     Code = "",
                                                                     CursorPosition = new IntPoint(0, 0)
                                                                 },
                                                      GameLayout = new GameLayoutModel()
                                                                   {
                                                                       Areas = new List<GameAreaModel>(),
                                                                       Spaces = new List<GameSpaceModel>(),
                                                                       Texts = new List<GameTextModel>(),
                                                                       Width = 16,
                                                                       Height = 16
                                                                   },
                                                      GameLayoutScenarios = new List<GameLayoutScenario>()
                                                                            {
                                                                                new GameLayoutScenario()
                                                                                {
                                                                                    Spaces =
                                                                                        new List
                                                                                        <GameLayoutScenarioSpace>(),
                                                                                    Effects =
                                                                                        new List
                                                                                        <GameLayoutScenarioEffect>() {},
                                                                                    Name = "Default",
                                                                                    NumberOfPlayers = 6,
                                                                                    ScreenSize = new IntPoint(1024, 768)
                                                                                }
                                                                            },

                                                      UserHash = userHash,
                                                      Name = gameName,
                                                      Description = "",
                                                      MaxNumberOfPlayers = 6,
                                                      Deleted = false
                                                  };
                    collection.Insert(gameDataModel);
                    result(gameDataModel);
                });
        }