Switch to edit mode.
Name(s): add_feature1: "Copied from Generic player (#6):add_Feature by Hacker (#38) Aug 28 01:32:06 1997"
2: "Add a feature to this player's features list. Caller must be this or have suitable permissions (this or wizardly)."
3: "If this is a nonprogrammer, then ask feature if it is feature_ok (that is, if it has a verb :feature_ok which returns a true value, or a property .feature_ok which is true)."
4: "After adding feature, call feature:feature_add(this)."
5: "Returns true if successful, E_INVARG if not a valid object, and E_PERM if !feature_ok or if caller doesn't have permission."
6: if (caller == this || $perm_utils:controls(caller_perms(), this))
7: feature = args[1]
8: if (typeof(feature) != $obj || !valid(feature))
9: player:tell("odd. " + toliteral(args))
10: raise(E_INVARG, "Not a valid object")
11: endif
12: if (`$code_utils:verb_or_property(feature, "feature_ok", this) ! E_PROPNF')
13: "The object is willing to be a feature."
14: if (typeof(this.features) == $LIST)
15: "If list, we can simply setadd the feature."
16: if (length(args) > 1 && args[2])
17: this.features = $list_utils:remove_duplicates({feature, @this.features})
18: else
19: this.features = setadd(this.features, feature)
20: endif
21: else
22: "If not, we erase the old value and create a new list."
23: this.features = {feature}
24: endif
25: "Tell the feature it's just been added."
26: `feature:feature_add(this) ! E_VERBNF => 0'
27: return 1
28: "We're done."
29: else
30: return E_PERM
31: "Feature isn't feature_ok."
32: endif
33: else
34: return E_PERM
35: "Caller doesn't have permission."
36: endif
37: "Last modified by Dax (#789) on Mon Aug 7 21:47:23 2006 MDT."