public Product DispenseProduct(int credit, int productNumber)
        {
            Product product;
            bool    enoughFunds;

            switch (productNumber)
            {
            case 1:
                enoughFunds = CreditVerification(credit, product = new Cola());
                break;

            case 2:
                enoughFunds = CreditVerification(credit, product = new Chips());
                break;

            case 3:
                enoughFunds = CreditVerification(credit, product = new Candy());
                break;

            default:
                return(null);
            }

            return(enoughFunds ? product : null);
        }
Example #2
0
        static void Main(string[] args)
        {
            Food[] foodArray = new Food[6];
            foodArray[0] = new Pizza(80, false, 4, 2);
            foodArray[1] = new Pizza(40, false, 4, 2);
            foodArray[2] = new Pizza(30, true, 4, 2);
            foodArray[3] = new Chips(true, true, 158, false);
            foodArray[4] = new Chips(true, true, 18, false);
            foodArray[5] = new Chips(true, true, 20, true);

            for (int i = 0; i < foodArray.Length; i++)
            {
                Console.WriteLine("===================");
                Console.WriteLine("is veg ? " + foodArray[i].IsVeg);
                Console.WriteLine($"The Price is : " + foodArray[i].Price);
                Console.WriteLine("===================");

                if (foodArray[i] is Chips)
                {
                    Console.WriteLine($"=== Item {i+1} ===");
                    Console.WriteLine($"have dipps? " + ((Chips)foodArray[i]).IsWithDipps);
                    Console.WriteLine($"is Extra Big?? " + ((Chips)foodArray[i]).IsExtaBig);
                }
                else
                {
                    Console.WriteLine($"=== Item {i + 1} ===");
                    Console.WriteLine($"num of slices : " + ((Pizza)foodArray[i]).NumOfSlices);
                    Console.WriteLine($"num of toppings: " + ((Pizza)foodArray[i]).NumOftoppings);
                }
            }
        }
Example #3
0
        public void ChipsToStringTest()
        {
            DollarAmount dollar = new DollarAmount(0);
            Chips        test   = new Chips("candy", dollar);

            Assert.AreEqual("Salty goodness.", test.ToString());
        }
        private void ConvertToChips(decimal value)
        {
            Chips.Clear();

            if (value == 0)
            {
                return;
            }

            foreach (var key in ChipRates.Keys.Reverse())
            {
                int chipAmount = (int)(value / key);
                if (chipAmount > 0)
                {
                    Chips.Add(new ChipModel()
                    {
                        ChipColor = ChipRates[key], Count = chipAmount
                    });
                    value %= key;

                    if (value == 0)
                    {
                        break;
                    }
                }
            }
        }
Example #5
0
        public static Chip Read(BinaryReader reader, int position)
        {
            var chip = (Chip)Empty.MemberwiseClone();

            chip.Position = position;
            chip.BaseCode = reader.ReadInt32();
            chip.BaseId   = reader.ReadInt32();
            chip.Type     = reader.ReadInt32();
            chip.Level    = reader.ReadInt32();
            chip.Weight   = reader.ReadInt32();
            chip.SlotA    = reader.ReadInt32();
            chip.SlotB    = reader.ReadInt32();
            chip.SlotC    = reader.ReadInt32();
            for (int i = 0; i < 0x10; i++)
            {
                reader.ReadByte();
            }

            if (Chips.TryGetValue(chip.Type, out var knownChip))
            {
                chip.Name     = knownChip.Name;
                chip.BaseCode = knownChip.BaseCode;
                chip.BaseId   = knownChip.BaseId;
            }
            else if (chip.Type != Empty.Type)
            {
                chip.Name      = "???";
                chip.BaseCode -= chip.Level;
                chip.BaseId   -= chip.Level;
            }

            return(chip);
        }
 public void place_bet_on_free_position(Chips chips_wagered, BlackJackTable black_jack_table)
 {
     if (players_active_hand == null)
     {
         _hands.Add(_hand_factory.create_players_hand_with(chips_wagered, black_jack_table, HandLetters.A.ToString()));
     }
 }
Example #7
0
 public void decrease_pot_by(Chips wager)
 {
     if (can_afford_to_bet(wager))
     {
         dollars_in_pot -= wager.value;
     }
 }
 public ProductManager()
 {
     cola            = new Cola();
     chips           = new Chips();
     candy           = new Candy();
     SelectedProduct = new SelectedProduct();
 }
Example #9
0
        /// <summary>
        /// Plays a single hand.  This may be called multiple times if a hand is split.
        /// </summary>
        /// <param name="table">The Table object to use to request cards</param>
        /// <param name="CurrentHand">Hand to play</param>
        public void PlayHand(Hand CurrentHand)
        {
            while (CurrentHand.Value <= 21 && !CurrentHand.DoubledDown)
            {
                PlayAction Action = this.DecideAction(_Table.UpCard, CurrentHand);
                switch (Action)
                {
                case PlayAction.Split:
                    _Table.Split(CurrentHand, this, Chips.RemoveChips(CurrentHand.Bet.Value));
                    Track.Splits++;
                    break;

                case PlayAction.DoubleDown:
                    _Table.DoubleDown(CurrentHand, Chips.RemoveChips(CurrentHand.Bet.Value));
                    Track.Doubles++;
                    break;

                case PlayAction.Hit:
                    _Table.Hit(CurrentHand);
                    Track.Hits++;
                    break;

                case PlayAction.Stand:
                    Track.Stands++;
                    return;
                }
            }
            if (CurrentHand.Value > 21)
            {
                Track.Busted++;
            }                                                   // Wah wah waaaah.
        }
Example #10
0
        public void UpdateMovePreview(int column)
        {
            if (Game.Finished || GetCurrentPlayerType == PlayerType.Computer)
            {
                return;
            }

            var row = GetEmptyRowIndex(column);

            if (row == -1)
            {
                return;
            }

            if (Preview == null)
            {
                Preview = new ChipViewModel();
                Chips.Add(Preview);
            }

            var previewChip = Preview.Chip;

            previewChip.Column = column;
            previewChip.Row    = row;
            previewChip.Player = Game.CurrentPlayer;
        }
Example #11
0
        private void frm_NewChip_NewChipUpdated(object sender, NewChipUpdateEventArgs e)
        {
            //string RecName = ExtractRecordName(LastRightClickedNode.Text);

            if (SubChips.ProjectRoot.Length == 0)
            {
                SubChips.ProjectRoot = this.ProjectRoot;
            }

            string RecName = LastRightClickedNode.Text;

            if (SubChips.AddSubChipRows(e.XMLFileName, e.SampleFileName, e.ChipName, RecName)
                == true)
            {
                ChipInfo ci = new ChipInfo();

                ci.chipname           = e.ChipName;
                ci.owner              = RecName;
                ci.chipid             = e.ChipID;
                ci.xmlfilename        = e.XMLFileName;
                ci.samplelistfilename = e.SampleFileName;
                ci.invlocalhandling   = e.InvHandling;
                Chips.AddNewChip(ci);
            }
        }
Example #12
0
        public void place_bet_on_free_position(Chips chips_wagered)
        {
            if (status.can_accept_bet)
            {
                if (_playing_positions.has_free_position_for_bet())
                {
                    if (player.can_afford_to_bet(chips_wagered))
                    {
                        player.decrease_pot_by(chips_wagered);
                        _playing_positions.place_bet_on_free_position(chips_wagered, this);
                    }
                    else
                    {
                        throw new NotEnoughFundsException("You will need to cash in to place a bet.");
                    }
                }
                else
                {
                    throw new IllegalMoveException("There are no more free positions to place a bet.");
                }

                if (!_playing_positions.has_free_position_for_bet())
                {
                    change_status_to(TableStatus.full_table);
                }
            }
        }
Example #13
0
 // Start is called before the first frame update
 void Start()
 {
     StartCoroutine(SetMoves());
     //MoveId1 = Random.Range(1, 6);
     //MoveId2 = Random.Range(6, 11);
     //MoveId3 = Random.Range(11, 16);
     //MoveId4 = Random.Range(16, 21);
     name = "The Player";
     //    es = Enemy.GetComponent<EnemyScr>();
     //we are going to want to start the player off with two random moves, one to attack, one to defend
     Stuntime        = -1;
     Muck            = -1;
     IsCharacterTurn = true;
     StartAtk        = 10;
     StartDef        = 10;
     StartLuck       = 10;
     AtkText.text    = "Atk X " + Atk.ToString();
     DefText.text    = "Def X " + Def.ToString();
     LuckText.text   = "Luck X " + Luck.ToString();
     LvlText.text    = "Lvl X " + Lvl.ToString();
     ChipsText.text  = "Chips X " + Chips.ToString();
     //   MoveId1 = 0; //id for first move
     // MoveId2 = 0; //id for second move
     // MoveId3 = 0; //id for third move
     // MoveId4 = 0; //id for fourth move
 }
Example #14
0
        private void CreateEmptyProject(string pp, string projectname)
        {
            try
            {
                // Try to create the directory.
                Directory.CreateDirectory(pp);

                Directory.CreateDirectory(pp + "\\Data");
                Directory.CreateDirectory(pp + "\\Info");
                Directory.CreateDirectory(pp + "\\XML");

                DataSet ds = new DataSet();

                ds.DataSetName = "ProjectData";
                ds.Tables.Add(Project.GetProjects().Copy());
                ds.Tables.Add(Records.GetRecords().Copy());
                ds.Tables.Add(Chips.GetChips().Copy());
                ds.Tables.Add(SubChips.GetSubChips().Copy());


                ds.WriteXml(pp + "\\" + projectname + ".proj");
            }
            catch (Exception ex)
            {
                //
            }
            finally { }
        }
Example #15
0
 private Chip FindChip(Guid id)
 {
     if (!ChipDict.ContainsKey(id))
     {
         ChipDict[id] = Chips.Find(x => x.ID == id);
     }
     return(ChipDict[id]);
 }
        public Hand create_players_hand_with(Chips chips_wagered, BlackJackTable black_jack_table, string hand_letter)
        {
            var players_hand = new PlayersHand(chips_wagered, black_jack_table, hand_letter);

            players_hand.mark_as_active();

            return(players_hand);
        }
 public Builder AddChips(IEnumerable <ChipModel> models)
 {
     foreach (ChipModel model in models)
     {
         Chips.Add(model);
     }
     return(this);
 }
Example #18
0
        void UpdateResultCountChips(HashSet <Medicine> ts)
        {
            panel2.Children.Clear();
            Chips chip = new Chips((Color)ColorConverter.ConvertFromString("#FFFFEB21"), ts.Count.ToString());

            chip.Width = 40;
            panel2.Children.Add(chip);
        }
Example #19
0
        private void UpdateTreeView()
        {
            tv_tree.Nodes.Clear();
            tv_tree.ImageList = imageList1;
            //Add projects to treeview
            foreach (DataRow drp in Project.GetProjects().Rows)
            {
                NodeProj np = new NodeProj();
                tv_tree.Nodes.Add(np.Node);
                // set text after adding it to treeview to prevent truncation bug
                np.Node.Text                          = /* "Project - " + */ drp["ProjectName"].ToString() /* + " - " + drp["ProjectOwner"].ToString()*/;
                np.Node.ImageIndex                    = 0;
                np.Node.SelectedImageIndex            = 0;
                np.Node.ContextMenuStrip.ItemClicked += new ToolStripItemClickedEventHandler(ProjNodeMenu_ItemClicked);

                string owner;

                foreach (DataRow drr in Records.GetRecords().Rows)
                {
                    //get the owner of the record
                    //owner = this.ExtractProjectName(drr["Owner"].ToString());
                    owner = drr["Owner"].ToString();


                    if (owner == drp["ProjectName"].ToString())
                    {
                        NodeRec nr = new NodeRec();
                        np.Node.Nodes.Add(nr.Node);

                        // set text after adding it to treeview to prevent truncation bug
                        nr.Node.Text                          = /* "Record - " +*/ drr["RecordName"].ToString();
                        nr.Node.ImageIndex                    = 1;
                        nr.Node.SelectedImageIndex            = 1;
                        nr.Node.ContextMenuStrip.ItemClicked += new ToolStripItemClickedEventHandler(RecNodeMenu_ItemClicked);

                        foreach (DataRow drc in Chips.GetChips().Rows)
                        {
                            //owner = this.ExtractRecordName(drc["Owner"].ToString());
                            owner = drc["Owner"].ToString();

                            if (owner == drr["RecordName"].ToString())
                            {
                                NodeChip nc = new NodeChip();
                                nr.Node.Nodes.Add(nc.Node);

                                // set text after adding it to treeview to prevent truncation bug
                                nc.Node.Text                          = /*"Chip - " +*/ drc["ChipName"].ToString();
                                nc.Node.ImageIndex                    = 2;
                                nc.Node.SelectedImageIndex            = 2;
                                nc.Node.ContextMenuStrip.ItemClicked += new ToolStripItemClickedEventHandler(ChipNodeMenu_ItemClicked);
                            }
                        }
                    }
                }
            }

            tv_tree.ExpandAll();
        }
Example #20
0
            public void Give(ref Bot low, ref Bot high)
            {
                low.Assign(Chips.First());
                high.Assign(Chips.Last());

                Chips.Clear();
                Chips.Add(int.MaxValue);
                Chips.Add(int.MaxValue);
            }
        public void ChipsTest_Consume()
        {
            decimal price = 1.00M;
            string  item  = "Chips";

            Chips testItem = new Chips(price, item);

            Assert.AreEqual("Crunch, Crunch, YUM!", testItem.Consume());
        }
        public ActionResult EditChips(int?id, Chips chips)
        {
            if (id != null)
            {
                new Chips_SQL().EditChips(id, chips);
            }

            return(View("Index"));
        }
Example #23
0
 protected int AddChip(Chip chip)
 {
     Chips.Add(chip);
     if (!WireDict.ContainsKey(chip.ID))
     {
         WireDict.Add(chip.ID, new List <Wire>());
     }
     return(Chips.Count - 1);
 }
Example #24
0
 /// <summary>
 /// Called by the table to play insurance bets.  This calls DecideInsurance(), implemented in child classes.
 /// </summary>
 /// <returns>Returns a ChipStack with an insurance bet, otherwise null.</returns>
 public ChipStack PlayInsurance()
 {
     if (DecideInsurance())
     {
         ChipStack insurance = Chips.RemoveChips((int)(Hands[0].Bet.Value * 0.5));
         return(insurance);
     }
     return(null);
 }
Example #25
0
 public void Deliver()
 {
     if (Chips.Min(x => x) == 17 && Chips.Max(x => x) == 61)
     {
         Console.WriteLine($"Bot {Id} is comparing chips 17 and 61");
     }
     LowReceiver.Receive(Chips.Min(x => x));
     HighReceiver.Receive(Chips.Max(x => x));
 }
Example #26
0
        public void ChipsHappinessTest()
        {
            IFood  food              = new Chips();
            double expected          = 105;
            double startingHappiness = 100;
            double happiness         = food.CalculateHappiness(startingHappiness);

            Assert.AreEqual(happiness, expected);
        }
    public void newTournament()
    {
        int amountToStart = 100000;

        foreach (PlayerImplementation player in playersImplementation.players)
        {
            Chips.Add(player.Id, 100000);
            ExecuteEvents.Execute <PlayerHandler> (player.PlayerInstance.gameObject, null, (x, y) => x.editChipsText(amountToStart));
        }
    }
        public void ChipsTest_Constructor()
        {
            decimal price = 1.00M;
            string  item  = "Chips";

            Chips testItem = new Chips(price, item);

            Assert.AreEqual(item, testItem.Name);
            Assert.AreEqual(price, testItem.Price);
        }
Example #29
0
 protected Chip AddChipIndexed(Chip chip)
 {
     Chips.Add(chip);
     if (!WireDict.ContainsKey(chip.ID))
     {
         WireDict.Add(chip.ID, new List <Wire>());
     }
     chip.index = Chips.Count - 1;
     return(chip);
 }
Example #30
0
        public InBetween(Table table) : base(table)
        {
            _chips = Table.GetBagItem("TablePot", () => new Chips());
            _decks = Table.GetBagItem("TableDecks", () => new List <Deck>()
            {
                new Deck()
            });

            if (Deck.Count < 3)
            {
                _decks.Add(new Deck());
            }

            var playerBags = Table.GetBagItem("PlayerBags", () => Table.Players.ToDictionary(
                                                  p => p,
                                                  p => new InBetweenPlayerBag()
                                                  ));

            PlayerHands = new List <InBetweenPlayerHand>(playerBags.Select(kvp => new InBetweenPlayerHand(kvp.Key, kvp.Value)));

            // initial pot
            if (Pot == 0)
            {
                foreach (var playerHand in PlayerHands)
                {
                    if (playerHand.ChipsBalance <= 3 * MIN_BET_AMOUNT)
                    {
                        playerHand.ChipsPurchased += LOT_AMOUNT;
                        playerHand.ChipsBalance   += LOT_AMOUNT;
                        Bank += LOT_AMOUNT;
                    }

                    playerHand.ChipsBalance -= MIN_BET_AMOUNT;
                    Pot += MIN_BET_AMOUNT;
                }
            }

            // first game of series
            if (Table.ActivePlayer == null)
            {
                Table.SetNextPlayer();
            }
            else
            {
                if (IsEliminated(Table.ActivePlayer))
                {
                    Table.SetNextPlayer();
                }
            }

            // deal active hand
            ActiveHand = PlayerHands.First(ph => ph.Player == Table.ActivePlayer);
            ActiveHand.Cards.Add(Deck.DealExposed());
            ActiveHand.Cards.Add(Deck.DealExposed());
        }