Sha256: 071811465c9f6503f68969612278f6dacfaa6901f54934bd3a0f6fecd818dc8c
Contents?: true
Size: 1.91 KB
Versions: 2
Compression:
Stored size: 1.91 KB
Contents
def unique_items? false end # set card content based on array and save card # @param array [Array] list of strings/names (Cardish) def items= array self.content = array save! end # append item to list (does not save) # @param cardish [Cardish] def << cardish add_item cardish end # append item to list (does not save) # @param cardish [String, Card::Name] item name def add_item cardish self.content = item_strings + Array.wrap(cardish) end # append item to list and save card # @param name [String, Card::Name] item name def add_item! name add_item(name) && save! end # remove item from list # @param cardish [String, Card::Name] item to drop def drop_item cardish item_name = cardish.cardname self.content = (item_names.reject { |i| i == item_name }) end # remove item from list and save card # @param cardish [String, Card::Name] item to drop def drop_item! cardish drop_item cardish save! end # insert item into list at specified location # @param index [Integer] Array index in which to insert item (0 is first) # @param name [String, Card::Name] item name def insert_item index, name new_names = item_names new_names.delete name new_names.insert index, name self.content = new_names end # insert item into list at specified location and save # @param index [Integer] Array index in which to insert item (0 is first) # @param name [String, Card::Name] item name def insert_item! index, name insert_item index, name save! end def replace_item old, new return unless include_item? old drop_item old add_item new end def items_content array standardized_items(array).to_pointer_content end def standardized_items array array.map! { |i| standardize_item i }.reject!(&:blank?) array.uniq! if unique_items? array end def standardize_item item Card::Name[item] rescue Card::Error::NotFound item end def duplicate_item_names item_names.group_by { |e| e }.select { |_k, v| v.size > 1 }.keys end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
card-mod-collection-0.18.1 | set/all/item_assignment.rb |
card-mod-collection-0.18.0 | set/all/item_assignment.rb |