Commit | Line | Data |
---|---|---|
1304202a | 1 | #! /usr/bin/tclsh |
5a74fac2 MW |
2 | ### |
3 | ### Describe a particular world | |
4 | ### | |
5 | ### (c) 2003 Mark Wooding | |
6 | ### | |
7 | ||
8 | ###----- Licensing notice --------------------------------------------------- | |
9 | ### | |
10 | ### This program is free software; you can redistribute it and/or modify | |
11 | ### it under the terms of the GNU General Public License as published by | |
12 | ### the Free Software Foundation; either version 2 of the License, or | |
13 | ### (at your option) any later version. | |
14 | ### | |
15 | ### This program is distributed in the hope that it will be useful, | |
16 | ### but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | ### GNU General Public License for more details. | |
19 | ### | |
20 | ### You should have received a copy of the GNU General Public License | |
21 | ### along with this program; if not, write to the Free Software Foundation, | |
22 | ### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
1304202a | 23 | |
161e6ada | 24 | package require "elite" "1.0.1" |
1304202a | 25 | |
5a74fac2 MW |
26 | ###-------------------------------------------------------------------------- |
27 | ### Support functions. | |
28 | ||
1304202a | 29 | proc describe n { |
5a74fac2 MW |
30 | ## Describe the world with seed N. |
31 | ||
1304202a | 32 | global economy government |
5a74fac2 MW |
33 | |
34 | ## Fetch the necessary information. | |
1304202a | 35 | elite-worldinfo p $n |
5a74fac2 MW |
36 | |
37 | ## Format most of the data. | |
1304202a | 38 | puts "Name: $p(name)" |
665a500e | 39 | puts "Seed: $p(seed)" |
1304202a | 40 | puts "Position: $p(x), $p(y) LY" |
41 | puts "Economy: $economy($p(economy))" | |
42 | puts "Government: $government($p(government))" | |
43 | puts "Tech. level: $p(techlevel)" | |
44 | puts [format "Population: %s billion (%s)" \ | |
45 | [expr {$p(population)/10.0}] $p(inhabitants)] | |
46 | puts "Gross productivity: $p(productivity) M Cr" | |
47 | puts "Radius: $p(radius) km" | |
5a74fac2 MW |
48 | |
49 | ## Format the world description, word-wrapping as necessary. | |
1304202a | 50 | puts "" |
51 | set ll {} | |
52 | set l 0 | |
53 | foreach w $p(description) { | |
54 | incr l | |
55 | incr l [string length $w] | |
56 | if {$l > 72} { puts $ll; set ll {}; set l 0 } | |
57 | lappend ll $w | |
58 | } | |
59 | puts $ll | |
60 | } | |
61 | ||
5a74fac2 MW |
62 | ###-------------------------------------------------------------------------- |
63 | ### Main program. | |
64 | ||
65 | ## Parse the command line and describe the planets indicated. | |
1304202a | 66 | if {[llength $argv] < 1} { |
67 | puts stderr "usage: $argv0 \[-g GALAXY\] PLANET ..." | |
68 | exit 1 | |
69 | } | |
70 | set g $galaxy1 | |
71 | for {set i 0} {$i < [llength $argv]} {incr i} { | |
72 | set a [lindex $argv $i] | |
73 | switch -- $a { | |
74 | "-g" { | |
75 | incr i | |
76 | set a [lindex $argv $i] | |
77 | set g [parse-galaxy-spec $a] | |
78 | if {[string equal $g ""]} { | |
79 | puts stderr "$argv0: bad galaxy string `$a'" | |
80 | exit 1 | |
81 | } | |
82 | destructure {. g} $g | |
83 | } | |
84 | default { | |
85 | set n [parse-planet-spec $g $a] | |
86 | if {[string equal $n ""]} { | |
87 | puts stderr "$argv0: unknown planet `$a'" | |
88 | continue | |
89 | } | |
90 | describe $n | |
91 | puts "" | |
92 | } | |
93 | } | |
94 | } | |
5a74fac2 MW |
95 | |
96 | ###----- That's all, folks -------------------------------------------------- |