Crossfire Server, Trunk
castle_write.py
Go to the documentation of this file.
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2010 The Crossfire Development Team
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 #
19 
20 import Crossfire
21 import CFDataFile
22 
23 player = Crossfire.WhoIsActivator()
24 
25 if type(player) == Crossfire.Player:
26  nobledata = CFDataFile.CFData('scorn_nobility', ['rank', 'title'])
27  currentstep = player.QuestGetState("scorn/Aristocracy")
28  currentrecord = { '#' : player.Name, 'rank' : currentstep, 'title' : player.Title }
29  lastrecord = nobledata.get_record(player.Name)
30  Crossfire.Log(Crossfire.LogDebug, "castle_write: previous record %s, new record %s." % (lastrecord, currentrecord))
31  if lastrecord == 0:
32  lastrecord = { '#' : player.Name, 'rank' : -10, 'title' : 'The Default' }
33  if (currentrecord['rank'] == 0) or (currentrecord['rank'] == int(lastrecord['rank']) and currentrecord['title'] == lastrecord['title']):
34  Crossfire.Log(Crossfire.LogDebug, "castle_write, no update needed for player %s." % player.Name)
35  else:
36  Crossfire.Log(Crossfire.LogDebug, "castle_write, updating player %s, old state %s, new state %d" %(player.Name, lastrecord['rank'], currentstep))
37  nobledata.put_record(currentrecord)
38  player.Message("The castle sage scribbles as you walk past")
CFDataFile.CFData
Definition: CFDataFile.py:94
make_face_from_files.int
int
Definition: make_face_from_files.py:32
is_valid_types_gen.type
list type
Definition: is_valid_types_gen.py:25