-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1273025
commit 6e00fc7
Showing
42 changed files
with
5,926 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
#include "Armor.hpp" | ||
#include "ArmorInfo.hpp" | ||
|
||
|
||
Armor::Armor(armor_type t){ | ||
a=t; | ||
set_name(); | ||
set_power(); | ||
set_weight(); | ||
set_immunity_type(); | ||
cont_immunity=set_max_immunity();} | ||
|
||
Armor::Armor(armor_type t,int i){ | ||
a=t; | ||
set_name(); | ||
set_power(); | ||
set_weight(); | ||
set_immunity_type(); | ||
set_immunity(i);} | ||
|
||
void Armor::set_name(){ | ||
switch (a){ | ||
case (vesti_da_laboratorio): {strcpy(name,(char*)"Vesti da Laboratorio"); break;} | ||
case (completo_di_pelle): {strcpy(name,(char*)"Completo di Pelle"); break;} | ||
case (tuta_hazmat): {strcpy(name,(char*)"Tuta HAZMAT"); break;} | ||
case (scafandro): {strcpy(name,(char*)"Scafandro"); break;} | ||
case (giubotto_antiproiettile): {strcpy(name,(char*)"Giubotto Antiproiettile"); break;} | ||
case (corazza): {strcpy(name,(char*)"Corazza"); break;} | ||
default: {strcpy(name,(char*)"Armatura non identificata!"); break;}}} | ||
|
||
|
||
void Armor::set_name_immunity(){ | ||
switch (type){ | ||
case (no_immunity): {strcpy(name_immunity,(char*)"Niente"); break;} | ||
case (chemical_agent): {strcpy(name_immunity,(char*)"Agenti chimici"); break;} | ||
case (poison): {strcpy(name_immunity,(char*)"Veleni"); break;} | ||
case (cutlass): {strcpy(name_immunity,(char*)"Armi da taglio"); break;} | ||
case (firearm): {strcpy(name_immunity,(char*)"Armi da fuoco"); break;} | ||
default: {strcpy(name_immunity,(char*)"Immunità non identificata!"); break;}}} | ||
|
||
|
||
void Armor::set_power(){ | ||
switch (a){ | ||
case (vesti_da_laboratorio): {power=value_armor_vesti;} | ||
case (completo_di_pelle): {power=value_armor_pelle; break;} | ||
case (tuta_hazmat): {power=value_armor_hazmat; break;} | ||
case (scafandro): {power=value_armor_scafandro; break;} | ||
case (giubotto_antiproiettile): {power=value_armor_giubotto; break;} | ||
case (corazza): {power=value_armor_corazza; break;} | ||
default: {power=value_armor_free; break;}}} | ||
|
||
|
||
void Armor::set_immunity_type(){ | ||
switch (a){ | ||
case (vesti_da_laboratorio): {type=no_immunity; break;} | ||
case (completo_di_pelle): {type=cutlass; break;} | ||
case (tuta_hazmat): {type=chemical_agent; break;} | ||
case (scafandro): {type=poison; break;} | ||
case (giubotto_antiproiettile): {type=firearm; break;} | ||
case (corazza): {type=firearm; break;}} | ||
set_name_immunity();} | ||
|
||
|
||
void Armor::set_weight(){ | ||
switch (a){ | ||
case (vesti_da_laboratorio): {weight=4; break;} | ||
case (completo_di_pelle): {weight=5; break;} | ||
case (tuta_hazmat): {weight=8; break;} | ||
case (scafandro): {weight=10; break;} | ||
case (giubotto_antiproiettile): {weight=12; break;} | ||
case (corazza): {weight=14; break;} | ||
default: {weight=0; break;}}} | ||
|
||
|
||
void Armor::set_immunity(int i){ | ||
if ((i+cont_immunity)>(set_max_immunity())) | ||
cont_immunity=set_max_immunity(); | ||
else | ||
cont_immunity+=i;} | ||
|
||
|
||
int Armor::set_max_immunity(){ | ||
switch (type){ | ||
case (no_immunity): {return 0; break;} | ||
case (chemical_agent): {return 15; break;} | ||
case (poison): {return 12; break;} | ||
case (cutlass): {return 10; break;} | ||
case (firearm): {return 7; break;} | ||
default: {return 0; break;}}} | ||
|
||
|
||
bool Armor::is_immune() {return (cont_immunity>0);} | ||
|
||
|
||
bool Armor::is_immune(type_of_immunity t) {return (t==type);} | ||
|
||
|
||
char* Armor::get_name(){ | ||
char *n=name; | ||
return n;} | ||
|
||
|
||
void Armor::print_power(){ | ||
int a=(int) ((power/3)*100); | ||
cout<<"\t\tPotenza:\t"<<a<<"%"<<endl;} | ||
|
||
|
||
int Armor::get_weight() {return weight;} | ||
|
||
|
||
char* Armor::get_name_immunity(){ | ||
char* n=name_immunity; | ||
return n;} | ||
|
||
|
||
void Armor::print_immunity(){ | ||
if (is_immune()){ | ||
int a=(int) (((double) cont_immunity)/set_max_immunity()*100); | ||
a=100-a; | ||
cout<<"\t\tImmunità contro <"<<name_immunity<<"> al "<<a<<"%"; | ||
cout<<" di usura"<<endl;}} | ||
|
||
|
||
void Armor::print_name_power_and_immunity(){ | ||
cout<<"\t\t"<<name<<endl; | ||
print_power(); | ||
print_immunity();} | ||
|
||
|
||
void Armor::print_armor_info(){ | ||
switch (a){ | ||
case (vesti_da_laboratorio): {cout<<vesti_da_laboratorio_armor_info; break;} | ||
case (completo_di_pelle): {cout<<completo_di_pelle_armor_info;break;} | ||
case (tuta_hazmat): {cout<<tuta_hazmat_armor_info; break;} | ||
case (scafandro): {cout<<scafandro_armor_info; break;} | ||
case (giubotto_antiproiettile): {cout<<giubotto_armor_info; break;} | ||
case (corazza): {cout<<corazza_armor_info;break;}}} | ||
|
||
|
||
int Armor::get_cont_immunity() {return cont_immunity;} | ||
|
||
|
||
bool Armor::has_more_immunity(){ | ||
return (cont_immunity>0);} | ||
|
||
|
||
void Armor::use_immunity(){ | ||
cont_immunity--;} | ||
|
||
|
||
armor_type Armor::get_enum_armor() {return a;} | ||
|
||
|
||
bool Armor::confronta(Armor* b){ | ||
return (b->get_enum_armor()==a);} | ||
|
||
|
||
int Armor::absorb(int c){ | ||
c=(int) (c/power); | ||
return c;} | ||
|
||
|
||
void Armor::merge(Armor* b){ //FONDE DUE ARMATURE (PER TERRA E IN INVENTARIO) | ||
int i=b->get_cont_immunity(); | ||
set_immunity(i);} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#ifndef ARMOR_HPP_ | ||
#define ARMOR_HPP_ | ||
#include "Mylibrary.hpp" | ||
#ifndef tipi_armi_armature | ||
#define tipi_armi_armature | ||
enum weapon_type{fasce_da_combattimento,mazza,manganello,scure_antincendio,laser_chirurgico,coltello,spara_chiodi,pistola,uzi,arpione,fucile_a_pompa,lanciagranate,balestra_esplosiva,sniper, | ||
lanciafiamme,lanciarazzi,pistola_particellare,fucile_sperimentale}; | ||
enum armor_type{vesti_da_laboratorio,completo_di_pelle,tuta_hazmat,scafandro,giubotto_antiproiettile,corazza}; | ||
enum type_of_weapon{no_res,light_fire_weapon,heavy_fire_weapon,explosive_weapon,huddle_weapon,white_weapon,special_weapon}; | ||
enum type_of_immunity{no_immunity,chemical_agent,poison,firearm,cutlass}; | ||
#endif | ||
|
||
const double value_armor_vesti=1.1; | ||
const double value_armor_pelle=1.4; //TAGLIO | ||
const double value_armor_hazmat=1.8; //CHIMICI | ||
const double value_armor_scafandro=2.2; //POISON | ||
const double value_armor_giubotto=2.6; //ANTIPROIETTILE | ||
const double value_armor_corazza=3.0; //ANTIPROIETTILE | ||
const double value_armor_free=1.0; | ||
|
||
class Armor{ | ||
protected: | ||
char name[25]; | ||
armor_type a; | ||
double power; | ||
int weight; | ||
char name_immunity[25]; | ||
type_of_immunity type; | ||
int cont_immunity; | ||
void set_name(); | ||
void set_power(); | ||
void set_immunity_type(); | ||
void set_immunity(int); | ||
void set_name_immunity(); | ||
int set_max_immunity(); | ||
void set_weight(); | ||
public: | ||
Armor(armor_type); | ||
Armor(armor_type,int); | ||
bool is_immune(); | ||
bool is_immune(type_of_immunity); | ||
bool has_more_immunity(); | ||
int get_weight(); | ||
int get_cont_immunity(); | ||
void merge(Armor*); | ||
void use_immunity(); | ||
int absorb(int); | ||
char* get_name_immunity(); | ||
armor_type get_enum_armor(); | ||
bool confronta(Armor*); | ||
char* get_name(); | ||
void print_power(); | ||
void print_immunity(); | ||
void print_name_power_and_immunity(); | ||
void print_armor_info(); | ||
}; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#ifndef ARMORINFO_HPP_ | ||
#define ARMORINFO_HPP_ | ||
const char* vesti_da_laboratorio_armor_info="VESTI DA LABORATORIO\nRESISTENZA: NESSUNA\nPESO: 4\n\n Tipico vestiario da chimico. Non garantisce nessuna immunità e offre poca resistenza.\n"; | ||
const char* completo_di_pelle_armor_info="COMPLETO DI PELLE\nRESISTENZA: ARMI DA TAGLIO\nPESO: 5\n\n Giacca e pantaloni rivesiti di cuoio, appartenuti forse a qualche capo-settore dello stabilimento.\n"; | ||
const char* tuta_hazmat_armor_info="TUTA HAZMAT\nRESISTENZA: AGENTI CHIMICI\nPESO: 8\n\n Tipica protezione indossata da coloro che hanno a che fare con agenti contaminanti e scorie radioattive. Sapevano di aver a che fare con qualcosa di pericoloso.\n"; | ||
const char* scafandro_armor_info="SCAFANDRO\nRESISTENZA: VELENO\nPESO: 10\n\n Indossato dai palombari, richiede molto sforzo per portarlo ma offre una buona protezione e soprattutto la resistenza al veleno grazie al sistema di respirazione\n. Probabilmente qualcuno stava cercando qualcosa di inabissato.\n"; | ||
const char* giubotto_armor_info="GIUBOTTO\nRESISTENZA: ARMI DA FUOCO\nPESO: 12\n\n Classico giubotto in dotazione alle forze dell'ordine\n Ottima protezione e resistenza alle armi da fuoco\n Un giorno forse appartenuta a qualche guardia dello stabilimento.\n"; | ||
const char* corazza_armor_info="CORAZZA\nRESISTENZA: ARMI DA FUOCO\nPESO: 14\n\n La miglior protezione possibile\n Indossata dalle guardie d'elite, facente parte della scorta del team di sviluppo ai piani alti.\n"; | ||
|
||
|
||
#endif |
Oops, something went wrong.