diff --git a/CMakeLists.txt b/CMakeLists.txt index 903fd13..3310be4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/assets-cg/converters.py b/assets-cg/converters.py index 61a394d..7f66ea1 100644 --- a/assets-cg/converters.py +++ b/assets-cg/converters.py @@ -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) \ No newline at end of file diff --git a/assets-cg/fxconv-metadata.txt b/assets-cg/fxconv-metadata.txt index e6aee0c..f855440 100644 --- a/assets-cg/fxconv-metadata.txt +++ b/assets-cg/fxconv-metadata.txt @@ -34,3 +34,7 @@ battle_ui.png: type: bopti-image name: img_battle profile: p4 + +player_moves.txt: + custom-type: player_moves + name:levelupplayer diff --git a/assets-cg/player_moves.txt b/assets-cg/player_moves.txt new file mode 100644 index 0000000..4a037d2 --- /dev/null +++ b/assets-cg/player_moves.txt @@ -0,0 +1,3 @@ +7:1 +10:2 +15:3 diff --git a/include/player.h b/include/player.h index 08bd25e..f302ca2 100644 --- a/include/player.h +++ b/include/player.h @@ -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); \ No newline at end of file +void reset_pp(struct Player *player); +void check_level(struct Player *player, int prec_level); \ No newline at end of file diff --git a/src/battle.c b/src/battle.c index 78ebdcf..2496de3 100644 --- a/src/battle.c +++ b/src/battle.c @@ -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); diff --git a/src/monster.c b/src/monster.c index 1d045e2..4ff8946 100644 --- a/src/monster.c +++ b/src/monster.c @@ -9,7 +9,6 @@ #include "map.h" #include "util.h" - #include #include diff --git a/src/player.c b/src/player.c index c54aaec..261cb99 100644 --- a/src/player.c +++ b/src/player.c @@ -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) diff --git a/src/stats.c b/src/stats.c index 4c9bb5a..f5be0b2 100644 --- a/src/stats.c +++ b/src/stats.c @@ -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) {