Add +/- 5 levels diff

This commit is contained in:
bgiraudr 2022-02-17 01:04:45 +01:00
parent cb8a7db95a
commit 35cbdca9c5
9 changed files with 42 additions and 15 deletions

View File

@ -1,4 +1,4 @@
Test capacité;5;3
Deuxième;100;11
Charge;25;15
Cheat;25;45
Test capacité;5;5;3
Deuxième;100;100;11
Charge;25;25;15
Cheat;25;25;45

View File

@ -189,7 +189,7 @@ def parseZone(layer):
try:
zone += fxconv.u32(i["properties"][0]["value"])
except KeyError:
print("parseZone() : Zone sans niveau de référence, passage automatique à -1")
print(f"parseZone() : Zone {origin};{to} sans niveau de référence, passage automatique à -1")
zone += fxconv.u32(-1)
return zone

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.8" tiledversion="1.8.1" orientation="orthogonal" renderorder="right-down" width="100" height="38" tilewidth="16" tileheight="16" infinite="0" nextlayerid="14" nextobjectid="59">
<map version="1.8" tiledversion="1.8.1" orientation="orthogonal" renderorder="right-down" width="100" height="38" tilewidth="16" tileheight="16" infinite="0" nextlayerid="14" nextobjectid="61">
<editorsettings>
<export target="testCarte.json" format="json"/>
</editorsettings>

View File

@ -3,6 +3,7 @@
struct Move {
char *name;
int init_pp;
int pp;
int atk;
};

View File

@ -37,4 +37,5 @@ void add_move(struct Player *player, struct Move move);
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);
int get_nb_moves(struct Player *player);
void reset_pp(struct Player *player);

View File

@ -9,7 +9,6 @@
#include "monster.h"
#include <stdlib.h>
#include <math.h>
#include <gint/rtc.h>
extern bopti_image_t img_dialogue;
@ -18,6 +17,7 @@ extern bopti_image_t img_dialogue;
*/
void create_battle(struct Game *game) {
game->player->stats.pv = game->player->stats.max_pv;
reset_pp(game->player);
struct Monster *monster = generate_monster(game);
int status = battle(game->player, monster);
@ -87,7 +87,7 @@ void finish_battle(int status, struct Game *game, struct Monster *monster) {
dimage(42,DHEIGHT-75,&img_dialogue);
dprint(50,DHEIGHT-75/2-10, C_BLACK, "Vous remportez %d points d'experience", xp);
dprint(50,DHEIGHT-47, C_BLACK, "Vous remportez %d points d'experience", xp);
dupdate();
wait_for_input(KEY_SHIFT);
@ -98,7 +98,7 @@ void finish_battle(int status, struct Game *game, struct Monster *monster) {
for(int i = game->player->stats.level; i < calc_level; i++) {
draw_battle(game->player, monster);
dimage(42,DHEIGHT-75,&img_dialogue);
dprint(50,DHEIGHT-75/2-10,C_BLACK,"Vous passez au niveau %d !", i+1);
dprint(50,DHEIGHT-47,C_BLACK,"Vous passez au niveau %d !", i+1);
dupdate();
wait_for_input(KEY_SHIFT);
}
@ -106,6 +106,11 @@ void finish_battle(int status, struct Game *game, struct Monster *monster) {
set_stats_level_from(&game->player->base_stats, &game->player->stats);
} else if(status == LOSE) {
draw_battle(game->player, monster);
dimage(42,DHEIGHT-75,&img_dialogue);
dprint(50,DHEIGHT-47,C_BLACK,"%s a eu raison de vous !", monster->name);
dupdate();
wait_for_input(KEY_SHIFT);
game->player->stats.pv = 0;
}
@ -139,7 +144,6 @@ int select_move(struct Player *player, struct Monster *monster, int prec_selecte
else break;
}
if(keydown(KEY_EXIT)) {
player->stats.pv--;
break;
}
while(keydown_any(KEY_RIGHT, KEY_LEFT, KEY_SHIFT, 0)) clearevents();
@ -190,13 +194,13 @@ void draw_battle(struct Player *player, struct Monster *monster) {
void draw_executed_move(struct Move *move, struct Monster *monster, int is_monster) {
dimage(42,DHEIGHT-75,&img_dialogue);
if(is_monster) {
dprint(50,DHEIGHT-75/2-10, C_BLACK, "%s lance %s !", monster->name, move->name);
dprint(50,DHEIGHT-47, C_BLACK, "%s lance %s !", monster->name, move->name);
} else {
dprint(50,DHEIGHT-75/2-10, C_BLACK, "Vous lancez %s !", move->name);
dprint(50,DHEIGHT-47, C_BLACK, "Vous lancez %s !", move->name);
}
}
void draw_crit() {
dimage(42,DHEIGHT-75,&img_dialogue);
dprint(50,DHEIGHT-75/2-10, C_BLACK, "Coup critique !");
dprint(50,DHEIGHT-47, C_BLACK, "Coup critique !");
}

View File

@ -25,6 +25,8 @@ struct Move *get_move_id_pointer(int id) {
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->pp = move.pp;
copyMove->atk = move.atk;

View File

@ -1,11 +1,13 @@
#include <string.h>
#include <stdlib.h>
#include <gint/rtc.h>
#include "monster.h"
#include "stats.h"
#include "capacite.h"
#include "player.h"
#include "map.h"
#include "util.h"
struct Monster *generate_monster(struct Game *game) {
@ -13,14 +15,24 @@ struct Monster *generate_monster(struct Game *game) {
struct Monster *monster = copyMonster(&monster_test);
srand(rtc_ticks());
int level_zone = get_level_zone(game->player, game->map);
//En cas d'erreur / aucune zone trouvée
if(level_zone == -1) {
level_zone = game->player->stats.level;
}
monster->stats->level = level_zone;
int signe = rand_range(0,2);
signe = signe ? -1 : 1;
int variation = signe*rand_range(0,6);
int level = level_zone + variation;
if(level > 100) level = 100;
if(level < 1) level = 1;
monster->stats->level = level;
set_stats_level(monster->stats);
monster->stats->pv = monster->stats->max_pv;
return monster;
}

View File

@ -123,4 +123,11 @@ void draw_ui(struct Player *player) {
for(int i = 0; i < index; i++) {
draw_classic_move(2+132*i,DHEIGHT-70, player->moves[i]);
}
}
void reset_pp(struct Player *player) {
int index = get_nb_moves(player);
for(int i = 0; i < index; i++) {
player->moves[i]->pp = player->moves[i]->init_pp;
}
}