diff --git a/assets-cg/capacites/capacites.txt b/assets-cg/capacites/capacites.txt index be598ad..e69de29 100644 --- a/assets-cg/capacites/capacites.txt +++ b/assets-cg/capacites/capacites.txt @@ -1,4 +0,0 @@ -Test capacité;5;5;3;20 -Deuxième;100;100;11;50 -Charge;25;25;15;100 -Cheat;25;25;45;100 diff --git a/assets-cg/converters.py b/assets-cg/converters.py index 744f8ff..be471ca 100644 --- a/assets-cg/converters.py +++ b/assets-cg/converters.py @@ -1,5 +1,6 @@ import fxconv import json +import pathlib def convert(input, output, params, target): if params["custom-type"] == "map": @@ -194,23 +195,26 @@ def parseZone(layer): return zone def convert_capa(input, output, params, target): - with open(input, "r") as file: - capacities = fxconv.Structure() + liste_file = list(pathlib.Path(input).parent.glob('*.json')) - lines = file.read().splitlines() - matrix = [i.split(";") for i in lines] - - capacities += fxconv.u32(len(lines)) - - for i in matrix: - moves = fxconv.Structure() - for j in range(len(i)): - if j == 0: - moves += fxconv.string(i[j]) - else: - moves += fxconv.u32(int(i[j])) + capacities = fxconv.Structure() + capacities += fxconv.u32(len(liste_file)) + for f in liste_file: + file = open(f,"r") + data = json.load(file) + move = fxconv.Structure() - capacities += fxconv.ptr(moves) + try: + move += fxconv.string(data["name"]) + move += fxconv.u32(data["id"]) + move += fxconv.u32(data["pp"]) + move += fxconv.u32(data["pp"]) + move += fxconv.u32(data["atk"]) + move += fxconv.u32(data["precision"]) + except KeyError: + raise Exception(f"convert_capa() : La capacité {data['name']} est mal configurée") + + capacities += fxconv.ptr(move) fxconv.elf(capacities, output, "_" + params["name"], **target) diff --git a/include/battle.h b/include/battle.h index a557799..2092ee8 100644 --- a/include/battle.h +++ b/include/battle.h @@ -3,9 +3,9 @@ #include "monster.h" enum battle_state { - EXIT = 0, - LOSE = 1, - WIN = 2, + EXIT, + LOSE, + WIN, }; void create_battle(struct Game *game); diff --git a/include/capacite.h b/include/capacite.h index 57d1f3e..7db342d 100644 --- a/include/capacite.h +++ b/include/capacite.h @@ -3,6 +3,7 @@ struct Move { char *name; + int id; int init_pp; int pp; int atk; @@ -15,9 +16,9 @@ struct Capacities { }; enum status { - MISS = 0, - SUCCESS = 1, - CRIT = 2 + MISS, + SUCCESS, + CRIT, }; struct Move default_move(); diff --git a/include/map.h b/include/map.h index 24ce39a..67870e6 100644 --- a/include/map.h +++ b/include/map.h @@ -31,13 +31,13 @@ struct Map { }; enum map_state { - TILE_AIR = 0, - TILE_SOLID = 1, - TILE_DOOR_IN = 2, - TILE_DOOR_OUT = 3, - TILE_TALKABLE = 4, - TILE_TELEPORTER = 5, - TILE_GRASS = 6, + TILE_AIR, + TILE_SOLID, + TILE_DOOR_IN, + TILE_DOOR_OUT, + TILE_TALKABLE, + TILE_TELEPORTER, + TILE_GRASS, }; /*check if a tile is walkable*/ diff --git a/src/battle.c b/src/battle.c index 1767d37..a46f63d 100644 --- a/src/battle.c +++ b/src/battle.c @@ -78,7 +78,7 @@ void check_move_status(int status, struct Player *player, struct Monster *monste if(status == MISS) { draw_battle(player, monster); - draw_status("Mais il rate !"); + draw_status("Mais cela échoue !"); dupdate(); wait_for_input(KEY_SHIFT); } diff --git a/src/capacite.c b/src/capacite.c index db5aa82..5c91e5c 100644 --- a/src/capacite.c +++ b/src/capacite.c @@ -15,10 +15,16 @@ struct Move default_move() { } struct Move get_move_id(int id) { - return *capacities.moves[id]; + for(int i = 0; i < capacities.nbCapacities; i++) { + if(capacities.moves[i]->id == id) return *capacities.moves[i]; + } + return *capacities.moves[0]; } struct Move *get_move_id_pointer(int id) { + for(int i = 0; i < capacities.nbCapacities; i++) { + if(capacities.moves[i]->id == id) return capacities.moves[i]; + } return capacities.moves[id]; } @@ -26,6 +32,7 @@ struct Move *copy_move(struct Move move) { struct Move *copyMove = malloc(sizeof(struct Move)); copyMove->name = move.name; copyMove->init_pp = move.init_pp; + copyMove->id = move.id; copyMove->pp = move.pp; copyMove->atk = move.atk;