1 // Copyright (C) 2008 Ben Asselstine
3 // This program is free software; you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation; either version 3 of the License, or
6 // (at your option) any later version.
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU Library General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 #include <sigc++/functors/mem_fun.h>
24 #include "GameScenarioOptions.h"
28 #define debug(x) {cerr<<__FILE__<<": "<<__LINE__<<": "<<x<<endl<<flush;}
31 bool GameScenarioOptions::s_see_opponents_stacks = false;
32 bool GameScenarioOptions::s_see_opponents_production = false;
33 GameParameters::QuestPolicy GameScenarioOptions::s_play_with_quests = GameParameters::ONE_QUEST_PER_PLAYER;
34 bool GameScenarioOptions::s_hidden_map = false;
35 bool GameScenarioOptions::s_diplomacy = false;
36 bool GameScenarioOptions::s_cusp_of_war = false;
37 GameParameters::NeutralCities GameScenarioOptions::s_neutral_cities = GameParameters::AVERAGE;
38 GameParameters::RazingCities GameScenarioOptions::s_razing_cities = GameParameters::ALWAYS;
39 bool GameScenarioOptions::s_intense_combat = false;
40 bool GameScenarioOptions::s_military_advisor = false;
41 bool GameScenarioOptions::s_random_turns = false;
42 bool GameScenarioOptions::s_surrender_already_offered = false;
43 unsigned int GameScenarioOptions::s_round = 0;
45 GameScenarioOptions::GameScenarioOptions()
50 GameScenarioOptions::~GameScenarioOptions()
54 int GameScenarioOptions::calculate_difficulty_rating(GameParameters g)
56 float total_difficulty = 0;
57 int max_player_difficulty = 73;
59 for (std::vector<GameParameters::Player>::iterator it = g.players.begin();
60 it != g.players.end(); it++)
62 if ((*it).type != GameParameters::Player::OFF)
66 int players_off = g.players.size() - players_on;
68 //find out how much each player is worth
69 float player_difficulty;
70 player_difficulty = (float) max_player_difficulty / (float) players_off;
72 player_difficulty = (float)max_player_difficulty / (float)players_on;
74 //go through all players, adding up difficulty points for each
75 for (std::vector<GameParameters::Player>::iterator i = g.players.begin();
76 i != g.players.end(); i++)
78 if ((*i).type == GameParameters::Player::HUMAN ||
79 ((*i).type == GameParameters::Player::HARD))
80 total_difficulty += player_difficulty;
81 else if ((*i).type == GameParameters::Player::EASY)
82 total_difficulty += player_difficulty;
83 //FIXME: when the hard player gets better, switch this.
84 //total_difficulty += (player_difficulty * 0.325);
85 //else if ((*i).type == GameParameters::Player::EASIER)
86 //total_difficulty += (player_difficulty * 0.655);
89 total_difficulty += (float) 3.0;
91 total_difficulty += (float) 3.0;
92 if (g.play_with_quests)
93 total_difficulty += (float) 3.0;
94 if (g.see_opponents_production == false)
95 total_difficulty += (float) 2.0;
96 if (g.see_opponents_stacks == false)
97 total_difficulty += (float) 2.0;
98 if (g.neutral_cities == GameParameters::STRONG)
99 total_difficulty += (float) 3.0;
100 else if (g.neutral_cities == GameParameters::ACTIVE)
101 total_difficulty += (float) 5.0;
102 else if (g.neutral_cities == GameParameters::DEFENSIVE)
103 total_difficulty += (float) 6.0;
104 if (g.razing_cities == GameParameters::ON_CAPTURE)
105 total_difficulty += (float) 3.0;
106 else if (g.razing_cities == GameParameters::NEVER)
107 total_difficulty += (float) 6.0;
108 if (g.cusp_of_war == true)
109 total_difficulty += (float) 2.0;
110 return (int) total_difficulty;