train
This commit is contained in:
@@ -13,7 +13,7 @@ struct string *my_str_init(const char* s, size_t size){
|
||||
rslt->size = 0;
|
||||
}
|
||||
else{
|
||||
rslt->data = malloc(size);
|
||||
rslt->data = malloc((1 + size) * sizeof(char*));
|
||||
if(rslt->data == NULL){
|
||||
free(rslt);
|
||||
return NULL;
|
||||
|
||||
@@ -23,7 +23,7 @@ size_t detect_points(struct point center, double range, struct point *interestin
|
||||
for(size_t i = 0; i < nb_points; i++){
|
||||
|
||||
if(is_in_area(center, range,interesting_points[i]) == 1){
|
||||
printf("{ %f, %f }\n",interesting_points[i].x, interesting_points[i].y);
|
||||
printf("{%f, %f}\n",interesting_points[i].x, interesting_points[i].y);
|
||||
found ++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
//#include <stdio.h>
|
||||
#include <stdio.h>
|
||||
#include "demon.h"
|
||||
#include "villager.h"
|
||||
#include "weapons.h"
|
||||
|
||||
//#include "demon.h"
|
||||
//#include "villager.h"
|
||||
//#include "weapons.h"
|
||||
|
||||
//int main()
|
||||
//{
|
||||
int main()
|
||||
{
|
||||
/*
|
||||
char gun_name[50] = "BFG";
|
||||
struct gun *gun = init_gun(gun_name, 50, FAR, 16);
|
||||
@@ -35,11 +34,12 @@
|
||||
pp_villager(villager);
|
||||
destroy_villager(villager);
|
||||
*/
|
||||
/* char demon_name[50] = "Cyberdemon";
|
||||
/* char demon_name[50] = "Cyberdemon";
|
||||
struct demon *demon = init_demon(NIGHTMARE, demon_name, 40, 5, CLOSE);
|
||||
update_demon_hp(demon, 200);
|
||||
*/
|
||||
/* char name[50] = "Isabelle";
|
||||
/*
|
||||
char name[50] = "Isabelle";
|
||||
char gun_name[50] = "BFG";
|
||||
struct gun *gun = init_gun(gun_name, 50, FAR, 16);
|
||||
struct villager *villager =
|
||||
@@ -62,14 +62,14 @@
|
||||
init_villager(name, 50, gun, 1);
|
||||
|
||||
// Heal
|
||||
villager->cur_HP -= 40;
|
||||
villager->cur_HP -= 12;
|
||||
pp_villager(villager);
|
||||
putchar('\n');
|
||||
heal(villager);
|
||||
pp_villager(villager);
|
||||
destroy_villager(villager);
|
||||
*/
|
||||
/* char name[50] = "Isabelle";
|
||||
char name[50] = "Isabelle";
|
||||
char gun_name[50] = "BFG";
|
||||
struct gun *gun = init_gun(gun_name, 50, FAR, 16);
|
||||
struct villager *villager =
|
||||
@@ -81,7 +81,7 @@
|
||||
walk(villager, 50);
|
||||
pp_villager(villager);
|
||||
destroy_villager(villager);
|
||||
*/
|
||||
|
||||
/*
|
||||
// Init Villager
|
||||
char name[50] = "Isabelle";
|
||||
@@ -202,8 +202,9 @@
|
||||
|
||||
destroy_villager(villager);
|
||||
destroy_demon(demon);
|
||||
|
||||
}*/
|
||||
*/
|
||||
}
|
||||
/*
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -315,4 +316,4 @@ int main()
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
|
||||
@@ -50,6 +50,15 @@ void shoot(struct villager *villager, struct demon *demon){
|
||||
}
|
||||
|
||||
//villager shoot le demon
|
||||
|
||||
//Si les degats sont <= 0
|
||||
if((villager->gun->damage + villager->gun_mastery) <= 0 ){
|
||||
update_demon_hp(demon, 0);
|
||||
printf("BAM! %s lost 0 HP.\n", demon->name);
|
||||
return ;
|
||||
|
||||
}
|
||||
//Si les degats sont > 0
|
||||
villager->gun->current_magazine --;
|
||||
|
||||
if((villager->distance >= demon->range) && (villager->gun->range >= demon->range)){
|
||||
@@ -71,7 +80,7 @@ void heal(struct villager *villager){
|
||||
|
||||
villager->medicines --;
|
||||
|
||||
int gain = villager->cur_HP * 1.25;
|
||||
int gain = villager->HP_max * 0.25;
|
||||
villager->cur_HP += gain;
|
||||
|
||||
if (villager->cur_HP > villager->HP_max) villager->cur_HP = villager->HP_max;
|
||||
@@ -116,6 +125,7 @@ enum distance walk(struct villager *villager, int direction){
|
||||
//printf("Distance act: %d\n", villager->distance);
|
||||
villager->distance -= direction;
|
||||
//printf("Distance apres chg: %d\n",villager->distance);
|
||||
printf("You decided to move.\n");
|
||||
return villager->distance;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user