void player_maritime_trade(gint player_num, gint ratio, Resource supply, Resource receive) { gchar *buf_give; gchar *buf_receive; gint resources[NO_RESOURCE]; gint idx; for (idx = 0; idx < NO_RESOURCE; ++idx) resources[idx] = 0; resources[supply] = ratio; resources[receive] = -1; modify_bank(resources); player_modify_statistic(player_num, STAT_RESOURCES, 1 - ratio); if (player_num == my_player_num()) { resource_modify(supply, -ratio); resource_modify(receive, 1); } buf_give = resource_cards(ratio, supply); buf_receive = resource_cards(1, receive); log_message(MSG_TRADE, _("%s exchanged %s for %s.\n"), player_name(player_num, TRUE), buf_give, buf_receive); g_free(buf_give); g_free(buf_receive); }
void monopoly_player(gint player_num, gint victim_num, gint num, Resource type) { gchar *buf; gchar *tmp; player_modify_statistic(player_num, STAT_RESOURCES, num); player_modify_statistic(victim_num, STAT_RESOURCES, -num); buf = resource_cards(num, type); if (player_num == my_player_num()) { /* I get the cards */ /* $1=resources, $2=player that loses resources */ log_message(MSG_STEAL, _("You get %s from %s.\n"), buf, player_name(victim_num, FALSE)); resource_modify(type, num); } else if (victim_num == my_player_num()) { /* I lose the cards */ /* $1=player that steals, $2=resources */ log_message(MSG_STEAL, _("%s took %s from you.\n"), player_name(player_num, TRUE), buf); resource_modify(type, -num); } else { /* I'm a bystander */ /* $1=player that steals, $2=resources, $3=player that loses resources */ tmp = g_strdup(player_name(player_num, TRUE)); log_message(MSG_STEAL, _("%s took %s from %s.\n"), tmp, buf, player_name(victim_num, FALSE)); g_free(tmp); } g_free(buf); }
void player_stole_from(gint player_num, gint victim_num, Resource resource) { player_modify_statistic(player_num, STAT_RESOURCES, 1); player_modify_statistic(victim_num, STAT_RESOURCES, -1); if (resource == NO_RESOURCE) { /* CHECK THIS: Since anonymous players (NULL) no longer exist, * player_name doesn't use its static buffer anymore, and * two calls can be safely combined. If not: ai/player.c should also be fixed */ /* FIXME: in the client, anonymous players can exist. * I prefer changing that instead of this function */ log_message(MSG_STEAL, /* We are not in on the action someone stole a resource from someone else */ _("%s stole a resource from %s.\n"), player_name(player_num, TRUE), player_name(victim_num, FALSE)); } else { gchar *buf; buf = resource_cards(1, resource); if (player_num == my_player_num()) { /* We stole a card :-) */ log_message(MSG_STEAL, _("You stole %s from %s.\n"), buf, player_name(victim_num, FALSE)); resource_modify(resource, 1); } else { /* Someone stole our card :-( */ log_message(MSG_STEAL, _("%s stole %s from you.\n"), player_name(player_num, TRUE), buf); resource_modify(resource, -1); } g_free(buf); } callbacks.player_robbed(player_num, victim_num, resource); }