engine/XML/source/XMLTrapsReader.cpp
// Takes in the "Trap" node and sets the details
Takes in the "Trap" node and sets the details
Takes in the " Trap " node and sets the details
void XMLTrapsReader::parse_trap(const XMLNode& trap_node, TrapPtr trap)
{
  if (!trap_node.is_null() && trap != nullptr)
  {
    string trap_id = XMLUtils::get_attribute_value(trap_node, "id");
    string description_sid = XMLUtils::get_child_node_value(trap_node, "DescriptionSID");
    string trigger_message_sid = XMLUtils::get_child_node_value(trap_node, "TriggerMessageSID");
    string trigger_char = XMLUtils::get_child_node_value(trap_node, "TriggerSymbol");
    string player_damage_message_sid = XMLUtils::get_child_node_value(trap_node, "PlayerDamageMessageSID");
    Colour colour = static_cast<Colour>(XMLUtils::get_child_node_int_value(trap_node, "Colour"));
    string item_id = XMLUtils::get_child_node_value(trap_node, "Item");
    EffectType effect = static_cast<EffectType>(XMLUtils::get_child_node_int_value(trap_node, "Effect"));
    Damage dam;
    XMLNode damage_node = XMLUtils::get_next_element_by_local_name(trap_node, "Damage");
    parse_damage(dam, damage_node);
    XMLNode properties_node = XMLUtils::get_next_element_by_local_name(trap_node, "Properties");
    map<string, string> prop_map;
    parse_properties(prop_map, properties_node);
    trap->set_additional_properties(prop_map);
    int uses = XMLUtils::get_child_node_int_value(trap_node, "Uses", 1);
    trap->set_id(trap_id);
    trap->set_description_sid(description_sid);
    trap->set_trigger_message_sid(trigger_message_sid);
    if (!trigger_char.empty())
    {
      trap->set_trigger_symbol(trigger_char.at(0));
    }
    trap->set_player_damage_message_sid(player_damage_message_sid);
    trap->set_colour(colour);
    trap->set_item_id(item_id);
    trap->set_damage(dam);
    trap->set_effect(effect);
    trap->set_uses(uses);
  }
}
void XMLTrapsReader :: parse_trap ( const XMLNode & trap_node , TrapPtr trap ) { if ( ! trap_node . is_null ( ) && trap != nullptr ) { string trap_id = XMLUtils :: get_attribute_value ( trap_node , " " ) ; string description_sid = XMLUtils :: get_child_node_value ( trap_node , " " ) ; string trigger_message_sid = XMLUtils :: get_child_node_value ( trap_node , " " ) ; string trigger_char = XMLUtils :: get_child_node_value ( trap_node , " " ) ; string player_damage_message_sid = XMLUtils :: get_child_node_value ( trap_node , " " ) ; Colour colour = static_cast < Colour > ( XMLUtils :: get_child_node_int_value ( trap_node , " " ) ) ; string item_id = XMLUtils :: get_child_node_value ( trap_node , " " ) ; EffectType effect = static_cast < EffectType > ( XMLUtils :: get_child_node_int_value ( trap_node , " " ) ) ; Damage dam ; XMLNode damage_node = XMLUtils :: get_next_element_by_local_name ( trap_node , " " ) ; parse_damage ( dam , damage_node ) ; XMLNode properties_node = XMLUtils :: get_next_element_by_local_name ( trap_node , " " ) ; map < string , string > prop_map ; parse_properties ( prop_map , properties_node ) ; trap -> set_additional_properties ( prop_map ) ; int uses = XMLUtils :: get_child_node_int_value ( trap_node , " " , 1 ) ; trap -> set_id ( trap_id ) ; trap -> set_description_sid ( description_sid ) ; trap -> set_trigger_message_sid ( trigger_message_sid ) ; if ( ! trigger_char . empty ( ) ) { trap -> set_trigger_symbol ( trigger_char . at ( 0 ) ) ; } trap -> set_player_damage_message_sid ( player_damage_message_sid ) ; trap -> set_colour ( colour ) ; trap -> set_item_id ( item_id ) ; trap -> set_damage ( dam ) ; trap -> set_effect ( effect ) ; trap -> set_uses ( uses ) ; } }
Takes in the "Trap" node and sets the details
Takes in the " Trap " node and sets the details