Here's a table of how much affection you actually gain. For an explanation, read below.
And here's (mostly) how the affection is calculated (at least for non-negative affection values):
The base affection gain is 24.
There are a few things that affect how much affection you get:
- Gift type
- Gift rank and current affection
- Gift rarity (colour)
For the gift type, each companions separately ranks each gift type on a scale with 4 grades. Torhead used a "star" rating, so that is what I have in the table. Referencing the linked sites, "1 star" is "likes", "2 star" is "favorite", "3 star" is "loves".
For a 1 star gift, multiply the affection gain by 1
For a 2 star gift, multiply the value by 2.25
For a 3 star gift, multiply the value by 4
Gift rank and current affection
Your affection value with your companion is converted into an affection rank. Each rank consists of a range of 2000 affection and starts with rank 1 for 0 to 2000 (or possibly 0 to 1999, I havn't managed to get any data on the exact value of the threshold).
Subtract this from the gift rank and call it the gift rank difference. E.g. if you have 6500 affection (affection rank 4
) and give a gift of rank 2
, the gift rank difference is 2
For a premium gift, multiply the gain by 1
For a prototype gift, multiply the gain by 1.666...
For an artifact gift, multiply the value by 4
After multiplying it all together, the value is rounded to the closest integer.