API Rest em java spring boot com sistema de turnos e cadastro de personagens que simula um sistema de batalha utilizando PostgreSql
- Realize a instalação dos pacotes necessários
- Configure o seu banco Postgresql
- Mude o arquivo application.properties de acordo com suas configurações de banco
/character
// Character type deve ser HERO ou MONSTER
{
"character_type": "HERO",
"name":"leo",
"health_points":2,
"strength": 2,
"defense":2,
"agility":2,
"dice_times_roll":0,
"dice_faces":8
}
**STATUS 201**
{
"character_type": "HERO",
"name":"leo",
"health_points":2,
"strength": 2,
"defense":2,
"agility":2,
"dice_times_roll":0,
"dice_faces":8
}
/character
**STATUS 200**
[
{
"id": 553,
"character_type": "HERO",
"name": "Leonardo",
"health_points": 20,
"strength": 20,
"defense": 40,
"agility": 30,
"dice_times_roll": 8,
"dice_faces": 1
},
{
"id": 602,
"character_type": "MONSTER",
"name": "Ogro",
"health_points": 10,
"strength": 10,
"defense": 30,
"agility": 20,
"dice_times_roll": 8,
"dice_faces": 1
},
]
/character/Id
**STATUS 200**
{
"id": 702,
"character_type": "MONSTER",
"name": "Ogro",
"health_points": 10,
"strength": 10,
"defense": 30,
"agility": 20,
"dice_times_roll": 1,
"dice_faces": 8
}
/character/Id
{
"character_type": "HERO",
"name":"Mudando nome",
"health_points": 5,
"strength": 30,
"defense": 30,
"agility": 15,
"dice_times_roll": 1,
"dice_faces": 20
}
**STATUS 200**
{
"id": 553,
"character_type": "HERO",
"name":"Mudando nome",
"health_points": 5,
"strength": 30,
"defense": 30,
"agility": 15,
"dice_times_roll": 1,
"dice_faces": 20
}
/character/Id
/session
{
"ally_id":4203,
"enemy_id":902
}
**STATUS 201**
{
"session_id": 2302,
"ally_roll": 5,
"enemy_roll": 12
}
/session/turn
{
"session_id": 2302,
"attacker_id":902,
"defender_id":4203
}
**STATUS 201**
//Ataque abateu defensor
{
"damage_done": 28,
"current_defender_health_points": -26,
"is_session_over": true,
"message": "Defender was killed!"
}
ou
//Caso o defensor nessa sessão tenha já morrido
{
"is_session_over": true,
"message": "Session is over!"
}
ou
//Caso o defensor tenha uma defesa maior que o ataque
{
"is_session_over": false,
"message": "Attack failed! Defender defended successfully."
}
ou
//Ataque seja maior que a defesa do defensor
{
"damage_done": 28,
"current_defender_health_points": 10,
"is_session_over": false,
"message": "Successful attack"
}
/session/Id
[
{
"session": {
"id": 2204,
"currentAllyHealthPoints": -29,
"currentEnemyHealthPoints": 60,
"allyRollNumber": 12,
"enemyRollNumber": 3,
"currentTurn": "ALLY",
"characterAlly": {
"id": 4203,
"characterType": "HERO",
"name": "leo",
"healthPoints": 2,
"strength": 2,
"defense": 2,
"agility": 2,
"diceTimesRoll": 2,
"diceFaces": 8
},
"characterEnemy": {
"id": 902,
"characterType": "MONSTER",
"name": "NormalMonster",
"healthPoints": 60,
"strength": 20,
"defense": 20,
"agility": 5,
"diceTimesRoll": 2,
"diceFaces": 8
},
"turnCount": 2,
"sessionOver": true
},
"first_to_attack": "ALLY",
"attack": 9,
"current_turn_count": 1,
"defense": 30,
"damage_done": 13,
"current_ally_hp": 2,
"current_enemy_hp": 60
},
{
"session": {
"id": 2204,
"currentAllyHealthPoints": -29,
"currentEnemyHealthPoints": 60,
"allyRollNumber": 12,
"enemyRollNumber": 3,
"currentTurn": "ALLY",
"characterAlly": {
"id": 4203,
"characterType": "HERO",
"name": "leo",
"healthPoints": 2,
"strength": 2,
"defense": 2,
"agility": 2,
"diceTimesRoll": 2,
"diceFaces": 8
},
"characterEnemy": {
"id": 902,
"characterType": "MONSTER",
"name": "NormalMonster",
"healthPoints": 60,
"strength": 20,
"defense": 20,
"agility": 5,
"diceTimesRoll": 2,
"diceFaces": 8
},
"turnCount": 2,
"sessionOver": true
},
"first_to_attack": "ALLY",
"attack": 27,
"current_turn_count": 2,
"defense": 10,
"damage_done": 31,
"current_ally_hp": -29,
"current_enemy_hp": 60
}
]
Esses endpoints são chamados automaticamente pela aplicação para realização da jogada de turno
/calculate/defense/id
**STATUS 200**
{
"result": 57
}
/calculate/attack/id
**STATUS 200**
{
"result": 57
}
/calculate/damage/id
**STATUS 200**
{
"result": 57
}