src/ai/api/ai_subsidy.hpp
branchnoai
changeset 10344 b7e9f5c65e30
child 10855 90904faa1890
equal deleted inserted replaced
10343:0ccd326f082e 10344:b7e9f5c65e30
       
     1 /* $Id$ */
       
     2 
       
     3 /** @file ai_subsidy.hpp Everything to query subsidies. */
       
     4 
       
     5 #ifndef AI_SUBSIDY_HPP
       
     6 #define AI_SUBSIDY_HPP
       
     7 
       
     8 #include "ai_object.hpp"
       
     9 #include "ai_company.hpp"
       
    10 
       
    11 /**
       
    12  * Class that handles all subsidy related functions.
       
    13  */
       
    14 class AISubsidy : public AIObject {
       
    15 public:
       
    16 	static const char *GetClassName() { return "AISubsidy"; }
       
    17 
       
    18 	/**
       
    19 	 * Check whether this is a valid SubsidyID.
       
    20 	 * @param subsidy_id The SubsidyID to check.
       
    21 	 * @return True if and only if this subsidy is still valid.
       
    22 	 */
       
    23 	static bool IsValidSubsidy(SubsidyID subsidy_id);
       
    24 
       
    25 	/**
       
    26 	 * Checks whether this subsidy is already awarded to some company.
       
    27 	 * @param subsidy_id The SubsidyID to check.
       
    28 	 * @pre IsValidSubsidy(subsidy).
       
    29 	 * @return True if and only if this subsidy is already awarded.
       
    30 	 */
       
    31 	static bool IsAwarded(SubsidyID subsidy_id);
       
    32 
       
    33 	/**
       
    34 	 * Get the company index of the company this subsidy is awarded to.
       
    35 	 * @param subsidy_id The SubsidyID to check.
       
    36 	 * @pre IsAwarded(subsidy_id).
       
    37 	 * @return The companyindex of the company this subsidy is awarded to.
       
    38 	 */
       
    39 	static AICompany::CompanyIndex GetAwardedTo(SubsidyID subsidy_id);
       
    40 
       
    41 	/**
       
    42 	 * Get the date this subsidy expires. In case the subsidy is already
       
    43 	 *  awarded, return the date the subsidy expires, else, return the date the
       
    44 	 *  offer expires.
       
    45 	 * @param subsidy_id The SubsidyID to check.
       
    46 	 * @pre IsValidSubsidy(subsidy_id).
       
    47 	 * @return The last valid date of this subsidy.
       
    48 	 * @note The return value of this function will change if the subsidy is
       
    49 	 *  awarded.
       
    50 	 */
       
    51 	static int32 GetExpireDate(SubsidyID subsidy_id);
       
    52 
       
    53 	/**
       
    54 	 * Get the cargo type that has to be transported in order to be awarded this
       
    55 	 *  subsidy.
       
    56 	 * @param subsidy_id The SubsidyID to check.
       
    57 	 * @pre IsValidSubsidy(subsidy_id).
       
    58 	 * @return The cargo type to transport.
       
    59 	 */
       
    60 	static CargoID GetCargoType(SubsidyID subsidy_id);
       
    61 
       
    62 	/**
       
    63 	 * Is the source of the subsidy a town or an industry.
       
    64 	 * @param subsidy_id The SubsidyID to check.
       
    65 	 * @pre IsValidSubsidy(subsidy_id) && !IsAwarded(subsidy_id).
       
    66 	 * @return True if the source is a town, false if it is an industry.
       
    67 	 */
       
    68 	static bool SourceIsTown(SubsidyID subsidy_id);
       
    69 
       
    70 	/**
       
    71 	 * Return the source TownID/IndustryID/StationID the subsidy is for.
       
    72 	 * 1) IsAwarded(subsidy_id) -> return the StationID the subsidy is awarded to.
       
    73 	 * 2) !IsAwarded(subsidy_id) && SourceIsTown(subsidy_id) -> return the TownID.
       
    74 	 * 3) !IsAwarded(subsidy_id) && !SourceIsTown(subsidy_id) -> return the IndustryID.
       
    75 	 * @param subsidy_id The SubsidyID to check.
       
    76 	 * @pre IsValidSubsidy(subsidy_id).
       
    77 	 * @return One of TownID/IndustryID/StationID.
       
    78 	 */
       
    79 	static int32 GetSource(SubsidyID subsidy_id);
       
    80 
       
    81 	/**
       
    82 	 * Is the destination of the subsidy a town or an industry.
       
    83 	 * @param subsidy_id The SubsidyID to check.
       
    84 	 * @pre IsValidSubsidy(subsidy_id) && !IsAwarded(subsidy_id).
       
    85 	 * @return True if the destination is a town, false if it is an industry.
       
    86 	 */
       
    87 	static bool DestinationIsTown(SubsidyID subsidy_id);
       
    88 
       
    89 	/**
       
    90 	 * Return the destination TownID/IndustryID/StationID the subsidy is for.
       
    91 	 * 1) IsAwarded(subsidy_id) -> return the StationID the subsidy is awarded to.
       
    92 	 * 2) !IsAwarded(subsidy_id) && SourceIsTown(subsidy_id) -> return the TownID.
       
    93 	 * 3) !IsAwarded(subsidy_id) && !SourceIsTown(subsidy_id) -> return the IndustryID.
       
    94 	 * @param subsidy_id the SubsidyID to check.
       
    95 	 * @pre IsValidSubsidy(subsidy_id).
       
    96 	 * @return One of TownID/IndustryID/StationID.
       
    97 	 */
       
    98 	static int32 GetDestination(SubsidyID subsidy_id);
       
    99 };
       
   100 
       
   101 #endif /* AI_SUBSIDY_HPP */