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