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
58
59
60
61
62
63
64
65
66
67
68
69
import random, replit

die_prices = 0,100,750,5000,75000,10000000
dice_string = 'Dice {} LVL {}:\n\t {}  x{} ( +${} )'

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():
  replit.clear()
  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'))
  else:
    print('No upgrades avalible...')
  print('\nDICE')
  lastdice = die[-1]
  if lastdice[0] >= 10:
    print(f'8)Dice #{die.ind(lastdice+2)}: ${die_prices[die.ind(lastdice+1)]}')
  else:
    print('No dice avalible...')
  print('\nWhat do you buy?')
  input()

die = [(1, 1, 1)]
money = 0

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 = dice_string.format(ind+1, dice[0], roll, dice[1], gain)
    print(dicestring)
  print('\t\t+ $' + str(total) + '!!!')
  money += total
  print('\nPress enter to roll or type shop to shop...')
  if input().startswith('s'):
    upgrade_shop()
?