I’ve always loved the fantasy genre and this backend service representation really encapsulates a lot of my favorite aspects of the common role-playing tropes. One of the best things about rpgs is the interactions and experiences one shares with others, so making a service to connect adventurers would only add on to this positive effect.
This project uses a MySQL database. To set up the database, run the following commands in the MySQL shell, the sql file is also provided in the repository:
CREATE DATABASE SynergyDB;
CREATE TABLE Races
(
Id int NOT NULL PRIMARY KEY AUTO_INCREMENT,
Name VARCHAR(255) NOT NULL,
Origin VARCHAR(255) NOT NULL
);
CREATE TABLE Classes
(
Id int NOT NULL PRIMARY KEY AUTO_INCREMENT COMMENT 'Primary Key',
Name VARCHAR(255) NOT NULL,
Role ENUM("Tank", "Damage", "Healer") NOT NULL,
Resource ENUM("Fervor", "Focus", "Mana", "Faith", "Energy", "Soul") NOT NULL
);
CREATE TABLE Adventurers
(
Id int NOT NULL PRIMARY KEY AUTO_INCREMENT,
Name VARCHAR(255) NOT NULL,
`Rank` ENUM("Rookie", "Veteran", "Elite", "Master", "Legendary") NOT NULL,
Race int NOT NULL,
Class int NOT NULL,
Foreign Key (Race) REFERENCES Races(Id),
Foreign Key (Class) REFERENCES Classes(Id)
);
CREATE TABLE Parties
(
Id int NOT NULL PRIMARY KEY AUTO_INCREMENT,
Name VARCHAR(255) NOT NULL,
DateFounded DATETIME
);
ALTER TABLE Adventurers ADD Party int NOT NULL;
ALTER TABLE Adventurers
ADD CONSTRAINT Party Foreign Key (Party) REFERENCES Parties(Id);
Once the database is all setup, you can now begin seeding the Races and Classes of this fantasy world. To do so, simply run the API and the seeding process should beging. This is ony done the first time you run the API.
using (var scope = app.Services.CreateScope())
{
var db = scope.ServiceProvider.GetRequiredService<SynergyDbContext>();
RaceSeed.Seed(db);
ClassSeed.Seed(db);
}
The following races available:
Human,
Lush Elf,
Dwarf,
Mist Elf,
Giant,
Orc
The following classes available:
Warrior,
Marksman,
Mage,
Cleric,
Paladin,
Rogue,
Reaper
These are enums that may be used in some requests:
public enum Rank
{
Rookie,
Veteran,
Elite,
Master,
Legendary
}
public enum Role
{
Tank,
Damage,
Healer
}
public enum Resource
{
Fervor,
Focus,
Mana,
Faith,
Energy,
Soul
}
Property | Type | Description |
---|---|---|
Id | Int | Primary Key |
Name | String | Adventurer's name |
Rank | Rank | Current ranking |
Race | Race | Adventurer's race |
Class | Class | Adventurer's class |
Party | Party? | Adventurer's party |
GET https://localhost:7000/api/adventurer
{
"statusCode": 200,
"statusDescription": "OK - All registered adventurers",
"data": [
{
"id": 1,
"name": "Rouge Voltgale",
"rank": "Elite",
"race": {
"id": 1,
"name": "Human",
"origin": "Thundorum City"
},
"class": {
"id": 6,
"name": "Rogue",
"role": "Damage",
"resource": "Energy"
},
"party": {
"id": 1,
"name": "Origin Seekers",
"dateFounded": "2020-10-05T00:00:00"
}
},
{
"id": 2,
"name": "Gildun Fullbash",
"rank": "Elite",
"race": {
"id": 1,
"name": "Human",
"origin": "Thundorum City"
},
"class": {
"id": 5,
"name": "Paladin",
"role": "Tank",
"resource": "Faith"
},
"party": {
"id": 1,
"name": "Origin Seekers",
"dateFounded": "2020-01-01T00:00:00"
},
...
}
]
}
GET https://localhost:7000/api/adventurer/{id}
{
"statusCode": 200,
"statusDescription": "OK - Adventurer with id 4 found",
"data": {
"id": 4,
"name": "Celuna Silverstreak",
"rank": "Elite",
"race": {
"id": 2,
"name": "Lush Elf",
"origin": "Serinii Valush"
},
"class": {
"id": 2,
"name": "Marksman",
"role": "Damage",
"resource": "Focus"
},
"party": {
"id": 1,
"name": "Origin Seekers",
"dateFounded": "2020-01-01T00:00:00"
}
}
}
POST https://localhost:7000/api/adventurer
{
"name": "Finn the Human",
"rank": "Legendary",
"raceName": "Human",
"className": "Warrior",
"partyId": 2
}
{
"statusCode": 201,
"statusDescription": "Created - Adventurer with Id 7 created",
"data": {
"id": 7,
"name": "Finn the Human",
"rank": "Legendary",
"race": {
"id": 1,
"name": "Human",
"origin": "Thundorum City"
},
"class": {
"id": 1,
"name": "Warrior",
"role": "Tank",
"resource": "Fervor"
},
"party": {
"id": 2,
"name": "The Treehouse",
"dateFounded": "2010-10-05T00:00:00"
}
}
}
PUT https://localhost:7000/api/adventurer/{id}
{
"name": "Finn the Legendary Human",
"rank": "Legendary",
"raceName": "Human",
"className": "Warrior",
"partyId": 3
}
{
"statusCode": 200,
"statusDescription": "OK - Adventurer with Id 7 updated",
"data": {
"id": 7,
"name": "Finn the Legendary Human",
"rank": "Legendary",
"race": {
"id": 1,
"name": "Human",
"origin": "Thundorum City"
},
"class": {
"id": 1,
"name": "Warrior",
"role": "Tank",
"resource": "Fervor"
},
"party": {
"id": 3,
"name": "Hall of Champions",
"dateFounded": "2021-12-20T02:08:30"
}
}
}
DELETE https://localhost:7000/api/adventurer/{id}
{
"statusCode": 200,
"statusDescription": "OK - Adventurer with Id 7 deleted",
"data": {
"id": 7,
"name": "Finn the Legendary Human",
"rank": "Legendary",
"race": {
"id": 1,
"name": "Human",
"origin": "Thundorum City"
},
"class": {
"id": 1,
"name": "Warrior",
"role": "Tank",
"resource": "Fervor"
},
"party": {
"id": 3,
"name": "Hall of Champions",
"dateFounded": "2021-12-20T02:08:30"
}
}
}
Property | Type | Description |
---|---|---|
Id | Int | Primary Key |
Name | String | Party's name |
Date Founded | DateTime | Party's founding date |
Members | [Adventurer] | Party's members |
GET https://localhost:7000/api/party
{
"statusCode": 200,
"statusDescription": "OK - All registered parties",
"data": [
{
"id": 1,
"name": "Origin Seekers",
"dateFounded": "2020-01-01T00:00:00",
"members": [
{
"id": 1,
"name": "Rouge Voltgale",
"rank": "Elite",
"race": {
"id": 1,
"name": "Human",
"origin": "Thundorum City"
},
"class": {
"id": 3,
"name": "Rogue",
"role": "Damage",
"resource": "Energy"
}
},
{
"id": 2,
"name": "Gildun Fullbash",
"rank": "Elite",
"race": {
"id": 1,
"name": "Human",
"origin": "Thundorum City"
},
"class": {
"id": 5,
"name": "Paladin",
"role": "Tank",
"resource": "Faith"
}
},
{
"id": 4,
"name": "Celuna Silverstreak",
"rank": "Elite",
"race": {
"id": 2,
"name": "Lush Elf",
"origin": "Serinii Valush"
},
"class": {
"id": 2,
"name": "Marksman",
"role": "Damage",
"resource": "Focus"
}
}
]
},
{
"id": 3,
"name": "Hall of Champions",
"dateFounded": "2021-12-20T02:08:30",
"members": [
{
"id": 7,
"name": "Finn the Legendary Human",
"rank": "Legendary",
"race": {
"id": 1,
"name": "Human",
"origin": "Thundorum City"
},
"class": {
"id": 1,
"name": "Warrior",
"role": "Tank",
"resource": "Fervor"
}
}
]
},
...
]
}
GET https://localhost:7000/api/party/{id}
{
"statusCode": 200,
"statusDescription": "OK - Party with Id 3 found",
"data": {
"id": 3,
"name": "Hall of Champions",
"dateFounded": "2021-12-20T02:08:30",
"members": [
{
"id": 7,
"name": "Finn the Legendary Human",
"rank": "Legendary",
"race": {
"id": 1,
"name": "Human",
"origin": "Thundorum City"
},
"class": {
"id": 1,
"name": "Warrior",
"role": "Tank",
"resource": "Fervor"
}
}
]
}
}
POST https://localhost:7000/api/party
{
"name": "Adventurers Guild"
}
{
"statusCode": 201,
"statusDescription": "Created - Party with Id 4 created",
"data": {
"id": 4,
"name": "Adventurers Guild",
"dateFounded": "2022-11-25T10:00:00",
"members": []
}
}
PUT https://localhost:7000/api/party/{id}
{
"name": "Thee Adventurers Guild"
}
{
"statusCode": 200,
"statusDescription": "OK - Party with Id 4 updated",
"data": {
"id": 4,
"name": "Thee Adventurers Guild",
"dateFounded": "2022-11-25T10:00:00",
"members": []
}
}
DELETE https://localhost:7000/api/party/{id}
{
"statusCode": 200,
"statusDescription": "OK - Party with Id 4 deleted",
"data": {
"id": 4,
"name": "Thee Adventurers Guild",
"dateFounded": "2022-11-25T10:00:00",
"members": []
}
}
Property | Type | Description |
---|---|---|
Id | Int | Primary Key |
Name | String | Name of the race |
Origin | String | Name of the race origin location |
GET https://localhost:7000/api/race
{
"statusCode": 200,
"statusDescription": "OK - All available races",
"data": [
{
"id": 1,
"name": "Human",
"origin": "Thundorum City"
},
{
"id": 2,
"name": "Lush Elf",
"origin": "Serinii Valush"
},
{
"id": 3,
"name": "Dwarf",
"origin": "Stoneborn Mountain"
},
{
"id": 4,
"name": "Mist Elf",
"origin": "Miswood Forest"
},
{
"id": 5,
"name": "Giant",
"origin": "Jotunheim"
},
{
"id": 6,
"name": "Orc",
"origin": "Red Valley"
}
]
}
GET https://localhost:7000/api/race/{name}
{
"statusCode": 200,
"statusDescription": "OK - Race with name Dwarf found.",
"data": {
"id": 3,
"name": "Dwarf",
"origin": "Stoneborn Mountain"
}
}
Property | Type | Description |
---|---|---|
Id | Int | Primary Key |
Name | String | Name of the class |
Role | Role | The role the class plays |
Resource | Resource | The resource used for abilities |
GET https://localhost:7000/api/class
{
"statusCode": 200,
"statusDescription": "OK - All available classes",
"data": [
{
"id": 1,
"name": "Warrior",
"role": "Tank",
"resource": "Fervor"
},
{
"id": 2,
"name": "Marksman",
"role": "Damage",
"resource": "Focus"
},
{
"id": 3,
"name": "Mage",
"role": "Damage",
"resource": "Mana"
},
{
"id": 4,
"name": "Cleric",
"role": "Healer",
"resource": "Faith"
},
{
"id": 5,
"name": "Paladin",
"role": "Tank",
"resource": "Faith"
},
{
"id": 6,
"name": "Rogue",
"role": "Damage",
"resource": "Energy"
},
{
"id": 7,
"name": "Reaper",
"role": "Damage",
"resource": "Soul"
}
]
}
GET https://localhost:7000/api/class/{name}
{
"statusCode": 200,
"statusDescription": "OK - Class with name Reaper found.",
"data": {
"id": 7,
"name": "Reaper",
"role": "Damage",
"resource": "Soul"
}
}
Youssef Elshabasy 2022 - CSCI 39537 Intro to APIs - Hunter College Fall 2022