lib/gamefic/plot.rb in gamefic-0.0.3 vs lib/gamefic/plot.rb in gamefic-0.0.4
- old
+ new
@@ -134,15 +134,16 @@
if (@commands[action.command] == nil)
@commands[action.command] = Array.new
end
@commands[action.command].unshift action
@commands[action.command].sort! { |a, b|
- if a.specificity == b.specificity
- # For actions of the same length, creation order takes precedence
- 0
- else
- b.specificity <=> a.specificity
- end
+ if a.specificity == b.specificity
+ # Newer action takes precedence
+ b.order_key <=> a.order_key
+ else
+ # Higher specificity takes precedence
+ b.specificity <=> a.specificity
+ end
}
user_friendly = action.command.to_s.sub(/_/, ' ')
args = Array.new
used_names = Array.new
action.queries.each { |c|