Advertisement
Guest User

PvZ Income

a guest
Jun 13th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.12 KB | None | 0 0
  1. time = 0
  2.  
  3. sun_f = 50                                              # spendable sun for sunflower simulation
  4. sun_f_total = 0                                         # total earned sun for sunflowers
  5. sun_s = 50                                              # spendable sun for sunshroom simulation
  6. sun_s_total = 0                                         # total earned sun for sunshrooms
  7.  
  8. cooldownflower = 0
  9. cooldownshroom = 0
  10.  
  11. sunflowers = 0
  12. sunshrooms = 0
  13.  
  14. ageflower = []                                          # lists for calculating income timing and shroom evolving
  15. ageshroom = []
  16.  
  17.  
  18. def buildsunflower():
  19.     global sun_f
  20.     global sunflowers
  21.     global cooldownflower
  22.     if sunflowers < 12:
  23.         sun_f -= 50                               # normal cost
  24.     elif sunflowers > 11:
  25.         sun_f -= 75                               # adjusted lily pad cost for water placement after 12 land spots fill
  26.     sunflowers += 1                               # running total for sunflowers
  27.     ageflower.append(12)                          # the first income packet only requires 12 instead of 24 seconds
  28.     cooldownflower = 9                            # sets sunflower build cooldown to 8 + 1 second of human error
  29.  
  30.  
  31. def buildsunshroom():
  32.     global sun_s
  33.     global sunshrooms
  34.     global cooldownshroom
  35.     if sunshrooms < 12:
  36.         sun_s -= 25
  37.     elif sunshrooms > 11:
  38.         sun_s -= 50
  39.     sunshrooms += 1
  40.     ageshroom.append(12)
  41.     cooldownshroom = 9
  42.  
  43.  
  44. def update():
  45.     global time
  46.     global cooldownflower
  47.     global cooldownshroom
  48.     global ageflower
  49.     global ageshroom
  50.     print('\t', time, '\t\t', sun_f, '/', sun_s, '\t\t', sun_f_total, '/', sun_s_total,
  51.           '\t\t', sunflowers, '/', sunshrooms)                                         # per second readout
  52.     time += 1                                                                          # running total of seconds
  53.     cooldownflower -= 1                                                                # reduces build cooldowns from 9
  54.     cooldownshroom -= 1
  55.     ageflower = [x + 1 for x in ageflower]                                # magical aging code I don't understand yet
  56.     ageshroom = [x + 1 for x in ageshroom]
  57.  
  58.  
  59. for n in range(300):
  60.     if sun_f >= 50 and cooldownflower <= 0 and sunflowers < 16:               # plants flower if currency,
  61.         buildsunflower()                                                      # cooldown, and room allow
  62.  
  63.     for x in ageflower:
  64.         if x % 24 == 0:                                                       # adds income in multiples of 24 seconds
  65.             sun_f += 25
  66.             sun_f_total += 25
  67.  
  68.     if sun_s >= 25 and cooldownshroom <= 0 and sunshrooms < 16:
  69.         buildsunshroom()
  70.  
  71.     for x in ageshroom:
  72.         if x % 24 == 0 and x > 120:                                           # the 120 is to check for evolved shroom
  73.             sun_s += 25
  74.             sun_s_total += 25
  75.         elif x % 24 == 0:
  76.             sun_s += 15
  77.             sun_s_total += 15
  78.  
  79.     update()                                                                   # recalculates before new loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement