hanafuda/field_multiplier.c
2025-02-26 20:05:31 -05:00

31 lines
1.4 KiB
C

// Copyright 2025 Bill Rossi
//
// This file is part of Hanafuda Hachi-Hachi.
//
// Hanafuda Hachi-Hachi is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
//
// Hanafuda Hachi-Hachi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with Hanafuda Hachi-Hachi. If not, see <https://www.gnu.org/licenses/>.
#include <stdbool.h>
#include "field_multiplier.h"
#include "card.h"
static FieldMultiplier small_field = { "Small Field", "", 1 };
static FieldMultiplier large_field = { "Large Field", "Score transfers are doubled", 2 };
static FieldMultiplier grand_field = { "Grand Field", "Score transfers are quadrupled" ,4 };
FieldMultiplier *calculate_field_multiplier(Hand *h) {
bool large = false;
for (int i = 0; i < h->count; i++) {
Card *c = h->cards[i];
if (c->index == CRANE_INDEX || c->index == CURTAIN_INDEX || c->index == MOON_INDEX)
large = true;
else if (c->index == RAINY_MAN_INDEX || c->index == PHOENIX_INDEX)
return &grand_field;
}
return large ? &large_field : &small_field;
}