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  if len(text) > 1:
122  record = guild.info(text[1])
123  if record:
124  if len(text)==3:
125  if guild.change_status(text[1],text[2]):
126  record = guild.info(text[1]) #refresh record
127  message = '%s now has status of %s' %(text[1], record['Status'])
128  else:
129  status = ', '.join(guild.status)
130  message = '%s is not a valid status, valid values are %s.' %(text[2],status)
131  else:
132  status = ', '.join(guild.status)
133  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)
134  else:
135  message = '%s is not a member' %text[1]
136  else:
137  message = "Say status <member> to query the member's status."
138  elif text[0] == 'add' and isDM:
139  if len(text)==2:
140  if log.info(text[1]):
141  if guild.info(text[1]):
142  message = '%s is already a member.' %text[1]
143  else:
144  guild.add_member(text[1], 'Initiate' )
145  message = 'Added %s to the guild as Initiate' %text[1]
146  else:
147  message = 'Sorry, I don\'t know any %s' %text[1]
148  else:
149  message = 'Usage "add <membername>"'
150  elif text[0] == 'guildstatus' and isDM:
151  record = guildhouse.info(guildname)
152  if len(text)==2:
153  if record:
154  if guildhouse.change_status(guildname,text[1]):
155  record = guildhouse.info(guildname) #refresh record
156  message = '%s now has status of %s' %(guildname, record['Status'])
157  else:
158  message = '%s is not a valid status' %text[1]
159  else:
160  message = '%s is not a guild' %guildname
161  else:
162  status = ", ".join(guildhouse.status)
163  message = 'Current guild status is %s.\nTo change it use "guildstatus <status>" where status is one of %s' %(str(record['Status']),status)
164  else:
165  message = 'What did you need?'
166  else:
167  message = 'Board Error'
168  whoami.Say(message)
CFLog.CFLog
Definition: CFLog.py:34
make_face_from_files.str
str
Definition: make_face_from_files.py:30
CFGuilds.CFGuild
Definition: CFGuilds.py:131
CFGuilds.CFGuildHouses
Definition: CFGuilds.py:47
split
static std::vector< std::string > split(const std::string &field, const std::string &by)
Definition: mapper.cpp:2606
CFGuildClearance.CheckClearance
def CheckClearance(lParams, oActivator)
Definition: CFGuildClearance.py:21