Compare commits

..

2 Commits

Author SHA1 Message Date
bgiraudr df3e9ab714 remove json on gitignore 2022-02-18 00:01:46 +01:00
bgiraudr f997efb737 Moves are now JSON 2022-02-17 21:26:33 +01:00
13 changed files with 88 additions and 35 deletions

2
.gitignore vendored
View File

@ -3,7 +3,7 @@
/build-cg
/*.g1a
/*.g3a
*.json
/assets-cg/maps/**/*.json
*~
/images

View File

@ -0,0 +1,7 @@
{
"name":"Charge",
"id":2,
"pp":25,
"atk":15,
"precision":100
}

View File

@ -0,0 +1,7 @@
{
"name":"Cheat",
"id":3,
"pp":25,
"atk":45,
"precision":100
}

View File

@ -0,0 +1,7 @@
{
"name":"Deuxième",
"id":1,
"pp":100,
"atk":11,
"precision":50
}

View File

@ -0,0 +1,7 @@
{
"name":"Test capacité",
"id":0,
"pp":5,
"atk":20,
"precision":50
}

View File

@ -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

View File

@ -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)

View File

@ -0,0 +1,17 @@
{
"name":"test",
"sprite":"test",
"stats":{
"atk":10,
"def":10,
"pv":20,
"level":1,
"xp":300,
"max_pv":20
},
"moves":[
0,
1,
2
]
}

View File

@ -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);

View File

@ -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();

View File

@ -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*/

View File

@ -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);
}

View File

@ -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;