Skip to content

Instantly share code, notes, and snippets.

@SamuXarick
Created January 24, 2023 21:12
Show Gist options
  • Save SamuXarick/f5bb4cde38780e7ce25df935d34f9231 to your computer and use it in GitHub Desktop.
Save SamuXarick/f5bb4cde38780e7ce25df935d34f9231 to your computer and use it in GitHub Desktop.
Is this gonna work?
/**
* Event Company Ask Merger, indicating a company can be bought (cheaply) by you.
* @api ai game
*/
class ScriptEventCompanyAskMerger : public ScriptEvent {
public:
/**
* @param owner The company that can be bought.
* @param value The value/costs of buying the company.
* @api -game
*/
ScriptEventCompanyAskMerger(Owner owner, int32 value) :
ScriptEvent(ET_COMPANY_ASK_MERGER),
owner((ScriptCompany::CompanyID)owner),
value(value)
{}
/**
* @param buyer The company that can purchase the other.
* @param owner The company that can be bought.
* @param value The value/costs of buying the company.
* @api -ai
*/
ScriptEventCompanyAskMerger(Owner buyer, Owner owner, int32 value) :
ScriptEvent(ET_COMPANY_ASK_MERGER),
buyer((ScriptCompany::CompanyID)buyer),
owner((ScriptCompany::CompanyID)owner),
value(value)
{}
/**
* Convert an ScriptEvent to the real instance.
* @param instance The instance to convert.
* @return The converted instance.
*/
static ScriptEventCompanyAskMerger *Convert(ScriptEvent *instance) { return (ScriptEventCompanyAskMerger *)instance; }
/**
* Get the CompanyID of the company that can purchase the other.
* @return The CompanyID of the company that can purchase.
* @note If the company is bought this will become invalid.
* @api -ai
*/
ScriptCompany::CompanyID GetBuyerID() { return this->buyer; }
/**
* Get the CompanyID of the company that can be bought.
* @return The CompanyID of the company that can be bought.
* @note If the company is bought this will become invalid.
*/
ScriptCompany::CompanyID GetCompanyID() { return this->owner; }
/**
* Get the value of the new company.
* @return The value of the new company.
*/
int32 GetValue() { return this->value; }
/**
* Take over the company for this merger.
* @return true if the merger was a success.
* @game @pre Valid ScriptCompanyMode active in scope.
*/
bool AcceptMerger();
private:
ScriptCompany::CompanyID buyer; ///< The company that is buying.
ScriptCompany::CompanyID owner; ///< The company that is in trouble.
int32 value; ///< The value of the company, i.e. the amount you would pay.
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment