Crossfire Server, Trunk
castle_read.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 params = Crossfire.ScriptParameters()
25 Crossfire.SetReturnValue(1)
26 
27 nobledata = CFDataFile.CFData('scorn_nobility', ['rank', 'title'])
28 args = params.split()
29 targetrank = int(args[0])
30 suffix=""
31 prefix=""
32 if targetrank >= 90:
33  rankname = "Prince"
34  prefix = "His Royal Highness "
35 elif targetrank >= 80:
36  rankname = "Archduke"
37  prefix = "His Highness "
38 elif targetrank >= 70:
39  rankname = "Duke"
40  prefix = "His Grace "
41 elif targetrank >= 60:
42  rankname = "Count"
43  prefix = "His Excellency "
44 elif targetrank >= 50:
45  rankname = "Marquis"
46  prefix = "The Most Honourable "
47 elif targetrank >= 40:
48  rankname = "Earl"
49  prefix = "The Right Honourable "
50 elif targetrank >= 30:
51  rankname = "Baron"
52  prefix = "The Much Honoured "
53 elif targetrank >= 20:
54  rankname = "Baronet"
55  prefix = "Sir "
56  suffix = " Bt."
57 elif targetrank >= 10:
58  rankname = "Knight"
59  prefix = "Sir "
60 
61 player.Message("Herein are recorded those who have obtained the rank of " + rankname + " in the Kingdom of Scorn:")
62 playercount = 0
63 names = nobledata.get_keys()
64 names.sort(key = str.lower)
65 for noble in names :
66  record = nobledata.get_record(noble)
67  if int(record['rank']) == targetrank:
68  player.Message(prefix+noble+" "+record['title']+suffix)
69  playercount +=1
70 if playercount == 0:
71  player.Message("... The list is empty.")
CFDataFile.CFData
Definition: CFDataFile.py:94
make_face_from_files.int
int
Definition: make_face_from_files.py:26