personajes.cpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. *
  3. * This file is part of Luces de 1984 (L1).
  4. * Copyright (C) <2017> <alkeon> [alkeon@autistici.org]
  5. * L1 is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * L1 is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with l1. If not, see <http://www.gnu.org/licenses/>.
  17. *
  18. */
  19. #include <iostream>
  20. #include "personajes.h"
  21. #include <string>
  22. #include <random>
  23. #include "ncurses.h"
  24. using namespace std;
  25. //Constructor y destructor
  26. Personaje::Personaje(int primer_argumento,int segundo_argumento,int tercer_argumento,int cuarto_argumento,int quinto_argumento){
  27. balas=primer_argumento;
  28. balas_dano=segundo_argumento;
  29. botiquin=tercer_argumento;
  30. ganzua=cuarto_argumento;
  31. isBot=quinto_argumento;
  32. }
  33. Personaje::~Personaje(){}
  34. void Personaje::acierto(Personaje& agredido, Personaje& v){
  35. //dqmutil::setColor(1);
  36. cout<<"Narrador:Le diste"<<endl;
  37. this->balas-=1;
  38. agredido.vida-=this->balas_dano;
  39. }
  40. void Personaje::fallo(Personaje& v){
  41. this->balas-=1;
  42. }
  43. void Personaje::disparas(Personaje& agredido, Personaje& v){
  44. int aleatorio;
  45. std::uniform_int_distribution<int> d(0, 1);
  46. std::random_device rd1;
  47. aleatorio=d(rd1);
  48. if(aleatorio==1){
  49. this->acierto(agredido,v);
  50. } else {
  51. this->fallo(v);
  52. }
  53. }
  54. void Personaje::pegar(Personaje& agredido){
  55. agredido.vida -= this->ataque;
  56. }
  57. void Personaje::curar(Personaje& v){
  58. if(botiquin>0){
  59. this->botiquin-=1;
  60. this->vida+=100;
  61. cout << "Narrador:Tu vida ->"<<this->vida<<endl;
  62. cout << "Narrador:Tus botiquines->"<<this->botiquin<<endl;
  63. } else {
  64. cout<<"Narrador:No te puedes curar"<<endl;
  65. }
  66. }
  67. void Personaje::disparo_acertado(Personaje& agredido){
  68. agredido.vida-=this->balas_dano;
  69. if(this->isBot==0){
  70. this->balas-=1;
  71. }
  72. }