Skip to content

Commit

Permalink
Fix gift cost scaling
Browse files Browse the repository at this point in the history
It no longers increases part of the gift cost which scales with your
salary, which lead to gift costs being impossible to satisfy
  • Loading branch information
Keriew committed Sep 1, 2024
1 parent 5010688 commit 19aad70
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
15 changes: 12 additions & 3 deletions src/city/emperor.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@

static const int SALARY_PERCENTAGE_FOR_RANK[11] = {0, 2, 5, 8, 12, 20, 30, 40, 60, 80, 100};

static const struct {
int base;
int savings_divisor ;
} GIFT_DATA[GIFT_MAX] = {
{20, 8},
{50, 4},
{100, 2}
};

static int cheated_invasion = 0;

void city_emperor_init_scenario(int rank)
Expand Down Expand Up @@ -207,9 +216,9 @@ int city_emperor_can_send_gift(int size)
void city_emperor_calculate_gift_costs(void)
{
int savings = city_data.emperor.personal_savings;
city_data.emperor.gifts[GIFT_MODEST].cost = calc_adjust_with_percentage(savings / 8 + 20, city_data.emperor.caesar_salary);
city_data.emperor.gifts[GIFT_GENEROUS].cost = calc_adjust_with_percentage(savings / 4 + 50, city_data.emperor.caesar_salary);
city_data.emperor.gifts[GIFT_LAVISH].cost = calc_adjust_with_percentage(savings / 2 + 100, city_data.emperor.caesar_salary);
city_data.emperor.gifts[GIFT_MODEST].cost = savings/ GIFT_DATA[GIFT_MODEST].savings_divisor + calc_adjust_with_percentage(GIFT_DATA[GIFT_MODEST].base, city_data.emperor.caesar_salary);
city_data.emperor.gifts[GIFT_GENEROUS].cost = savings / GIFT_DATA[GIFT_GENEROUS].savings_divisor + calc_adjust_with_percentage(GIFT_DATA[GIFT_GENEROUS].base, city_data.emperor.caesar_salary);
city_data.emperor.gifts[GIFT_LAVISH].cost = savings / GIFT_DATA[GIFT_LAVISH].savings_divisor + calc_adjust_with_percentage(GIFT_DATA[GIFT_LAVISH].base, city_data.emperor.caesar_salary);
}

void city_emperor_send_gift(void)
Expand Down
3 changes: 2 additions & 1 deletion src/city/emperor.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
enum {
GIFT_MODEST = 0,
GIFT_GENEROUS = 1,
GIFT_LAVISH = 2
GIFT_LAVISH = 2,
GIFT_MAX = 3,
};

typedef struct {
Expand Down

0 comments on commit 19aad70

Please sign in to comment.