private void OnRunningIntoKnife(Knife knife) { _knifeCount--; knife.RanIntoApple -= OnAppleEnter; knife.RanIntoKnife -= OnRunningIntoKnife; knife.RanIntoKnife -= OnLogEnter; knife.RanIntoApple -= OnAppleEnter; Lose?.Invoke(); }
protected virtual void TeamLose() { HasLoose = true; Lose?.Invoke(ID); }
public void PrintStatisticsOfBets() { currentTime = DateTime.Now; foreach (var bet in manage.LoggedUser.BetsPlaced) { if (currentTime > bet.Value.EventEnd) { int winnerCounter = 0; int randWinner = randomWinner.Next(0, 1000); double teamOneChance = (double)(bet.Value.TeamOneMonetPlaced / (bet.Value.TeamOneMonetPlaced + bet.Value.TeamTwoMoneyPlaced)); Math.Round(teamOneChance, 2); teamOneChance *= 10; if (randWinner <= teamOneChance && bet.Value.TeamOne.Last() == '<') { int counter = 1; int moneyPlaced = 0; int numHelper; int i = bet.Value.TeamOne.Length - 1; while (bet.Value.TeamOne[i] != ' ') { if (bet.Value.TeamOne[i] != '<') { numHelper = Int32.Parse(bet.Value.TeamOne[i].ToString()); moneyPlaced += numHelper * counter; counter *= 10; } } manage.LoggedUser.Balance += (decimal)(moneyPlaced * bet.Value.TeamOneCoefitient); Win?.Invoke(this, new StatusEventArgs("You have won!")); Console.WriteLine($"Current balance:{manage.LoggedUser.Balance}"); winnerCounter++; } else if (randWinner > teamOneChance && bet.Value.TeamTwo.Last() == '<') { int counter = 1; int moneyPlaced = 0; int numHelper; int i = bet.Value.TeamTwo.Length - 1; while (bet.Value.TeamOne[i] != ' ') { if (bet.Value.TeamOne[i] != '<') { numHelper = Int32.Parse(bet.Value.TeamTwo[i].ToString()); moneyPlaced += numHelper * counter; counter *= 10; } } manage.LoggedUser.Balance += (decimal)(moneyPlaced * bet.Value.TeamTwoCoefitient); Win?.Invoke(this, new StatusEventArgs("You have won!")); Console.WriteLine($" Current balance:{manage.LoggedUser.Balance}"); winnerCounter++; } else if (winnerCounter == 0) { if (bet.Value.TeamOne.Last() == '<') { int counter = 1; int moneyPlaced = 0; int numHelper; int i = bet.Value.TeamOne.Length - 1; while (bet.Value.TeamOne[i] != ' ') { if (bet.Value.TeamOne[i] != '<') { numHelper = Int32.Parse(bet.Value.TeamOne[i].ToString()); moneyPlaced += numHelper * counter; counter *= 10; } } manage.LoggedUser.Balance += (decimal)(moneyPlaced * bet.Value.TeamOneCoefitient); } else { int counter = 1; int moneyPlaced = 0; int numHelper; int i = bet.Value.TeamTwo.Length - 1; while (bet.Value.TeamOne[i] != ' ') { if (bet.Value.TeamOne[i] != '<') { numHelper = Int32.Parse(bet.Value.TeamTwo[i].ToString()); moneyPlaced += numHelper * counter; counter *= 10; } } manage.LoggedUser.Balance += (decimal)(moneyPlaced * bet.Value.TeamTwoCoefitient); } Lose?.Invoke(this, new StatusEventArgs("You have lost!")); Console.WriteLine($" Current balance:{manage.LoggedUser.Balance}"); } } } }
public void RaiseLose() => Lose?.Invoke(this, new EventArgs());