File: guildoracle.py

package info (click to toggle)
crossfire-maps 1.75.0%2Bdfsg1-1
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 275,656 kB
  • sloc: python: 7,711; sql: 92; sh: 73; makefile: 7
file content (168 lines) | stat: -rw-r--r-- 7,402 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# Script for say event of guild member board
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# authors: majorwoo josh@woosworld.net, Avion temitchell@sourceforge.net


import Crossfire
import CFGuilds
import CFLog

import sys
import string
from CFGuildClearance import CheckClearance

activator=Crossfire.WhoIsActivator()
activatorname=activator.Name
whoami=Crossfire.WhoAmI()
isDM=activator.DungeonMaster
mymap=activator.Map
log=CFLog.CFLog()
guildname=Crossfire.ScriptParameters() # 6 is say eventC fi
if CheckClearance([guildname,"GuildMaster"],activator):
    guild=CFGuilds.CFGuild(guildname)
    guildrecord=CFGuilds.CFGuildHouses().info(guildname)
    Approved = 'Access granted'
else:
    Approved = 'Access denied'

Access = 0

if (Approved == 'Access granted'):
    Access = 1
else:
    whoami.Say(Approved)

if (Access ==1) or (isDM == 1):
    if (guildname):
        guild = CFGuilds.CFGuild(guildname)
        guildhouse = CFGuilds.CFGuildHouses()
        text = string.split(Crossfire.WhatIsMessage())
        if guild.info(activatorname) == 0 and isDM == 0:
            message = 'You don\'t belong to this guild!'
        elif text[0] == 'help' or text[0] == 'yes':
            if isDM:
                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>'
            else:
                message='\nList of commands:\n-list\n-remove <member>\n-info <member>\n-promote <member>\n-demote <member>\n-status <member> <status>'
        elif text[0] == 'info':
            if len(text)==2:
                record = guild.info(text[1])
                if record:
                    message = 'Information for %s:\n' %text[1]
                    message += 'Rank: %s\n'%record['Rank']
                    message += 'Status: %s\n'%record['Status']
                    message += 'Join date: %s\n'%record['Join_date']
                    if record['Demerits'] != '0':
                        message += 'Demerits: %s\n'%record['Demerits']
                    if record['Dues'] != '0':
                        message += 'Paid dues: %s\n'%Crossfire.CostStringFromValue(long(record['Dues']))
                else:
                    message =  '%s is not a member' %text[1]
            else:
                message = 'Usage "info <member_name>"'

        elif text[0] == 'remove':
            if len(text)==2:
                if guild.info(text[1]):
                    message = 'Removed %s from the guild' %text[1]
                    guild.remove_member(text[1])
                else:
                    message = '%s was not a member' %text[1]
            else:
                message = 'Usage "remove <member_name>"'
        elif text[0] == 'list':
            Crossfire.SetPlayerMessage('Who are the members?', 2)
            list = guild.list_members()

            message = '\nList of members:\n'
            for member in list:
                message += '%s (%s)\n'%(member, guild.info(member)['Rank'])
            message += 'Total members = ' + str(len(list))

        elif text[0] == 'promote':
            if len(text)==2:
                record = guild.info(text[1])
                if record:
                    if guild.promote_member(text[1]):
                        record = guild.info(text[1]) #refresh record
                        message = '%s promoted to %s' %(text[1], record['Rank'])
                    else:
                        message = 'You cannot promote %s' %text[1]
                else:
                    message = '%s is not a member' %text[1]
            else:
                message = 'Usage "promote <member_name>"'
        elif text[0] == 'demote':
            if len(text)==2:
                record = guild.info(text[1])
                if record:
                    if guild.demote_member(text[1]):
                        record = guild.info(text[1]) #refresh record
                        message = '%s demoted to %s' %(text[1], record['Rank'])
                    else:
                        message = 'You cannot demote %s' %text[1]
                else:
                    message = '%s is not a member' %text[1]
            else:
                message = 'Usage "demote <member_name>"'
        elif text[0] == 'status':
            record = guild.info(text[1])
            if record:
                if len(text)==3:
                    if guild.change_status(text[1],text[2]):
                        record = guild.info(text[1]) #refresh record
                        message = '%s now has status of %s' %(text[1], record['Status'])
                    else:
                        status = ', '.join(guild.status)
                        message = '%s is not a valid status, valid values are %s.' %(text[2],status)
                else:
                    status = ', '.join(guild.status)
                    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)
            else:
                message = '%s is not a member' %text[1]
        elif text[0] == 'add' and isDM:
            if len(text)==2:
                if log.info(text[1]):
                    if guild.info(text[1]):
                        message = '%s is already a member.' %text[1]
                    else:
                        #changed to support python 2.5                                                        guild.add_member(text[1], 'Initiate' if len(text)==2 else text[2])
                        guild.add_member(text[1], 'Initiate' )
                        message = 'Added %s to the guild' %text[1]
                else:
                    message = 'Sorry, I don\'t know any %s' %text[1]
            else:
                message = 'Usage "add <membername>"'
        elif text[0] == 'guildstatus' and isDM:
            record = guildhouse.info(guildname)
            if len(text)==2:
                if record:
                    if guildhouse.change_status(guildname,text[1]):
                        record = guildhouse.info(text[1]) #refresh record
                        message = '%s now has status of %s' %(guildname, record['Status'])
                    else:
                        message = '%s is not a valid status' %text[1]
                else:
                    message = '%s is not a guild' %guildname
            else:
                status = ", ".join(guildhouse.status)
                message = 'Current guild status is %s.\nTo change it use "guildstatus <status>" where status is one of %s' %(str(record['Status']),status)
        else:
            message = 'What did you need?'
    else:
        message = 'Board Error'
    whoami.Say(message)