This repository has been archived on 2026-05-11. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
prog-103-p-04-2030/HolidayTrip/Fundamentals/reap_and_tear/weapons.c
T
2026-02-13 16:12:39 +01:00

25 lines
626 B
C

#include "weapons.h"
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
struct gun *init_gun(char name[50], int damage, enum distance range, int magazine_size){
struct gun *gun = malloc(sizeof( struct gun));
if (gun == NULL) return NULL;
//init des var du struct
strcpy(gun->name, name);
gun->damage = damage;
gun->range = range;
gun->magazine_size = magazine_size;
gun->current_magazine = magazine_size;
return gun;
}
void reload(struct gun *gun){ gun->current_magazine = gun->magazine_size; }
void destroy_gun(struct gun *gun){
if( gun == NULL) return;
free(gun);
}