TODO format
[aymargeddon/current.git] / src / FROGS / Config.pm
1 ##########################################################################
2 #
3 #   Copyright (c) 2003 Aymargeddon Development Team
4 #
5 #   This file is part of "Last days of Aymargeddon"
6 #
7 #   Aymargeddon is free software; you can redistribute it and/or modify it
8 #   under the terms of the GNU General Public License as published by the Free
9 #   Software Foundation; either version 2 of the License, or (at your option)
10 #   any later version.
11 #
12 #   Aymargeddon is distributed in the hope that it will be useful, but WITHOUT
13 #   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 #   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
15 #   more details.
16 #   You should have received a copy of the GNU General Public License along
17 #   with this program; if not, write to the Free Software Foundation, Inc., 675
18 #   Mass Ave, Cambridge, MA 02139, USA.
19 #
20 ###########################################################################
21 #
22
23 # TODO: seperate FROGS-config from Aymargeddon-config in different files
24
25 # change this file to configure your game
26
27 use strict;
28 package Config;
29 require Exporter;
30 @::ISA = qw(Exporter);
31 @::EXPORT_OK = qw($conf);
32
33 $::conf = {
34            # FROGS stuff
35            -DB_SOURCE => 'mysql:RAGNAROEK',
36            -DB_USER => 'aymargeddon',
37            -DB_SECRETS => '/home/benni/aymargeddon/current/+secrets',
38            -COMMANDS => 'AymCommand.pm',
39            -GAME_NAME => 'Aymargeddon',
40            -DEFAULT_LANGUAGE => 'EN',
41            -LOG_TIME_IN_LOOP => 1000, # loops until next time output in log
42            -DEBUG => 1,
43            -EPL_DEBUG => 0,
44            -MESSAGE_IN_LOG => 0,
45            -FULL_DEBUG_FILE => '/home/benni/aymargeddon/current/src/FROGS/+out',
46            -SCHEDULER_SLEEP => 2,
47            -DELETE_OLD_EVENTS => 1, # dont touch this, it will not work!
48            -DELETE_OLD_COMMANDS => 1, # dont touch this, it will not work!
49            -SEND_MESSAGE_TO_FIELD => 1, # set to 0 to stop slow messages
50            -MAX_ARGS => 4, # maximum arguments for localisation tags
51                            # (hardcoded in database-structure)
52            -MANY => 99999,
53
54            # Aymargeddon stuff... you maybe dont need this for other games
55
56            -START_MANA => 33,
57            -START_FORTUNE => 3,
58            -START_WARRIORS => 2,
59            -MAX_MOUNTAINS => 1, # mountains per god/earthling-combination
60            -MIN_DISTANCE_HOME => 3, # minimal distance between homecitys
61            -NEIGHBOUR_CITIES => 2, # number of citys in the neighbourhood of a home
62            -MIN_DISTANCE_MOUNTAIN => 2,
63            -WANTED_DISTANCE_MOUNTAIN => 3,
64            -MIN_DISTANCE_MOUNTAIN_FROM_WATER => 2,
65            -MIN_LUCK => 3,
66            -MAX_LUCK => 12,
67            -MANA_FOR_TEMPLE => 1,
68            -FORTUNE_FAKTOR_ISLAND => 1,
69            -FORTUNE_FAKTOR_MOUNTAIN => 2,
70            -MAX_UNBUILD_DESTROY => 1,
71            # -ARK_RETREAT_POSSIBILITY => 0.5, (in the moment hardcoded)
72            -WINNER_DEATH_COUNT_FRACTION => 5,
73            -LOOSER_DEATH_COUNT_FRACTION => 3,
74            -WINNER_AVATARS_DYING_FRACTION => 4,
75            -LOOSER_AVATARS_DYING_FRACTION => 2,
76            -DEATH_SHARE_ROW => [0.4, 0.3, 0.2, 0.1], # should sum to 1
77            -DEFAULT_DYING => 'KHP',
78
79            -PLAGUES => ['INFLUENZA','PESTILENTIA','TUBERCULOSIS'],
80            -PESTILENTIA_DEATH_SHARE => 0.5,
81            -SPREAD_PLAGUE => {'CITY' => 0.1,
82                               'PLAIN' => 0.05,
83                               'MOUNTAIN' => 0.03,
84                               'ISLE' => 0.02,
85                               'WATER' => 0},
86            -HEAL_PLAGUE => 0.4,
87
88            # can gods give earthlings right to see?
89            -GODS_SHOW_EARTHLINGS => 0,
90
91            # which fields keep there owner without units?
92            -HOMECITY_KEEP_OWNER => 1,
93            -TEMPLE_KEEP_OWNER => 1,
94            -KEEP_OWNER => {'CITY' => 1},
95
96            # which fields fight without owner?
97            -FIGHTS_WITHOUT_OWNER => {'CITY' => 1},
98
99            # which fields fights without units?
100            #-HOMECITY_FIGHTS => 1,
101            #-FIGHTS_WITHOUT_UNIT => {'CITY' => 1},
102
103            -DURATION => {
104
105                          -MOVE_AVATAR => 1,
106                          -MOVE_HERO => 8,
107                          -MOVE_WARRIOR => 10,
108                          -MOVE_PRIEST => 6,
109                          # -MOVE_PROPHET => 6, # 12
110                          -MOVE_ARK => 5,
111                          -FIGHT_EARTHLING => 6,
112                          -FIGHT_GOD => 10, #10
113                          -BUILD_TEMPLE => 3, # 50
114                          -FLOOD => 40, # 40
115                          -CH_ADORING => 20,
116                          -CH_LUCK => 5,
117                          -PRODUCE_WARRIOR => 40, # 40
118                          -PRODUCE_WARRIOR_HOME => 20, # 20
119                          -PRODUCE_WARRIOR_CHANGE => 0,
120                          -PRODUCE_PRIEST => 40, # 40
121                          -PRODUCE_PRIEST_HOME => 40, # 40
122                          -BUILD_ARK => 30, #30
123                          -PLAGUE => 20,
124                          -PRAY => 10, # 10
125                         },
126
127            -FIGHT => {
128                       -PRIEST => 0,
129                       -WARRIOR => 1,
130                       -HERO => 2,
131                       -PROPHET => 0,
132                       -AVATAR => 4, # maximum
133                       -HOME => 2,
134                       -ISLE => 2,
135                       -ARK => 1,
136                       -FLANKING => 1,
137                      },
138            #-SEE_FIGHT => {
139            #              -PRIEST => 0,
140            #      -WARRIOR => 0,
141            #  -HERO => 1,
142            # -PROPHET => 0,
143            #-AVATAR => 0,
144            #-HOME => 0,
145            #-ARK => 3,
146            #-FLANKING => 0,
147            #},
148            # -ISLAND_FIGHT => {
149            #              -PRIEST => 0,
150            #      -WARRIOR => 1,
151            #  -HERO => 2,
152            # -PROPHET => 0,
153            #-AVATAR => 4, # maximum
154            #-HOME => 2,
155            #-ARK => 3,
156            #-FLANKING => 0,
157            #},
158
159            -LAST_BATTLE => {
160                             -DEATH_HERO => 1,
161                             -DEATH_AVATAR => 0,
162                             -AVATAR => 7,
163                            },
164            -MANA => {
165                      -MOVE_AVATAR => 1,
166                      -FIGHT_AVATAR => 2,
167                      -DESTROY => 7,
168                      -FLOOD => 4,
169                      -CH_LUCK => 1,
170                      -BUILD_ARK => 7,
171                      -BLESS_PRIEST => 7,
172                      -BLESS_HERO => 2,
173                      -INCARNATE => 5,
174                      # plagues:
175                      -INFLUENZA => 10,
176                      -PESTILENTIA => 20,
177                      -TUBERCULOSIS => 40,
178                     },
179
180            -COLOR => {
181                       -EMPTY => '#fcffd9',
182                       -NEUTRAL => '#b8a266',
183                      },
184           };
185
186 # read password from secrets-file. password should not be included in source!
187
188 my $conf = $::conf->{-DB_SECRETS};
189
190 # substitute "~" (UNIX only!) from Perl Cookbook 7.3 not really useful
191 # here, because HOME is different in webserver and in user context
192 $conf  =~ s{ ^ ~ ( [^/]* ) }{ $1 ? (getpwnam($1))[7] : ($ENV{HOME}||$ENV{LOGDIR}||
193                                                         (getpwuid($<))[7])}ex;
194
195 open(CONFIG,$conf) or die "could not open config file $conf: $!\n";
196
197 while(<CONFIG>){
198   chop $_;
199   next if /^\s*$/;
200   next if /^\s*\#.*$/;
201   $::conf->{-DB_PASSWD} = $_;
202 }
203 close CONFIG or die "could not close config file $conf: $!\n";
204
205 1;
206