mirror of
https://github.com/tstellar/bygfoot.git
synced 2025-01-31 07:54:50 +01:00
Star player balking.
This commit is contained in:
parent
f82150f793
commit
4f737b04b6
@ -527,6 +527,12 @@ callback_offer_new_contract(gint idx)
|
||||
game_gui_show_warning(_("The player won't negotiate with you anymore."));
|
||||
return;
|
||||
}
|
||||
else if(query_player_star_balks(pl, current_user.tm, FALSE))
|
||||
{
|
||||
pl->offers = const_int("int_contract_max_offers");
|
||||
game_gui_show_warning(_("The player feels he doesn't have a future in your star-studded team. He refuses to negotiate."));
|
||||
return;
|
||||
}
|
||||
|
||||
stat1 = player_assign_wage(pl);
|
||||
statp = (gpointer)pl;
|
||||
|
55
src/player.c
55
src/player.c
@ -1401,6 +1401,8 @@ player_move_from_ya(gint idx)
|
||||
Player *pl = &g_array_index(current_user.youth_academy.players, Player, idx);
|
||||
Player player = *pl;
|
||||
|
||||
player.contract = const_float("float_player_contract_youth");
|
||||
|
||||
g_array_remove_index(current_user.youth_academy.players, idx);
|
||||
g_array_append_val(current_user.tm->players, player);
|
||||
}
|
||||
@ -1426,3 +1428,56 @@ query_player_is_in_ya(const Player *pl)
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/** Find out if a star balks when offered a new or a renewed contract
|
||||
because there are already enough stars on the prospective new team. */
|
||||
gboolean
|
||||
query_player_star_balks(const Player *pl, const Team *tm, gboolean transfer)
|
||||
{
|
||||
gint i;
|
||||
gint number_of_stars_field;
|
||||
gint number_of_stars_goal;
|
||||
gfloat skill_limit;
|
||||
|
||||
/* Weak players never balk. */
|
||||
if(pl->skill < const_float("float_transfer_star_skill_limit"))
|
||||
return FALSE;
|
||||
|
||||
/* There is some chance that the new star doesn't balk at all. */
|
||||
if((transfer && math_rnd(0, 1) < const_float("float_transfer_star_no_balk")) ||
|
||||
(!transfer && math_rnd(0, 1) < const_float("float_contract_star_no_balk")))
|
||||
return FALSE;
|
||||
|
||||
/* Find out if there are any stars at all on the team. */
|
||||
number_of_stars_field =
|
||||
number_of_stars_goal = 0;
|
||||
skill_limit = (transfer ?
|
||||
const_float("float_transfer_star_skill_limit") :
|
||||
const_float("float_contract_star_skill_limit"));
|
||||
for(i = 0; i < tm->players->len; i++)
|
||||
{
|
||||
if(g_array_index(tm->players, Player, i).skill > skill_limit)
|
||||
{
|
||||
if(g_array_index(tm->players, Player, i).pos == PLAYER_POS_GOALIE)
|
||||
number_of_stars_goal++;
|
||||
else
|
||||
number_of_stars_field++;
|
||||
}
|
||||
}
|
||||
|
||||
if(pl->pos == PLAYER_POS_GOALIE)
|
||||
{
|
||||
if(number_of_stars_goal == 0)
|
||||
return FALSE;
|
||||
else
|
||||
return (math_rnd(0, 1) > const_float("float_transfer_star_goalie_accepts"));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(number_of_stars_field == 0)
|
||||
return FALSE;
|
||||
else
|
||||
return (math_rnd(0, 1) > 1 - number_of_stars_field *
|
||||
const_float("float_transfer_star_prob_decrease"));
|
||||
}
|
||||
}
|
||||
|
@ -183,4 +183,7 @@ player_update_streak(Player *pl);
|
||||
gboolean
|
||||
query_player_is_in_ya(const Player *pl);
|
||||
|
||||
gboolean
|
||||
query_player_star_balks(const Player *pl, const Team *tm, gboolean transfer);
|
||||
|
||||
#endif
|
||||
|
@ -248,6 +248,16 @@ transfer_evaluate_offers(void)
|
||||
player_of_id_team(trans(i).tm, trans(i).id)->name);
|
||||
transoff(i, j).status = TRANSFER_OFFER_REJECTED;
|
||||
}
|
||||
else if(query_player_star_balks(
|
||||
player_of_id_team(trans(i).tm, trans(i).id), transoff(i, j).tm, TRUE))
|
||||
{
|
||||
user_event_add(
|
||||
user_from_team(transoff(i, j).tm),
|
||||
EVENT_TYPE_TRANSFER_OFFER_REJECTED_STARS, -1, -1,
|
||||
trans(i).tm,
|
||||
player_of_id_team(trans(i).tm, trans(i).id)->name);
|
||||
transoff(i, j).status = TRANSFER_OFFER_REJECTED;
|
||||
}
|
||||
else
|
||||
notify = TRUE;
|
||||
}
|
||||
|
@ -525,6 +525,12 @@ user_event_show_next(void)
|
||||
event->value_string,
|
||||
((Team*)event->value_pointer)->name, buf2, buf3);
|
||||
break;
|
||||
case EVENT_TYPE_TRANSFER_OFFER_REJECTED_STARS:
|
||||
/* A player from a team has rejected a transfer offer. */
|
||||
game_gui_show_warning(_("%s of %s has rejected your offer because your team has too many star players already. 'A player of my caliber doesn't play second fiddle,' he was quoted."),
|
||||
event->value_string,
|
||||
((Team*)event->value_pointer)->name);
|
||||
break;
|
||||
case EVENT_TYPE_TRANSFER_OFFER_MONEY:
|
||||
/* Buy a player from a team. */
|
||||
game_gui_show_warning(_("You didn't have enough money to buy %s from %s."),
|
||||
|
@ -196,6 +196,7 @@ enum EventType
|
||||
EVENT_TYPE_TRANSFER_OFFER_REJECTED_FEE_WAGE,
|
||||
EVENT_TYPE_TRANSFER_OFFER_REJECTED_FEE,
|
||||
EVENT_TYPE_TRANSFER_OFFER_REJECTED_WAGE,
|
||||
EVENT_TYPE_TRANSFER_OFFER_REJECTED_STARS,
|
||||
EVENT_TYPE_TRANSFER_OFFER_MONEY,
|
||||
EVENT_TYPE_TRANSFER_OFFER_ROSTER,
|
||||
EVENT_TYPE_PLAYER_CAREER_STOP,
|
||||
|
Loading…
x
Reference in New Issue
Block a user