示例#1
0
    def _roll_precipitation(self):
        '''Determine precipitation parameters.'''
        def _roll_duration(base, mod):
            '''Look up precipitation duration from table.'''
            roll = drm() + mod
            for row in precipitation_duration_table:
                if roll <= row[0]:
                    return row[base]
            return precipitation_duration_table[-1][base]

        def _roll_inches(base, mod):
            '''Look up precipitation inches from table.'''
            roll = drm() + mod
            for row in precipitation_inches_table:
                if roll <= row[0]:
                    return row[base]
            return precipitation_inches_table[-1][base]

        roll = d100()
        for i, precipitation, mintemp, maxtemp, duration, duration_mod, inches, inchmod, wind, windmod, movemod, awaremod, trackmod, directionmod in precipitation_table:
            if roll <= i:
                if self.high > maxtemp or self.low < mintemp:
                    return None, 0
                self.precipitation_mods = movemod, awaremod, trackmod, directionmod
                self.precipitation_start = random.randint(1, 24)
                self.precipitation_end = self.precipitation_start + _roll_duration(duration, duration_mod)
                # stupidly high inches = _roll_inches(inches, inchmod)
                return precipitation, self._roll_wind(wind, windmod)
示例#2
0
 def _calc_precipitation(self, prev_day, chance, cloud_table):
     '''Is it raining?
     :param chance: % chance of precipitation
     :param cloud_table: data from month table
     '''
     if prev_day and prev_day.precipitation_end > 24:
         self.precipitation = prev_day.precipitation
         self.precipitation_start = 1
         self.precipitation_end = prev_day.precipitation_end - 24
         self.precipitation_mods = prev_day.precipitation_mods
         self.wind = prev_day.wind  # todo roll my own wind
         cloud_mod = 30
     else:
         roll = drm() + chance
         if roll > 100:
             self.precipitation = None
             while self.precipitation is None:
                 # Note: sets start/end.
                 self.precipitation, self.wind = self._roll_precipitation()
             cloud_mod = 30
         else:
             self.precipitation = None
             self.precipitation_start = 0
             self.precipitation_end = 0
             self.precipitation_mods = (0, 0, 0, 0)
             self.wind = self._roll_wind(1, -10)  # clear
             cloud_mod = 0
     # Cloud cover
     roll = d100() + cloud_mod
     if roll <= cloud_table[0]:
         self.cloud = 'Clear'
     elif roll <= cloud_table[1]:
         self.cloud = 'Partly'
     else:
         self.cloud = 'Cloudy'
示例#3
0
 def get_order(self, order=None):
     if order:
         order_data = [o for o in ORDERS if o[1] == order][0]
     else:
         r = d100(1)
         for o in ORDERS:
             if r <= o[0]:
                 order_data = o
                 break
     self.order = order_data[1]
     self.dms["weapon"] += order_data[2]
     self.dms["armor"] += order_data[2]
示例#4
0
 def get_order(self, order=None):
     if order:
         order_data = [o for o in ORDERS
                       if o[1] == order][0]
     else:
         r = d100(1)
         for o in ORDERS:
             if r <= o[0]:
                 order_data = o
                 break
     self.order = order_data[1]
     self.dms["weapon"] += order_data[2]
     self.dms["armor"] += order_data[2]
示例#5
0
 def determine_star_class(self):
     roll = dice.d6(3)
     if roll >= 3 and roll <= 5:
         self.star_class = "D"
     elif roll == 6:
         self.star_class = "VI"
     elif roll == 18:
         roll = dice.d6(3)
         if roll == 3:
             roll = dice.d100()
             if roll <= 33:
                self.star_class = "Ia"
             else:
                self.star_class = "Ib"
         elif roll == 4:
             self.star_class = "II"
         elif roll >= 5 and roll <= 12:
             self.star_class = "III"
         else:
             self.star_class = "IV"
     else:
         self.star_class = "V"
示例#6
0
文件: gui.py 项目: juntaizheng/summer
	E1.insert(END, "0")
	E2.insert(END, "0")
	E3.insert(END, "0")
	E4.insert(END, "0")
v=StringVar()
L6 = Label(textvariable=v)
B1 = Button(text="Roll!", command=lambda: v.set(E2.get() + "d(" + E1.get() + '{:+}'.format(int(E3.get())) + ") " + '{:+}'.format(int(E4.get())) + " = "
	'{:+}'.format(dice.roller(int(E1.get()), int(E2.get()), int(E3.get())) + int(E4.get()))))
B2 = Button(text='d2', command=lambda: v.set("d2: " + str(dice.d2())))
B3 = Button(text="d3", command=lambda: v.set("d3: " + str(dice.d3())))
B4 = Button(text="d4", command=lambda: v.set("d4: " + str(dice.d4())))
B6 = Button(text="d6", command=lambda: v.set("d6: " + str(dice.d6())))
B8 = Button(text="d8", command=lambda: v.set("d8: " + str(dice.d8())))
B10 = Button(text="d10", command=lambda: v.set("d10: " + str(dice.d10())))
B20 = Button(text="d20", command=lambda: v.set("d20: " + str(dice.d20())))
B100 = Button(text="d100", command=lambda: v.set("d100: " + str(dice.d100())))
L1.grid(row=0, column=0, columnspan=1)
E1.grid(row=1, column=0, columnspan=1)
L2.grid(row=2, column=0, columnspan=1)
E2.grid(row=3, column=0, columnspan=1)
L3.grid(row=4, column=0, columnspan=1)
E3.grid(row=5, column=0, columnspan=1)
L4.grid(row=6, column=0, columnspan=1)
E4.grid(row=7, column=0, columnspan=1)
L5.grid(row=8, column=0, columnspan=1, sticky=W)
L6.grid(row=9, column=0, columnspan=1, sticky=W)
B1.grid(row=0, column=1, columnspan=1, sticky=W, padx = 10)
B2.grid(row=0, column=2, columnspan=1, sticky=W, padx = 10)
B3.grid(row=0, column=3, columnspan=1, sticky=W, padx = 10)
B4.grid(row=2, column=1, columnspan=1, sticky=W, padx = 10)
B6.grid(row=2, column=2, columnspan=1, sticky=W, padx = 10)