////////////////////////////////////////////////////////////////////////////// // // File : k_inc_pcontent.skrit // Author(s): Witness (Lisa Hui) // Purpose : utility functions for comparing (specifically, matching) pcontent // History : v1.0 [November 6, 2004] // //---------------------------------------------------------------------------- // Version: 1.0 Date: November 6, 2004 //---------------------------------------------------------------------------- ////////////////////////////////////////////////////////////////////////////// bool MatchPContent$( Go itemA$, Go itemB$ ) { if ( (itemA$ == NULL) || (itemB$ == NULL) ) { return false; } if ( !StringTool.SameNoCase( itemA$.TemplateName, itemB$.TemplateName ) ) { return false; } if ( itemA$.Gui.Variation != itemB$.Gui.Variation ) { return false; } if ( itemA$.HasMagic() ) { if ( !itemB$.HasMagic() ) { return false; } if ( itemA$.Magic.PrefixModifierName != itemB$.Magic.PrefixModifierName ) { return false; } if ( itemA$.Magic.SuffixModifierName != itemB$.Magic.SuffixModifierName ) { return false; } } else if ( itemB$.HasMagic() ) { return false; } return true; } //pcontent string must be ordered as :var/+prefix/+suffix, cannot interchange //prefix and suffix order! bool MatchPContentString$( Go item$, string pcontent$ ) { if ( item$ != NULL ) { string item_pcontent$ = ""; if ( item$.Gui.Variation != "" ) { StringTool.AppendF( item_pcontent$, ":%s", item$.Gui.Variation ); } if ( item$.HasMagic() ) { if ( item$.Magic.PrefixModifierName != "" ) { StringTool.AppendF( item_pcontent$, "/+%s", item$.Magic.PrefixModifierName ); } if ( item$.Magic.SuffixModifierName != "" ) { StringTool.AppendF( item_pcontent$, "/+%s", item$.Magic.SuffixModifierName ); } } if ( item_pcontent$ != "" ) { item_pcontent$ = MakeStringF( "#%s%s", item$.TemplateName, item_pcontent$ ); } else { item_pcontent$ = item$.TemplateName; } if ( StringTool.SameNoCase( item_pcontent$, pcontent$ ) ) { //report.screenf("MatchPContentString$ - pcontent matched (%s)",pcontent$); return true; } } return false; }