Ejemplo n.º 1
0
 public PlayerModel(GameModel parent, string key, PlayerInfo info, DeckItem deck, string password)
     : base(parent, null, key)
 {
     this.Info = info;
       this.Deck = deck;
       this.Points = new ObservableProperty<int, PlayerModel>(this, 0);
       this.Sectors = new ModelCollection(this);
       this.NumCounters = new ModelCollection(this);
       this.Password = password;
 }
Ejemplo n.º 2
0
        void StartGame(List<PlayerAccountData> players, GameModel gameModel, GameType gameType)
        {
            bool savedGame = gameModel != null;
              if(savedGame)
            gameModel.Console.Messages.Clear(); // clients must not see saved server's log
              else
            gameModel = new GameModel(gameItem);

              bool exitGame = false;
              while(!exitGame)
              {
            var gameView = viewFactory.CreateGameView();
            using(var commandHandler = new GameCommandHandler(gameModel, players.First().Info.NickName, servicesProvider))
            {
              foreach(var player in players.Where(e => e.Channel != null))
            commandHandler.AddChannel(player.Channel, player.Info.NickName);
              var gameController = new GameController(commandHandler, gameModel, gameView, players, gameType, servicesProvider, !savedGame);
              gameController.ShowOptionsRequested += new EventHandler(gameController_ShowOptionsRequested);
              gameView.ShowModal();
            }
            exitGame = !gameModel.IsRestartNotified;
            if(!exitGame)
            {
              players = players.Where(e => gameModel.Players.Any(p => p.Key == e.Info.NickName)).ToList();
              exitGame = RunRestartGame(players, gameType);
              if(!exitGame)
              {
            gameModel = new GameModel(gameItem);
            savedGame = false;
              }
            }
              }
        }
 public RotateSectorCardsCommand(GameModel game)
     : base(game)
 {
 }
Ejemplo n.º 4
0
 public LockCardsCommand(GameModel game)
     : base(game)
 {
 }
Ejemplo n.º 5
0
 public SaveGameCommand(GameModel game)
     : base(game)
 {
 }
Ejemplo n.º 6
0
 public CreatePawnCommand(GameModel game)
     : base(game)
 {
 }
 public DuplicateCardCommand(GameModel game)
     : base(game)
 {
 }
Ejemplo n.º 8
0
 public ThrowDiceCommand(GameModel game)
     : base(game)
 {
     seed = DateTime.Now.Millisecond;
 }
 public RemovePlayerCommand(GameModel game)
     : base(game)
 {
 }
 public CloseSectorLookupCommand(GameModel game)
     : base(game)
 {
 }
Ejemplo n.º 11
0
 public AddTokenCommand(GameModel game)
     : base(game)
 {
     keysArchive = Enumerable.Range(0, 100).Select(e => Guid.NewGuid().ToString()).ToList();
 }
Ejemplo n.º 12
0
 public ChatCommand(GameModel game)
     : base(game)
 {
 }
Ejemplo n.º 13
0
        public static void LogMovement(GameModel game, string executorPlayerKey, CardModel card, SectorModel fromSector, 
            SectorModel toSector, int fromIndex, int toIndex, CardVisibility? toCardVisibility, bool verbose)
        {
            if(fromSector.Key == toSector.Key && fromSector.Data.Behavior != SectorBehavior.Simple)
            return;

              IEnumerable<SectorModel> sectors = game.Players.Cast<PlayerModel>().SelectMany(e => e.Sectors).Cast<SectorModel>();
              SectorCardsVisibility fromSectorVisibility = sectors.First(e => e.Data.Code == fromSector.Data.Code).Data.CardsVisibility;
              SectorCardsVisibility toSectorVisibility = sectors.First(e => e.Data.Code == toSector.Data.Code).Data.CardsVisibility;

              PlayerModel fromPlayer = (PlayerModel)fromSector.Parent;
              PlayerModel toPlayer = (PlayerModel)toSector.Parent;
              PlayerModel executorPlayer = game.GetPlayerByKey(executorPlayerKey);

              MessageContent logContent = new MessageContent();
              StringBuilder logText = new StringBuilder(200);

              if(verbose)
              {
            logText.Append("[").Append(executorPlayer.Info.NickName).Append("] ");
            logText.Append(game.GetCommandByKey(MoveCardsCommand.COMMANDCODE_SINGLE).Data.Name).Append(" ");
              }

              bool fromVisible = fromSectorVisibility == SectorCardsVisibility.Visibile ||
            (fromSectorVisibility == SectorCardsVisibility.Private && fromPlayer.Key == game.ActivePlayer.Key);
              if(fromVisible)
              {
            fromVisible = (card.Visibility.Value == CardVisibility.Visible ||
              (card.Visibility.Value == CardVisibility.Private && fromPlayer.Key == game.ActivePlayer.Key));
              }
              bool toVisible = toSectorVisibility == SectorCardsVisibility.Visibile ||
            (toSectorVisibility == SectorCardsVisibility.Private && toPlayer.Key == game.ActivePlayer.Key);
              if(toVisible)
              {
            if(toCardVisibility.HasValue)
              toVisible = (toCardVisibility.Value == CardVisibility.Visible ||
            (toCardVisibility.Value == CardVisibility.Private && toPlayer.Key == game.ActivePlayer.Key));
            else
              toVisible = (card.Visibility.Value == CardVisibility.Visible ||
            (card.Visibility.Value == CardVisibility.Private && toPlayer.Key == game.ActivePlayer.Key));
              }
              logContent.Add(logText.ToString());
              logText.Length = 0;
              logContent.Add(EncodeCardSmartName(card, fromVisible || toVisible));
              if(verbose)
              {
            logText.Append(" (");
            if(fromPlayer.Key != executorPlayerKey)
              logText.Append(fromPlayer.Info.NickName).Append("-");
            logText.Append(fromSector.Data.Name);
            if(fromSector.Data.Behavior == SectorBehavior.Simple)
              logText.Append("[").Append(fromIndex + 1).Append("]");
            logText.Append(">");
            if(toPlayer.Key != executorPlayerKey)
              logText.Append(toPlayer.Info.NickName).Append("-");
            logText.Append(toSector.Data.Name);
            if(toSector.Data.Behavior == SectorBehavior.Simple)
              logText.Append("[").Append(toIndex + 1).Append("]");
            logText.Append(")");
              }
              else
              {
            if(fromSector.Data.Behavior == SectorBehavior.Simple)
              logText.Append("[").Append(fromIndex + 1).Append("]");
            if(toSector.Data.Behavior == SectorBehavior.Simple)
              logText.Append("[").Append(toIndex + 1).Append("]");
              }
              logContent.Add(logText.ToString());
              game.Console.WriteLog(logContent);
        }
Ejemplo n.º 14
0
 public MoveCardsCommand(GameModel game)
     : base(game)
 {
 }
Ejemplo n.º 15
0
        void StartGame(List<PlayerConnection> connections, List<PlayerInfo> players, List<DeckItem> decks, 
            string[] passwords, GameType gameType, bool modal)
        {
            List<PlayerAccountData> allPlayers = new List<PlayerAccountData>();
              for(int i = 0; i < players.Count; i++)
            allPlayers.Add(new PlayerAccountData() { Info = players[i], Password = passwords[i], Deck = decks[i] });

              var gameModel = new GameModel(logicStarter.GameItem);
              var gameView = logicStarter.ViewFactory.CreateGameView();

              //using(GameCommandHandler gameCommandHandler = new GameCommandHandler(gameModel, allPlayers.First().Player.UniqueID))
              //{
              GameCommandHandler gameCommandHandler = new GameCommandHandler(gameModel, allPlayers.First().Info.NickName, logicStarter.ServicesProvider);

              for(int i = 0; i < connections.Count; i++)
              gameCommandHandler.AddChannel(connections[i].NetClient, players[i + 1].NickName);
            var gameController = new GameController(gameCommandHandler, gameModel, gameView, allPlayers, gameType, logicStarter.ServicesProvider, true);
            gameController.ShowOptionsRequested += new EventHandler(gameController_ShowOptionsRequested);
            if(modal)
              gameView.ShowModal();
            else
              gameView.Show();
              //}
        }
Ejemplo n.º 16
0
 public void Start(GameModel savedGame)
 {
     this.savedGame = savedGame;
       OnStarted();
 }
 public SetTokenAmountCommand(GameModel game)
     : base(game)
 {
 }
Ejemplo n.º 18
0
 public RemoveTokenCommand(GameModel game)
     : base(game)
 {
 }
 public CloseCardDisplayCommand(GameModel game)
     : base(game)
 {
 }
Ejemplo n.º 20
0
 public RestartGameCommand(GameModel game)
     : base(game)
 {
 }
 public SetNumCounterValueCommand(GameModel game)
     : base(game)
 {
 }
 public SetCardsVisibilityCommand(GameModel game)
     : base(game)
 {
 }
 public SetCardsCustomCharacteristicsCommand(GameModel game)
     : base(game)
 {
 }
Ejemplo n.º 24
0
 public DoMulliganCommand(GameModel game)
     : base(game)
 {
 }
 public SetPlayerPointsCommand(GameModel game)
     : base(game)
 {
 }
Ejemplo n.º 26
0
 public ReverseCardsCommand(GameModel game)
     : base(game)
 {
 }
 public SetTokenColorCommand(GameModel game)
     : base(game)
 {
 }
 public OpenSectorLookupCommand(GameModel game)
     : base(game)
 {
     lookupKey = Guid.NewGuid().ToString();
       seed = DateTime.Now.Millisecond;
 }
 public ShuffleSectorCommand(GameModel game)
     : base(game)
 {
 }
Ejemplo n.º 30
0
 List<PlayerAccountData> CreatePlayerAccounts(string activePlayerKey, GameModel gameModel)
 {
     var players = gameModel.Players.Cast<PoL.Models.Game.PlayerModel>().Select(e => new PlayerAccountData()
       {
     Info = e.Info,
     Deck = e.Deck,
     Password = e.Password,
       }).ToList();
       var tmp = players.Single(e => e.Info.NickName == activePlayerKey);
       players.Remove(tmp);
       players.Insert(0, tmp);
       return players;
 }