#include <stdio.h>

#define RACES 10 //10 races daily
#define MAX_HORSES 20 // Each race could have up to a max of 20 horses, each uniquely identified by the numbers 1 through 20
//Betting  amount limit per race:  minimum of $5 to a maximum of $1000
#define BET_MIN 5;
#define BET_MAX 1000;
#define GAINAMT_MUL_WIN 10; //*How much bet will be multiplied by if correctly guess a win
#define GAINAMT_MUL_PLACE 5; //*How much bet will be multiplied by if correctly guess a horse that places
#define GAINAMT_MUL_SHOW 3; //*How much bet will be multiplied by if correctly guess a horse that shows

//**************************************************************
// Function: myHorseBet
// 
// Purpose: calculate winnings associated with horse bet
// 
// Parameters:
//      myBet : structure that has information on the bet that I placed
//      theDailyResults: structure that has information on the daily race results
//     
//
// Returns: float with winnings associated with the bet
//  
//**************************************************************

// race results
struct raceResult
{
    int raceNumber;           // The unique Race Number
    int winningHorseNumber;   // 1st place horse number for the race
    int placeHorseNumber;     // 2nd place horse number for the race
    int showHorseNumber;      // 3rd place horse number for the race
};


// assume you can access this array that contains the results of horse races for a given day
struct raceResult theDailyResults[RACES];

// your specific race wager
struct raceWager
{
    int raceNumber;      // the race number where you bet your horse
    int myHorseNumber;   // the horse you bet on
    float myBetAmount;   // how much money you are betting
    char betType;        // W for "Win", P for "Place", or S for "Show"
};

// call this function and pass in your bet to see how much you won ... if you lost or there
// is an error Â in your wager info, it just returns zero
float myHorseBet (struct raceWager myBet, struct raceResult raceResult1){ /*Eventually, second argument will need to be array*/
    int winnings=0; //declaring and initializing integer variable for winnings
    if (myBet.raceNumber== raceResult1.raceNumber){ //checking if the race number associated with the bet is equal to the race number that have results for
        // if placed bet expecting the horse that bet on to win
        if (myBet.betType='W'){
            if (myBet.myHorseNumber==raceResult1.winningHorseNumber){// check if horse that expected to win actually did win
                winnings=myBet.myBetAmount*GAINAMT_MUL_WIN;
            } 
        }
        // if placed bet expecting the horse that bet on to place
        else if (myBet.betType='P'){
            if (myBet.myHorseNumber==raceResult1.placeHorseNumber ||myBet.myHorseNumber==raceResult1.winningHorseNumber){// check if horse that expected to place actually did place
                winnings=myBet.myBetAmount*GAINAMT_MUL_PLACE;
            } 
        }
        // if placed bet expecting the horse that bet on to show
        else if (myBet.betType='S'){
            if (myBet.myHorseNumber==raceResult1.showHorseNumber || myBet.myHorseNumber==raceResult1.placeHorseNumber ||myBet.myHorseNumber==raceResult1.winningHorseNumber){// check if horse that expected to show actually did show
                winnings=myBet.myBetAmount*GAINAMT_MUL_SHOW;
            } 
        }
    }
    return winnings;

}

int main() {
    struct raceWager raceWager1={1,1,5,'S'}; // bet on race 1, bet on horse 1, bet $5, bet on horse 1 placing 
    struct raceResult raceResult1={1,1,2,3}; //race 1, horse 1 won, horse 2 second, horse 3 third
    int winnings=myHorseBet(raceWager1,raceResult1);

    printf("Winnings: %i\n", winnings); 
    
	return 0;
}