87 lines
2.3 KiB
Python
87 lines
2.3 KiB
Python
from dicelib import AceDie, AdvancedDie, BasicDie, BlankDie, Deck, QueueDeck
|
|
from input_assist import iyes_or_no, iranged_input_int
|
|
from random import choice, shuffle
|
|
|
|
# seed(42069) # for testing
|
|
|
|
|
|
def rai(r, dice_list):
|
|
if r[0] == "AdvancedDie":
|
|
return choice([1, 6])
|
|
exit("Achievement unlocked: How did we get here?")
|
|
|
|
|
|
def smolthink_ai(r, dice_list):
|
|
if r[0] == "AdvancedDie":
|
|
if Deck.sum(dice_list) > 7:
|
|
return 1
|
|
else:
|
|
return 6
|
|
|
|
|
|
def pfunc(dice_list):
|
|
dice = [f"{DICE_NAMES[x[0]]}: {x[1]}" for x in dice_list]
|
|
print("\nDice so far:\n " + ("\n ".join(dice) or "None"))
|
|
|
|
|
|
def efunc(dice_list):
|
|
return Deck.sum(dice_list) >= 13
|
|
|
|
|
|
def shuffled(_list):
|
|
l1 = _list.copy()
|
|
shuffle(l1)
|
|
return l1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
DICE_NAMES = {
|
|
"AdvancedDie": "Advanced",
|
|
"BasicDie": "Basic",
|
|
"BlankDie": "Blank",
|
|
"AceDie": "Ace",
|
|
}
|
|
deck = QueueDeck(shuffled(BasicDie.multiple(11)
|
|
+ AdvancedDie.multiple(6)
|
|
+ BlankDie.multiple(3)
|
|
+ AceDie.multiple(1)))
|
|
balance = 500
|
|
|
|
while balance > 0:
|
|
bet = iranged_input_int(f"Your bet? [1-{balance}] ",
|
|
range(1, balance+1))
|
|
if bet is None:
|
|
exit("\nBye!~")
|
|
else:
|
|
bet = int(bet)
|
|
roll = deck.roll("Roll more? [Y/n] ",
|
|
print_func=pfunc, exit_check=efunc)
|
|
if roll is None:
|
|
exit()
|
|
|
|
print("\nDice:")
|
|
for res in roll:
|
|
print(f"> {DICE_NAMES[res[0]]}: {res[1]}")
|
|
print("Total:", Deck.sum(roll))
|
|
if Deck.sum(roll) > 13:
|
|
print("You've busted out!")
|
|
balance -= bet
|
|
if Deck.sum(roll) == 13:
|
|
print("You've won!")
|
|
balance += bet
|
|
if Deck.sum(roll) < 13:
|
|
print("You've backed out.")
|
|
balance -= bet // 2
|
|
|
|
print("-"*24)
|
|
if balance <= 0:
|
|
print("No money left :(")
|
|
print("Goodbye!")
|
|
exit()
|
|
print(f"Your beans: {balance}")
|
|
c = iyes_or_no("Continue playing? [Y/n] ", default_pos=True)
|
|
if c is None:
|
|
exit()
|
|
if not c:
|
|
break
|