compare.h

./lib/include/fn/compare.h · 747 B

From the archive h7v3.0a.tar.gz

Download the archive   « Back to the archive contents

#ifndef COMPARE_H
#define COMPARE_H

/***************************************************************************/
/* compare two skills */

object *compare(string my_skill, string their_skill, object *compare) { 
  if(!my_skill || !their_skill) return ({}); 
  if(!compare) compare = all_inventory(environment());
  return filter_array(compare,"comp",this_object(),({my_skill,their_skill,}));
}

static status comp(object ob, string *skills) {
  int my_skill, their_skill;

  if(!ob || ob == this_player()) return 0;
  my_skill = (int)call_other(this_player(), "query_"+skills[0]) + 1; 
  their_skill = (int)call_other(ob, "query_"+skills[1]) + 1;
  if(random(my_skill) < random(their_skill)) return 1;
  return 0;
} 

#endif /* end COMPARE_H */

Site Stats

Snippets: 1791
Codebases: 571