public HandAction(string playerName,
     HandActionType handActionType,
     decimal amount,
     Street street,
     int actionNumber)
     : this(playerName, handActionType, amount, street, false, actionNumber)
 {
 }
Example #2
0
 //public BettingAction(PlayerInfo Player, PlayerBettingActions Act, double Amount = 0, bool All_In = false):base(Player)
 public BettingAction(PlayerInfo player, Street street, double amount, bool All_In = false)
     : base(player, street)
 {
     //_Act = Act;
     _amount = amount;
     _all_In = All_In;
     //_curGameState.PotSize += amount;
 }
 public AllInAction(string playerName,
                    decimal amount,
                    Street street,
                    bool isRaiseAllIn,
                    int actionNumber = 0)
     : base(playerName, HandActionType.ALL_IN, amount, street, actionNumber)
 {
     IsRaiseAllIn = isRaiseAllIn;
 }
 public HandAction(string playerName, 
                   HandActionType handActionType,                           
                   decimal amount,
                   Street street, 
                   int actionNumber = 0)
 {
     Street = street;
     HandActionType = handActionType;
     PlayerName = playerName;
     Amount = GetAdjustedAmount(amount, handActionType);
     ActionNumber = actionNumber;
 }
Example #5
0
    private VehicleType _type; //the vehicle type

    #endregion Fields

    #region Constructors

    //the constructor
    public Vehicle(VehicleType type,float speed,float size, StreetDirection curDir, Street curStreet, Street nextStreet,int curStrNum, GamePath path, AudioClip theHorn)
    {
        _type = type;
        _speed = speed;
        _size = size;
        _currentDirection = curDir;
        _currentStreet = curStreet;
        _nextStreet = nextStreet;
        _curStreetNumber = curStrNum;
        _myPath = path;
        _horn = theHorn;
    }
 public HandAction(string playerName,
                   HandActionType handActionType,
                   Street street,
                   bool AllInAction = false,
                   int actionNumber = 0)
 {
     Street = street;
     HandActionType = handActionType;
     PlayerName = playerName;
     Amount = 0m;
     ActionNumber = actionNumber;
     IsAllIn = AllInAction;
 }
 public AllInAction(string playerName,
                    decimal amount,
                    Street street,
                    bool isRaiseAllIn,
                    int actionNumber = 0)
     : base(playerName, HandActionType.RAISE, amount, street, true, actionNumber)
 {
     IsRaiseAllIn = isRaiseAllIn;
     if (!isRaiseAllIn)
     {
         HandActionType = Actions.HandActionType.BET;
     }
 }
Example #8
0
            public static Street Parse(string input)
            {
                var res = new Street();
                string[] coords = input.Split(' ');

                res.From = Junctions[Int32.Parse(coords[0])];
                res.To = Junctions[Int32.Parse(coords[1])];
                res.Direction = (DirectionEnum)Int32.Parse(coords[2]);
                res.Cost = Int32.Parse(coords[3]);
                res.Length = Int32.Parse(coords[4]);
                res.OriginalLength = res.Length;

                return res;
            }
        public HandAction ParseCollectedLine(string actionLine, Street currentStreet)
        {
            // 0 = main pot
            int potNumber = 0;
            HandActionType handActionType = HandActionType.WINS;

            // check for side pot lines like
            //  CinderellaBD collected $7 from side pot-2
            if (actionLine[actionLine.Length - 2] == '-')
            {
                handActionType = HandActionType.WINS_SIDE_POT;
                potNumber = Int32.Parse(actionLine[actionLine.Length - 1].ToString());
                // This removes the ' from side pot-2' from the line
                actionLine = actionLine.Substring(0, actionLine.Length - 16);
            }
            // check for a side pot line like
            // bozzoTHEclow collected $136.80 from side pot
            else if (actionLine[actionLine.Length - 8] == 's')
            {
                potNumber = 1;
                handActionType = HandActionType.WINS_SIDE_POT;
                // This removes the ' from side pot' from the line
                actionLine = actionLine.Substring(0, actionLine.Length - 14);
            }
            // check for main pot line like
            //bozzoTHEclow collected $245.20 from main pot
            else if (actionLine[actionLine.Length - 8] == 'm')
            {
                // This removes the ' from main pot' from the line
                actionLine = actionLine.Substring(0, actionLine.Length - 14);
            }
            // otherwise is basic line like
            // alecc frost collected $1.25 from pot
            else
            {
                // This removes the ' from pot' from the line
                actionLine = actionLine.Substring(0, actionLine.Length - 9);
            }

            // Collected bet lines look like:
            // alecc frost collected $1.25 from pot

            int firstAmountDigit = actionLine.LastIndexOf(' ') + 2;
            decimal amount = decimal.Parse(actionLine.Substring(firstAmountDigit, actionLine.Length - firstAmountDigit), DecimalSeperator);

            // 12 characters from first digit to the space infront of collected
            string playerName = actionLine.Substring(0, firstAmountDigit - 12);

            return new WinningsAction(playerName, handActionType, amount, potNumber);
        }
        private static HandActionType ParseActionType(SiteActionRegexesBase siteActionRegexes, Street street, string actionText)
        {
            foreach (var actionRegex in siteActionRegexes.GetPossibleActions(street))
            {
                if (string.IsNullOrWhiteSpace(actionRegex.ActionRegex)) continue;

                var match = Regex.Match(actionText, actionRegex.ActionRegex);

                if (match.Success)
                {
                    return actionRegex.HandActionType;
                }
            }

            return HandActionType.UNKNOWN;
        }
 public BoardCards GetBoardOnStreet(Street streetAllIn)
 {
     switch (streetAllIn)
     {
         case Street.Preflop:
             return BoardCards.ForPreflop();
         case Street.Flop:
             return BoardCards.ForFlop(this[0], this[1], this[2]);
         case Street.Turn:
             return BoardCards.ForTurn(this[0], this[1], this[2], this[3]);
         case Street.River:
             return BoardCards.ForRiver(this[0], this[1], this[2], this[3], this[4]);
         default:
             throw new ArgumentException("Can't get board in for null street");
     }
 }
        /// <summary>
        /// Gets the ActionType for an unadjusted action amount
        /// </summary>
        /// <param name="playerName"></param>
        /// <param name="amount"></param>
        /// <param name="street"></param>
        /// <param name="actions"></param>
        /// <returns></returns>
        public static HandActionType GetAllInActionType(string playerName, decimal amount, Street street, List<HandAction> actions)
        {
            var streetActions = actions.Street(street);

            if (street != Street.Preflop && streetActions.FirstOrDefault(p => p.HandActionType == HandActionType.BET) == null)
            {
                return HandActionType.BET;
            }

            if (Math.Abs(amount) <= Math.Abs(actions.Min(p => p.Amount)))
            {
                return HandActionType.CALL;
            }
            else
            {
                return HandActionType.RAISE;
            }
        }
Example #13
0
    //this method changes the state of the light from red to green and vice versa
    public void ChangeState(Street str)
    {
        if(str.StreetLight.Stopped){

            str.StreetLight.Stopped = false;
            //if(str.StreetLight.tLight.renderer.material.color != Color.green)
                str.StreetLight.tLight.renderer.material.color = Color.green;
        }
        else if(!(str.StreetLight.Stopped)){

            str.StreetLight.Stopped = true;
            //if(str.StreetLight.tLight.renderer.material.color != Color.red)
                str.StreetLight.tLight.renderer.material.color = Color.red;
        }
        else{
            Debug.LogWarning("you can't change the light while it is yellow");
        }
    }
Example #14
0
        private void ButtonAddStreet_Click(object sender, RoutedEventArgs e)
        {
            AreButtonsEnabled = false;
            string name = TextBoxStreetName.Text;

            if (string.IsNullOrEmpty(name) || string.IsNullOrWhiteSpace(name))
            {
                MessageBox.Show("Debe ingresar un nombre", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                AreButtonsEnabled = true;
                return;
            }

            if (ComboBoxSectors.SelectedItem == null)
            {
                MessageBox.Show("Debe seleccionar un sector", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                AreButtonsEnabled = true;
                return;
            }

            Street street = new Street()
            {
                Name   = name,
                Sector = (Sector)ComboBoxSectors.SelectedItem
            };

            App.DbContext.Streets.Add(street);

            try
            {
                App.DbContext.SaveChanges();
            }
            catch
            {
                MessageBox.Show("No se pudieron guardar los cambios en la base de datos", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                AreButtonsEnabled = true;
                return;
            }

            MessageBox.Show("Calle agregada con éxito", "Éxito", MessageBoxButton.OK, MessageBoxImage.Information);
            TextBoxStreetName.Text       = string.Empty;
            ComboBoxSectors.SelectedItem = null;
            Streets.Add(street);
            AreButtonsEnabled = true;
        }
 public Schema()
     : base() {
     InstanceType = typeof(__Frtransact__);
     Properties.ClearExposed();
     City = Add<__TString__>("City$");
     City.DefaultValue = "";
     City.Editable = true;
     City.SetCustomAccessors((_p_) => { return ((__Frtransact__)_p_).__bf__City__; }, (_p_, _v_) => { ((__Frtransact__)_p_).__bf__City__ = (System.String)_v_; }, false);
     Country = Add<__TString__>("Country$");
     Country.DefaultValue = "";
     Country.Editable = true;
     Country.SetCustomAccessors((_p_) => { return ((__Frtransact__)_p_).__bf__Country__; }, (_p_, _v_) => { ((__Frtransact__)_p_).__bf__Country__ = (System.String)_v_; }, false);
     Name = Add<__TString__>("Name$");
     Name.DefaultValue = "";
     Name.Editable = true;
     Name.SetCustomAccessors((_p_) => { return ((__Frtransact__)_p_).__bf__Name__; }, (_p_, _v_) => { ((__Frtransact__)_p_).__bf__Name__ = (System.String)_v_; }, false);
     Number = Add<__TString__>("Number$");
     Number.DefaultValue = "";
     Number.Editable = true;
     Number.SetCustomAccessors((_p_) => { return ((__Frtransact__)_p_).__bf__Number__; }, (_p_, _v_) => { ((__Frtransact__)_p_).__bf__Number__ = (System.String)_v_; }, false);
     Street = Add<__TString__>("Street$");
     Street.DefaultValue = "";
     Street.Editable = true;
     Street.SetCustomAccessors((_p_) => { return ((__Frtransact__)_p_).__bf__Street__; }, (_p_, _v_) => { ((__Frtransact__)_p_).__bf__Street__ = (System.String)_v_; }, false);
     ZipCode = Add<__TString__>("ZipCode$");
     ZipCode.DefaultValue = "";
     ZipCode.Editable = true;
     ZipCode.SetCustomAccessors((_p_) => { return ((__Frtransact__)_p_).__bf__ZipCode__; }, (_p_, _v_) => { ((__Frtransact__)_p_).__bf__ZipCode__ = (System.String)_v_; }, false);
     Date = Add<__TString__>("Date$");
     Date.DefaultValue = "";
     Date.Editable = true;
     Date.SetCustomAccessors((_p_) => { return ((__Frtransact__)_p_).__bf__Date__; }, (_p_, _v_) => { ((__Frtransact__)_p_).__bf__Date__ = (System.String)_v_; }, false);
     SalesPrice = Add<__TLong__>("SalesPrice$");
     SalesPrice.DefaultValue = 0L;
     SalesPrice.Editable = true;
     SalesPrice.SetCustomAccessors((_p_) => { return ((__Frtransact__)_p_).__bf__SalesPrice__; }, (_p_, _v_) => { ((__Frtransact__)_p_).__bf__SalesPrice__ = (System.Int64)_v_; }, false);
     Commission = Add<__TLong__>("Commission$");
     Commission.DefaultValue = 0L;
     Commission.Editable = true;
     Commission.SetCustomAccessors((_p_) => { return ((__Frtransact__)_p_).__bf__Commission__; }, (_p_, _v_) => { ((__Frtransact__)_p_).__bf__Commission__ = (System.Int64)_v_; }, false);
     Address = Add<__TString__>("Address");
     Address.DefaultValue = "";
     Address.SetCustomAccessors((_p_) => { return ((__Frtransact__)_p_).__bf__Address__; }, (_p_, _v_) => { ((__Frtransact__)_p_).__bf__Address__ = (System.String)_v_; }, false);
 }
Example #16
0
        /// <summary>
        /// Parses a handaction or changes the current street
        /// </summary>
        /// <param name="line"></param>
        /// <param name="currentStreet"></param>
        /// <param name="handActions"></param>
        /// <returns>True if we have reached the end of the action block.</returns>
        public static void ParseRegularActionLine(string line, ref Street currentStreet, List <HandAction> actions, List <WinningsAction> winners)
        {
            char lastChar = line[line.Length - 1];

            switch (lastChar)
            {
            //Expected formats:
            //player posts small blind [$5 USD].
            //player posts big blind [$10 USD].
            case '.':
                ParseDotAction(line, currentStreet, actions, winners);
                return;

            case ']':
                char firstChar = line[0];
                if (firstChar == '*')
                {
                    currentStreet = ParseStreet(line);
                }
                else
                {
                    actions.Add(ParseActionWithSize(line, currentStreet));
                }
                return;

            case 's':
                //saboniiplz wins 28,304 chips
                if (line[line.Length - 2] == 'p')
                {
                    winners.Add(ParseWinsAction(line));
                }
                else
                {
                    actions.Add(ParseActionWithoutSize(line, currentStreet));
                }
                return;

            //Expected Formats:
            //"Player wins $5.18 USD"
            case 'D':
                winners.Add(ParseWinsAction(line));
                return;
            }
        }
Example #17
0
        private void SetBoardCardItems(Street street)
        {
            FilterSectionItem           filterSectionItem = null;
            IEnumerable <BoardCardItem> collection;
            string filterSectionItemString = string.Empty;

            switch (street)
            {
            case Street.Flop:
                filterSectionItem       = this.FilterSectionCollection.FirstOrDefault(x => x.ItemType == EnumFilterSectionItemType.FlopBoardCardItem);
                filterSectionItemString = "Specific Flop";
                collection = BoardTextureModel.FlopCardItemsCollection;
                break;

            case Street.Turn:
                filterSectionItem       = this.FilterSectionCollection.FirstOrDefault(x => x.ItemType == EnumFilterSectionItemType.TurnBoardCardItem);
                filterSectionItemString = "Specific Flop+Turn";
                collection = BoardTextureModel.TurnCardItemsCollection;
                break;

            case Street.River:
                filterSectionItem       = this.FilterSectionCollection.FirstOrDefault(x => x.ItemType == EnumFilterSectionItemType.RiverBoardCardItem);
                filterSectionItemString = "Specific Full Board";
                collection = BoardTextureModel.RiverCardItemsCollection;
                break;

            default:
                return;
            }

            var selectedHandValues = collection.Where(x => x.Suit != RangeCardSuit.None);

            if (selectedHandValues == null || selectedHandValues.Count() == 0)
            {
                filterSectionItem.IsActive = false;
                return;
            }


            var handValueItemsString = String.Join("+", selectedHandValues.Select(x => x.ToString().Trim()));

            filterSectionItem.Name     = String.Format("{0}={1}", filterSectionItemString, handValueItemsString);
            filterSectionItem.IsActive = true;
        }
        public void Update(string name, string street, int number, string neighborhood, string city, string state, string country, string zipCode)
        {
            if (!string.IsNullOrEmpty(name) && !Name.Equals(name))
            {
                Name = name;
            }

            if (!string.IsNullOrEmpty(street) && !Street.Equals(street))
            {
                Street = street;
            }

            if (number > 0)
            {
                Number = number;
            }

            if (!string.IsNullOrEmpty(neighborhood) && !Neighborhood.Equals(neighborhood))
            {
                Neighborhood = neighborhood;
            }

            if (!string.IsNullOrEmpty(city) && !City.Equals(city))
            {
                City = city;
            }

            if (!string.IsNullOrEmpty(state) && !State.Equals(state))
            {
                State = state;
            }

            if (!string.IsNullOrEmpty(country) && !Country.Equals(country))
            {
                Country = country;
            }

            if (!string.IsNullOrEmpty(zipCode) && !ZipCode.Equals(zipCode))
            {
                ZipCode = zipCode;
            }

            Updated = DateTime.Now;
        }
Example #19
0
        private void SetHandValueItems(Street street)
        {
            FilterSectionItem           filterSectionItem = null;
            IEnumerable <HandValueItem> collection;
            string filterSectionItemString = string.Empty;

            switch (street)
            {
            case Street.Flop:
                filterSectionItem       = this.FilterSectionCollection.FirstOrDefault(x => x.ItemType == EnumFilterSectionItemType.FlopHandValue);
                filterSectionItemString = "Flop Hands";
                collection = HandValueModel.FlopHandValuesCollection;
                break;

            case Street.Turn:
                filterSectionItem       = this.FilterSectionCollection.FirstOrDefault(x => x.ItemType == EnumFilterSectionItemType.TurnHandValue);
                filterSectionItemString = "Turn Hands";
                collection = HandValueModel.TurnHandValuesCollection;
                break;

            case Street.River:
                filterSectionItem       = this.FilterSectionCollection.FirstOrDefault(x => x.ItemType == EnumFilterSectionItemType.RiverHandValue);
                filterSectionItemString = "River Hands";
                collection = HandValueModel.RiverHandValuesCollection;
                break;

            default:
                return;
            }

            var selectedHandValues = collection.Where(x => x.IsChecked);

            if (selectedHandValues == null || selectedHandValues.Count() == 0)
            {
                filterSectionItem.IsActive = false;
                return;
            }


            var handValueItemsString = String.Join("+", selectedHandValues.Select(x => x.Name.Trim()));

            filterSectionItem.Name     = String.Format("{0}={1}", filterSectionItemString, handValueItemsString);
            filterSectionItem.IsActive = true;
        }
Example #20
0
        public void Run()
        {
            List <House> houses;
            var          streets = new List <Street>();

            using (var db = new NpgDbContext(conn))
            {
                houses  = db.Houses.ToList();
                streets = db.Streets.ToList();
                foreach (var house in houses)
                {
                    var    parts = house.number.Split(new string[] { ", д." }, StringSplitOptions.RemoveEmptyEntries);
                    string streetStr;
                    if (parts.Length == 1)
                    {
                        house.number = "д. " + parts[0].Replace(", Домодедово", "");
                        streetStr    = "Домодедово";
                    }
                    else
                    {
                        house.number = "д. " + parts[1].Replace(", Домодедово", "");
                        streetStr    = parts[0].Replace("г. Домодедово, ", "");
                    }

                    Street street;
                    if (streets.Exists(p => p.name == streetStr))
                    {
                        street = streets.FirstOrDefault(p => p.name == streetStr);
                        street.Houses.Add(house);
                    }
                    else
                    {
                        street = new Street
                        {
                            name = streetStr
                        };
                        street.Houses.Add(house);
                        streets.Add(street);
                    }
                }

                db.SaveChanges();
            }
        }
Example #21
0
    ////Must be filled later!
    //public static MapClass()
    //{

    //    settings = new Settings();
    //    Streets = new Street[20];
    //    Buildings = new Building[20];
    //    Map = new int[length][];
    //}

    public static void AddStreet(Point start, Point end)
    {
        int i;

        for (i = 0; Streets[i] != null; i++)
        {
            ;
        }
        Streets[i] = new Street(start, end);
        if (start.Y == end.Y)
        {
            if (start.X < end.X)
            {
                for (int j = 0; j <= System.Math.Abs(start.X - end.X); j++)
                {
                    Map[start.Y][start.X + j] = Streets[i].StreetNumber + 100;
                }
            }
            else
            {
                for (int j = 0; j <= System.Math.Abs(start.X - end.X); j++)
                {
                    Map[end.Y][end.X + j] = Streets[i].StreetNumber + 100;
                }
            }
        }
        else
        {
            if (start.Y < end.Y)
            {
                for (int j = 0; j <= System.Math.Abs(start.Y - end.Y); j++)
                {
                    Map[start.Y + j][start.X] = Streets[i].StreetNumber + 100;
                }
            }
            else
            {
                for (int j = 0; j <= System.Math.Abs(start.Y - end.Y); j++)
                {
                    Map[end.Y + j][end.X] = Streets[i].StreetNumber + 100;
                }
            }
        }
    }
Example #22
0
 public Schema()
     : base()
 {
     InstanceType = typeof(__Franchis__);
     Properties.ClearExposed();
     Html = Add <__TString__>("Html");
     Html.DefaultValue = "/tatiana/FranchiseOfficeEditPage.html";
     Html.SetCustomAccessors((_p_) => { return(((__Franchis__)_p_).__bf__Html__); }, (_p_, _v_) => { ((__Franchis__)_p_).__bf__Html__ = (System.String)_v_; }, false);
     Name = Add <__TString__>("Name$");
     Name.DefaultValue = "";
     Name.Editable     = true;
     Name.SetCustomAccessors((_p_) => { return(((__Franchis__)_p_).__bf__Name__); }, (_p_, _v_) => { ((__Franchis__)_p_).__bf__Name__ = (System.String)_v_; }, false);
     Street = Add <__TString__>("Street$");
     Street.DefaultValue = "";
     Street.Editable     = true;
     Street.SetCustomAccessors((_p_) => { return(((__Franchis__)_p_).__bf__Street__); }, (_p_, _v_) => { ((__Franchis__)_p_).__bf__Street__ = (System.String)_v_; }, false);
     Number = Add <__TLong__>("Number$");
     Number.DefaultValue = 0L;
     Number.Editable     = true;
     Number.SetCustomAccessors((_p_) => { return(((__Franchis__)_p_).__bf__Number__); }, (_p_, _v_) => { ((__Franchis__)_p_).__bf__Number__ = (System.Int64)_v_; }, false);
     ZipCode = Add <__TLong__>("ZipCode$");
     ZipCode.DefaultValue = 0L;
     ZipCode.Editable     = true;
     ZipCode.SetCustomAccessors((_p_) => { return(((__Franchis__)_p_).__bf__ZipCode__); }, (_p_, _v_) => { ((__Franchis__)_p_).__bf__ZipCode__ = (System.Int64)_v_; }, false);
     City = Add <__TString__>("City$");
     City.DefaultValue = "";
     City.Editable     = true;
     City.SetCustomAccessors((_p_) => { return(((__Franchis__)_p_).__bf__City__); }, (_p_, _v_) => { ((__Franchis__)_p_).__bf__City__ = (System.String)_v_; }, false);
     Country = Add <__TString__>("Country$");
     Country.DefaultValue = "";
     Country.Editable     = true;
     Country.SetCustomAccessors((_p_) => { return(((__Franchis__)_p_).__bf__Country__); }, (_p_, _v_) => { ((__Franchis__)_p_).__bf__Country__ = (System.String)_v_; }, false);
     SaveTrigger = Add <__TLong__>("SaveTrigger$");
     SaveTrigger.DefaultValue = 0L;
     SaveTrigger.Editable     = true;
     SaveTrigger.SetCustomAccessors((_p_) => { return(((__Franchis__)_p_).__bf__SaveTrigger__); }, (_p_, _v_) => { ((__Franchis__)_p_).__bf__SaveTrigger__ = (System.Int64)_v_; }, false);
     SaveTrigger.AddHandler((Json pup, Property <Int64> prop, Int64 value) => { return(new Input.SaveTrigger()
         {
             App = (FranchiseOfficeEditPage)pup, Template = (TLong)prop, Value = value
         }); }, (Json pup, Starcounter.Input <Int64> input) => { ((FranchiseOfficeEditPage)pup).Handle((Input.SaveTrigger)input); });
     FullAddress = Add <__TString__>("FullAddress", bind: "FullAddress");
     FullAddress.DefaultValue = "";
     FullAddress.SetCustomAccessors((_p_) => { return(((__Franchis__)_p_).__bf__FullAddress__); }, (_p_, _v_) => { ((__Franchis__)_p_).__bf__FullAddress__ = (System.String)_v_; }, false);
 }
        public async Task ValidateAsync_StreetExists_DoesNothing()
        {
            // Arrange
            var streetContainer = new Mock <IStreetContainer>();

            var street         = new Street();
            var streetDAL      = new Mock <IStreetDAL>();
            var streetIdentity = new Mock <IStreetIdentity>();

            streetDAL.Setup(x => x.GetAsync(streetIdentity.Object)).ReturnsAsync(street);

            var streetGetService = new StreetService(streetDAL.Object);

            // Act
            var action = new Func <Task>(() => streetGetService.ValidateAsync(streetContainer.Object));

            // Assert
            await action.Should().NotThrowAsync <Exception>();
        }
Example #24
0
        public void GetStreetRent()
        {
            var group  = new Group(1, 50);
            var street = new Street(21, group, 220, new int[] { 18, 90, 250, 700, 875, 1050 }, "Kentucky Ave");

            Assert.AreEqual(18, street.GetRent());   //Undeveloped
            street.DevelopProperty(1);
            Assert.AreEqual(90, street.GetRent());   //1 house
            street.DevelopProperty(2);
            Assert.AreEqual(250, street.GetRent());  //2 houses
            street.DevelopProperty(3);
            Assert.AreEqual(700, street.GetRent());  //3 houses
            street.DevelopProperty(4);
            Assert.AreEqual(875, street.GetRent());  //4 houses
            street.DevelopProperty(5);
            Assert.AreEqual(1050, street.GetRent()); //Hotel
            street.DevelopProperty(-1);
            Assert.AreEqual(0, street.GetRent());    //Mortgaged street
        }
Example #25
0
        public IEnumerable <HandActionFilterButton> GetButonsCollectionForStreet(Street street)
        {
            switch (street)
            {
            case Street.Preflop:
                return(PreflopButtons);

            case Street.Flop:
                return(FlopButtons);

            case Street.Turn:
                return(TurnButtons);

            case Street.River:
                return(RiverButtons);
            }

            throw new ArgumentOutOfRangeException("street", street, "Street should be within Preflop-River range");
        }
Example #26
0
        public Street DeleteStreet(int id)
        {
            Street street = null;
            string query  = " Delete from StreetTable where Id =@id";

            using (SqlCommand command = new SqlCommand(query, _connection))
            {
                command.Parameters.Add(new SqlParameter("@id", System.Data.SqlDbType.Int)
                {
                    Value = id
                });
                using (SqlDataReader reader = command.ExecuteReader())
                {
                    street = new Street();
                    reader.Read();
                }
            }
            return(street);
        }
Example #27
0
        /// <summary>
        /// Returns true if Address instances are equal
        /// </summary>
        /// <param name="other">Instance of Address to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Address other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Number == other.Number ||
                     Number != null &&
                     Number.Equals(other.Number)
                     ) &&
                 (
                     Street == other.Street ||
                     Street != null &&
                     Street.Equals(other.Street)
                 ) &&
                 (
                     City == other.City ||
                     City != null &&
                     City.Equals(other.City)
                 ) &&
                 (
                     Locality == other.Locality ||
                     Locality != null &&
                     Locality.Equals(other.Locality)
                 ) &&
                 (
                     Zip == other.Zip ||
                     Zip != null &&
                     Zip.Equals(other.Zip)
                 ) &&
                 (
                     Country == other.Country ||
                     Country != null &&
                     Country.Equals(other.Country)
                 ));
        }
Example #28
0
        static void Main(string[] args)
        {
            logger.Info("Парсер начал работу.");
            // string ab = Resources.jsonTest;
            // var asd = Newtonsoft.Json.JsonConvert.DeserializeObject<SchoolsJSON>(ab);
            Street        s = DataProvider.Instance.GetStreetsFromDb(94, 94)[0];
            List <string> streetProperties = Parser.ParseHomes(s);

            foreach (string a in streetProperties)
            {
                Parser.ParseProperty(a);
            }

            logger.Info("Парсер закончил работу.");



            Console.ReadKey();
        }
        private void LISTZAKAZ_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Declaration decla = (Declaration)(e.AddedItems.Count != 0 ? e.AddedItems[0] : null);

            // ADRESS.DataContext = decla.
            if (decla != null)
            {
                STATUS.Content = adapter.GetSostzakaz().FirstOrDefault(f => f.SOSTZAKAZID == decla.SOSTZAKAZID);

                Street adress = adapter.GetAdressPODID(decla.PODCOD.ToString());

                STREETLabel.Content = $"{adress.STREETNAME}. дом {adress.DOMN} {adress.DOML}";
            }
            else
            {
                STATUS.Content      = null;
                STREETLabel.Content = null;
            }
        }
Example #30
0
    public void StartLevel()
    {
        gameObject.SetActive(true);

        HomeMarker home = GetComponentInChildren <HomeMarker>();

        // forgive me padre for I have sinned
        CharacterPlayer player = GetComponentInChildren <CharacterPlayer>();

        if (player != null)
        {
            player.SetPosition(home.GetPosition());
            player.gameObject.transform.SetParent(home.gameObject.transform.parent);
            Street  backstreetsBackAlright = home.gameObject.transform.parent.gameObject.GetComponent <Street>();
            Vector3 temp = player.gameObject.transform.localPosition;
            temp.y = backstreetsBackAlright.StreetYOffset;
            player.gameObject.transform.localPosition = temp;
        }
    }
Example #31
0
 /// <summary>
 /// Construktor
 /// </summary>
 /// <param name="A">First node</param>
 /// <param name="B">Second node</param>
 /// <param name="Parent">Paretn of object</param>
 /// <param name="Hide">Hide mark</param>
 /// <param name="Prioritet">Priority mark</param>
 public Path(Node A, Node B, Transform Parent, HidePath Hide = HidePath.Shown, BlockType Prioritet = BlockType.Open)
 {
     queueTimes = new List <float>();
     hide       = Hide;
     street     = Parent.GetComponent <Street>();
     priority   = Prioritet;
     a          = A; b = B;
     if (this.hide < HidePath.Hiden)
     {
         var go = GameObject.CreatePrimitive(PrimitiveType.Cube);
         go.GetComponent <BoxCollider>().size = new Vector3(1.4f, 1f, 1f);
         transform        = go.transform;
         transform.parent = Parent;
         go.GetComponent <Renderer>().material = (Material)AssetDatabase.LoadAssetAtPath("Assets/QPathSimulation/Materials/street.mat", typeof(Material));
         mat  = new Material(source: transform.GetComponent <MeshRenderer>().sharedMaterial);
         matR = transform.GetComponent <MeshRenderer>();
     }
     Visualize();
 }
Example #32
0
    //this method called when we hold on a state .. it enqueues the holded light street and the current time + the time it has to change the state in
    //(the calculations of the timer are based on street width and the minimum speed of the slowest vehicle)
    public void PutStateOnHold(Street str)
    {
        if(!str.StreetLight.OnHold){
            str.StreetLight.OnHold = true;
            //Debug.Log("Inside Put State On hold");

            str.StreetLight.tLight.renderer.material.color = Color.yellow;

        //	timer += str.MinimumDistanceToOpenTrafficLight / MIN_VEHICLE_SPEED ;
            timer += .2f;
            //timer +=1;
            //Debug.Log("The current time is --->  " + Time.time + "and the timer is ---> " + timer);
            if(timersQueue.Count == 0){
                checkedTimer = timer;
            }
            timersQueue.Enqueue(timer);
            streetObjectsQueue.Enqueue(str);
        }
    }
Example #33
0
 private void makeCornerFromStreet(uint x, uint y, ushort direction,
                                   Street street)
 {
     if (this.map[y, x] > 1)
     {
         this.map[y, x] = -1;
         Corner newCorner = new Corner(Consts.roadWidth * x +
                                       Consts.roadHalfWidth, Consts.roadWidth * y + Consts.roadHalfWidth,
                                       Consts.roadHalfWidth, street);
         street.connectToPathOnDirection(newCorner, direction);
         this.pathMap[y, x] = newCorner;
         goThroughDirectionsFromCorner(x, y, newCorner);
     }
     else
     {
         Path corner = this.pathMap[y, x];
         street.connectToPathOnDirection(corner, direction);
     }
 }
Example #34
0
        public async Task <string> CreateAsyncStreet(string name, string areaId)
        {
            var street = this.streetRepository.All().Where(x => x.Name == name && x.AreaId == areaId).FirstOrDefault();

            if (street == null)
            {
                street = new Street
                {
                    Name   = name,
                    AreaId = areaId,
                };
            }

            await this.streetRepository.AddAsync(street);

            await this.streetRepository.SaveChangesAsync();

            return(street.Id);
        }
Example #35
0
        public override bool Equals(object obj)
        {
            // Check paramater not null
            if (obj == null)
            {
                return(false);
            }

            // Check object is instance of type
            Address a = obj as Address;

            if ((System.Object)a == null)
            {
                return(false);
            }

            // True if properties match
            return(Street.Equals(a.Street) && City.Equals(a.City) && State.Equals(a.State) && ZipCode.Equals(a.ZipCode));
        }
Example #36
0
        public static Card FillToRiver(Card board, Street street, Card deadCards = Card.None)
        {
            switch (street)
            {
            case Street.Flop:
                return(board | GenerateCards(2, deadCards | board));

            case Street.Turn:
                return(board | GenerateCards(1, deadCards | board));

            case Street.River:
            case Street.Showdown:
            case Street.Fold:
                return(board);

            default:
                throw new InvalidOperationException();
            }
        }
Example #37
0
        private ObservableCollection <HandActionFilterButton> GetButtonsForStreet(Street street)
        {
            switch (street)
            {
            case Street.Preflop:
                return(new ObservableCollection <HandActionFilterButton>()
                {
                    new HandActionFilterButton()
                    {
                        HandActionType = HandActionType.RAISE, TargetStreet = street
                    },
                    new HandActionFilterButton()
                    {
                        HandActionType = HandActionType.CALL, TargetStreet = street
                    },
                    new HandActionFilterButton()
                    {
                        HandActionType = HandActionType.CHECK, TargetStreet = street
                    },
                });

            default:
                return(new ObservableCollection <HandActionFilterButton>()
                {
                    new HandActionFilterButton()
                    {
                        HandActionType = HandActionType.CHECK, TargetStreet = street
                    },
                    new HandActionFilterButton()
                    {
                        HandActionType = HandActionType.BET, TargetStreet = street
                    },
                    new HandActionFilterButton()
                    {
                        HandActionType = HandActionType.CALL, TargetStreet = street
                    },
                    new HandActionFilterButton()
                    {
                        HandActionType = HandActionType.RAISE, TargetStreet = street
                    },
                });
            }
        }
Example #38
0
        public async Task <IHttpActionResult> PutAddress(AddressEmployee address)
        {
            Street  street  = this.AddressStreet(address.Street);
            City    city    = this.AddressCity(address.City);
            Country country = this.AddressCountry(address.Country);

            Address emplAddress = database.Addresses.Single(a => a.Id == address.Id);

            database.Entry(emplAddress).State = EntityState.Modified;
            emplAddress.StreetId    = street.Id == 0 ? emplAddress.StreetId : street.Id;
            emplAddress.HouseNumber = String.IsNullOrEmpty(address.HouseNumber) ? emplAddress.HouseNumber : address.HouseNumber;
            emplAddress.FlatNumber  = String.IsNullOrEmpty(address.FlatNumber) ? emplAddress.FlatNumber : address.FlatNumber;
            emplAddress.PostalCode  = String.IsNullOrEmpty(address.PostalCode) ? emplAddress.PostalCode : address.PostalCode;
            emplAddress.CityId      = city.Id == 0 ? emplAddress.CityId : city.Id;
            emplAddress.CountryId   = country.Id == 0 ? emplAddress.CountryId : country.Id;
            await database.SaveChangesAsync();

            return(StatusCode(HttpStatusCode.OK));
        }
Example #39
0
        private int CompareStreet(string street)
        {
            if (street == null && Street == null)
            {
                return(0);
            }

            if (street == null && Street != null)
            {
                return(1);
            }

            if (street != null && Street == null)
            {
                return(-1);
            }

            return(Street.CompareTo(street));
        }
Example #40
0
        bool importStreet(DataRow row)
        {
            string name   = row["NAME"].ToString().Trim();
            string socr   = row["SOCR"].ToString().Trim();
            string code   = row["CODE"].ToString().Trim();
            string INDEX  = row["INDEX"].ToString().Trim();
            string GNINMB = row["GNINMB"].ToString().Trim();
            string UNO    = row["UNO"].ToString().Trim();
            string OCATD  = row["OCATD"].ToString().Trim();

            if (!code.StartsWith("28"))
            {
                return(false);
            }
            ;

            Street street = (from s in addressModel.Street
                             where s.Code == code select s).FirstOrDefault();

            if (street == null)
            {
                // Area area = GetAreaByCode(code);
                City city = GetCityByCode(code);
                if (city == null)
                {
                    return(false);
                    //throw new Exception("City is not found for street code " + code);
                }
                //Add new Street to model
                street      = new Street();
                street.City = city;
                city.Streets.Add(street);
            }
            //Update / Set attributes in any case
            street.Code             = code;
            street.Index            = INDEX;
            street.LastModifiedTime = DateTime.Now;
            street.Source           = "KLADR";
            street.OCATD            = OCATD;
            street.Name             = name;
            street.Socr             = socr;
            return(true);
        }
Example #41
0
        public MainViewModel()
        {
            Console.WriteLine("MainViewModel()");

            Random rand = new Random();

            // -------------

            Countries = new ObservableCollection <Country>(DB_Countries_Queries.SelectAllCountries());

            foreach (var country in Countries)
            {
                List <City> citiesForCountry = DB_Countries_Queries.SelectAllCitiesByCountryID(country.ID);

                foreach (var city in citiesForCountry)
                {
                    List <Street> streetsForCity = new List <Street>();

                    for (int i = 0; i < 6; i++)
                    {
                        Street genStreet = Street.GenerateNewRandomStreet(rand);
                        streetsForCity.Add(genStreet);

                        List <House> housesForStreet = new List <House>();

                        int jStart     = rand.Next(1, 50);
                        int jMaxHouses = jStart + rand.Next(6, 20);
                        for (; jStart <= jMaxHouses; jStart++)
                        {
                            House house = House.GenerateNewHouse("House №" + jStart.ToString());

                            housesForStreet.Add(house);
                        }

                        genStreet.HOUSES = housesForStreet;
                    }

                    city.STREETS = streetsForCity;
                }

                country.CITIES = citiesForCountry;
            }
        }
Example #42
0
        public HttpResponseMessage InsertStreet(Street street)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Modelstate invalid"));
            }

            int affectedRows = 0;

            try
            {
                affectedRows = LocRepo.InsertStreet(street);
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message));
            }
            return(Request.CreateResponse(HttpStatusCode.OK, affectedRows));
        }
Example #43
0
        static HandAction ParseActionWithoutSize(string line, Street street)
        {
            //Expected formats:
            //"Player checks"
            //"Player folds"
            char identifier = line[line.Length - 2];

            switch (identifier)
            {
            case 'd':
                return(new HandAction(ParseActionPlayerName(line, 6), HandActionType.FOLD, 0m, street));

            case 'k':
                return(new HandAction(ParseActionPlayerName(line, 7), HandActionType.CHECK, 0m, street));

            default:
                throw new ArgumentException("Unknown Action: \"" + line + "\"");
            }
        }
Example #44
0
        public static void AddStreet()
        {
            Street newStreet = new Street()
            {
                Name   = SetInformations.SetName(),
                CityId = SetInformations.SetCityId()
            };

            using (var dataService = new TableDataService <Street>())
            {
                if (newStreet.Id == Guid.Empty)
                {
                    if (!dataService.GetAll().Any(street => street.Name.ToLower() == newStreet.Name.ToLower() && street.CityId == newStreet.CityId))
                    {
                        dataService.Add(newStreet);
                    }
                }
            }
        }
        private static HandAction GetAction(SiteActionRegexesBase siteActions, Street street, string actionText, string playerName)
        {
            HandActionType ActionType = ParseActionType(siteActions, street, actionText);

            decimal amount;

            if (ActionType == HandActionType.CHAT)
            {
                amount = 0m;
            }
            else if (ActionType == HandActionType.POSTS)
            {
                amount = ParseAmountPosts(siteActions, actionText);
            }
            else
            {
                amount = ParseAmount(siteActions, actionText);
            }

            if (ActionType == HandActionType.ALL_IN)
            {
                return new AllInAction(playerName, amount, street, true);
            }

            HandAction handAction = new HandAction(playerName, ActionType, amount, street);
            if (handAction.IsWinningsAction)
            {
                int potNumber;
                if (actionText.Contains(" main pot ")) potNumber = 0;
                else if (actionText.Contains(" side pot 1 ")) potNumber = 1;
                else if (actionText.Contains(" side pot ") == false) potNumber = 0;
                else throw new NotImplementedException("Can't do side pots for " + actionText);

                return new WinningsAction(playerName, ActionType, amount, potNumber);
            }
            return handAction;
        }
        static HandAction ParseActionWithAmount(string line, Street currentStreet, bool isAllIn = false)
        {
            int idIndex = line.LastIndexOf(' ');
            char idChar = line[idIndex - 3];

            string playerName;
            HandActionType actionType;
            decimal amount = ParseAmount(line, idIndex + 2);

            switch (idChar)
            {
                //Rene Lacoste bets $20
                case 'e':
                    playerName = line.Remove(idIndex - 5);
                    actionType = HandActionType.BET;
                    break;

                //ElkY calls $10
                case 'l':
                    playerName = line.Remove(idIndex - 6);
                    actionType = HandActionType.CALL;
                    break;

                //Rene Lacoste raises to $20
                case ' ':
                    playerName = line.Remove(idIndex - 10);
                    actionType = HandActionType.RAISE;
                    break;

                //jobetzu adds $30
                case 'd':
                    return null;

                default:
                    throw new ArgumentException(string.Format("Unhandled IdChar: {0} : Line: {1}",
                        idChar,
                        line));
            }

            return new HandAction(playerName, actionType, amount, currentStreet, isAllIn);
        }
 public int ParseGameActions(string[] handLines, ref List<HandAction> handActions, int firstActionIndex, out Street street)
 {
     throw new NotImplementedException();
 }
        static HandAction ParseWinActionOrStreet(string line, ref Street currentStreet)
        {
            char idChar = line[line.Length - 2];

            switch (idChar)
            {
                //*** FLOP *** [Ad 5d 5c] (Total Pot: $165, 2 Players)
                case 's':
                //*** FLOP *** [Ad 5d 5c] (Total Pot: $165, 2 Players, 2 All-In)
                case 'n':
                    currentStreet = ParseStreet(line);
                    return null;

                case '0':
                case '1':
                case '2':
                case '3':
                case '4':
                case '5':
                case '6':
                case '7':
                case '8':
                case '9':
                    return ParseWinAction(line);

                default:
                    throw new ArgumentException(string.Format("Unknown IdChar: '{0}' Line: {1}",
                        idChar,
                        line));
            }
        }
        static HandAction ParseUncalledBet(string line, Street currentStreet)
        {
            const int amountStartIndex = 16;//"Uncalled bet of ".Length

            int amountEndIndex = line.IndexOf(' ', amountStartIndex);

            string amountString = line.Substring(amountStartIndex, amountEndIndex - amountStartIndex);

            decimal amount = decimal.Parse(amountString, NumberStyles.AllowCurrencySymbol | NumberStyles.Number, NumberFormatInfo);

            string playerName = line.Substring(amountEndIndex + 13);//" returned to ".Length

            return new HandAction(playerName, HandActionType.UNCALLED_BET, amount, currentStreet);
        }
        static HandAction ParseFoldCheckLine(string line, Street currentStreet)
        {
            char actionId = line[line.Length - 4];

            //ElkY folds
            if (actionId == 'o')
            {
                string playerName = line.Remove(line.Length - 6);
                return new HandAction(playerName, HandActionType.FOLD, 0m, currentStreet);
            }
            //ElkY checks
            else if (actionId == 'e')
            {
                string playerName = line.Remove(line.Length - 7);
                return new HandAction(playerName, HandActionType.CHECK, 0m, currentStreet);
            }
            //Rene Lacoste mucks
            else if (actionId == 'u')
            {
                string playerName = line.Remove(line.Length - 6);
                return new HandAction(playerName, HandActionType.MUCKS, 0m, currentStreet);
            }

            // showdown lines can also occur here, without the *** SHOW DOWN *** line... this happens during allins
            // mukas72 wins the side pot ($0.26) with King High
            // Jurgu shows a pair of Tens, for high and 6,5,4,2,A, for low
            // mukas72 shows a pair of Kings
            // xxbugajusxx shows a pair of Threes
            // mukas72 wins side pot #1 ($0.26) with a pair of Kings
            // mukas72 wins the side pot ($0.26) with a pair of Kings
            // mukas72 wins the main pot ($0.26) with a pair of Kings
            // mukas72 wins the pot ($0.26) with a pair of Kings

            // we return null and don't add anything to the handactions
            return null;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="line"></param>
        /// <param name="currentStreet"></param>
        /// <param name="handActions"></param>
        /// <returns>True if we have reached the end of the action block.</returns>
        private bool ParseLine(string line, GameType gameType, ref Street currentStreet, ref List<HandAction> handActions)
        {
            //Chat lines start with the PlayerName and
            //PlayerNames can contain characters that disturb parsing
            //So we must check for chatlines first
            char lastChar = line[line.Length - 1];
            if (lastChar == '\"')
            {
            #if DEBUG
                if (!line.Contains(" said, "))
                {
                    throw new ArgumentException("Did not find \" said, \"");
                }
            #endif
                return false;
            }

            char firstChar = line[0];

            if (firstChar == '*') // lines with a * are either board cards, hole cards or summary info
            {
                char typeOfEventChar = line[4];

                // we don't use a switch as we need to be able to break
                switch (line[4])
                {
                    case 'H':
                        currentStreet = Street.Preflop;
                        return false;
                    case 'F':
                        currentStreet = Street.Flop;
                        return false;
                    case 'T':
                        currentStreet = Street.Turn;
                        return false;
                    case 'R':
                        currentStreet = Street.River;
                        return false;
                    case 'S':
                        if (line[5] == 'H')
                        {
                            currentStreet = Street.Showdown;
                            return false;
                        }
                        return true;
                    default:
                        throw new HandActionException(line, "Unrecognized line w/ a *:" + line);
                }
                ////*** HOLE CARDS ***
                //if (typeOfEventChar == 'H')
                //{
                //    currentStreet = Street.Preflop;
                //    return false;
                //}
                ////*** FLOP *** [6d 4h Jc]
                //else if (typeOfEventChar == 'F')
                //{
                //    currentStreet = Street.Flop;
                //    return false;
                //}
                ////*** TURN *** [6d 4h Jc] [5s]
                //else if (typeOfEventChar == 'T')
                //{
                //    currentStreet = Street.Turn;
                //    return false;
                //}
                ////*** RIVER *** [6d 4h Jc 5s] [6h]
                //else if (typeOfEventChar == 'R')
                //{
                //    currentStreet = Street.River;
                //    return false;
                //}
                ////*** SHOW DOWN ***
                ////*** SUMMARY ***
                //else if (typeOfEventChar == 'S')
                //{
                //    if (line[5] == 'H')
                //    {
                //        currentStreet = Street.Showdown;
                //        return false;
                //    }
                //    else
                //    {
                //        // we are done at the summary line
                //        return true;
                //    }
                //}
                //else
                //{
                //    throw new HandActionException(line, "Unrecognized line w/ a *:" + line);
                //}
            }

            if (currentStreet == Street.Preflop &&
                line.StartsWith("Dealt to"))
            {
                // todo: parse the player hand from this line instead of ignoring it
                return false;
            }

            int colonIndex = line.LastIndexOf(':'); // do backwards as players can have : in their name

            // Uncalled bet lines look like:
            // Uncalled bet ($6) returned to woezelenpip
            if (line.Length > 14 && line[13] == '(' && currentStreet != Street.Showdown)
            {
                handActions.Add(ParseUncalledBetLine(line, currentStreet));
                currentStreet = Street.Showdown;
                return false;
            }

            if (currentStreet == Street.Showdown ||
                colonIndex == -1)
            {
                if (lastChar == 't' ||
                     line[line.Length - 2] == '-')
                {
                    // woezelenpip collected $7.50 from pot
                    // templargio collected €6.08 from side pot-2
                    if (line[line.Length - 3] == 'p' ||
                        line[line.Length - 2] == '-')
                    {
                        currentStreet = Street.Showdown;
                        handActions.Add(ParseCollectedLine(line, currentStreet));
                        return false;
                    }
                    // golfiarzp has timed out
                    else if (line[line.Length - 3] == 'o')
                    {
                        // timed out line. don't bother with it
                        return false;
                    }
                }
                // line such as
                //    2As88 will be allowed to play after the button
                else if (lastChar == 'n')
                {
                    return false;
                }
                // line such as:
                //    Mr Sturmer is disconnected
                // Ensure that is ed ending otherwise false positive with hand
                else if (lastChar == 'd' &&
                         line[line.Length - 2] == 'e')
                {
                    return false;
                }

                //zeranex88 joins the table at seat #5
                if (lastChar == '#' || line[line.Length - 2] == '#')
                {
                    // joins action
                    // don't bother parsing it or adding it
                    return false;
                }
                //MS13ZEN leaves the table
                else if (lastChar == 'e')
                {
                    // leaves action
                    // don't bother parsing or adding it
                    return false;
                }
            }

            HandAction handAction;
            switch (currentStreet)
            {
                case Street.Null:
                    // Can have non posting action lines:
                    //    Craftyspirit: is sitting out
                    if (lastChar == 't' || // sitting out line
                        lastChar == 'n') // play after button line
                    {
                        return false;
                    }
                    handAction = ParsePostingActionLine(line, colonIndex);
                    break;
                case Street.Showdown:
                    handAction = ParseMiscShowdownLine(line, colonIndex, gameType);
                    break;
                default:
                    handAction = ParseRegularActionLine(line, colonIndex, currentStreet);
                    break;
            }

            if (handAction != null)
            {
                handActions.Add(handAction);
            }

            return false;
        }
        private HandAction ParseAction(string Line, Street currentStreet, List<HandAction> actions)
        {
            const int playerHandActionStartIndex = 21;
            const int fixedAmountDistance = 9;

            char handActionType = Line[playerHandActionStartIndex];
            int playerNameStartIndex;
            string playerName;

            switch (handActionType)
            {
                //<ACTION TYPE="ACTION_ALLIN" PLAYER="SAMERRRR" VALUE="15972.51"></ACTION>
                case 'A':
                    playerNameStartIndex = playerHandActionStartIndex + 15;
                    playerName = GetActionPlayerName(Line, playerNameStartIndex);
                    decimal amount = GetActionAmount(Line, playerNameStartIndex + playerName.Length + fixedAmountDistance);
                    HandActionType allInType = AllInActionHelper.GetAllInActionType(playerName, amount, currentStreet, actions);
                    if (allInType == HandActionType.CALL)
                    {
                        amount = AllInActionHelper.GetAdjustedCallAllInAmount(amount, actions.Player(playerName));
                    }

                    return new HandAction(playerName, allInType, amount, currentStreet, true);

                //<ACTION TYPE="ACTION_BET" PLAYER="ItalyToast" VALUE="600.00"></ACTION>
                case 'B':
                    playerNameStartIndex = playerHandActionStartIndex + 13;
                    playerName = GetActionPlayerName(Line, playerNameStartIndex);
                    return new HandAction(
                        playerName,
                        HandActionType.BET,
                        GetActionAmount(Line, playerNameStartIndex + playerName.Length + fixedAmountDistance),
                        currentStreet
                        );

                //<ACTION TYPE="ACTION_CHECK" PLAYER="gasmandean"></ACTION>
                //<ACTION TYPE="ACTION_CALL" PLAYER="fatima1975" VALUE="0.04"></ACTION>
                case 'C':
                    if (Line[playerHandActionStartIndex + 1] == 'H')
                    {
                        playerNameStartIndex = playerHandActionStartIndex + 15;
                        playerName = GetActionPlayerName(Line, playerNameStartIndex);
                        return new HandAction(
                        playerName,
                        HandActionType.CHECK,
                        0,
                        currentStreet
                        );
                    }
                    else
                    {
                        playerNameStartIndex = playerHandActionStartIndex + 14;
                        playerName = GetActionPlayerName(Line, playerNameStartIndex);
                        return new HandAction(
                        playerName,
                        HandActionType.CALL,
                        GetActionAmount(Line, playerNameStartIndex + playerName.Length + fixedAmountDistance),
                        currentStreet
                        );
                    }

                //<ACTION TYPE="ACTION_FOLD" PLAYER="Belanak"></ACTION>
                case 'F':
                    playerNameStartIndex = playerHandActionStartIndex + 14;
                    playerName = GetActionPlayerName(Line, playerNameStartIndex);
                    return new HandAction(
                        playerName,
                        HandActionType.FOLD,
                        0,
                        currentStreet
                        );

                //<ACTION TYPE="ACTION_RAISE" PLAYER="ItalyToast" VALUE="400.00"></ACTION>
                case 'R':
                    playerNameStartIndex = playerHandActionStartIndex + 15;
                    playerName = GetActionPlayerName(Line, playerNameStartIndex);
                    return new HandAction(
                        playerName,
                        HandActionType.RAISE,
                        GetActionAmount(Line, playerNameStartIndex + playerName.Length + fixedAmountDistance),
                        currentStreet
                        );

                default:
                    throw new ArgumentOutOfRangeException("Unkown hand action: " + handActionType + " - " + Line);
            }
        }
        public HandAction ParseRegularActionLine(string actionLine, int colonIndex, Street currentStreet)
        {
            string playerName = actionLine.Substring(0, colonIndex);

            // all-in likes look like: 'Piotr280688: raises $8.32 to $12.88 and is all-in'
            bool isAllIn = actionLine[actionLine.Length - 1] == 'n';
            if (isAllIn)// Remove the  ' and is all in' and just proceed like normal
            {
                actionLine = actionLine.Remove(actionLine.Length - 14);
            }

            // lines that reach the cap look like tzuiop23: calls $62 and has reached the $80 cap
            bool hasReachedCap = actionLine[actionLine.Length - 1] == 'p';
            if (hasReachedCap)// Remove the  ' and has reached the $80 cap' and just proceed like normal
            {
                int lastNonCapCharacter = actionLine.LastIndexOf('n') - 2;  // find the n in the and
                actionLine = actionLine.Remove(lastNonCapCharacter);
            }

            char actionIdentifier = actionLine[colonIndex + 2];

            HandActionType actionType;
            bool isRaise = false;
            decimal amount;
            int firstDigitIndex;

            switch (actionIdentifier)
            {
                //gaydaddy: folds
                case 'f':
                    return new HandAction(playerName, HandActionType.FOLD, 0, currentStreet);

                case 'c':
                    //Piotr280688: checks
                    if (actionLine[colonIndex + 3] == 'h')
                    {
                        return new HandAction(playerName, HandActionType.CHECK, 0, currentStreet);
                    }
                    //MECO-LEO: calls $1.23
                    firstDigitIndex = actionLine.LastIndexOf(' ') + 2;
                    amount = decimal.Parse(actionLine.Substring(firstDigitIndex, actionLine.Length - firstDigitIndex), System.Globalization.CultureInfo.InvariantCulture);
                    actionType = (isAllIn) ? HandActionType.ALL_IN : HandActionType.CALL;
                    break;

                //MS13ZEN: bets $1.76
                case 'b':
                    firstDigitIndex = actionLine.LastIndexOf(' ') + 2;
                    amount = decimal.Parse(actionLine.Substring(firstDigitIndex, actionLine.Length - firstDigitIndex), System.Globalization.CultureInfo.InvariantCulture);
                    actionType = (isAllIn) ? HandActionType.ALL_IN : HandActionType.BET;
                    break;

                //Zypherin: raises $6400 to $8300
                case 'r':
                    isRaise = true;
                    firstDigitIndex = actionLine.LastIndexOf(' ') + 2;
                    amount = decimal.Parse(actionLine.Substring(firstDigitIndex, actionLine.Length - firstDigitIndex), System.Globalization.CultureInfo.InvariantCulture);
                    actionType = (isAllIn) ? HandActionType.ALL_IN : HandActionType.RAISE;
                    break;
                default:
                    throw new HandActionException(actionLine, "ParseRegularActionLine: Unrecognized line:" + actionLine);
            }

            return isAllIn
                       ? new AllInAction(playerName, amount, currentStreet, isRaise)
                       : new HandAction(playerName, actionType, amount, currentStreet);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="line"></param>
        /// <param name="currentStreet"></param>
        /// <param name="handActions"></param>
        /// <returns>True if we have reached the end of the action block.</returns>
        private bool ParseLine(string line, GameType gameType, ref Street currentStreet, ref List<HandAction> handActions)
        {
            if (line[0] == '*') // lines with a * are either board cards, hole cards or summary info
            {
                char typeOfEventChar = line[4];

                // we don't use a switch as we need to be able to break

                //*** HOLE CARDS ***
                if (typeOfEventChar == 'H')
                {
                    currentStreet = Street.Preflop;
                    return false;
                }
                //*** FLOP *** [6d 4h Jc]
                else if (typeOfEventChar == 'F')
                {
                    currentStreet = Street.Flop;
                    return false;
                }
                //*** TURN *** [6d 4h Jc] [5s]
                else if (typeOfEventChar == 'T')
                {
                    currentStreet = Street.Turn;
                    return false;
                }
                //*** RIVER *** [6d 4h Jc 5s] [6h]
                else if (typeOfEventChar == 'R')
                {
                    currentStreet = Street.River;
                    return false;
                }
                //*** SHOW DOWN ***
                //*** SUMMARY ***
                else if (typeOfEventChar == 'S')
                {
                    if (line[5] == 'H')
                    {
                        currentStreet = Street.Showdown;
                        return false;
                    }
                    else
                    {
                        // we are done at the summary line
                        return true;
                    }
                }
                else
                {
                    throw new HandActionException(line, "Unrecognized line w/ a *:" + line);
                }
            }

            // throw away chat lines. can contain : and anything else so check before we proceed.
            // allpokerjon said, "33 :-)"
            if (line[line.Length - 1] == '\"')
            {
                return false;
            }

            int colonIndex = line.LastIndexOf(':'); // do backwards as players can have : in their name

            // Uncalled bet lines look like:
            // Uncalled bet ($6) returned to woezelenpip
            if (line.Length > 14 && line[13] == '(' && currentStreet != Street.Showdown)
            {
                handActions.Add(ParseUncalledBetLine(line, currentStreet));
                currentStreet = Street.Showdown;
                return false;
            }

            if (currentStreet == Street.Showdown ||
                colonIndex == -1)
            {
                if (line[line.Length - 1] == 't')
                {
                    // woezelenpip collected $7.50 from pot
                    if (line[line.Length - 3] == 'p')
                    {
                        currentStreet = Street.Showdown;
                        handActions.Add(ParseCollectedLine(line, currentStreet));
                        return false;
                    }
                    // golfiarzp has timed out
                    else if (line[line.Length - 3] == 'o')
                    {
                        // timed out line. don't bother with it
                        return false;
                    }
                }
                // line such as
                //    2As88 will be allowed to play after the button
                else if (line[line.Length - 1] == 'n')
                {
                    return false;
                }
                // line such as:
                //    Mr Sturmer is disconnected
                // Ensure that is ed ending otherwise false positive with hand
                else if (line[line.Length - 1] == 'd' &&
                         line[line.Length - 2] == 'e')
                {
                    return false;
                }

                //zeranex88 joins the table at seat #5
                if (line[line.Length - 1] == '#' || line[line.Length - 2] == '#')
                {
                    // joins action
                    // don't bother parsing it or adding it
                    return false;
                }
                //MS13ZEN leaves the table
                else if (line[line.Length - 1] == 'e')
                {
                    // leaves action
                    // don't bother parsing or adding it
                    return false;
                }
            }

            HandAction handAction;
            switch (currentStreet)
            {
                case Street.Null:
                    // Can have non posting action lines:
                    //    Craftyspirit: is sitting out
                    char lastChar = line[line.Length - 1];
                    if (lastChar == 't' || // sitting out line
                        lastChar == 'n') // play after button line
                    {
                        return false;
                    }
                    handAction = ParsePostingActionLine(line, colonIndex);
                    break;
                case Street.Showdown:
                    handAction = ParseMiscShowdownLine(line, colonIndex, gameType);
                    break;
                default:
                    handAction = ParseRegularActionLine(line, colonIndex, currentStreet);
                    break;
            }

            if (handAction != null)
            {
                handActions.Add(handAction);
            }

            return false;
        }
 public static IEnumerable<HandAction> Street(this IEnumerable<HandAction> actions, Street street)
 {
     return actions.Where(p => p.Street == street);
 }
Example #56
0
    void SettingBuildingPos()
    {
        GameObject[] planes = PlaneManager.Instance().GetPlanes();

        //Debug.ClearDeveloperConsole();

        for(int i = 0; i< planes.Length; ++i)
        {
            GameObject obj = planes[i];

            float x = obj.transform.position.x;
            float y = obj.transform.position.z;

            Pos[] posTemp = new Pos[6];

            posTemp[0].x = x + 1.0f;
            posTemp[0].y = y + 0.5f;

            posTemp[1].x = x + 1.0f;
            posTemp[1].y = y - 0.5f;

            posTemp[2].x = x;
            posTemp[2].y = y - 1.0f;

            posTemp[3].x = x - 1.0f;
            posTemp[3].y = y - 0.5f;

            posTemp[4].x = x - 1.0f;
            posTemp[4].y = y + 0.5f;

            posTemp[5].x = x;
            posTemp[5].y = y + 1.0f;

        //             buildingPos.Add(a);
        //             buildingPos.Add(b);
        //             buildingPos.Add(c);
        //             buildingPos.Add(d);
        //             buildingPos.Add(e);
        //             buildingPos.Add(f);

            for (int j = 0; j < posTemp.Length; ++j)
            {
                if (!planeDic.ContainsKey(posTemp[j]))
                {
                    List<GameObject> list = new List<GameObject>();
                    planeDic.Add(posTemp[j], list);
                }

                buildingPosHash.Add(posTemp[j]);
                planeDic[posTemp[j]].Add(obj);
            }

            StreetPos[] streetTemp = new StreetPos[6];
            Street[] street = new Street[6];

            streetTemp[0].s = posTemp[5];
            streetTemp[0].e = posTemp[4];
            street[0].pos.x = x - 0.5f;
            street[0].pos.y = y + 0.75f;
            street[0].rotate = 150;

            streetTemp[1].s = posTemp[1];
            streetTemp[1].e = posTemp[2];
            street[1].pos.x = x + 0.5f;
            street[1].pos.y = y - 0.75f;
            street[1].rotate = 150;

            streetTemp[2].s = posTemp[5];
            streetTemp[2].e = posTemp[0];
            street[2].pos.x = x + 0.5f;
            street[2].pos.y = y + 0.75f;
            street[2].rotate = 30;

            streetTemp[3].s = posTemp[3];
            streetTemp[3].e = posTemp[2];
            street[3].pos.x = x - 0.5f;
            street[3].pos.y = y - 0.75f;
            street[3].rotate = 30;

            streetTemp[4].s = posTemp[4];
            streetTemp[4].e = posTemp[3];
            street[4].pos.x = x - 1.0f;
            street[4].pos.y = y;
            street[4].rotate = 90;

            streetTemp[5].s = posTemp[0];
            streetTemp[5].e = posTemp[1];
            street[5].pos.x = x - 1.0f;
            street[5].pos.y = y;
            street[5].rotate = 90;

            for(int j = 0; j < streetTemp.Length; ++j)
            {
        //                 Debug.Log(obj.name);
        //                 Debug.Log(j);
        //                 Debug.Log(streetTemp[j].s.x);
        //                 Debug.Log(streetTemp[j].e.x);

                if(!streetDic.ContainsKey(streetTemp[j]))
                {
                    streetDic.Add(streetTemp[j], street[j]);
                }

                streetPosHash.Add(streetTemp[j]);
            }
        }

        Debug.Log("BuildingPosNum" + planeDic.Count);
        Debug.Log("streetPosNum" + streetPosHash.Count);
        Debug.Log("streetNum" + streetDic.Count);
    }
 private HandAction GetHandActionFromActionLine(string handLine, Street street)
 {
     int actionTypeNumber = GetActionTypeFromActionLine(handLine);
     string actionPlayerName = GetPlayerFromActionLine(handLine);
     decimal value = GetValueFromActionLine(handLine);
     int actionNumber = GetActionNumberFromActionLine(handLine);
     HandActionType actionType;
     switch (actionTypeNumber)
     {
         case 0:
             actionType = HandActionType.FOLD;
             break;
         case 1:
             actionType = HandActionType.SMALL_BLIND;
             break;
         case 2:
             actionType = HandActionType.BIG_BLIND;
             break;
         case 3:
             actionType = HandActionType.CALL;
             break;
         case 4:
             actionType = HandActionType.CHECK;
             break;
         case 5:
             actionType = HandActionType.BET;
             break;
         case 7:
             return new AllInAction(actionPlayerName, value, street, false, actionNumber);
         case 8: //Case 8 is when a player sits out at the beginning of a hand
         case 9: //Case 9 is when a blind isn't posted - can be treated as sitting out
             actionType = HandActionType.SITTING_OUT;
             break;
         case 15:
             actionType = HandActionType.ANTE;
             break;
         case 23:
             actionType = HandActionType.RAISE;
             break;
         default:
             throw new Exception(string.Format("Encountered unknown Action Type: {0} w/ line \r\n{1}", actionTypeNumber, handLine));
     }
     return new HandAction(actionPlayerName, actionType, value, street, actionNumber);
 }
Example #58
0
        private Address BuildAddress()
        {
            StreetAddress streetAddress = null;
              // country is required
              string country = tbCountry.Text.ToUpper();
              Address result = new Address(country);
              if (tbStreet.Text != null && !tbStreet.Text.Equals(string.Empty)) {
              Street street = new Street(tbStreet.Text);
            if (tbPlace.Text != null && !tbPlace.Text.Equals(string.Empty))  {
              Building building = new Building();
              building.BuildingName = tbPlace.Text;
              streetAddress = new StreetAddress(street, building);
            } else {
              streetAddress = new StreetAddress(street);
            }
            result.StreetAddress = streetAddress;
              }

              int numPlaces = 0;
              if (tbCity.Text != null && !tbCity.Text.Equals(string.Empty)) numPlaces++;
            if (tbState.Text != null && !tbState.Text.Equals(string.Empty)) numPlaces++;
              if (numPlaces > 0) {
            int iPlace = 0;
              Place[] cityState = new Place[numPlaces];
              if (tbCity.Text != null && !tbCity.Text.Equals(string.Empty)) {
                cityState[iPlace] = new Place(tbCity.Text, NamedPlaceClassification.Municipality);
              iPlace++;
            }
              if (tbState.Text != null && !tbState.Text.Equals(string.Empty)) {
                cityState[iPlace] = new Place(tbState.Text, NamedPlaceClassification.CountrySubdivision);
            }
              result.PlaceList = cityState;
              }
              if (tbPostalCode.Text != null && !tbPostalCode.Text.Equals(string.Empty)) {
              result.PrimaryPostalCode = tbPostalCode.Text;
              }
            return result;
        }
        public HandAction ParseUncalledBetLine(string actionLine, Street currentStreet)
        {
            // Uncalled bet lines look like:
            // Uncalled bet ($6) returned to woezelenpip

            // position 15 is after the currency symbol
            int closeParenIndex = actionLine.IndexOf(')', 16);
            decimal amount = decimal.Parse(actionLine.Substring(15, closeParenIndex - 15), System.Globalization.CultureInfo.InvariantCulture);

            int firstLetterOfName = closeParenIndex + 14; // ' returned to ' is length 14

            string playerName = actionLine.Substring(firstLetterOfName, actionLine.Length - firstLetterOfName);

            return new HandAction(playerName, HandActionType.UNCALLED_BET, amount, currentStreet);
        }
        private HandAction GetHandActionFromEventElement(XElement eventElement, Street currentStreet, PlayerList playerList)
        {
            string actionString = eventElement.Attribute("type").Value;
            int actionNumber = Int32.Parse(eventElement.Attribute("sequence").Value);
            decimal value = 0;
            if (eventElement.Attribute("amount") != null)
            {
                value = decimal.Parse(eventElement.Attribute("amount").Value, DecimalSeperator);
            }

            int seatId = -1;
            if (eventElement.Attribute("player") != null)
            {
                seatId = Int32.Parse(eventElement.Attribute("player").Value);
            }

            Player matchingPlayer = GetPlayerBySeatId(playerList, seatId);

            string playerName = matchingPlayer.PlayerName;

            HandActionType actionType;
            switch (actionString)
            {
                case "FOLD":
                    actionType = HandActionType.FOLD;
                    break;
                case "SMALL_BLIND":
                    actionType = HandActionType.SMALL_BLIND;
                    break;
                case "BIG_BLIND":
                    actionType = HandActionType.BIG_BLIND;
                    break;
                case "INITIAL_BLIND":
                    actionType = HandActionType.POSTS;
                    break;
                case "CALL":
                    actionType = HandActionType.CALL;
                    break;
                case "CHECK":
                    actionType = HandActionType.CHECK;
                    break;
                case "BET":
                    actionType = HandActionType.BET;
                    break;
                case "ALL_IN":
                    return new AllInAction(playerName, value, currentStreet, false, actionNumber);
                case "SHOW":
                    actionType = HandActionType.SHOW;
                    break;
                case "MUCK":
                    actionType = HandActionType.MUCKS;
                    break;
                case "GAME_CANCELLED":
                    actionType = HandActionType.GAME_CANCELLED;
                    break;
                case "SIT_OUT":
                case "SITTING_OUT":
                    actionType = HandActionType.SITTING_OUT;
                    break;
                case "SIT_IN":
                    actionType = HandActionType.RETURNED;
                    break;
                case "RAISE":
                    actionType = HandActionType.RAISE;
                    break;
                case "RABBIT":
                    actionType = HandActionType.RABBIT;
                    break;
                default:
                    throw new Exception(string.Format("Encountered unknown Action Type: {0} w/ line \r\n{1}", actionString, eventElement));
            }
            return new HandAction(playerName, actionType, value, currentStreet, actionNumber);
        }