示例#1
0
 public Player(MessageResult pParams)
 {
     Statistics = new Statistics();
     Profile = new Profile();
     this.Profile.Id = Int32.Parse(pParams["PlayerID"]);
     DateTime d;
     Profile.Nickname = pParams["Nickname"];
     Profile.Name = pParams["Name"];
     Profile.Surname = pParams["Surname"];
     Profile.Email = pParams["Email"];
     Profile.Phone = pParams["Phone"];
     Profile.VK = pParams["VK"];
     Profile.FB = pParams["FB"];
     Profile.OK = pParams["OK"];
     Profile.Country = pParams["Country"];
     Profile.Address = pParams["Address"];
     Profile.ZipCode = pParams["ZipCode"];
     Profile.Language = pParams["Language"];
     Profile.Sex = Helpers.StringToBool(pParams["Sex"]);
     Profile.TimeZone = pParams["TimeZone"];
     if (DateTime.TryParse(pParams["BirthDate"], out d))
         Profile.BirtDate = d;
     if (DateTime.TryParse(pParams["VIPExperies"], out d))
         Profile.VIPExperies = d;
 }
示例#2
0
 public Table(MessageResult tParams)
 {
     ID = Int32.Parse(tParams["ID"]);
     Bet = Int32.Parse(tParams["Bet"]);
     PlayersVisibility = Helpers.StringToBool(tParams["PlayersVisibility"]);
     Chat = Helpers.StringToBool(tParams["Chat"]);
     MinimalLevel = Int32.Parse(tParams["MinimalLevel"]);
     VIPOnly = Helpers.StringToBool(tParams["VIPOnly"]);
     Moderation = Helpers.StringToBool(tParams["Moderation"]);
     AI = Helpers.StringToBool(tParams["AI"]);
     TableCreator = Int32.Parse(tParams["Creator"]);
     int Player2, Player3, Player4;
     if (!Int32.TryParse(tParams["Player2"], out Player2))
         Player2 = -1;
     this.Player2 = Player2;
     if (!Int32.TryParse(tParams["Player3"], out Player3))
         Player3 = -1;
     this.Player3 = Player3;
     if (!Int32.TryParse(tParams["Player4"], out Player4))
         Player4 = -1;
     this.Player4 = Player4;
     TableVisibility = true;
 }
 // Ход другого игрока
 private void RemindCardHandler(Message Msg)
 {
     try
     {
         MessageResult cParams = new MessageResult(Msg);
         int cardPlace = Int32.Parse(cParams["Place"]);
         Card newCard = new Card(cParams["Card"]);
         int beloteRemind = Int32.Parse(cParams["Belote"]);
         gameData.Bribes.PutCard(newCard, cardPlace);
         gameData.LocalScores[BeloteTeam.TEAM1_1_3] = Int32.Parse(cParams["Scores1"]);
         gameData.LocalScores[BeloteTeam.TEAM2_2_4] = Int32.Parse(cParams["Scores2"]);
         if (beloteRemind == 1)
             gameData.Bribes.CurrentBribe.BelotePlace = cardPlace;
         else
         if (beloteRemind == 2)
             gameData.Bribes.CurrentBribe.RebelotePlace = cardPlace;
         if (OnUpdateGraphics != null)
             OnUpdateGraphics();
     }
     catch (Exception Ex)
     {
         throw new BeloteClientException("Произошла ошибка во время оповещения о карте, которой походил кто-то из игроков", Ex);
     }
 }
 // Обработчик удаление другого игрока со стола
 private void PlayerDeleteHandler(Message Msg)
 {
     MessageResult pParams = new MessageResult(Msg);
     int PlayerPlace = Int32.Parse(pParams["Place"]);
     Players.Delete(Players[currentTable[PlayerPlace]]);
     currentTable.SetPlayerAtPlace(-1, PlayerPlace);
     if (OnUpdateWaitingTable != null)
         OnUpdateWaitingTable();
 }
 // Выход игрока со стола во время игры
 private void PlayerQuitHandler(Message Msg)
 {
     try
     {
         MessageResult qParams = new MessageResult(Msg);
         // Продолжаем игру
         if (qParams["Continue"] == "1")
         {
             int BotPlace = Int32.Parse(qParams["Place"]);
             if (BotPlace != place)
             {
                 currentTable.SetPlayerAtPlace(-BotPlace, BotPlace);
                 if (OnUpdateGraphics != null)
                     OnUpdateGraphics();
                 return;
             }
         }
         SetGameHandlers(false);
         ChangeCurrentTable(null);
         if (OnPlayerQuit != null)
             OnPlayerQuit();
     }
     catch (Exception Ex)
     {
         throw new BeloteClientException("Произошла ошибка во время выхода кого-то со стола", Ex);
     }
 }
 // Переход хода к игроку
 private void NextPlayerHandler(Message Msg)
 {
     try
     {
         // Если это первый ход, то нужно огласить бонусы
         if (gameData.Bonuses != null)
         {
             // Если есть неоглашенные бонусы, то предлагаем их огласить
             if (gameData.Bonuses.Count != 0)
             {
                 if (OnAnnounceBonuses != null)
                     OnAnnounceBonuses();
                 serverActions.Game.PlayerAnnounceBonuses(gameData.Bonuses);
                 // Обнуляем бонусы
                 gameData.Bonuses = null;
             }
         }
         MessageResult cParams = new MessageResult(Msg);
         // Получаем список возможных карт
         gameData.PossibleCards = new CardList(cParams["Cards"]);
         // Разрешаем игроку сделать ход
         gameData.IsMakingMove = true;
         if (OnUpdateGraphics != null)
             OnUpdateGraphics();
     }
     catch (Exception Ex)
     {
         throw new BeloteClientException("Произошла ошибка во время перехода хода к игроку", Ex);
     }
 }
 //**********************************************************************************************************************************************************************************
 //                      Обработчики доигровых событий: посадка игрока на стол, удаление игрока со стола, старт игры
 //**********************************************************************************************************************************************************************************
 // Обработчик добавления другого игрока на стол
 private void PlayerAddHandler(Message Msg)
 {
     MessageResult pParams = new MessageResult(Msg);
     int PlayerID = Int32.Parse(pParams["Player"]);
     int PlayerPlace = Int32.Parse(pParams["Place"]);
     currentTable.SetPlayerAtPlace(PlayerID, PlayerPlace);
     if (!Players.PlayerExists(PlayerID))
     {
         Player p = serverActions.Players.GetPlayer(PlayerID);
         if (p != null)
             Players.Add(p);
     }
     if (OnUpdateWaitingTable != null)
         OnUpdateWaitingTable();
 }
 // Завершение игры
 private void GameEndHandler(Message Msg)
 {
     try
     {
         MessageResult gParams = new MessageResult(Msg);
         gameData.TotalScores[BeloteTeam.TEAM1_1_3] = Int32.Parse(gParams["Scores1"]);
         gameData.TotalScores[BeloteTeam.TEAM2_2_4] = Int32.Parse(gParams["Scores2"]);
         SetGameHandlers(false);
         ChangeCurrentTable(null);
         if (OnGameEnd != null)
             OnGameEnd();
     }
     catch (Exception Ex)
     {
         throw new BeloteClientException("Произошла ошибка при завершении игры", Ex);
     }
 }
 //**********************************************************************************************************************************************************************************
 //                      Обработчики основных игровых событийf
 //**********************************************************************************************************************************************************************************
 // Обработчик получения списка карт
 private void GetCardsHandler(Message Msg)
 {
     try
     {
         MessageResult cParams = new MessageResult(Msg);
         string cardsStr = cParams["Cards"];
         int totalScore1 = Int32.Parse(cParams["Scores1"]);
         int totalScore2 = Int32.Parse(cParams["Scores2"]);
         gameData.NewDistribution(new CardList(cardsStr), totalScore1, totalScore2);
         if (OnUpdateGraphics != null)
             OnUpdateGraphics();
     }
     catch (Exception Ex)
     {
         throw new BeloteClientException("Произошла ошибка при получении списка карт", Ex);
     }
 }
示例#10
0
 // Объявление победителя по бонусам
 private void BonusesShowWinnerHandler(Message Msg)
 {
     try
     {
         gameData.ChangeGameStatus(TableStatus.PLAY);
         MessageResult wParams = new MessageResult(Msg);
         BeloteTeam winner = (BeloteTeam)Int32.Parse(wParams["Winner"]);
         int scores = Int32.Parse(wParams["Scores"]);
         gameData.AnnouncedBonuses.SetWinner(winner, scores);
         if (OnShowBonusesWinner != null)
             OnShowBonusesWinner();
         gameData.AnnouncedBonuses.Clear();
         if (OnUpdateGraphics != null)
             OnUpdateGraphics();
     }
     catch (Exception Ex)
     {
         throw new BeloteClientException("Произошла ошибка во время объявления команды попедителя по бонусам", Ex);
     }
 }
示例#11
0
 // Объявление о типах объявленных бонусов одного из игроков
 private void BonusesShowTypesHandler(Message Msg)
 {
     try
     {
         MessageResult tParams = new MessageResult(Msg);
         int count = Int32.Parse(tParams["Count"]);
         int place = Int32.Parse(tParams["Place"]);
         if (count == 0)
             return;
         for (var i = 0; i < count; i++)
         {
             BonusType nextB = (BonusType)Int32.Parse(tParams["Type" + i.ToString()]);
             gameData.AnnouncedBonuses.AddBonus(place, nextB);
         }
         if (OnUpdateGraphics != null)
             OnUpdateGraphics();
     }
     catch (Exception Ex)
     {
         throw new BeloteClientException("Произошла ошибка при получении типов объявленныъ другим игроком бонусов", Ex);
     }
 }
示例#12
0
 // Произношение заявки сделанной одним из игроков
 private void BazarPlayerSayHandler(Message Msg)
 {
     try
     {
         MessageResult bParams = new MessageResult(Msg);
         int playerNum = Int32.Parse(bParams["Player"]);
         OrderType orderType = (OrderType)Int32.Parse(bParams["Type"]);
         int orderSize = Int32.Parse(bParams["Size"]);
         CardSuit orderSuit = Helpers.StringToSuit(bParams["Trump"]);
         gameData.Orders[playerNum] = new Order(orderType, orderSize, orderSuit);
         if (OnUpdateGraphics != null)
             OnUpdateGraphics();
     }
     catch (Exception Ex)
     {
         throw new BeloteClientException("Произошла ошибка во время информирования игрока о ставке другого игрока", Ex);
     }
 }
示例#13
0
 // Переход хода к игроку во время торговли
 private void BazarNextPlayerHandler(Message Msg)
 {
     try
     {
         gameData.IsMakingMove = true;
         MessageResult bParams = new MessageResult(Msg);
         gameData.Orders.PossibleBetType = (BetType)Int32.Parse(bParams["Type"]);
         gameData.Orders.PossibleBetSize = Int32.Parse(bParams["MinSize"]);
         if (OnBazarMakingBet != null)
             OnBazarMakingBet();
     }
     catch (Exception Ex)
     {
         throw new BeloteClientException("Произошла ошибка при переходе хода во время торговли к игроку", Ex);
     }
 }
示例#14
0
 // Завершение процесса торговли
 private void BazarEndHandler(Message Msg)
 {
     try
     {
         MessageResult bParams = new MessageResult(Msg);
         BeloteTeam oTeam = (BeloteTeam)Int32.Parse(bParams["Team"]);
         OrderType oType = (OrderType)Int32.Parse(bParams["Type"]);
         CardSuit oSuit = (CardSuit)Int32.Parse(bParams["Trump"]);
         int oSize = Int32.Parse(bParams["Size"]);
         gameData.Orders.SetEndOrder(new Order(oType, oSize, oSuit));
         gameData.Orders.EndOrder.ChangeTeam(oTeam);
         gameData.ChangeGameStatus(TableStatus.BONUSES);
         if (OnUpdateGraphics != null)
             OnUpdateGraphics();
     }
     catch (Exception Ex)
     {
         throw new BeloteClientException("Произошла ошибка во время завершения процесса торговли", Ex);
     }
 }