Advertisement
joaoantoniodornelas

Pratica 10 - parte 1

Oct 23rd, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.67 KB | None | 0 0
  1. typedef struct Guerreiro{
  2.  
  3.     int ataque;
  4.     int defesa;
  5.     int pontos_vida;
  6.     int id_jogador;
  7.  
  8. }Guerreiro;
  9.  
  10.  
  11. int rolaDados(){
  12.  
  13.     int i;
  14.     int r = 0;
  15.  
  16.     for(i = 0; i <3, i++){
  17.         r = r + (1 + rand()%6);
  18.     }
  19.  
  20.     return rand;
  21. }
  22.  
  23. void criaGuerreiro (Guerreiro *warrior){
  24.  
  25.     (*warrior).ataque = rolaDados();
  26.     (*warrior).defesa = rolaDados();
  27.     (*warrior).pontos_vida = rolaDados();
  28.     (*warrior).id_jogador = rolaDados();
  29.  
  30. }
  31.  
  32. void ataca(Guerreiro *g1, Guerreiro *g2){
  33.  
  34.     g1->ataque += rolaDados();
  35.     g2->defesa += rolaDados();
  36.  
  37.     int golpe = g1->ataque;
  38.     int escudo = g2->defesa;
  39.  
  40.     int dano = golpe - escudo;
  41.  
  42.     if(dano > 0){
  43.  
  44.         g2->pontos_vida -= dano;
  45.     }0
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement