add persistent ailment data model
This commit is contained in:
parent
4909a1f089
commit
c71a7b7b59
1
Makefile
1
Makefile
@ -38,6 +38,7 @@ SRC += graphic.cpp
|
|||||||
SRC += menu.cpp
|
SRC += menu.cpp
|
||||||
SRC += number.cpp
|
SRC += number.cpp
|
||||||
SRC += pokemon_instance.cpp
|
SRC += pokemon_instance.cpp
|
||||||
|
SRC += ailment.cpp
|
||||||
|
|
||||||
DEP = $(patsubst %.cpp,%.cpp.d,$(SRC))
|
DEP = $(patsubst %.cpp,%.cpp.d,$(SRC))
|
||||||
|
|
||||||
|
14
ailment.cpp
Normal file
14
ailment.cpp
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#include "ailment.hpp"
|
||||||
|
|
||||||
|
#define S reinterpret_cast<const uint8_t *>
|
||||||
|
|
||||||
|
const ailment_t ailments[] = {
|
||||||
|
[ailment_t::ok] = { .name = S("OK") },
|
||||||
|
[ailment_t::poison] = { .name = S("PSN") },
|
||||||
|
[ailment_t::burn] = { .name = S("BRN") },
|
||||||
|
[ailment_t::freeze] = { .name = S("FRZ") },
|
||||||
|
[ailment_t::paralysis] = { .name = S("PAR") },
|
||||||
|
[ailment_t::sleep] = { .name = S("SLP") },
|
||||||
|
};
|
||||||
|
|
||||||
|
#undef S
|
18
ailment.hpp
Normal file
18
ailment.hpp
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
struct ailment_t {
|
||||||
|
const uint8_t * name;
|
||||||
|
|
||||||
|
enum ailment {
|
||||||
|
ok,
|
||||||
|
poison,
|
||||||
|
burn,
|
||||||
|
freeze,
|
||||||
|
paralysis,
|
||||||
|
sleep,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
extern const ailment_t ailments[];
|
18
graphic.cpp
18
graphic.cpp
@ -10,6 +10,7 @@
|
|||||||
#include "gen/pokemon/types.hpp"
|
#include "gen/pokemon/types.hpp"
|
||||||
|
|
||||||
#include "pokemon_instance.hpp"
|
#include "pokemon_instance.hpp"
|
||||||
|
#include "ailment.hpp"
|
||||||
|
|
||||||
#define S reinterpret_cast<const uint8_t *>
|
#define S reinterpret_cast<const uint8_t *>
|
||||||
|
|
||||||
@ -54,8 +55,6 @@ void draw_text(const uint32_t base_pattern,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef S
|
|
||||||
|
|
||||||
void draw_box_border(const uint32_t base_pattern,
|
void draw_box_border(const uint32_t base_pattern,
|
||||||
const screen_cell_t& top_left, const screen_cell_t& bottom_right)
|
const screen_cell_t& top_left, const screen_cell_t& bottom_right)
|
||||||
{
|
{
|
||||||
@ -151,6 +150,14 @@ void draw_hp_bar(const uint32_t base_pattern,
|
|||||||
put_char(base_pattern, top_left.x + 8, top_left.y, end_cap);
|
put_char(base_pattern, top_left.x + 8, top_left.y, end_cap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const uint8_t * status_string(const pokemon_instance_t& pokemon_instance)
|
||||||
|
{
|
||||||
|
if (pokemon_instance.current_hit_points == 0)
|
||||||
|
return S("FNT");
|
||||||
|
else
|
||||||
|
return ailments[pokemon_instance.ailment].name;
|
||||||
|
}
|
||||||
|
|
||||||
void draw_stats1(const uint32_t base_pattern,
|
void draw_stats1(const uint32_t base_pattern,
|
||||||
const pokemon_instance_t& pokemon_instance)
|
const pokemon_instance_t& pokemon_instance)
|
||||||
{
|
{
|
||||||
@ -186,8 +193,8 @@ void draw_stats1(const uint32_t base_pattern,
|
|||||||
pokemon_instance.level,
|
pokemon_instance.level,
|
||||||
3); // width
|
3); // width
|
||||||
|
|
||||||
#define S reinterpret_cast<const uint8_t *>
|
draw_text(base_pattern, S("STATUS/"), 9, 6);
|
||||||
draw_text(base_pattern, S("STATUS/___"), 9, 6);
|
draw_text(base_pattern, status_string(pokemon_instance), 16, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
// bottom right border
|
// bottom right border
|
||||||
@ -213,7 +220,6 @@ void draw_stats1(const uint32_t base_pattern,
|
|||||||
draw_text(base_pattern, S("DEFENSE"), 1, 9 + 2);
|
draw_text(base_pattern, S("DEFENSE"), 1, 9 + 2);
|
||||||
draw_text(base_pattern, S("SPEED"), 1, 9 + 4);
|
draw_text(base_pattern, S("SPEED"), 1, 9 + 4);
|
||||||
draw_text(base_pattern, S("SPECIAL"), 1, 9 + 6);
|
draw_text(base_pattern, S("SPECIAL"), 1, 9 + 6);
|
||||||
#undef S
|
|
||||||
|
|
||||||
draw_number_right_align(base_pattern, {6, 10 + 0},
|
draw_number_right_align(base_pattern, {6, 10 + 0},
|
||||||
pokemon_instance.stat_values.attack,
|
pokemon_instance.stat_values.attack,
|
||||||
@ -287,3 +293,5 @@ void dialog_t::draw(const uint32_t base_pattern,
|
|||||||
ix++;
|
ix++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef S
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include "gen/pokemon/moves.hpp"
|
#include "gen/pokemon/moves.hpp"
|
||||||
#include "pokemon.hpp"
|
#include "pokemon.hpp"
|
||||||
|
#include "ailment.hpp"
|
||||||
|
|
||||||
struct determinant_values_t {
|
struct determinant_values_t {
|
||||||
uint16_t dvs;
|
uint16_t dvs;
|
||||||
@ -64,17 +65,18 @@ struct stat_values_t {
|
|||||||
static_assert((sizeof (stat_values_t)) == 10);
|
static_assert((sizeof (stat_values_t)) == 10);
|
||||||
|
|
||||||
struct pokemon_instance_t {
|
struct pokemon_instance_t {
|
||||||
|
uint8_t nickname[12];
|
||||||
enum pokemon_t::pokemon species;
|
enum pokemon_t::pokemon species;
|
||||||
uint8_t * nickname[12];
|
|
||||||
uint8_t level;
|
uint8_t level;
|
||||||
uint32_t experience; // total experience
|
uint32_t total_experience;
|
||||||
determinant_values_t determinant_values;
|
determinant_values_t determinant_values;
|
||||||
stat_values_t stat_values;
|
stat_values_t stat_values;
|
||||||
stat_experience_t stat_experience;
|
stat_experience_t stat_experience;
|
||||||
enum move_t::move moves[4];
|
enum move_t::move moves[4];
|
||||||
uint16_t current_hit_points;
|
uint16_t current_hit_points;
|
||||||
|
enum ailment_t::ailment ailment;
|
||||||
|
|
||||||
// missing attributes:
|
// missing attributes:
|
||||||
// - status modifiers (burn, poison, etc...)
|
|
||||||
// "fluff" attributes:
|
// "fluff" attributes:
|
||||||
// - id number
|
// - id number
|
||||||
// - original trainer
|
// - original trainer
|
||||||
|
Loading…
x
Reference in New Issue
Block a user