virtual void Decide(const DataObject &input, DataObject &output) { // There are two conditions that must be met in order for a player to // be allowed to build a knight: // // 1) They must have the resources to activate a knight. // 2) They must have at least one inactive knight on the board // // None of these conditions can be affected by other rulesets. bool can = false; wxInt32 trades = 0; // Condition 1. RULE.Decide(shLogicCanPurchaseActivateKnight, input, output); wxASSERT(2 <= output.numItems()); if(true == output.read<bool>()) { trades = output.read<wxInt32>(1); // Condition 2. output.reset(); RULE.Decide(shLogicCanPlaceActivateKnight, input, output); can = (false == output.read<PlayerGame::CornerObjectArray>().empty()); } output = DataObject(can, trades); }
virtual void Decide(const DataObject &input, DataObject &output) { // There are three conditions that must be met in order for a player to // be allowed to build a road: // // 1) They must have at least one road in stock. // 2) They must have the resources to purchase a road. // 3) They must have a location on the board to place the road. // // Condition 1 is static and cannot be affected by any other rulesets. // Condition 2 may be affected by other rulesets (i.e. Road Building // card). // Condition 3 may be affected by other rulesets (i.e. Seafarers). bool canBuild = false; wxInt32 trades = 0; // Condition 1. if(0 < playerGameData<wxInt32>(shStockRoads)) { // Condition 2. RULE.Decide(shLogicCanPurchaseRoad, input, output); wxASSERT(2 <= output.numItems()); if(true == output.read<bool>()) { trades = output.read<wxInt32>(1); // Condition 3. output.reset(); RULE.Decide(shLogicCanPlaceRoad, input, output); typedef std::pair<wxInt32, wxInt32> TileSide; typedef std::set<TileSide> TileSideSet; canBuild = (false == output.read<TileSideSet>().empty()); } } output = DataObject(canBuild, trades); }