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; }
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) { }
public LockCardsCommand(GameModel game) : base(game) { }
public SaveGameCommand(GameModel game) : base(game) { }
public CreatePawnCommand(GameModel game) : base(game) { }
public DuplicateCardCommand(GameModel game) : base(game) { }
public ThrowDiceCommand(GameModel game) : base(game) { seed = DateTime.Now.Millisecond; }
public RemovePlayerCommand(GameModel game) : base(game) { }
public CloseSectorLookupCommand(GameModel game) : base(game) { }
public AddTokenCommand(GameModel game) : base(game) { keysArchive = Enumerable.Range(0, 100).Select(e => Guid.NewGuid().ToString()).ToList(); }
public ChatCommand(GameModel game) : base(game) { }
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); }
public MoveCardsCommand(GameModel game) : base(game) { }
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(); //} }
public void Start(GameModel savedGame) { this.savedGame = savedGame; OnStarted(); }
public SetTokenAmountCommand(GameModel game) : base(game) { }
public RemoveTokenCommand(GameModel game) : base(game) { }
public CloseCardDisplayCommand(GameModel game) : base(game) { }
public RestartGameCommand(GameModel game) : base(game) { }
public SetNumCounterValueCommand(GameModel game) : base(game) { }
public SetCardsVisibilityCommand(GameModel game) : base(game) { }
public SetCardsCustomCharacteristicsCommand(GameModel game) : base(game) { }
public DoMulliganCommand(GameModel game) : base(game) { }
public SetPlayerPointsCommand(GameModel game) : base(game) { }
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) { }
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; }