FirelandsProject / firelands-cata

This is an open source project, from the emulator version 4.3.4. Log in to the discord for more information: https://discord.com/invite/GZ5rsxumxN
GNU Affero General Public License v3.0
55 stars 45 forks source link

feat (core\db): Server Mail Reward System #162

Closed acidmanifesto closed 1 year ago

acidmanifesto commented 1 year ago

This is based on my module with remake assistance from @Kitzunu to make it a core feature back on azerothcore. The Server Mail Reward System is known to be a blizzlike retail feature, the only challenge is, are we able to present it as a blizzlike retail feature in the terms of a open source project. We are able to incorporate play time as a option with the option to input subject and body messages, which would work out in replicating seasonal and promotional blizzlike messages that were never present in the dbc\db2 files. This also helps with the ease of localization since we have a active collumn to have the reward run active or not. by default tables are blank, however two simple examples are provided below at the bottom.

Co-Authored-By: Kitzunu 24550914+Kitzunu@users.noreply.github.com

In-Game: image

New Tables

Character Database:

Explanation of tables:

The `mail_server_character` table

This table keeps entries of which player has recieved a server mail. This prevents the same mail to be sent twice to the same player.

Structure

![image](https://github.com/TrinityCore/TrinityCore/assets/16887899/8549277a-c7e7-41b3-9952-d0b49d19d78a) Field | Type | Attributes | Key | Null | Default | Extra | Comment -- | -- | -- | -- | -- | -- | -- | -- guid | INT | UNSIGNED | PRI | NO |   |   |   mailId | INT | UNSIGNED | PRI | NO |   |   |  

Description of the fields

guid

characters.guid.

mailId

mail_server_template.id.

The `mail_server_template` table

This table contains information for server mail to be sent to players that meet the requirement. Mails are sent OnLogin.

Structure

![image](https://github.com/FirelandsProject/firelands-cata/assets/16887899/9e1f9513-270c-4a2d-a339-6f9e6ba3a213) Field | Type | Attributes | Key | Null | Default | Extra | Comment -- | -- | -- | -- | -- | -- | -- | -- id | INT | UNSIGNED | PRI | NO |   | AUTO_INCREMENT |   reqLevel | TINYINT | UNSIGNED |   | NO | 0 |   |   reqPlayTime | INT | UNSIGNED |   | NO | 0 |   |   moneyA | INT | UNSIGNED |   | NO | 0 |   |   moneyH | INT | UNSIGNED |   | NO | 0 |   |   itemA | INT | UNSIGNED |   | NO | 0 |   |   itemCountA | INT | UNSIGNED |   | NO | 0 |   |   itemH | INT | UNSIGNED |   | NO | 0 |   |   itemCountH | INT | UNSIGNED |   | NO | 0 |   |   subject | TEXT |   |   | NO |   |   |   body | TEXT |   |   | NO |   |   |   active | TINYINT | UNSIGNED |   | NO | 1 |   |  

Description of the fields

id

Unique ID.

reqLevel

Players required level to be able to recieve the mail.

reqPlayTime

Players required play time in milliseconds to recieve the mail.

moneyA

Money in copper that is sent to Alliance player.

moneyH

Money in copper that is sent to Horde player.

itemA

item_template.entry that is sent to Alliance player.

itemCountA

How many of the specified itemA is sent.

itemH

item_template.entry.

itemCountH

How many of the specified itemH is sent that is sent to Horde player.

subject

The title/subject of the mail.

body

The body of the mail.

active

boolean

Examples image Apply to Character DB

-- send testing test message when player is level 1 with zero time played in ms
DELETE FROM `mail_server_template` WHERE `id`=1;
INSERT INTO `mail_server_template` (`id`, `reqLevel`, `reqPlayTime`, `moneyA`, `moneyH`, `itemA`, `itemCountA`, `itemH`, `itemCountH`, `subject`, `body`, `active`) VALUES 
(1, 1, 0, 0, 0, 0, 0, 0, 0, 'testing', 'this is a test', 1);
-- send money test of 12 copper when player is level 1 after 1 hours in ms passes in toon play time
DELETE FROM `mail_server_template` WHERE `id`=2;
INSERT INTO `mail_server_template` (`id`, `reqLevel`, `reqPlayTime`, `moneyA`, `moneyH`, `itemA`, `itemCountA`, `itemH`, `itemCountH`, `subject`, `body`, `active`) VALUES 
(2, 1, 3600000, 12, 12, 0, 0, 0, 0, 'money test', 'test', 1);

Issues addressed

SOURCE:

Tests performed

How to Test the Changes:

Known issues and TODO list