Inheritance: INotifyPropertyChanged
Ejemplo n.º 1
0
 private static void StartGameDeal(Game game)
 {
     List<CardsMovement> moves = new List<CardsMovement>();
     // Deal everyone 4 cards
     foreach (Player player in game.Players)
     {
         CardsMovement move = new CardsMovement();
         move.Cards = new List<Card>();
         move.To = new DeckPlace(player, DeckType.Hand);
         for (int i = 0; i < 4; i++)
         {
             game.SyncImmutableCard(player, game.PeekCard(0));
             Card c = game.DrawCard();
             move.Cards.Add(c);
         }
         moves.Add(move);
     }
     game.MoveCards(moves, null);
     int p = 0;
     foreach (Player player in game.Players)
     {
         game.PlayerAcquiredCard(player, moves[p].Cards);
         p++;
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Initialize and start the server.
 /// </summary>
 public Server(Game game, int capacity)
 {
     maxClients = capacity;
     handlers = new ServerHandler[capacity];
     for (int i = 0; i < capacity; i++)
     {
         handlers[i] = new ServerHandler();
     }
     this.game = game;
     Trace.TraceInformation("Server initialized with capacity {0}", capacity);
 }
Ejemplo n.º 3
0
 public GlobalServerUiProxy(Game g, Dictionary<Player, IUiProxy> p)
 {
     game = g;
     proxy = new Dictionary<Player, ServerNetworkUiProxy>();
     foreach (var v in p)
     {
         if (!(v.Value is ServerNetworkUiProxy))
         {
             Trace.TraceWarning("Some of my proxies are not server network proxies!");
             continue;
         }
         proxy.Add(v.Key, v.Value as ServerNetworkUiProxy);
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Initialize and start the server.
 /// </summary>
 public Server(Game game, int capacity, IPAddress address)
 {
     ipAddress = address;
     IPEndPoint ep = new IPEndPoint(ipAddress, 0);
     listener = new TcpListener(ep);
     listener.Start();
     ipPort = ((IPEndPoint)listener.LocalEndpoint).Port;
     maxClients = capacity;
     handlers = new ServerHandler[capacity];
     for (int i = 0; i < capacity; i++)
     {
         handlers[i] = new ServerHandler();
     }
     this.game = game;
     Trace.TraceInformation("Server initialized with capacity {0}", capacity);
 }
Ejemplo n.º 5
0
 protected static void StartGameDeal(Game game, Player player)
 {
     List<CardsMovement> moves = new List<CardsMovement>();
     CardsMovement move = new CardsMovement();
     move.Cards = new List<Card>();
     move.To = new DeckPlace(player, DeckType.Hand);
     game.Emit(GameEvent.StartGameDeal, new GameEventArgs() { Source = player });
     int dealCount = player.MaxHealth + player[Player.DealAdjustment];
     for (int i = 0; i < dealCount; i++)
     {
         game.SyncImmutableCard(player, game.PeekCard(0));
         Card c = game.DrawCard();
         move.Cards.Add(c);
     }
     moves.Add(move);
     game.MoveCards(moves, null, GameDelays.GameBeforeStart);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Initialize and start the server.
 /// </summary>
 public Server(Game game, int capacity, IPAddress address)
 {
     isStopped = false;
     ipAddress = address;
     IPEndPoint ep = new IPEndPoint(ipAddress, 0);
     listener = new TcpListener(ep);
     listener.Start();
     ipPort = ((IPEndPoint)listener.LocalEndpoint).Port;
     numberOfGamers = capacity;
     handlers = new List<ServerHandler>();
     for (int i = 0; i < capacity; i++)
     {
         handlers.Add(new ServerHandler());
     }
     this.game = game;
     Trace.TraceInformation("Server initialized with capacity {0}", capacity);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Initialize and start the server.
 /// </summary>
 public Server(Game game, int capacity, IPAddress address)
 {
     ipAddress = address;
     IPEndPoint ep = new IPEndPoint(ipAddress, 0);
     listener = new TcpListener(ep);
     listener.Start();
     ipPort = ((IPEndPoint)listener.LocalEndpoint).Port;
     numberOfGamers = capacity;
     Gamers = new List<ServerGamer>();
     for (int i = 0; i <= capacity; i++)
     {
         ServerGamer gamer = new ServerGamer() { Game = game, OnlineStatus = Network.OnlineStatus.Offline };
         gamer.OnDisconnected += Server_OnDisconnected;
         gamer.StartSender();
         Gamers.Add(gamer);
     }
     this.game = game;
     Trace.TraceInformation("Server initialized with capacity {0}", capacity);
 }
Ejemplo n.º 8
0
 private static void StartGameDeal(Game game)
 {
     List<CardsMovement> moves = new List<CardsMovement>();
     // Deal everyone 4 cards
     foreach (Player player in game.AlivePlayers)
     {
         CardsMovement move = new CardsMovement();
         move.Cards = new List<Card>();
         move.To = new DeckPlace(player, DeckType.Hand);
         game.Emit(GameEvent.StartGameDeal, new GameEventArgs() { Source = player });
         int dealCount = 4 + player[Player.DealAdjustment];
         for (int i = 0; i < dealCount; i++)
         {
             game.SyncImmutableCard(player, game.PeekCard(0));
             Card c = game.DrawCard();
             move.Cards.Add(c);
         }
         moves.Add(move);
     }
     game.MoveCards(moves, null, GameDelays.GameBeforeStart);
 }
Ejemplo n.º 9
0
 public GlobalClientProxy(Game g, ClientNetworkProxy p, List<ClientNetworkProxy> inactive)
 {
     game = g;
     proxy = p;
     inactiveProxies = inactive;
 }
Ejemplo n.º 10
0
 private void _DebugDealingDeck(Game game)
 {
     if (game.Decks[null, DeckType.Dealing].Any(tc => tc.Type is HeroCardHandler || tc.Type is RoleCardHandler || tc.Id == Card.UnknownHeroId || tc.Id == Card.UnknownRoleId))
     {
         var card = game.Decks[null, DeckType.Dealing].FirstOrDefault(tc => tc.Type is HeroCardHandler || tc.Type is RoleCardHandler || tc.Id == Card.UnknownHeroId || tc.Id == Card.UnknownRoleId);
         Trace.TraceError("Dealing deck poisoning by card {0} @ {1}", card.Id, game.Decks[null, DeckType.Dealing].IndexOf(card));
         Trace.Assert(false);
     }
 }
Ejemplo n.º 11
0
 public ServerHandler()
 {
     disconnected = false;
     semIn = new Semaphore(0, int.MaxValue);
     semOut = new Semaphore(0, int.MaxValue);
     semAccess = new Semaphore(1, 1);
     queueIn = new Queue<object>();
     queueOut = new Queue<object>();
     stream = null;
     client = null;
     commId = 0;
     threadServer = null;
     threadClient = null;
     game = null;
 }