mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-12 02:08:27 -04:00
Global usings and file scoped namespaces
This commit is contained in:
@@ -1,65 +1,60 @@
|
||||
using Discord;
|
||||
using NadekoBot.Modules.Gambling.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace NadekoBot.Modules.Gambling.Common.Blackjack
|
||||
namespace NadekoBot.Modules.Gambling.Common.Blackjack;
|
||||
|
||||
public abstract class Player
|
||||
{
|
||||
public abstract class Player
|
||||
public List<Deck.Card> Cards { get; } = new List<Deck.Card>();
|
||||
|
||||
public int GetHandValue()
|
||||
{
|
||||
public List<Deck.Card> Cards { get; } = new List<Deck.Card>();
|
||||
var val = GetRawHandValue();
|
||||
|
||||
public int GetHandValue()
|
||||
// while the hand value is greater than 21, for each ace you have in the deck
|
||||
// reduce the value by 10 until it drops below 22
|
||||
// (emulating the fact that ace is either a 1 or a 11)
|
||||
var i = Cards.Count(x => x.Number == 1);
|
||||
while (val > 21 && i-- > 0)
|
||||
{
|
||||
var val = GetRawHandValue();
|
||||
|
||||
// while the hand value is greater than 21, for each ace you have in the deck
|
||||
// reduce the value by 10 until it drops below 22
|
||||
// (emulating the fact that ace is either a 1 or a 11)
|
||||
var i = Cards.Count(x => x.Number == 1);
|
||||
while (val > 21 && i-- > 0)
|
||||
{
|
||||
val -= 10;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
public int GetRawHandValue()
|
||||
{
|
||||
return Cards.Sum(x => x.Number == 1 ? 11 : x.Number >= 10 ? 10 : x.Number);
|
||||
val -= 10;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
public class Dealer : Player
|
||||
public int GetRawHandValue()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class User : Player
|
||||
{
|
||||
public enum UserState
|
||||
{
|
||||
Waiting,
|
||||
Stand,
|
||||
Bust,
|
||||
Blackjack,
|
||||
Won,
|
||||
Lost
|
||||
}
|
||||
|
||||
public User(IUser user, long bet)
|
||||
{
|
||||
if (bet <= 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(bet));
|
||||
|
||||
this.Bet = bet;
|
||||
this.DiscordUser = user;
|
||||
}
|
||||
|
||||
public UserState State { get; set; } = UserState.Waiting;
|
||||
public long Bet { get; set; }
|
||||
public IUser DiscordUser { get; }
|
||||
public bool Done => State != UserState.Waiting;
|
||||
return Cards.Sum(x => x.Number == 1 ? 11 : x.Number >= 10 ? 10 : x.Number);
|
||||
}
|
||||
}
|
||||
|
||||
public class Dealer : Player
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class User : Player
|
||||
{
|
||||
public enum UserState
|
||||
{
|
||||
Waiting,
|
||||
Stand,
|
||||
Bust,
|
||||
Blackjack,
|
||||
Won,
|
||||
Lost
|
||||
}
|
||||
|
||||
public User(IUser user, long bet)
|
||||
{
|
||||
if (bet <= 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(bet));
|
||||
|
||||
this.Bet = bet;
|
||||
this.DiscordUser = user;
|
||||
}
|
||||
|
||||
public UserState State { get; set; } = UserState.Waiting;
|
||||
public long Bet { get; set; }
|
||||
public IUser DiscordUser { get; }
|
||||
public bool Done => State != UserState.Waiting;
|
||||
}
|
Reference in New Issue
Block a user