repl.it
@PYer/

Dice Game

Python

No description

fork
loading
Files
  • main.py
  • multipliers.txt
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import random, replit

def roll_dice(am=1):
  rolls = [] 
  for i in range(am):
    rolls.append(random.randint(1, 6))
  return rolls

multipliers = {}

with open('multipliers.txt', 'r') as multipliersfile:
  multiplierslist = multipliersfile.readlines()
  for line in multiplierslist:
    idname, multinc, prixinc, *string = line.split()
    multipliers[idname] = [1, float(multinc), int(prixinc), int(prixinc), ' '.join(string)]

def stringifymult(idname):
  obj = multipliers[idname]
  return obj[4].upper() + ' - $' + str(obj[2]) + '  [ x' + str(obj[0]) + ' >>> x' + str(obj[0]+obj[1]) + ' ]'

def upgrade_shop():
  print('UPGRADES')
  am = len(die)
  if am >= 2:
    print('1) ' + stringifymult('pair'))
  if am >= 3:
    print('2) ' + stringifymult('triplet'))
  if am >= 4:
    print('3) ' + stringifymult('twopairs'))
    print('4) ' + stringifymult('four'))
  if am>= 5:
    print('5) ' + stringifymult('fullhouse'))
    print('6) ' + stringifymult('straight'))
    print('7) ' + stringifymult('five'))

die = [(1, 1, 1)] * 6
die_prices = 0,100,750,5000,75000,10000000
money = 0

upgrade_shop()

while True:
  replit.clear()
  print('MONEY $' + str(money))
  rolls = roll_dice(am=len(die))
  total = 0
  for dice in die:
    ind = die.index(dice)
    roll = rolls[ind]
    gain = roll * dice[2]
    total += gain
    dicestring = f'Dice {ind+1} [ LVL {dice[0]} MULT {dice[1]}]: {roll} ( +${gain} )'
    print(dicestring)
  print('+ $' + str(total) + '!!!')
  money += total
  print('Press enter to roll...')
  input()