Crossfire Server, Trunk  1.75.0
age.py
Go to the documentation of this file.
1 # -*- coding: utf-8 -*-
2 #age.py
3 # This is one of the files that can be called by an npc_dialog,
4 # The following code runs when a dialog has a pre rule of 'age'
5 # The syntax is
6 # ["age", "agetoken", "years", "months", "days", "hours", "minutes"]
7 # To deliver a True verdict, the agetoken must correspond to a date
8 # that is was at least as long ago as the duration specified in the options.
9 
19 
20 import Crossfire
21 
22 class checkfailed(Exception):
23  pass
24 
25 # maximum months, days, hours, as defined by the server.
26 # minutes per hour is hardcoded to approximately 60
27 
28 try:
29  MAXTIMES = [Crossfire.Time.MONTHS_PER_YEAR, Crossfire.Time.WEEKS_PER_MONTH*Crossfire.Time.DAYS_PER_WEEK,
30  Crossfire.Time.HOURS_PER_DAY, 60]
31  # we have three times to consider, the old time, the current time, and the desired time difference.
32  if len(args) != 6:
33  raise checkfailed()
34  markername = args[0]
35  oldtime = self.getStatus(markername).split("-")
36  oldtime = list(map(int, oldtime))
37  if len(oldtime) !=5:
38  # The marker hasn't been set yet
39  raise checkfailed()
40 
41  desireddiff = list(map(int, args[1:]))
42  currenttime = (Crossfire.GetTime())[:5]
43  actualdiff = []
44 
45  for i in range(5):
46  actualdiff.append(currenttime[i]-oldtime[i])
47 
48  for i in range(4,0,-1):
49  # let's tidy up desireddiff first
50  if desireddiff[i] > MAXTIMES[i-1]:
51  desireddiff[i-1] += desireddiff[i] // MAXTIMES[i-1]
52  desireddiff[i] %= MAXTIMES[i-1]
53  # Then actualdiff
54  if actualdiff[i] < 0:
55  actualdiff[i] += MAXTIMES[i-1]
56  actualdiff[i-1] -=1
57  Crossfire.Log(Crossfire.LogDebug, "CFDialog: tidied up desired difference: %s actual difference %s" %(desireddiff, actualdiff))
58  for i in range(5):
59  if actualdiff[i] < desireddiff[i]:
60  raise checkfailed()
61 except checkfailed:
62  verdict = False
disinfect.map
map
Definition: disinfect.py:4
age.checkfailed
Definition: age.py:22
list
How to Install a Crossfire Server on you must install a python script engine on your computer Python is the default script engine of Crossfire You can find the python engine you have only to install them The VisualC Crossfire settings are for but you habe then to change the pathes in the VC settings Go in Settings C and Settings Link and change the optional include and libs path to the new python installation path o except the maps ! You must download a map package and install them the share folder Its must look like doubleclick on crossfire32 dsw There are projects in your libcross lib and plugin_python You need to compile all Easiest way is to select the plugin_python ReleaseLog as active this will compile all others too Then in Visual C press< F7 > to compile If you don t have an appropriate compiler you can try to get the the VC copies the crossfire32 exe in the crossfire folder and the plugin_python dll in the crossfire share plugins folder we will remove it when we get time for it o Last showing lots of weird write to the Crossfire mailing list
Definition: INSTALL_WIN32.txt:50