Star player balking.

This commit is contained in:
gyboth 2008-05-02 13:00:05 +00:00
parent 491ac8c785
commit 13c13850c8
8 changed files with 596 additions and 579 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,106 +1,108 @@
/* /*
bet_struct.h bet_struct.h
Bygfoot Football Manager -- a small and simple GTK2-based Bygfoot Football Manager -- a small and simple GTK2-based
football management game. football management game.
http://bygfoot.sourceforge.net http://bygfoot.sourceforge.net
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com) Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
#include "enums.h" #include "enums.h"
#include "finance.h"
#include "glib.h" #include "glib.h"
#include "option.h"
#include "training.h" #include "training.h"
#include "player.h" #include "player.h"
void void
calculateTrainingCamp(Team *current_team, calculateTrainingCamp(Team *current_team,
gdouble value_training, gdouble value_training,
gdouble value_recreation, gdouble value_recreation,
gint number_camp) gint number_camp)
{ {
gint count, i; gint count, i;
Player *player; Player *player;
gfloat skill_points=0.0; gfloat skill_points=0.0;
gfloat fitness_points=0.0; gfloat fitness_points=0.0;
gint recovery_points=0; gint recovery_points=0;
for (count=0; count<current_team->players->len; count++) for (count=0; count<current_team->players->len; count++)
{
player = &g_array_index(current_team->players, Player, count);
if (((value_training>0) || (value_recreation>0)) && (player->health == 0))
{ {
player = &g_array_index(current_team->players, Player, count); skill_points=calculate_skill_points((gint) value_training,
number_camp,
if (((value_training>0) || (value_recreation>0)) && (player->health == 0)) player->age,
{ player->fitness,
skill_points=calculate_skill_points((gint) value_training, player->lsu);
number_camp,
player->age,
player->fitness,
player->lsu);
fitness_points=calculate_fitness_points((gint) value_training, fitness_points=calculate_fitness_points((gint) value_training,
(gint) value_recreation, (gint) value_recreation,
number_camp, number_camp,
player->age); player->age);
recovery_points=0; recovery_points=0;
}
else
{
recovery_points = calculate_recovery_points((gint) value_recreation,
number_camp,
player->age);
skill_points=0.0;
fitness_points=0.0;
}
//Set new values
if ((player->health > 0) && (player->recovery > 0))
{
//Health & recovery
player->recovery -= recovery_points;
}
else
{
//Skill
if ((player->skill+skill_points) <= (player->talent-2))
{
player->skill += skill_points;
player->lsu = 0;
// Functions which are called during a skill-update by player_update_skill() in player.c
player->cskill = player_get_cskill(player, player->cpos, TRUE);
player->value = player_assign_value(player);
for(i=0; i<QUALITY_END; i++)
if(player->skill > player->etal[i])
{
player_estimate_talent(player);
break;
}
}
//Fitness
player->fitness -= fitness_points;
if (player->fitness > 1)
player->fitness = 1;
else if (player->fitness < 0)
player->fitness = 0;
}
} }
else
{
recovery_points = calculate_recovery_points((gint) value_recreation,
number_camp,
player->age);
skill_points=0.0;
fitness_points=0.0;
}
//Set new values
if ((player->health > 0) && (player->recovery > 0))
{
//Health & recovery
player->recovery -= recovery_points;
}
else
{
//Skill
if ((player->skill+skill_points) <= (player->talent-2))
{
player->skill += skill_points;
player->lsu = 0;
// Functions which are called during a skill-update by player_update_skill() in player.c
player->cskill = player_get_cskill(player, player->cpos, TRUE);
player->value = player_assign_value(player);
for(i=0; i<QUALITY_END; i++)
if(player->skill > player->etal[i])
{
player_estimate_talent(player);
break;
}
}
//Fitness
player->fitness -= fitness_points;
if (player->fitness > 1)
player->fitness = 1;
else if (player->fitness < 0)
player->fitness = 0;
}
}
} }
gfloat gfloat
@ -110,110 +112,110 @@ calculate_skill_points(gint value_training,
gfloat fitness, gfloat fitness,
gfloat lsu) gfloat lsu)
{ {
gint training_points=0; gint training_points=0;
gfloat skill_points=0.0; gfloat skill_points=0.0;
gint random=0; gint random=0;
//Calculat training points -> age //Calculat training points -> age
if (age < 20) if (age < 20)
training_points += 4; training_points += 4;
else if (age < 25) else if (age < 25)
training_points += 3; training_points += 3;
else if (age < 30) else if (age < 30)
training_points += 2; training_points += 2;
else else
training_points += 1; training_points += 1;
//Calculat training points -> fittness //Calculat training points -> fittness
if (fitness > 0.75) if (fitness > 0.75)
training_points += 4; training_points += 4;
else if (fitness > 0.50) else if (fitness > 0.50)
training_points += 3; training_points += 3;
else if (fitness > 0.25) else if (fitness > 0.25)
training_points += 2; training_points += 2;
else else
training_points += 1; training_points += 1;
//Calculat training points -> lsu //Calculat training points -> lsu
if (lsu > 15) if (lsu > 15)
training_points += 4; training_points += 4;
else if (lsu > 10) else if (lsu > 10)
training_points += 3; training_points += 3;
else if (lsu > 5) else if (lsu > 5)
training_points += 2; training_points += 2;
else else
training_points += 1; training_points += 1;
//Calculate skill points //Calculate skill points
random = random_int(1, 3); random = random_int(1, 3);
skill_points = training_points - random; skill_points = training_points - random;
if (skill_points == 0) if (skill_points == 0)
return skill_points; return skill_points;
else else
{ {
skill_points = skill_points * value_training * number_camp / 100.0; skill_points = skill_points * value_training * number_camp / 100.0;
return skill_points; return skill_points;
} }
} }
gfloat gfloat
calculate_fitness_points(gint value_training, calculate_fitness_points(gint value_training,
gint value_recreation, gint value_recreation,
gint number_camp, gint number_camp,
gfloat age) gfloat age)
{ {
gint training_points=0; gint training_points=0;
gfloat fitness_points=0.0; gfloat fitness_points=0.0;
gint random=0; gint random=0;
if (value_recreation > 8) if (value_recreation > 8)
{
if (value_recreation == 9)
{ {
if (value_recreation == 9) //Calculate fitness points
{ random = random_int(1, 2);
//Calculate fitness points fitness_points = ((0.02 * number_camp) + (random / 100.0)) * -1;
random = random_int(1, 2);
fitness_points = ((0.02 * number_camp) + (random / 100.0)) * -1;
}
else
{
//Calculate fitness points
random = random_int(1, 2);
fitness_points = ((0.04 * number_camp) + (random / 100.0)) * -1;
}
} }
else else
{ {
//Calculat fitness points -> age //Calculate fitness points
if (age < 20) random = random_int(1, 2);
training_points += 1; fitness_points = ((0.04 * number_camp) + (random / 100.0)) * -1;
else if (age < 25) }
training_points += 2; }
else if (age < 30) else
training_points += 3; {
else //Calculat fitness points -> age
training_points += 4; if (age < 20)
training_points += 1;
else if (age < 25)
training_points += 2;
else if (age < 30)
training_points += 3;
else
training_points += 4;
//Calculat fitness points -> value training //Calculat fitness points -> value training
switch (value_training) switch (value_training)
{ {
case 2: training_points += 1; break; case 2: training_points += 1; break;
case 3: training_points += 1; break; case 3: training_points += 1; break;
case 4: training_points += 2; break; case 4: training_points += 2; break;
case 5: training_points += 2; break; case 5: training_points += 2; break;
case 6: training_points += 3; break; case 6: training_points += 3; break;
case 7: training_points += 3; break; case 7: training_points += 3; break;
case 8: training_points += 4; break; case 8: training_points += 4; break;
case 9: training_points += 4; break; case 9: training_points += 4; break;
case 10: training_points += 5; break; case 10: training_points += 5; break;
}
//Calculate fitness points
random = random_int(1, 2);
fitness_points = (((gfloat) training_points + random) / number_camp) / 100;
} }
return fitness_points; //Calculate fitness points
random = random_int(1, 2);
fitness_points = (((gfloat) training_points + random) / number_camp) / 100;
}
return fitness_points;
} }
@ -222,66 +224,61 @@ calculate_recovery_points(gint value_recreation,
gint number_camp, gint number_camp,
gfloat age) gfloat age)
{ {
gint training_points=0; gint training_points=0;
gint recovery_points=0; gint recovery_points=0;
gint random=0; gint random=0;
//Calculat recovery points -> age //Calculat recovery points -> age
if (age < 20) if (age < 20)
training_points += 4; training_points += 4;
else if (age < 25) else if (age < 25)
training_points += 3; training_points += 3;
else if (age < 30) else if (age < 30)
training_points += 2; training_points += 2;
else else
training_points += 1; training_points += 1;
//Calculat recovery points -> recreation //Calculat recovery points -> recreation
switch (value_recreation) switch (value_recreation)
{ {
case 10: training_points += 4; break; case 10: training_points += 4; break;
case 9: training_points += 3; break; case 9: training_points += 3; break;
case 8: training_points += 2; break; case 8: training_points += 2; break;
case 7: training_points += 1; break; case 7: training_points += 1; break;
} }
//Calculate recreation points //Calculate recreation points
random = random_int(1, 2); random = random_int(1, 2);
recovery_points = (training_points + random) * number_camp; recovery_points = (training_points + random) * number_camp;
if (recovery_points > 17) if (recovery_points > 17)
return 1; return 1;
else else
return 0; return 0;
} }
gint gint
random_int(gint min, gint max) random_int(gint min, gint max)
{ {
gint random=0; gint random=0;
GRand *grand = NULL; GRand *grand = NULL;
grand = g_rand_new (); grand = g_rand_new ();
random = (gint) g_rand_int_range(grand, min, max+1); //random() works until max -1 random = (gint) g_rand_int_range(grand, min, max+1); //random() works until max -1
return random; return random;
} }
void void
calculateCostsTrainingCamp(gint number_camp) calculateCostsTrainingCamp(gint number_camp)
{ {
gint *money_out = current_user.money_out[0]; gint *money_out = current_user.money_out[0];
gint *money = &current_user.money; gint *money = &current_user.money;
gfloat factor = finance_wage_unit(current_user.tm);
switch (number_camp) gint costs[3] = {factor * const_float("float_training_camp_factor1"),
{ factor * const_float("float_training_camp_factor2"),
case 1: money_out[MON_OUT_TRAINING_CAMP] -= COSTS_CAMP_1; factor * const_float("float_training_camp_factor2")};
*money -= COSTS_CAMP_1;
break; money_out[MON_OUT_TRAINING_CAMP] -= costs[number_camp - 1];
case 2: money_out[MON_OUT_TRAINING_CAMP] -= COSTS_CAMP_2; *money -= costs[number_camp - 1];
*money -= COSTS_CAMP_2;
break;
case 3: money_out[MON_OUT_TRAINING_CAMP] -= COSTS_CAMP_3;
*money -= COSTS_CAMP_3;
break;
}
} }

View File

@ -1,26 +1,26 @@
/* /*
bet_struct.h bet_struct.h
Bygfoot Football Manager -- a small and simple GTK2-based Bygfoot Football Manager -- a small and simple GTK2-based
football management game. football management game.
http://bygfoot.sourceforge.net http://bygfoot.sourceforge.net
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com) Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
@ -30,7 +30,11 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "bygfoot.h" #include "bygfoot.h"
#include "finance.h"
#include "game_gui.h" #include "game_gui.h"
#include "option.h"
#include "maths.h"
#include "misc.h"
#include "support.h" #include "support.h"
#include "training.h" #include "training.h"
#include "training_callbacks.h" #include "training_callbacks.h"
@ -45,66 +49,68 @@ void
on_b_cancel_clicked (GtkButton *button, on_b_cancel_clicked (GtkButton *button,
gpointer user_data) gpointer user_data)
{ {
window_destroy(&window.training_camp); window_destroy(&window.training_camp);
} }
void void
on_b_ok_clicked (GtkButton *button, on_b_ok_clicked (GtkButton *button,
gpointer user_data) gpointer user_data)
{ {
GtkWidget *rb_camp1; GtkWidget *rb_camp1;
GtkWidget *rb_camp2; GtkWidget *rb_camp2;
GtkHScale *hs_recreation; GtkHScale *hs_recreation;
GtkHScale *hs_training; GtkHScale *hs_training;
gdouble value_training; gdouble value_training;
gdouble value_recreation; gdouble value_recreation;
gint number_camp; gint number_camp;
Team *current_team = current_user.tm; Team *current_team = current_user.tm;
//Get active radio //Get active radio
rb_camp1 = GTK_WIDGET(lookup_widget(window.training_camp, "rb_camp1")); rb_camp1 = GTK_WIDGET(lookup_widget(window.training_camp, "rb_camp1"));
rb_camp2 = GTK_WIDGET(lookup_widget(window.training_camp, "rb_camp2")); rb_camp2 = GTK_WIDGET(lookup_widget(window.training_camp, "rb_camp2"));
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(rb_camp1))) if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(rb_camp1)))
number_camp = 1; number_camp = 1;
else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(rb_camp2))) else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(rb_camp2)))
number_camp = 2; number_camp = 2;
else else
number_camp = 3; number_camp = 3;
//Get values for training and recreation //Get values for training and recreation
hs_recreation = GTK_HSCALE(lookup_widget(window.training_camp, "hs_recreation")); hs_recreation = GTK_HSCALE(lookup_widget(window.training_camp, "hs_recreation"));
hs_training = GTK_HSCALE(lookup_widget(window.training_camp, "hs_training")); hs_training = GTK_HSCALE(lookup_widget(window.training_camp, "hs_training"));
value_training = gtk_range_get_value(GTK_RANGE(hs_training)); value_training = gtk_range_get_value(GTK_RANGE(hs_training));
value_recreation = gtk_range_get_value(GTK_RANGE(hs_recreation)); value_recreation = gtk_range_get_value(GTK_RANGE(hs_recreation));
//Calculate training camp //Calculate training camp
calculateTrainingCamp(current_team, value_training, value_recreation, number_camp); calculateTrainingCamp(current_team, value_training, value_recreation, number_camp);
//Set new av-values -> GUI //Set new av-values -> GUI
game_gui_write_av_skills(current_team); game_gui_write_av_skills(current_team);
//Set new player values in GUI //Set new player values in GUI
treeview_show_user_player_list(); treeview_show_user_player_list();
//Calculate costs of the training camp //Calculate costs of the training camp
calculateCostsTrainingCamp(number_camp); calculateCostsTrainingCamp(number_camp);
//Set new av-values -> GUI //Set new av-values -> GUI
game_gui_write_money(); game_gui_write_money();
window_destroy(&window.training_camp); window_destroy(&window.training_camp);
} }
void void
on_rb_camp3_clicked (GtkButton *button, on_rb_camp3_clicked (GtkButton *button,
gpointer user_data) gpointer user_data)
{ {
GtkEntry *tfCosts; GtkEntry *tfCosts;
gchar buf[SMALL]; gchar buf[SMALL];
sprintf(buf, "%d", COSTS_CAMP_3); misc_print_grouped_int(
tfCosts = GTK_ENTRY(lookup_widget(window.training_camp, "tf_costs")); math_round_integer(finance_wage_unit(current_user.tm) * const_float("float_training_camp_factor3"), -2),
buf);
tfCosts = GTK_ENTRY(lookup_widget(window.training_camp, "tf_costs"));
gtk_entry_set_text (tfCosts, buf); gtk_entry_set_text (tfCosts, buf);
} }
@ -113,24 +119,28 @@ void
on_rb_camp2_clicked (GtkButton *button, on_rb_camp2_clicked (GtkButton *button,
gpointer user_data) gpointer user_data)
{ {
GtkEntry *tfCosts; GtkEntry *tfCosts;
gchar buf[SMALL]; gchar buf[SMALL];
sprintf(buf, "%d", COSTS_CAMP_2); misc_print_grouped_int(
tfCosts = GTK_ENTRY(lookup_widget(window.training_camp, "tf_costs")); math_round_integer(finance_wage_unit(current_user.tm) * const_float("float_training_camp_factor2"), -2),
buf);
tfCosts = GTK_ENTRY(lookup_widget(window.training_camp, "tf_costs"));
gtk_entry_set_text (tfCosts, buf); gtk_entry_set_text (tfCosts, buf);
} }
void void
on_rb_camp1_clicked (GtkButton *button, on_rb_camp1_clicked (GtkButton *button,
gpointer user_data) gpointer user_data)
{ {
GtkEntry *tfCosts; GtkEntry *tfCosts;
gchar buf[SMALL]; gchar buf[SMALL];
sprintf(buf, "%d", COSTS_CAMP_1); misc_print_grouped_int(
tfCosts = GTK_ENTRY(lookup_widget(window.training_camp, "tf_costs")); math_round_integer(finance_wage_unit(current_user.tm) * const_float("float_training_camp_factor1"), -2),
buf);
tfCosts = GTK_ENTRY(lookup_widget(window.training_camp, "tf_costs"));
gtk_entry_set_text (tfCosts, buf); gtk_entry_set_text (tfCosts, buf);
} }
@ -138,23 +148,23 @@ void
on_b_dec_recreation_clicked (GtkButton *button, on_b_dec_recreation_clicked (GtkButton *button,
gpointer user_data) gpointer user_data)
{ {
GtkHScale *hs_camp_points; GtkHScale *hs_camp_points;
GtkHScale *hs_recreation; GtkHScale *hs_recreation;
gdouble value_camp_points; gdouble value_camp_points;
gdouble value_recreation; gdouble value_recreation;
hs_camp_points = GTK_HSCALE(lookup_widget(window.training_camp, "hs_camp_points")); hs_camp_points = GTK_HSCALE(lookup_widget(window.training_camp, "hs_camp_points"));
hs_recreation = GTK_HSCALE(lookup_widget(window.training_camp, "hs_recreation")); hs_recreation = GTK_HSCALE(lookup_widget(window.training_camp, "hs_recreation"));
value_camp_points = gtk_range_get_value(GTK_RANGE(hs_camp_points)); value_camp_points = gtk_range_get_value(GTK_RANGE(hs_camp_points));
value_recreation = gtk_range_get_value(GTK_RANGE(hs_recreation)); value_recreation = gtk_range_get_value(GTK_RANGE(hs_recreation));
if (value_recreation > CAMP_SCALE_MIN) if (value_recreation > CAMP_SCALE_MIN)
{ {
value_recreation --; value_recreation --;
value_camp_points ++; value_camp_points ++;
gtk_range_set_value(GTK_RANGE(hs_recreation), value_recreation); gtk_range_set_value(GTK_RANGE(hs_recreation), value_recreation);
gtk_range_set_value(GTK_RANGE(hs_camp_points), value_camp_points); gtk_range_set_value(GTK_RANGE(hs_camp_points), value_camp_points);
} }
} }
@ -162,23 +172,23 @@ void
on_b_inc_recreation_clicked (GtkButton *button, on_b_inc_recreation_clicked (GtkButton *button,
gpointer user_data) gpointer user_data)
{ {
GtkHScale *hs_camp_points; GtkHScale *hs_camp_points;
GtkHScale *hs_recreation; GtkHScale *hs_recreation;
gdouble value_camp_points; gdouble value_camp_points;
gdouble value_recreation; gdouble value_recreation;
hs_camp_points = GTK_HSCALE(lookup_widget(window.training_camp, "hs_camp_points")); hs_camp_points = GTK_HSCALE(lookup_widget(window.training_camp, "hs_camp_points"));
hs_recreation = GTK_HSCALE(lookup_widget(window.training_camp, "hs_recreation")); hs_recreation = GTK_HSCALE(lookup_widget(window.training_camp, "hs_recreation"));
value_camp_points = gtk_range_get_value(GTK_RANGE(hs_camp_points)); value_camp_points = gtk_range_get_value(GTK_RANGE(hs_camp_points));
value_recreation = gtk_range_get_value(GTK_RANGE(hs_recreation)); value_recreation = gtk_range_get_value(GTK_RANGE(hs_recreation));
if (value_camp_points > CAMP_SCALE_MIN) if (value_camp_points > CAMP_SCALE_MIN)
{ {
value_recreation ++; value_recreation ++;
value_camp_points --; value_camp_points --;
gtk_range_set_value(GTK_RANGE(hs_recreation), value_recreation); gtk_range_set_value(GTK_RANGE(hs_recreation), value_recreation);
gtk_range_set_value(GTK_RANGE(hs_camp_points), value_camp_points); gtk_range_set_value(GTK_RANGE(hs_camp_points), value_camp_points);
} }
} }
@ -186,23 +196,23 @@ void
on_b_dec_training_clicked (GtkButton *button, on_b_dec_training_clicked (GtkButton *button,
gpointer user_data) gpointer user_data)
{ {
GtkHScale *hs_camp_points; GtkHScale *hs_camp_points;
GtkHScale *hs_training; GtkHScale *hs_training;
gdouble value_camp_points; gdouble value_camp_points;
gdouble value_training; gdouble value_training;
hs_camp_points = GTK_HSCALE(lookup_widget(window.training_camp, "hs_camp_points")); hs_camp_points = GTK_HSCALE(lookup_widget(window.training_camp, "hs_camp_points"));
hs_training = GTK_HSCALE(lookup_widget(window.training_camp, "hs_training")); hs_training = GTK_HSCALE(lookup_widget(window.training_camp, "hs_training"));
value_camp_points = gtk_range_get_value(GTK_RANGE(hs_camp_points)); value_camp_points = gtk_range_get_value(GTK_RANGE(hs_camp_points));
value_training = gtk_range_get_value(GTK_RANGE(hs_training)); value_training = gtk_range_get_value(GTK_RANGE(hs_training));
if (value_training > CAMP_SCALE_MIN) if (value_training > CAMP_SCALE_MIN)
{ {
value_training --; value_training --;
value_camp_points ++; value_camp_points ++;
gtk_range_set_value(GTK_RANGE(hs_training), value_training); gtk_range_set_value(GTK_RANGE(hs_training), value_training);
gtk_range_set_value(GTK_RANGE(hs_camp_points), value_camp_points); gtk_range_set_value(GTK_RANGE(hs_camp_points), value_camp_points);
} }
} }
@ -210,23 +220,23 @@ void
on_b_inc_training_clicked (GtkButton *button, on_b_inc_training_clicked (GtkButton *button,
gpointer user_data) gpointer user_data)
{ {
GtkHScale *hs_camp_points; GtkHScale *hs_camp_points;
GtkHScale *hs_training; GtkHScale *hs_training;
gdouble value_camp_points; gdouble value_camp_points;
gdouble value_training; gdouble value_training;
hs_camp_points = GTK_HSCALE(lookup_widget(window.training_camp, "hs_camp_points")); hs_camp_points = GTK_HSCALE(lookup_widget(window.training_camp, "hs_camp_points"));
hs_training = GTK_HSCALE(lookup_widget(window.training_camp, "hs_training")); hs_training = GTK_HSCALE(lookup_widget(window.training_camp, "hs_training"));
value_camp_points = gtk_range_get_value(GTK_RANGE(hs_camp_points)); value_camp_points = gtk_range_get_value(GTK_RANGE(hs_camp_points));
value_training = gtk_range_get_value(GTK_RANGE(hs_training)); value_training = gtk_range_get_value(GTK_RANGE(hs_training));
if (value_camp_points > CAMP_SCALE_MIN) if (value_camp_points > CAMP_SCALE_MIN)
{ {
value_training ++; value_training ++;
value_camp_points --; value_camp_points --;
gtk_range_set_value(GTK_RANGE(hs_training), value_training); gtk_range_set_value(GTK_RANGE(hs_training), value_training);
gtk_range_set_value(GTK_RANGE(hs_camp_points), value_camp_points); gtk_range_set_value(GTK_RANGE(hs_camp_points), value_camp_points);
} }
} }
@ -239,4 +249,3 @@ on_window_training_camp_delete_event (GtkWidget *widget,
return TRUE; return TRUE;
} }

View File

@ -66,3 +66,7 @@ gboolean
on_window_training_camp_delete_event (GtkWidget *widget, on_window_training_camp_delete_event (GtkWidget *widget,
GdkEvent *event, GdkEvent *event,
gpointer user_data); gpointer user_data);
void
on_hs_recreation_value_changed (GtkRange *range,
gpointer user_data);

View File

@ -51,10 +51,10 @@ create_window_training_camp (void)
GtkWidget *image4; GtkWidget *image4;
GtkWidget *hs_camp_points; GtkWidget *hs_camp_points;
GtkWidget *hs_training; GtkWidget *hs_training;
GtkWidget *hs_recreation;
GtkWidget *b_dec_recreation; GtkWidget *b_dec_recreation;
GtkWidget *image1; GtkWidget *image1;
GtkWidget *rb_camp1; GtkWidget *rb_camp1;
GtkWidget *hs_recreation;
window_training_camp = gtk_window_new (GTK_WINDOW_TOPLEVEL); window_training_camp = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window_training_camp), _("Training camp")); gtk_window_set_title (GTK_WINDOW (window_training_camp), _("Training camp"));
@ -171,13 +171,6 @@ create_window_training_camp (void)
GTK_WIDGET_UNSET_FLAGS (hs_training, GTK_CAN_FOCUS); GTK_WIDGET_UNSET_FLAGS (hs_training, GTK_CAN_FOCUS);
gtk_scale_set_value_pos (GTK_SCALE (hs_training), GTK_POS_RIGHT); gtk_scale_set_value_pos (GTK_SCALE (hs_training), GTK_POS_RIGHT);
hs_recreation = gtk_hscale_new (GTK_ADJUSTMENT (gtk_adjustment_new (0, 1, 10, 1, 0, 0)));
gtk_widget_show (hs_recreation);
gtk_fixed_put (GTK_FIXED (panel_camp), hs_recreation, 220, 120);
gtk_widget_set_size_request (hs_recreation, 200, 36);
GTK_WIDGET_UNSET_FLAGS (hs_recreation, GTK_CAN_FOCUS);
gtk_scale_set_value_pos (GTK_SCALE (hs_recreation), GTK_POS_RIGHT);
b_dec_recreation = gtk_button_new (); b_dec_recreation = gtk_button_new ();
gtk_widget_show (b_dec_recreation); gtk_widget_show (b_dec_recreation);
gtk_fixed_put (GTK_FIXED (panel_camp), b_dec_recreation, 176, 125); gtk_fixed_put (GTK_FIXED (panel_camp), b_dec_recreation, 176, 125);
@ -194,6 +187,13 @@ create_window_training_camp (void)
gtk_radio_button_set_group (GTK_RADIO_BUTTON (rb_camp1), rb_camp2_group); gtk_radio_button_set_group (GTK_RADIO_BUTTON (rb_camp1), rb_camp2_group);
rb_camp2_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (rb_camp1)); rb_camp2_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (rb_camp1));
hs_recreation = gtk_hscale_new (GTK_ADJUSTMENT (gtk_adjustment_new (0, 1, 10, 1, 0, 0)));
gtk_widget_show (hs_recreation);
gtk_fixed_put (GTK_FIXED (panel_camp), hs_recreation, 220, 120);
gtk_widget_set_size_request (hs_recreation, 200, 36);
GTK_WIDGET_UNSET_FLAGS (hs_recreation, GTK_CAN_FOCUS);
gtk_scale_set_value_pos (GTK_SCALE (hs_recreation), GTK_POS_RIGHT);
g_signal_connect ((gpointer) window_training_camp, "delete_event", g_signal_connect ((gpointer) window_training_camp, "delete_event",
G_CALLBACK (on_window_training_camp_delete_event), G_CALLBACK (on_window_training_camp_delete_event),
NULL); NULL);
@ -247,10 +247,10 @@ create_window_training_camp (void)
GLADE_HOOKUP_OBJECT (window_training_camp, image4, "image4"); GLADE_HOOKUP_OBJECT (window_training_camp, image4, "image4");
GLADE_HOOKUP_OBJECT (window_training_camp, hs_camp_points, "hs_camp_points"); GLADE_HOOKUP_OBJECT (window_training_camp, hs_camp_points, "hs_camp_points");
GLADE_HOOKUP_OBJECT (window_training_camp, hs_training, "hs_training"); GLADE_HOOKUP_OBJECT (window_training_camp, hs_training, "hs_training");
GLADE_HOOKUP_OBJECT (window_training_camp, hs_recreation, "hs_recreation");
GLADE_HOOKUP_OBJECT (window_training_camp, b_dec_recreation, "b_dec_recreation"); GLADE_HOOKUP_OBJECT (window_training_camp, b_dec_recreation, "b_dec_recreation");
GLADE_HOOKUP_OBJECT (window_training_camp, image1, "image1"); GLADE_HOOKUP_OBJECT (window_training_camp, image1, "image1");
GLADE_HOOKUP_OBJECT (window_training_camp, rb_camp1, "rb_camp1"); GLADE_HOOKUP_OBJECT (window_training_camp, rb_camp1, "rb_camp1");
GLADE_HOOKUP_OBJECT (window_training_camp, hs_recreation, "hs_recreation");
gtk_widget_grab_focus (rb_camp1); gtk_widget_grab_focus (rb_camp1);
return window_training_camp; return window_training_camp;

View File

@ -28,10 +28,6 @@
#include "bygfoot.h" #include "bygfoot.h"
#define COSTS_CAMP_1 200000
#define COSTS_CAMP_2 400000
#define COSTS_CAMP_3 600000
#define CAMP_SCALE_MIN 0 #define CAMP_SCALE_MIN 0
#define CAMP_SCALE_MAX 10 #define CAMP_SCALE_MAX 10
#define CAMP_SCALE_STEP 1 #define CAMP_SCALE_STEP 1

View File

@ -38,6 +38,7 @@
#include "load_save.h" #include "load_save.h"
#include "main.h" #include "main.h"
#include "maths.h" #include "maths.h"
#include "misc.h"
#include "misc_callback_func.h" #include "misc_callback_func.h"
#include "misc_interface.h" #include "misc_interface.h"
#include "misc2_interface.h" #include "misc2_interface.h"
@ -941,7 +942,9 @@ window_show_training_camp(void)
window_create(WINDOW_TRAINING_CAMP); window_create(WINDOW_TRAINING_CAMP);
// Initialize entry costs // Initialize entry costs
sprintf(buf, "%d", COSTS_CAMP_1); misc_print_grouped_int(
math_round_integer(finance_wage_unit(current_user.tm) * const_float("float_training_camp_factor1"), -2),
buf);
tfCosts = GTK_ENTRY(lookup_widget(window.training_camp, "tf_costs")); tfCosts = GTK_ENTRY(lookup_widget(window.training_camp, "tf_costs"));
gtk_entry_set_text (tfCosts, buf); gtk_entry_set_text (tfCosts, buf);

View File

@ -976,3 +976,8 @@ float_transfer_star_prob_decrease 15000
# probability of a star goalie accepting if there's # probability of a star goalie accepting if there's
# already one present # already one present
float_transfer_star_goalie_accepts 12000 float_transfer_star_goalie_accepts 12000
# wage unit factors for training camp hotel
float_training_camp_factor1 500000
float_training_camp_factor2 1000000
float_training_camp_factor3 1500000