public void SpendNoCredits() { var spent = _game.SpendCredits(1, 100); spent.ShouldBe(0); _game.Credits[0].ShouldBe(0); }
private void Name_Click(object sender, EventArgs e) { var me = e as MouseEventArgs; if (me == null || Item.AmountInvested == Item.Cost) { return; } if (me.Button != MouseButtons.Right) { return; } if (!Item.CanBuild()) { return; } SoundEffect.Play(ESounds.mousedown); // Right Click adds 20% or what you can afford if less, 5th adds 19%, 6th adds final 1% var perc = 0.2; var investedPerc = 1.0 * Item.AmountInvested / Item.Cost; if (investedPerc >= 0.99) { perc = 1 - investedPerc; } else if (investedPerc >= 0.8) { perc = 1 - investedPerc - 0.01; } var amount = (int)Math.Round(Item.Cost * perc); if (_game != null) { amount = _game.SpendCredits(1, amount); } else if (_researchForm != null) { amount = _researchForm.SpendCurrency(amount); } Item.AmountInvested += amount; InvestmentProgress.Value = Item.AmountInvested; }