Ejemplo n.º 1
0
 public System.Object ServerCommunication(Version clientversion, ICommunicateable communicator, bool full, System.Object obj)
 {
     try
     {
         if (clientversion.Major > 0)
         {
             if (full)
             {
                 communicator.SendString(Id);
                 communicator.SendString(Name);
                 communicator.SendInt(StockIndexes.Count);
                 if (StockIndexes.Count > 0)
                 {
                     foreach (StockIndex stockindex in StockIndexes.Values)
                         communicator.SendString(stockindex.Id);
                 }
                 PriceHistory.ServerCommunication(clientversion, communicator, full, obj);
             }
             if (clientversion.Major > 0 && clientversion.Minor >= 1)
             {
                 communicator.SendDouble(MinPrice);
                 communicator.SendDouble(MaxPrice);
             }
             communicator.SendDouble(Price);
             communicator.SendInt(Available);
             communicator.SendInt(OwnedByPlayers);
         }
         return this;
     }
     catch (System.Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 2
0
 public System.Object ClientCommunication(Version serverversion, ICommunicateable communicator, bool full, System.Object obj)
 {
     try
     {
         if (serverversion.Major > 0)
         {
             if (full)
             {
                 IsComputer = communicator.ReceiveBool();
                 IsYou      = communicator.ReceiveBool();
                 ValueHistory.ClientCommunication(serverversion, communicator, full, obj);
             }
             if (IsYou && !full)
             {
                 communicator.SendString(Company);
                 communicator.SendString(Name);
             }
             else
             {
                 Company = communicator.ReceiveString();
                 Name    = communicator.ReceiveString();
             }
             Deposit.ClientCommunication(serverversion, communicator, full, obj);
             Capital = communicator.ReceiveDouble();
             ValueHistory.AddHistory(Value);
         }
         return(this);
     }
     catch (System.Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 3
0
 public System.Object ServerCommunication(Version clientversion, ICommunicateable communicator, bool full, System.Object obj)
 {
     try
     {
         if (clientversion.Major > 0)
         {
             if (full)
             {
                 communicator.SendBool(IsComputer);
                 communicator.SendBool(Id == (int)obj);
                 ValueHistory.ServerCommunication(clientversion, communicator, full, obj);
             }
             if (Id == (int)obj && !full)
             {
                 Company = communicator.ReceiveString();
                 Name    = communicator.ReceiveString();
             }
             else
             {
                 communicator.SendString(Company);
                 communicator.SendString(Name);
             }
             Deposit.ServerCommunication(clientversion, communicator, full, obj);
             communicator.SendDouble(Capital);
         }
         return(this);
     }
     catch (System.Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 4
0
 public System.Object ClientCommunication(Version serverversion, ICommunicateable communicator, bool full, System.Object obj)
 {
     try
     {
         if (serverversion.Major > 0)
         {
             lock (SynchronizeRoot)
             {
                 if (full)
                 {
                     // Send information about the client.
                     communicator.SendString(CurrentPlayer.Company);
                     communicator.SendString(CurrentPlayer.Name);
                     // Clear and reset game informations.
                     while (PlayTimer.Enabled)
                     {
                         PlayTimer.Stop();
                     }
                     while (StockIndexes.Count > 0)
                     {
                         StockIndexes.Clear();
                     }
                     while (Stocks.Count > 0)
                     {
                         Stocks.Clear();
                     }
                     while (Players.Count > 0)
                     {
                         Players.Clear();
                     }
                     MarketState.Reset(Random);
                     CurrentPlayer = null;
                 }
                 // Receive new game informations.
                 StockIndexes.ClientCommunication(serverversion, communicator, full, null);
                 Stocks.ClientCommunication(serverversion, communicator, full, StockIndexes);
                 CurrentPlayer = (Player)Players.ClientCommunication(serverversion, communicator, full, Stocks);
                 MarketState.ClientCommunication(serverversion, communicator, full, null);
             }
         }
         return(this);
     }
     catch (System.Exception ex)
     {
         throw ex;
     }
 }
 public System.Object ServerCommunication(Version clientversion, ICommunicateable communicator, bool full, System.Object obj)
 {
     try
     {
         if (clientversion.Major > 0)
         {
             if (full)
             {
                 communicator.SendString(Id);
                 communicator.SendString(Name);
             }
         }
         return(this);
     }
     catch (System.Exception ex)
     {
         throw ex;
     }
 }