level up -> new move for player

pull/2/head
bgiraudr 6 months ago
parent 9c3e3c184a
commit 7a4f2c5ff3
  1. 1
      CMakeLists.txt
  2. 26
      assets-cg/converters.py
  3. 4
      assets-cg/fxconv-metadata.txt
  4. 3
      assets-cg/player_moves.txt
  5. 13
      include/player.h
  6. 2
      src/battle.c
  7. 1
      src/monster.c
  8. 11
      src/player.c
  9. 1
      src/stats.c

@ -63,6 +63,7 @@ set(ASSETS_cg
assets-cg/monsters/test.png
assets-cg/monsters/test2.png
assets-cg/monsters/monsters.txt
assets-cg/player_moves.txt
)
fxconv_declare_assets(${ASSETS} ${ASSETS_fx} ${ASSETS_cg} WITH_METADATA)

@ -12,6 +12,9 @@ def convert(input, output, params, target):
elif params["custom-type"] == "monster":
convert_monster(input, output, params, target)
return 0
elif params["custom-type"] == "player_moves":
convert_player_moves(input, output, params, target)
return 0
else:
return 1
@ -187,8 +190,17 @@ def parseZone(layer):
monsters = bytes()
try:
zone += fxconv.u32(i["properties"][0]["value"])
monster_list = i["properties"][1]["value"].split(";")
monster_list_raw = i["properties"][1]["value"].split(";")
monster_list = []
#x-y notation generate an array
for i in monster_list_raw:
if "-" in i:
a = i.split("-")
monster_list.extend(list(range(int(a[0]),int(a[1])+1)))
else:
monster_list.append(int(i))
zone += fxconv.u32(len(monster_list))
for j in monster_list:
monsters += fxconv.u16(int(j))
except IndexError:
@ -267,3 +279,15 @@ def convert_monster(input, output, params, target):
monsters += fxconv.ptr(monster)
fxconv.elf(monsters, output, "_" + params["name"], **target)
def convert_player_moves(input, output, params, target):
levelupplayer = fxconv.Structure()
data = open(input, 'r').readlines()
levelupplayer += fxconv.u32(len(data))
for i in data:
levelup = fxconv.Structure()
levelup += fxconv.u32(int(i.split(":")[0]))
levelup += fxconv.u32(int(i.split(":")[1]))
levelupplayer += fxconv.ptr(levelup)
fxconv.elf(levelupplayer, output, "_" + params["name"], **target)

@ -34,3 +34,7 @@ battle_ui.png:
type: bopti-image
name: img_battle
profile: p4
player_moves.txt:
custom-type: player_moves
name:levelupplayer

@ -0,0 +1,3 @@
7:1
10:2
15:3

@ -30,6 +30,16 @@ struct Player {
struct AnimData anim;
};
struct LevelUp {
int level;
int id_move;
};
struct LevelUpPlayer {
int nbLevelUp;
struct LevelUp *levelup[];
};
/*return the info tile value the player is facing to*/
int player_facing(struct Game const *game);
struct Player init_player(void);
@ -38,4 +48,5 @@ void draw_player_moves(struct Player *player);
void replace_capacities(struct Player *player, struct Move move);
void draw_ui(struct Player *player);
int get_nb_moves(struct Player *player);
void reset_pp(struct Player *player);
void reset_pp(struct Player *player);
void check_level(struct Player *player, int prec_level);

@ -121,7 +121,9 @@ void finish_battle(int status, struct Game *game, struct Monster *monster) {
dupdate();
wait_for_input(KEY_SHIFT);
}
int prec = game->player->stats.level;
game->player->stats.level = calc_level;
check_level(game->player, prec);
} else if(status == LOSE) {
draw_battle(game->player, monster);

@ -9,7 +9,6 @@
#include "map.h"
#include "util.h"
#include <gint/display.h>
#include <gint/keyboard.h>

@ -8,6 +8,8 @@
#include "capacite.h"
#include "util.h"
extern struct LevelUpPlayer levelupplayer;
struct Player init_player(void) {
struct Stats bstats = {
@ -42,6 +44,15 @@ struct Player init_player(void) {
return player;
}
void check_level(struct Player *player, int prec_level) {
for(int i = 0; i < levelupplayer.nbLevelUp; i++) {
if(player->stats.level >= levelupplayer.levelup[i]->level
&& prec_level < levelupplayer.levelup[i]->level) {
add_move(player, get_move_id(levelupplayer.levelup[i]->id_move));
}
}
}
/*
return the info tile value the player is facing to
TILE_SOLID by default (out of bound)

@ -12,6 +12,7 @@ void draw_stats(struct Stats stats) {
dprint(300,60,C_BLACK,"XP : %d",stats.xp);
dprint(300,80,C_BLACK,"ATK : %d",stats.atk);
dprint(300,100,C_BLACK,"DEF : %d",stats.def);
dprint(300,120,C_BLACK,"LVLUP : %d",(int)(pow(stats.level+1, 3.03))-stats.xp);
}
void set_stats_level_from(const struct Stats *from, struct Stats *to) {

Loading…
Cancel
Save