def __init__(self, guildname): self.guildname = guildname guildheader = ['Join_date', 'Rank', 'Status', 'Dues', 'Demerits', 'Quest_points'] self.ranks=['Initiate', 'Novice', 'Guildman', 'Journeyman', 'Master', 'GuildMaster'] self.status=['suspended', 'probation', 'good'] self.duescap = 1000000 #arbitrary limit on dues (if you change it remember it currently is an int) self.demeritcap = 100 #arbitrary limit on demerits self.qpcap = 100 guild_name = '%s_log' %self.guildname self.guildlist = CFData(guild_name, guildheader)
def __init__(self): logheader = [ 'Born', 'IP', 'Last_Login_Date', 'Login_Count', 'Kick_Count', 'Last_Kick_Date', 'Muzzle_Count', 'Last_Muzzle_Date' ] self.log = CFData('Player_log', logheader)
class CFLog: def __init__(self): logheader = [ 'Born', 'IP', 'Last_Login_Date', 'Login_Count', 'Kick_Count', 'Last_Kick_Date', 'Muzzle_Count', 'Last_Muzzle_Date' ] self.log = CFData('Player_log', logheader) def create(self, name): date = strftime("%a, %d %b %Y %H:%M:%S %Z", localtime(time())) record = { '#': name, 'Born': date, 'IP': 'unknown', 'Last_Login_Date': date, 'Login_Count': 0, 'Kick_Count': 0, 'Last_Kick_Date': 'never', 'Muzzle_Count': 0, 'Last_Muzzle_Date': 'never' } self.log.put_record(record) def remove(self, name): self.log.remove_record(name) def login_update(self, name, ip): date = strftime("%a, %d %b %Y %H:%M:%S %Z", localtime(time())) record = self.log.get_record(name) record['IP'] = ip record['Last_Login_Date'] = date record['Login_Count'] = int(record['Login_Count']) + 1 self.log.put_record(record) def kick_update(self, name): date = strftime("%a, %d %b %Y %H:%M:%S %Z", localtime(time())) record = self.log.get_record(name) record['Kick_Count'] = int(record['Kick_Count']) + 1 record['Last_Kick_Date'] = date self.log.put_record(record) def muzzle_update(self, name): date = strftime("%a, %d %b %Y %H:%M:%S %Z", localtime(time())) record = self.log.get_record(name) record['Muzzle_Count'] = int(record['Muzzle_Count']) + 1 record['Last_Muzzle_Date'] = date self.log.put_record(record) def info(self, name): if name == '#': return 0 record = self.log.get_record(name) if record: return record else: return 0
def player_set_status(uses): header = ['uses'] data = CFData('Scorn_HouseOfHealing', header) record = {'#': player.Name, 'uses': uses} data.put_record(record)
def player_status(): header = ['uses'] data = CFData('Scorn_HouseOfHealing', header) if data.exist(player.Name): return int(data.get_record(player.Name)['uses']) return 0
# For any other item, the player is added to the list, with her title. If the event # object itself has a message, it will be displayed to the player if she is added # to the list. # # The script's parameters is the internal name of the quest. import Crossfire from CFDataFile import CFData player = Crossfire.WhoIsActivator() me = Crossfire.WhoAmI() event = Crossfire.WhatIsEvent() name = 'hall_of_fame_' + Crossfire.ScriptParameters() header = ['title'] file = CFData(name, header) if me.Type == Crossfire.Type.SIGN: message = me.Message + "\n" keys = file.get_keys() for name in keys: message = message + name + " " + file.get_record(name)['title'] + "\n" if len(keys) == 0: message = message + "No one is recorded, will you attempt to be the first?" player.Write(message) Crossfire.SetReturnValue(1) else: record = file.get_record(player.Name) if record == 0: file.put_record({'#': player.Name, 'title': player.Title}) if event.Message != None:
def __init__(self): guildhousesheader= ['Founded_Date', 'Points', 'Status', 'Quest_points'] self.status=['active', 'suspended', 'probation', 'inactive'] self.guildhouselist = CFData('GuildHouses_log', guildhousesheader) self.pointscap = 2000000000 self.qpcap = 2000000000
class CFGuildHouses: '''Inter-Guild management class - loads guild from GuildList''' def __init__(self): guildhousesheader= ['Founded_Date', 'Points', 'Status', 'Quest_points'] self.status=['active', 'suspended', 'probation', 'inactive'] self.guildhouselist = CFData('GuildHouses_log', guildhousesheader) self.pointscap = 2000000000 self.qpcap = 2000000000 def info(self, name): record = self.guildhouselist.get_record(name) if record: return record else: return 0 def list_guilds(self): return self.guildhouselist.get_keys() def add_guild(self, name): record={'#' : name ,'Founded_Date' : 'never' ,'Points' : 0 ,'Status' : 'inactive' ,'Quest_points': 0 } try: self.guildhouselist.put_record(record) return 1 except: return 0 def establish(self, name): record = self.info(name) date = strftime("%a, %d %b %Y", localtime(time())) if record: record['Founded_Date'] = date record['Status'] = 'active' self.guildhouselist.put_record(record) return 1 else: return 0 def change_status(self, name, status): record = self.info(name) if record: if self.status.count(status) != 0: record['Status'] = status self.guildhouselist.put_record(record) return 1 else: return 0 else: return 0 def add_questpoints(self, name, number): record = self.info(name) if record: temp = int(record['Quest_points']) if temp + number >= self.qpcap: temp = self.qpcap else: temp = temp + number record['Quest_points'] = temp self.guildhouselist.put_record(record) return 1 else: return 0 def update_points(self, name, number): record = self.info(name) if record: temp = int(record['Points']) if temp + number >= self.pointscap: temp = self.pointscap else: temp = temp + number record['Points'] = temp self.guildhouselist.put_record(record) return 1 else: return 0
class CFGuild: def __init__(self, guildname): self.guildname = guildname guildheader = ['Join_date', 'Rank', 'Status', 'Dues', 'Demerits', 'Quest_points'] self.ranks=['Initiate', 'Novice', 'Guildman', 'Journeyman', 'Master', 'GuildMaster'] self.status=['suspended', 'probation', 'good'] self.duescap = 1000000 #arbitrary limit on dues (if you change it remember it currently is an int) self.demeritcap = 100 #arbitrary limit on demerits self.qpcap = 100 guild_name = '%s_log' %self.guildname self.guildlist = CFData(guild_name, guildheader) def add_member(self, name, rank): date = strftime("%a, %d %b %Y", localtime(time())) record={'#' : name ,'Join_date' : date ,'Rank' : rank ,'Status' : 'good' ,'Dues' : 0 ,'Demerits' : 0 ,'Quest_points': 0 } try: self.guildlist.put_record(record) return 1 except: return 0 def remove_member(self, name): try: self.guildlist.remove_record(name) return 1 except: return 0 def info(self, name): record = self.guildlist.get_record(name) if record: return record else: return 0 def list_members(self): return self.guildlist.get_keys() def count_members(self): number = len(self.guildlist.get_keys()) return number def add_demerits(self, name, number): record = self.info(name) if record: temp = int(record['Demerits']) if temp + number >= self.demeritcap: temp = self.demeritcap else: temp = temp + number record['Demerits'] = temp self.guildlist.put_record(record) return 1 else: return 0 def remove_demerits(self, name, number): record = self.info(name) if record: temp = int(record['Demerits']) if temp - number <=0: temp = 0 else: temp = temp - number record['Demerits'] = temp self.guildlist.put_record(record) return 1 else: return 0 def add_questpoints(self, name, number): record = self.info(name) if record: temp = int(record['Quest_points']) if temp + number >= self.qpcap: temp = self.qpcap else: temp = temp + number record['Quest_points'] = temp self.guildlist.put_record(record) return 1 else: return 0 def pay_dues(self, name, number): record = self.info(name) if record: temp = int(record['Dues']) if temp + number >= self.duescap: temp = self.duescap else: temp = temp + number record['Dues'] = temp self.guildlist.put_record(record) # add points to the guild record CFGuildHouses().update_points(self.guildname,number) return 1 else: return 0 def clear_dues(self, name, number): record = self.info(name) if record: record['Dues'] = 0 self.guildlist.put_record(record) return 1 else: return 0 def change_status(self, name, status): record = self.info(name) if record: if self.status.count(status) != 0: record['Status'] = status self.guildlist.put_record(record) return 1 else: return 0 else: return 0 def promote_member(self, name): record = self.info(name) if record: currentrank = record['Rank'] if currentrank != 'GuildMaster': ranknum = self.ranks.index(currentrank) newrank = ranknum+1 record['Rank'] = self.ranks[newrank] self.guildlist.put_record(record) return 1 else: return 0 else: return 0 def demote_member(self, name): record = self.info(name) if record: currentrank = record['Rank'] if currentrank != 'Initiate': ranknum = self.ranks.index(currentrank) Crossfire.Log(Crossfire.LogDebug, "ranknum = %d"%ranknum) newrank = ranknum-1 record['Rank'] = self.ranks[newrank] self.guildlist.put_record(record) return 1 else: return 0 else: return 0