Item 'Rarity' Column

Forum
Last Post
Threads / Messages

Kyttias

Super Moderator
Super Mod
Joined
Jan 26, 2014
Messages
849
Points
18
Mysidian Dollar
58,199
I'd like to add a column to the item table in the database, and make sure its included properly in places like class_item.php, so it can be rendered in shop and inventory pages. It also needs to be included in the admin back end when an item is created.

So~ just how many pages will I need to be editing/how painful is this going to be? :coloness: Should I just basically be imitating how categories are done?

The rarity will initially be used as a visual indicator of how potent or costly the item is. Later, when I make a system that will dispense random items from a specific category, the rarity will determine the percent chance you will end up having that random item dispensed.

-

In phpMyAdmin, I already added the column to the database with -
Code:
ALTER TABLE `adopts_items` ADD `rarity` VARCHAR(40) NOT NULL DEFAULT 'common' ;
- and this will allow all current items to have a 'common' rarity, and all future items to be such as well, if a rarity is not supplied when the item is created.

-

OK NVM. Apparently that was literally all I needed to do. I can already use {$item->rarity}. For example, in inventoryview.php, all I had to do was add rarity to the headers -
PHP:
$inventoryTable->buildHeaders("Image", "Category", "Name", "Description", "Rarity", "Quantity", "Use", "Sell", "Toss");
- and then add it to the table (I added it after description).
PHP:
$cells->add(new TCell($item->rarity));

-

SO all I have left to do is make it so I can add the rarity on the admin end during item creation...
 
Last edited:
SO all I have left to do is make it so I can add the rarity on the admin end during item creation...


Yeah, it's pretty easy to do, so don't worry! To put a field for rarity in the item creation on the acp you just need to edit the add() function in itemview.php and item.php (inside admincp folder). In itemview.php add the field to ask for a rarity and in item.php add the rarity field in $mysidia->db->insert(), and it should be done
 
Surprisingly painless! Thanks.

Eurghhh... Unrelated:

I renamed an item I already owned, so now my inventory is throwing a fit. Looks like even though we can rename items, we really can't - with the way the system works, it checks if an item exists by its name instead of by its id. :ColonEE: So now I have to go into the database and edit by hand every instance of that item in adopts_inventory for all users to the new name, else their inventories will throw an error.
 
Surprisingly painless! Thanks.

Eurghhh... Unrelated:

I renamed an item I already owned, so now my inventory is throwing a fit. Looks like even though we can rename items, we really can't - with the way the system works, it checks if an item exists by its name instead of by its id. :ColonEE: So now I have to go into the database and edit by hand every instance of that item in adopts_inventory for all users to the new name, else their inventories will throw an error.

In the edit item function (item.php in admincp), maybe you can add a database update that changes the item name in the inventory table as well
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,277
Messages
33,122
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Latest Posts

Top