Crossfire Server, Trunk
guildoracle.py
Go to the documentation of this file.
1 # Script for say event of guild member board
2 #
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 #
17 # authors: majorwoo josh@woosworld.net, Avion temitchell@sourceforge.net
18 
19 
20 import Crossfire
21 import CFGuilds
22 import CFLog
23 
24 from CFGuildClearance import CheckClearance
25 
26 activator=Crossfire.WhoIsActivator()
27 activatorname=activator.Name
28 whoami=Crossfire.WhoAmI()
29 isDM=activator.DungeonMaster
30 mymap=activator.Map
32 guildname=Crossfire.ScriptParameters() # 6 is say eventC fi
33 if CheckClearance([guildname,"GuildMaster"],activator):
34  guild=CFGuilds.CFGuild(guildname)
35  guildrecord=CFGuilds.CFGuildHouses().info(guildname)
36  Approved = 'Access granted'
37 else:
38  Approved = 'Access denied'
39 
40 Access = 0
41 
42 if (Approved == 'Access granted'):
43  Access = 1
44 else:
45  whoami.Say(Approved)
46 
47 if (Access ==1) or (isDM == 1):
48  if (guildname):
49  guild = CFGuilds.CFGuild(guildname)
50  guildhouse = CFGuilds.CFGuildHouses()
51  text = Crossfire.WhatIsMessage().split()
52  if guild.info(activatorname) == 0 and isDM == 0:
53  message = 'You don\'t belong to this guild!'
54  elif text[0] == 'help' or text[0] == 'yes':
55  if isDM:
56  message = '\nList of commands:\n-list\n-add <name>\n-remove <member>\n-info <member>\n-promote <member>\n-demote <member>\n-status <member> <status>\n-guildstatus <status>'
57  else:
58  message='\nList of commands:\n-list\n-remove <member>\n-info <member>\n-promote <member>\n-demote <member>\n-status <member> <status>'
59  elif text[0] == 'info':
60  if len(text)==2:
61  record = guild.info(text[1])
62  if record:
63  message = 'Information for %s:\n' %text[1]
64  message += 'Rank: %s\n'%record['Rank']
65  message += 'Status: %s\n'%record['Status']
66  message += 'Join date: %s\n'%record['Join_date']
67  if record['Demerits'] != '0':
68  message += 'Demerits: %s\n'%record['Demerits']
69  if record['Dues'] != '0':
70  message += 'Paid dues: %s\n'%Crossfire.CostStringFromValue(long(record['Dues']))
71  else:
72  message = '%s is not a member' %text[1]
73  else:
74  message = 'Usage "info <member_name>"'
75 
76  elif text[0] == 'remove':
77  if len(text)==2:
78  if guild.info(text[1]):
79  message = 'Removed %s from the guild' %text[1]
80  guild.remove_member(text[1])
81  else:
82  message = '%s was not a member' %text[1]
83  else:
84  message = 'Usage "remove <member_name>"'
85  elif text[0] == 'list':
86  Crossfire.SetPlayerMessage('Who are the members?', 2)
87  list = guild.list_members()
88 
89  message = '\nList of members:\n'
90  for member in list:
91  message += '%s (%s)\n'%(member, guild.info(member)['Rank'])
92  message += 'Total members = ' + str(len(list))
93 
94  elif text[0] == 'promote':
95  if len(text)==2:
96  record = guild.info(text[1])
97  if record:
98  if guild.promote_member(text[1]):
99  record = guild.info(text[1]) #refresh record
100  message = '%s promoted to %s' %(text[1], record['Rank'])
101  else:
102  message = 'You cannot promote %s' %text[1]
103  else:
104  message = '%s is not a member' %text[1]
105  else:
106  message = 'Usage "promote <member_name>"'
107  elif text[0] == 'demote':
108  if len(text)==2:
109  record = guild.info(text[1])
110  if record:
111  if guild.demote_member(text[1]):
112  record = guild.info(text[1]) #refresh record
113  message = '%s demoted to %s' %(text[1], record['Rank'])
114  else:
115  message = 'You cannot demote %s' %text[1]
116  else:
117  message = '%s is not a member' %text[1]
118  else:
119  message = 'Usage "demote <member_name>"'
120  elif text[0] == 'status':
121  record = guild.info(text[1])
122  if record:
123  if len(text)==3:
124  if guild.change_status(text[1],text[2]):
125  record = guild.info(text[1]) #refresh record
126  message = '%s now has status of %s' %(text[1], record['Status'])
127  else:
128  status = ', '.join(guild.status)
129  message = '%s is not a valid status, valid values are %s.' %(text[2],status)
130  else:
131  status = ', '.join(guild.status)
132  message = 'Current status for %s is %s.\nTo change use "status %s <status>" where status is one of %s.' %(text[1],record['Status'],text[1],status)
133  else:
134  message = '%s is not a member' %text[1]
135  elif text[0] == 'add' and isDM:
136  if len(text)==2:
137  if log.info(text[1]):
138  if guild.info(text[1]):
139  message = '%s is already a member.' %text[1]
140  else:
141  guild.add_member(text[1], 'Initiate' )
142  message = 'Added %s to the guild as Initiate' %text[1]
143  else:
144  message = 'Sorry, I don\'t know any %s' %text[1]
145  else:
146  message = 'Usage "add <membername>"'
147  elif text[0] == 'guildstatus' and isDM:
148  record = guildhouse.info(guildname)
149  if len(text)==2:
150  if record:
151  if guildhouse.change_status(guildname,text[1]):
152  record = guildhouse.info(guildname) #refresh record
153  message = '%s now has status of %s' %(guildname, record['Status'])
154  else:
155  message = '%s is not a valid status' %text[1]
156  else:
157  message = '%s is not a guild' %guildname
158  else:
159  status = ", ".join(guildhouse.status)
160  message = 'Current guild status is %s.\nTo change it use "guildstatus <status>" where status is one of %s' %(str(record['Status']),status)
161  else:
162  message = 'What did you need?'
163  else:
164  message = 'Board Error'
165  whoami.Say(message)
inja::string_view::split
std::pair< nonstd::string_view, nonstd::string_view > split(nonstd::string_view view, char Separator)
Definition: inja.hpp:1886
CFLog.CFLog
Definition: CFLog.py:33
make_face_from_files.str
str
Definition: make_face_from_files.py:24
CFGuilds.CFGuild
Definition: CFGuilds.py:136
CFGuilds.CFGuildHouses
Definition: CFGuilds.py:52
CFGuildClearance.CheckClearance
def CheckClearance(lParams, oActivator)
Definition: CFGuildClearance.py:21