File: CFTimeOfDay.py

package info (click to toggle)
crossfire-maps 1.71.0-1
  • links: PTS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch
  • size: 211,128 kB
  • sloc: python: 7,656; ansic: 2,143; perl: 744; sh: 73; makefile: 6
file content (20 lines) | stat: -rw-r--r-- 774 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import Crossfire

class TimeOfDay:
    def __init__(self):
        self.now = Crossfire.GetTime()
        self.current = [Crossfire.GetMonthName(self.now[1]),Crossfire.GetWeekdayName(self.now[5]),Crossfire.GetSeasonName(self.now[7]),Crossfire.GetPeriodofdayName(self.now[8])]

    def matchAny(self,what):
        if isinstance(what,list):
            return bool(set(what) & set(self.current))
        else:
            return bool(set([what]) & set (self.current))

    def matchAll(self,what):
        if isinstance(what,list):
            return bool(not (set(what) - set(self.current)))
        else:
            return bool(not (set([what]) - set (self.current)))
    def log(self):
        Crossfire.Log(Crossfire.LogDebug,"current time is seen as %s" %self.current)