Advertisement
Kalidor_Vorlich

Game Time

Aug 6th, 2018
673
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.92 KB | None | 0 0
  1. import time
  2. import random
  3. import sys
  4. from os import system, name
  5.  
  6. def getTime():
  7.     #Earth Time
  8.     seconds = int(time.time()) #seconds since epoch(1200am, Jan 01 1970)
  9.  
  10.     #Game Time
  11.     gseconds = int(seconds * 25)
  12.     mincount = int (gseconds / 60)
  13.     hourcount = int(mincount / 60)
  14.     daycount = int (hourcount / 24)
  15.     monthcount = int (daycount / 30)  #simplified 30 day month
  16.     yearcount = int(monthcount /12)
  17.     weekcount = int (daycount / 8) #8 day week
  18.  
  19.  
  20.  
  21.  
  22.     ### -- CALC HOUR -- ###
  23.     hour = hourcount%(24)
  24.  
  25.     ### -- CALC MIN -- ###
  26.     minute = mincount%(60)
  27.  
  28.     ### -- CALC DAY -- ###
  29.     day = None
  30.     dayremainder = daycount%(8)
  31.     if dayremainder == 0:
  32.         day = "Firesday"
  33.     elif dayremainder == 1:
  34.         day = "Earthsday"
  35.     elif dayremainder == 2:
  36.         day = "Watersday"
  37.     elif dayremainder == 3:
  38.         day = "Windsday"
  39.     elif dayremainder == 4:
  40.         day = "Iceday"
  41.     elif dayremainder == 5:
  42.         day = "Lightningday"
  43.     elif dayremainder == 6:
  44.         day = "Lightsday"
  45.     elif dayremainder == 7:
  46.         day = "Darksday"
  47.     else:
  48.         print("DefaultDay")
  49.         print(dayremainder)
  50.  
  51.     ### -- CALC DATE -- ###
  52.     date = daycount%(30)
  53.  
  54.  
  55.     ### -- CALC MONTH -- ##
  56.     month = None
  57.     monthremainder = monthcount%(12)
  58.     if monthremainder == 0:
  59.         month = "January"
  60.     elif monthremainder == 1:
  61.         month = "February"
  62.     elif monthremainder == 2:
  63.         month = "March"
  64.     elif monthremainder == 3:
  65.         month = "April"
  66.     elif monthremainder == 4:
  67.         month = "May"
  68.     elif monthremainder == 5:
  69.         month = "June"
  70.     elif monthremainder == 6:
  71.         month = "July"
  72.     elif monthremainder == 7:
  73.         month = "August"
  74.     elif monthremainder == 8:
  75.         month = "September"
  76.     elif monthremainder == 9:
  77.         month = "October"
  78.     elif monthremainder == 10:
  79.         month = "November"
  80.     elif monthremainder == 11:
  81.         month = "December"
  82.     else:
  83.         print("DefaultMonth")
  84.         print(monthremainder)
  85.        
  86.  
  87.     season = None
  88.     ### -- CALC SEASON -- ###
  89.     if month in ("November", "December", "January"):
  90.         season = "Winter"
  91.     elif month in ("February", "March", "April"):
  92.         season = "Spring"
  93.     elif month in ("May", "June", "July"):
  94.         season = "Summer"
  95.     elif month in ("August", "September", "October"):
  96.         season = "Autumn"
  97.     else:
  98.         print("DefaultSeason")
  99.         print(monthremainder)
  100.  
  101.  
  102.     ### -- CALC MOON
  103.     # new moon -> crescent moon -> half moon -> gibbous moon -> full moon
  104.     moon_day = daycount%(90)
  105.     moon_count = 0
  106.     full_moon_count = None
  107.     if moon_day >=1 and  moon_day <= 7:
  108.         moon = 'new_moon'
  109.     elif moon_day >=8 and  moon_day <47:
  110.         moon = 'crescent_moon'
  111.     elif moon_day >=48 and  moon_day <= 64:
  112.         moon = 'half_moon'
  113.     elif moon_day >=65 and  moon_day <= 82:
  114.         moon = 'gibbous_moon'
  115.     elif moon_day >=83 and  moon_day <= 90: #randomly is a blood moon
  116.         #full_moon_count += 1
  117.         full_moon_count = random.randint(1,6)
  118.         if full_moon_count == 3:
  119.             moon = 'blood_moon'
  120.         else:
  121.             moon = 'full_moon'
  122.  
  123.  
  124.     ### -- SPECIAL DAYS -- ###
  125.     if date == 1 and month == 'January':
  126.         special_day = 'New Years Day'
  127.     elif date == 25 and month == 'March':
  128.         special_day = 'Spring Equinox'
  129.     elif date == 21 and month == 'June':
  130.         special_day = 'Summer Solstice'
  131.     elif date == 22 and month == 'September':
  132.         special_day = 'Autumn Equinox'
  133.     elif date == 30 and month == 'October':
  134.         special_day = 'Halloween'
  135.     elif date == 21 and month == 'December':
  136.         special_day = 'Winter Solstice'
  137.     elif date == 25 and month == 'December':
  138.         special_day = 'Xmas'
  139.     else:
  140.         special_day = None
  141.  
  142.  
  143.         ### -- BONUS DAYS -- ###
  144.     if day == 'Firesday':
  145.         print("Firesday Bonus!")
  146.     elif day == 'Earthsday':
  147.         print("Earthsday Bonus!")
  148.     elif day == 'Watersday':
  149.         print("Watersday Bonus!")
  150.     elif day == 'Windsday':
  151.         print("Windsday Bonus!")
  152.     elif day == 'Iceday':
  153.         print("Iceday Bonus!")
  154.     elif day == 'Lightningday':
  155.         print("Lightningday Bonus!")
  156.     elif day == 'Lightsday':
  157.         print("Lightsday Bonus!")
  158.     elif day == 'Darksday':
  159.         print("Darksday Bonus!")
  160.     else:
  161.         print("No Bonus...")
  162.  
  163.        
  164.  
  165.  
  166.     def time_now():
  167.         print(day, " - ",date, " - " ,month, " - ", yearcount, " in the ", season, " time.", " It's: ",hour, ":",minute)
  168.         print("Moon = ",moon)
  169.         print("Special day - ",special_day)
  170.         time.sleep(1/25)
  171.         # for windows
  172.         if name == 'nt':
  173.             _ = system('cls')
  174.        
  175.         # for mac and linux(here, os.name is 'posix')
  176.         else:
  177.             _ = system('clear')
  178.  
  179.     time_now()
  180.  
  181.  
  182.  
  183. while True:
  184.     getTime()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement